mozzn 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 454e5a3c7cc085d45c2fafcd2d5e9b4deca671d6
4
- data.tar.gz: dbf48df77a6d527f31d77b1c9549382d92cc1ce7
3
+ metadata.gz: 818f4f826e286e0a92aa9cce89460f24e825795b
4
+ data.tar.gz: 1613633d49fe5ccdeae6445535c1b2b2124b3625
5
5
  SHA512:
6
- metadata.gz: cb0f39b1ff4c33ea5496ff1950ce1b4a0aa7bbdaa821afbfcdf59f9fe29e7f261fa4a428471f988447f77a8bba8de4b04b41674a6b51ef9415611359cb5aef0e
7
- data.tar.gz: ff490d0b66bc7ac52037bbca27ba3c501650faa8fe865f5c15ea0b2ebde9bbafd34c703c4e2bc2efdee7734a9048af43b34d1d4da176681d3c70afcb0ac3c268
6
+ metadata.gz: a2d64ee8a7a27a5d1f593bd6380e50a7d9074ba7109000b98bedaf0286483e7a6cd18d755a30482f03db2ee15a6a5955713c135d41cb4eea3d9c9d0532426436
7
+ data.tar.gz: 73b82862ed3cb5ee3692d059df3ea1a5a2c0c92a0f18148d3bfa858ea74e385cd26e881369ceb98a60aef27ffe0966cede599d4192e7a8679e56e1d83c4729ff
data/README.md CHANGED
@@ -11,34 +11,34 @@ Run the following command from your terminal:
11
11
 
12
12
 
13
13
  Commands:
14
- - mozzn add_key
15
- - mozzn create_app APPNAME
16
- - mozzn help COMMAND
17
- - mozzn login
18
- - mozzn remove_app APPNAME
19
- - mozzn update
14
+ - mozzn app SUBCOMMAND
15
+ - mozzn auth SUBCOMMAND
16
+ - mozzn help COMMAND
17
+ - mozzn key SUBCOMMAND
18
+ - mozzn update
20
19
 
21
20
  Detailed command usage:
22
21
 
23
- $ mozzn add_key
22
+ $ mozzn app
24
23
 
25
24
 
25
+ Commands:
26
+ ####mozzn app console
27
+ ####mozzn app create APPNAME
28
+ ####mozzn app destroy
29
+ ####mozzn app help [COMMAND]
30
+ ####mozzn app list
31
+ ####mozzn app resources
26
32
 
27
- ####mozzn add_key
28
-
29
- #####Options:
30
- -k, [--public-key=PUBLIC_KEY]
31
- -p, [--key-path=KEY_PATH]
32
-
33
- Add your SSH Public Key directily or add its path
34
-
35
- $ mozzn create_app
36
33
 
34
+ $ mozzn auth
37
35
 
38
36
 
39
- ####mozzn create_app APPNAME
37
+ Commands:
38
+ ####mozzn auth help [COMMAND]
39
+ ####mozzn auth login
40
+ ####mozzn auth register
40
41
 
41
- create a new application
42
42
 
43
43
  $ mozzn help
44
44
 
@@ -48,25 +48,15 @@ create a new application
48
48
 
49
49
  For more infromation about spicific COMMAND
50
50
 
51
- $ mozzn login
52
-
53
-
51
+ $ mozzn key
54
52
 
55
- ####mozzn login
56
53
 
57
- #####Options:
58
- -u, [--email=EMAIL]
59
- -p, [--password=PASSWORD]
60
-
61
- Login with your mozzn credentials, an interactive shell will ask you about your email and password
62
-
63
- $ mozzn remove_app
64
-
65
-
66
-
67
- ####mozzn remove_app APPNAME
54
+ Commands:
55
+ ####mozzn key add
56
+ ####mozzn key destroy
57
+ ####mozzn key help [COMMAND]
58
+ ####mozzn key list
68
59
 
69
- Remove spcicfic Application.
70
60
 
71
61
  $ mozzn update
72
62
 
@@ -74,7 +64,7 @@ Remove spcicfic Application.
74
64
 
75
65
  ####mozzn update
76
66
 
77
- To show if there is an update for the CLI
67
+ Check for updates
78
68
 
79
69
  ## Contributing
80
70
  1. Fork it ( http://github.com/mozzn/mozzn/fork )
@@ -11,7 +11,7 @@ module Mozzn
11
11
  if token.nil?
12
12
  raise Thor::Error,"You need to login in order to continue."
13
13
  end
14
- mozzn = Mozzn::Api.new(Mozzn::Config.new.read['token'])
14
+ mozzn = Mozzn::Api.new(token)
15
15
  if name == nil
16
16
  raise Thor::Error, "You must enter application name."
17
17
  end
@@ -54,7 +54,7 @@ module Mozzn
54
54
  if token.nil?
55
55
  raise Thor::Error,"You need to login in order to continue."
56
56
  end
57
- mozzn = Mozzn::Api.new(Mozzn::Config.new.read['token'])
57
+ mozzn = Mozzn::Api.new(token)
58
58
  if options['appname'].present?
59
59
  name = options['appname']
60
60
  else
@@ -82,10 +82,33 @@ module Mozzn
82
82
  rescue Mozzn::UnexpectedOutput
83
83
  say 'UnexpectedOutput', :red
84
84
  end
85
- desc "list", "List all your Applications"
86
85
 
86
+ desc "list", "List all your Applications"
87
87
  def list
88
- #TODO
88
+ token = Mozzn::Config.new.read['token']
89
+ if token.nil?
90
+ raise Thor::Error,"You need to login in order to continue."
91
+ end
92
+ mozzn = Mozzn::Api.new(token)
93
+ path = "applications"
94
+ response = mozzn.get(path, nil)
95
+ if response.has_key? ('message')
96
+ say response['message'], :yellow
97
+ return
98
+ end
99
+ table = Terminal::Table.new(headings: ['Name', 'Status']) do |t|
100
+ response['applications'].each do |app|
101
+ key = app['name']
102
+ value = app['status']
103
+ t.add_row [key, value]
104
+ end
105
+ end
106
+ say "Your applications are:"
107
+ say table
108
+ rescue Mozzn::Disconnected
109
+ say 'Unable to connect to Mozzn. Check your internet connection!', :red
110
+ rescue Mozzn::UnexpectedOutput
111
+ say 'UnexpectedOutput', :red
89
112
  end
90
113
 
91
114
  method_option :appname, :aliases => "-n", :desc => "Application name"
@@ -95,7 +118,7 @@ module Mozzn
95
118
  if token.nil?
96
119
  raise Thor::Error,"You need to login in order to continue."
97
120
  end
98
- mozzn = Mozzn::Api.new(Mozzn::Config.new.read['token'])
121
+ mozzn = Mozzn::Api.new(token)
99
122
  if options['appname'].present?
100
123
  name = options['appname']
101
124
  else
@@ -174,7 +197,7 @@ module Mozzn
174
197
  if token.nil?
175
198
  raise Thor::Error,"You need to login in order to continue."
176
199
  end
177
- mozzn = Mozzn::Api.new(Mozzn::Config.new.read['token'])
200
+ mozzn = Mozzn::Api.new(token)
178
201
  params = {
179
202
  name: appname
180
203
  }
@@ -9,7 +9,7 @@ module Mozzn
9
9
  if token.nil?
10
10
  raise Thor::Error,"You need to login in order to continue."
11
11
  end
12
- mozzn = Mozzn::Api.new(Mozzn::Config.new.read['token'])
12
+ mozzn = Mozzn::Api.new(token)
13
13
  if options[:key_path].present?
14
14
  key_path = File.expand_path(options[:key_path])
15
15
  elsif options[:public_key].present?
@@ -43,13 +43,65 @@ module Mozzn
43
43
  end
44
44
 
45
45
  desc 'destroy', 'Delete specific SSH public Key.'
46
- def destroy
47
- # TODO
46
+ def destroy name=nil
47
+ token = Mozzn::Config.new.read['token']
48
+ if token.nil?
49
+ raise Thor::Error,"You need to login in order to continue."
50
+ end
51
+ mozzn = Mozzn::Api.new(token)
52
+ params = {
53
+ name: name
54
+ }
55
+ search_path = "keys/search"
56
+ begin
57
+ response = mozzn.get(search_path, params)
58
+ if response.has_key?('info')
59
+ raise Thor::Error, "#{response['info']}."
60
+ else
61
+ id = response['key_id']
62
+ resources_path = "keys/#{id}/remove"
63
+ response = mozzn.get(resources_path,nil)
64
+ if response.has_key?('message')
65
+ raise Thor::Error,response['message']
66
+ else
67
+ say response['info'], :green
68
+ end
69
+ end
70
+ rescue JSON::ParserError => e
71
+ raise Thor::Error,"You do not have an application with the name #{params[:name]}. Please check the application name."
72
+ end
73
+ rescue Mozzn::Disconnected
74
+ say 'Unable to connect to Mozzn. Check your internet connection!', :red
75
+ rescue Mozzn::UnexpectedOutput
76
+ say 'UnexpectedOutput', :red
48
77
  end
49
78
 
50
79
  desc 'list', 'List all your SSH public keys.'
51
80
  def list
52
- # TODO
81
+ token = Mozzn::Config.new.read['token']
82
+ if token.nil?
83
+ raise Thor::Error,"You need to login in order to continue."
84
+ end
85
+ mozzn = Mozzn::Api.new(token)
86
+ path = "keys"
87
+ response = mozzn.get(path, nil)
88
+ if response.has_key? ('info')
89
+ say response['info'], :yellow
90
+ return
91
+ end
92
+ table = Terminal::Table.new(headings: ['ID', 'Name']) do |t|
93
+ response['keys'].each do |k|
94
+ key = k['id']
95
+ value = k['name']
96
+ t.add_row [key, value]
97
+ end
98
+ end
99
+ say "Your SSH keys are:"
100
+ say table
101
+ rescue Mozzn::Disconnected
102
+ say 'Unable to connect to Mozzn. Check your internet connection!', :red
103
+ rescue Mozzn::UnexpectedOutput
104
+ say 'UnexpectedOutput', :red
53
105
  end
54
106
  end
55
107
  end
@@ -1,3 +1,3 @@
1
1
  module Mozzn
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -16,7 +16,7 @@ describe Mozzn::Commands::App do
16
16
  describe "with invalid params" do
17
17
  it "returns creating faild " do
18
18
  capture(:stdout) { valid_user }
19
- expect { @app.create "App name" }.to raise_error(Thor::Error, "creating faild")
19
+ expect { @app.create "'App name'" }.to raise_error(Thor::Error, "creating faild.")
20
20
  end
21
21
  end
22
22
 
@@ -58,4 +58,25 @@ describe Mozzn::Commands::App do
58
58
  end
59
59
  end
60
60
  end
61
+
62
+ describe "mozzn app list" do
63
+ describe "With valid params" do
64
+ describe "With an existing Apps" do
65
+ it "returns Your applications are:" do
66
+ capture(:stdout) { valid_user }
67
+ valid_app
68
+ output = capture(:stdout) { @app.list }
69
+ expect(output).to be =~ /Your applications are:/
70
+ end
71
+ end
72
+
73
+ describe "With no existing Apps" do
74
+ it "returns You dont have any applications." do
75
+ capture(:stdout) { valid_user2 }
76
+ output = capture(:stdout) { @app.list }
77
+ expect(output).to be =~ /You dont have any applications./
78
+ end
79
+ end
80
+ end
81
+ end
61
82
  end
@@ -49,4 +49,38 @@ describe Mozzn::Commands::Key do
49
49
  end
50
50
  end
51
51
  end
52
+
53
+ describe "mozzn key list" do
54
+ describe "With valid params" do
55
+ describe "With an existing keys" do
56
+ it "returns Your keys are:" do
57
+ capture(:stdout) { valid_user }
58
+ output = capture(:stdout) { @key.list }
59
+ expect(output).to be =~ /Your SSH keys are:/
60
+ end
61
+ end
62
+
63
+ describe "With no existing Apps" do
64
+ it "returns You don't have any SSH key yet." do
65
+ capture(:stdout) { valid_user2 }
66
+ output = capture(:stdout) { @key.list }
67
+ expect(output).to be =~ /You don't have any SSH key yet./
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ describe "mozzn key destroy" do
74
+ describe "with valid params" do
75
+ it " returns Key deleted." do
76
+ pending
77
+ end
78
+ end
79
+
80
+ describe "with invalid params" do
81
+ it " returns Key did not deleted." do
82
+ pending
83
+ end
84
+ end
85
+ end
52
86
  end
@@ -46,6 +46,15 @@ def valid_user
46
46
  auth.login
47
47
  end
48
48
 
49
+ def valid_user2
50
+ auth = Mozzn::Commands::Auth.new
51
+ auth.options = {
52
+ email:'test2@mozzn.com',
53
+ password: '12345678'
54
+ }
55
+ auth.login
56
+ end
57
+
49
58
  def valid_app
50
59
  app = Mozzn::Commands::App.new
51
60
  app_name = unique_name
@@ -53,6 +62,11 @@ def valid_app
53
62
  app_name
54
63
  end
55
64
 
65
+ def valid_key
66
+ key = Mozzn::Commands::Key.new
67
+ key.options = {public_key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXwZsqptW/1sxBvT6FAukbGsDKzqoBwwaAj6yUgM1ygdupF3NHhpf3huenu9X09SQTjvGDUjLCn6MgIREumrn3JaIEceqRVI5wtAd2c8S1kwJxZLYqTJT4iifW/ydTocz94FADwrLYWHIjlGLh/FY6xDHhloL0Ymvv+iiEg4cWhdC23zenEUOBS7khnw2FeXxLag4/tcinEYR1+Z3PrhRvfg964Rlf1BdspRwuF26GbiRqgo2M1bj9tBH5PZyL17R06adOpBAh1UzT8X9qSXi9OYE9C2HDIGH3MRpCdpJWU36FWqg8iG/DnFzlxzheRJ78A5R8WdDL2oMFE/BrkM9d'}
68
+ output = capture(:stdout) { key.add }
69
+ end
56
70
 
57
71
 
58
72
  RSpec.configure do |config|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mozzn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mozzn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-18 00:00:00.000000000 Z
11
+ date: 2014-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -211,3 +211,4 @@ test_files:
211
211
  - spec/cli_spec.rb
212
212
  - spec/key_spec.rb
213
213
  - spec/spec_helper.rb
214
+ has_rdoc: