mozzn 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/cli_spec.rb CHANGED
@@ -1,154 +1,10 @@
1
1
  require 'spec_helper'
2
2
  require 'mozzn'
3
3
 
4
-
5
-
6
4
  describe Mozzn::Cli do
7
5
  before :each do
8
6
  @cli = Mozzn::Cli.new
9
7
  end
10
-
11
- describe "mozzn create_app" do
12
- describe "with valid params" do
13
- it "returns Application created successfuly" do
14
- output = capture(:stdout) { @cli.create_app "#{unique_name}"}
15
- one,two = output.split("\n")
16
- expect(one).to match('Application created successfuly')
17
- end
18
- end
19
-
20
- describe "with invalid params" do
21
- it "returns creating faild " do
22
- output = capture(:stdout) { @cli.create_app "App name"}
23
- one,two = output.split("\n")
24
- expect(one).to match('creating faild')
25
- end
26
- end
27
-
28
- describe "without params " do
29
- it "returns You must enter Application Name! " do
30
- expect { @cli.create_app }.to raise_error(Thor::Error, "You must enter application name.")
31
- end
32
- end
33
- end
34
-
35
- describe "mozzn add_key" do
36
- describe "with valid SSH key" do
37
- it "returns SSH key created" do
38
- @cli.options = {public_key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXwZsqptW/1sxBvT6FAukbGsDKzqoBwwaAj6yUgM1ygdupF3NHhpf3huenu9X09SQTjvGDUjLCn6MgIREumrn3JaIEceqRVI5wtAd2c8S1kwJxZLYqTJT4iifW/ydTocz94FADwrLYWHIjlGLh/FY6xDHhloL0Ymvv+iiEg4cWhdC23zenEUOBS7khnw2FeXxLag4/tcinEYR1+Z3PrhRvfg964Rlf1BdspRwuF26GbiRqgo2M1bj9tBH5PZyL17R06adOpBAh1UzT8X9qSXi9OYE9C2HDIGH3MRpCdpJWU36FWqg8iG/DnFzlxzheRJ78A5R8WdDL2oMFE/BrkM9d'}
39
- output = capture(:stdout) { @cli.add_key }
40
- expect(output).to match('SSH key created')
41
- end
42
- end
43
-
44
- describe "with invalid SSH key" do
45
- it "returns SSH key created" do
46
- @cli.options = {public_key: 'invalid_public_key'}
47
- output = capture(:stdout) { @cli.add_key }
48
- expect(output).to match('creating faild')
49
- end
50
- end
51
-
52
- describe "with valid SSH key path" do
53
- it "returns SSH key created" do
54
- @cli.options = {key_path: '~/.ssh/id_rsa.pub'}
55
- output = capture(:stdout) { @cli.add_key }
56
- expect(output).to match('SSH key created')
57
- end
58
- end
59
-
60
- describe "with invalid SSH key path" do
61
- it "returns Unable to read /invalid_path, file does not exist or not accessible!" do
62
- @cli.options = {key_path: '/invalid_path'}
63
- expect { @cli.add_key }.to raise_error(Thor::Error, "Unable to read /invalid_path. File does not exist or not accessible.")
64
- end
65
- end
66
-
67
- describe "without params " do
68
- it "returns You must enter an SSH key path or a public SSH key!" do
69
- expect { @cli.add_key }.to raise_error(Thor::Error, "Neither a key path or an SSH key were provided. You must use -p or -k options.")
70
- end
71
- end
72
- end
73
-
74
- describe "mozzn login" do
75
- describe "with valid params " do
76
- it "returns Successfully logged in." do
77
- name = 'rania'
78
- email = unique_email
79
- password = '12345678'
80
- password_confirmation = '12345678'
81
- @cli.options = {
82
- name: name,
83
- email: email ,
84
- password: password,
85
- password_confirmation: password_confirmation
86
- }
87
- output = capture(:stdout) { @cli.registration }
88
- cli1 = Mozzn::Cli.new
89
- cli1.options = {
90
- email:email,
91
- password: password
92
- }
93
- expect{ @cli.login }.to raise_error(Thor::Error,"You have to confirm your account before continuing.")
94
- end
95
- end
96
-
97
- describe "with long_string email and password " do
98
- it "returns Invalid email or password." do
99
- @cli.options = {
100
- email: long_string,
101
- password: long_string
102
- }
103
- expect { @cli.login }.to raise_error(Thor::Error, "Invalid email or password.")
104
- end
105
- end
106
-
107
- describe "with invalid params " do
108
- it "returns Invalid email or password." do
109
- @cli.options = {
110
- email: 'invalid@example.com',
111
- password: '12345678'
112
- }
113
- expect { @cli.login }.to raise_error(Thor::Error, "Invalid email or password.")
114
- end
115
- end
116
-
117
- describe "with nil params " do
118
- it "returns Invalid email or password." do
119
- @cli.options = {
120
- email: '',
121
- password: ''
122
- }
123
- expect { @cli.login }.to raise_error(Thor::Error, "Invalid email or password.")
124
- end
125
- end
126
-
127
- describe "without email " do
128
- it "returns Email and password must be provided! " do
129
- @cli.options = {
130
- password: '12345678'
131
- }
132
- expect { @cli.login }.to raise_error(Thor::Error, "Email and password must be provided!")
133
- end
134
- end
135
-
136
- describe "without password " do
137
- it "returns Email and password must be provided! " do
138
- @cli.options = {
139
- email: 'rania@overcstudios.com'
140
- }
141
- expect { @cli.login }.to raise_error(Thor::Error, "Email and password must be provided!")
142
- end
143
- end
144
-
145
- describe "with no params " do
146
- it "returns an interactive shell asking for email and password" do
147
- pending
148
- end
149
- end
150
- end
151
-
152
8
  describe "mozzn update" do
153
9
  describe "with avilable updates" do
154
10
  it "returns An update is available" do
@@ -162,168 +18,4 @@ describe Mozzn::Cli do
162
18
  end
163
19
  end
164
20
 
165
- describe "mozzn registration" do
166
- describe "with valid params" do
167
- it "returns Succesfully registered" do
168
- @cli.options = {
169
- name: 'rania',
170
- email: unique_email ,
171
- password: '12345678',
172
- password_confirmation: '12345678'
173
- }
174
- output = capture(:stdout) { @cli.registration }
175
- output.chomp!
176
- expect(output).to match("Successfully registered")
177
- end
178
- end
179
-
180
- describe "with missing email" do
181
- it "should return email missing" do
182
- @cli.options = {
183
- name: 'rania',
184
- password: '12345678',
185
- password_confirmation: '12345678'
186
- }
187
- output = capture(:stdout) { @cli.registration }
188
- output.chomp!
189
- expect(output).to be =~ /email/
190
- end
191
- end
192
-
193
- describe "with missing password" do
194
- it "should return password missing" do
195
- @cli.options = {
196
- name: 'rania',
197
- email: unique_name,
198
- password_confirmation: '12345678'
199
- }
200
- output = capture(:stdout) { @cli.registration }
201
- output.chomp!
202
- expect(output).to be =~ /password/
203
- end
204
- end
205
-
206
- describe "with missing confirmation Password" do
207
- it "should return password confirmation Missing" do
208
- @cli.options = {
209
- name: 'rania',
210
- email: unique_email,
211
- password: '12345678'
212
- }
213
- output = capture(:stdout) { @cli.registration }
214
- output.chomp!
215
- expect(output).to be =~ /password_confirmation/
216
- end
217
- end
218
-
219
- describe "with invalid email" do
220
- it "should return invalid email" do
221
- @cli.options = {
222
- name: 'rania',
223
- email: 'qqqqqqq',
224
- password: '12345678',
225
- password_confirmation: '12345678'
226
- }
227
- output = capture(:stdout) { @cli.registration }
228
- output.chomp!
229
- expect(output).to be =~ /email/
230
- end
231
- end
232
-
233
- describe "with short password" do
234
- it "should short password" do
235
- @cli.options = {
236
- name: 'rania',
237
- email: unique_email,
238
- password: '123',
239
- password_confirmation: '123'
240
- }
241
- output = capture(:stdout) { @cli.registration }
242
- output.chomp!
243
- expect(output).to be =~ /password/
244
- end
245
- end
246
-
247
- describe "with unmatched password and confirmation password" do
248
- it "should return password and confirmation password are not matched" do
249
- @cli.options = {
250
- name: 'rania',
251
- email: unique_email,
252
- password: '12345678',
253
- password_confirmation: '87654321'
254
- }
255
- output = capture(:stdout) { @cli.registration }
256
- output.chomp!
257
- expect(output).to be =~ /password_confirmation/
258
- end
259
- end
260
-
261
- describe "with nil parammeters" do
262
- it "should return Parameter Missing" do
263
- @cli.options = {
264
- name: nil,
265
- email: nil,
266
- password: nil,
267
- password_confirmation: nil
268
- }
269
- output = capture(:stdout) { @cli.registration }
270
- output.chomp!
271
- expect(output).to be =~ /email/
272
- end
273
- end
274
- end
275
-
276
- describe "mozzn resources" do
277
- describe "With valid params" do
278
- describe "With an existing App" do
279
- it "returns No assigned resources for this application." do
280
- capture(:stdout) { valid_user }
281
- appname = valid_app
282
- expect { @cli.resources "#{appname}" }.to raise_error(Thor::Error, "No assigned resources for this application.")
283
- end
284
- end
285
-
286
- describe "With an existing App having compnents and no datastores" do
287
- it "returns HTTP code 200:OK" do
288
- pending
289
- end
290
- end
291
-
292
- describe "With an existing App having datastores and no components" do
293
- it "returns HTTP code 200:OK" do
294
- pending
295
- end
296
- end
297
-
298
- describe "With an existing App having no datastores or components" do
299
- it "returns No assigned resources for this application." do
300
- capture(:stdout) { valid_user }
301
- appname = valid_app
302
- expect { @cli.resources "#{appname}" }.to raise_error(Thor::Error, "No assigned resources for this application.")
303
-
304
- end
305
- end
306
- end
307
- describe "With invalid parameters" do
308
- describe "with not existing application" do
309
- it "Rais error 'Application not found'" do
310
- capture(:stdout) { valid_user }
311
- appname = 'AppName'
312
- expect { @cli.resources "#{appname}" }.to raise_error(Thor::Error, "Application does not found")
313
- end
314
- end
315
-
316
- describe "with unauthorized user" do
317
- it "returns HTTP code 422" do
318
- pending
319
- end
320
- end
321
-
322
- describe "without name" do
323
- it "should return Application name must be provided." do
324
- expect { @cli.resources }.to raise_error(Thor::Error, "You must enter Application Name!")
325
- end
326
- end
327
- end
328
- end
329
21
  end
data/spec/key_spec.rb ADDED
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+ require 'mozzn'
3
+ require "mozzn/commands/key"
4
+
5
+ describe Mozzn::Commands::Key do
6
+ before :each do
7
+ @key = Mozzn::Commands::Key.new
8
+ end
9
+ describe "mozzn add_key" do
10
+ describe "with valid SSH key" do
11
+ it "returns SSH key created" do
12
+ capture(:stdout) { valid_user }
13
+ @key.options = {public_key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXwZsqptW/1sxBvT6FAukbGsDKzqoBwwaAj6yUgM1ygdupF3NHhpf3huenu9X09SQTjvGDUjLCn6MgIREumrn3JaIEceqRVI5wtAd2c8S1kwJxZLYqTJT4iifW/ydTocz94FADwrLYWHIjlGLh/FY6xDHhloL0Ymvv+iiEg4cWhdC23zenEUOBS7khnw2FeXxLag4/tcinEYR1+Z3PrhRvfg964Rlf1BdspRwuF26GbiRqgo2M1bj9tBH5PZyL17R06adOpBAh1UzT8X9qSXi9OYE9C2HDIGH3MRpCdpJWU36FWqg8iG/DnFzlxzheRJ78A5R8WdDL2oMFE/BrkM9d'}
14
+ output = capture(:stdout) { @key.add }
15
+ expect(output).to match('SSH key created')
16
+ end
17
+ end
18
+
19
+ describe "with invalid SSH key" do
20
+ it "returns SSH key created" do
21
+ capture(:stdout) { valid_user }
22
+ @key.options = {public_key: 'invalid_public_key'}
23
+ output = capture(:stdout) { @key.add }
24
+ expect(output).to match('creating faild')
25
+ end
26
+ end
27
+
28
+ describe "with valid SSH key path" do
29
+ it "returns SSH key created" do
30
+ capture(:stdout) { valid_user }
31
+ @key.options = {key_path: '~/.ssh/id_rsa.pub'}
32
+ output = capture(:stdout) { @key.add }
33
+ expect(output).to match('SSH key created')
34
+ end
35
+ end
36
+
37
+ describe "with invalid SSH key path" do
38
+ it "returns Unable to read /invalid_path, file does not exist or not accessible!" do
39
+ capture(:stdout) { valid_user }
40
+ @key.options = {key_path: '/invalid_path'}
41
+ expect { @key.add }.to raise_error(Thor::Error, "Unable to read /invalid_path. File does not exist or not accessible.")
42
+ end
43
+ end
44
+
45
+ describe "without params " do
46
+ it "returns You must enter an SSH key path or a public SSH key!" do
47
+ capture(:stdout) { valid_user }
48
+ expect { @key.add }.to raise_error(Thor::Error, "Neither a key path or an SSH key were provided. You must use -p or -k options.")
49
+ end
50
+ end
51
+ end
52
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,10 @@
1
+ ENV['GEM_ENV'] = 'test'
1
2
  require 'bundler/setup'
2
3
  require 'rspec'
3
4
  require "mozzn"
5
+ require "mozzn/commands/app"
6
+ require "mozzn/commands/key"
7
+ require "mozzn/commands/auth"
4
8
 
5
9
  Bundler.setup
6
10
 
@@ -34,18 +38,18 @@ def capture(stream)
34
38
  end
35
39
 
36
40
  def valid_user
37
- cli = Mozzn::Cli.new
38
- cli.options = {
39
- email:'test@mozzn.com',
40
- password: '12345678'
41
- }
42
- cli.login
41
+ auth = Mozzn::Commands::Auth.new
42
+ auth.options = {
43
+ email:'test@mozzn.com',
44
+ password: '12345678'
45
+ }
46
+ auth.login
43
47
  end
44
48
 
45
49
  def valid_app
46
- cli = Mozzn::Cli.new
50
+ app = Mozzn::Commands::App.new
47
51
  app_name = unique_name
48
- capture(:stdout) { cli.create_app "#{app_name}"}
52
+ capture(:stdout) { app.create "#{app_name}"}
49
53
  app_name
50
54
  end
51
55
 
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.2.0
4
+ version: 0.3.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-16 00:00:00.000000000 Z
11
+ date: 2014-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -153,18 +153,19 @@ files:
153
153
  - lib/mozzn.rb
154
154
  - lib/mozzn/api.rb
155
155
  - lib/mozzn/cli.rb
156
+ - lib/mozzn/commands/app.rb
157
+ - lib/mozzn/commands/auth.rb
158
+ - lib/mozzn/commands/key.rb
156
159
  - lib/mozzn/config.rb
157
160
  - lib/mozzn/exceptions.rb
158
161
  - lib/mozzn/extensions.rb
159
162
  - lib/mozzn/version.rb
160
163
  - mozzn.gemspec
161
164
  - scripts/generate_readme.sh
165
+ - spec/app_spec.rb
166
+ - spec/auth_spec.rb
162
167
  - spec/cli_spec.rb
163
- - spec/factories/applications.rb
164
- - spec/factories/components.rb
165
- - spec/factories/datastores.rb
166
- - spec/factories/keys.rb
167
- - spec/factories/users.rb
168
+ - spec/key_spec.rb
168
169
  - spec/spec_helper.rb
169
170
  homepage: http://mozzn.com
170
171
  licenses:
@@ -191,10 +192,9 @@ signing_key:
191
192
  specification_version: 4
192
193
  summary: Command Line Interface to mozzn.
193
194
  test_files:
195
+ - spec/app_spec.rb
196
+ - spec/auth_spec.rb
194
197
  - spec/cli_spec.rb
195
- - spec/factories/applications.rb
196
- - spec/factories/components.rb
197
- - spec/factories/datastores.rb
198
- - spec/factories/keys.rb
199
- - spec/factories/users.rb
198
+ - spec/key_spec.rb
200
199
  - spec/spec_helper.rb
200
+ has_rdoc:
@@ -1,14 +0,0 @@
1
- FactoryGirl.define do
2
- sequence :name do |n|
3
- "app#{DateTime.now.to_i}#{n}"
4
- end
5
-
6
- factory :valid_app, class: Application do
7
- name { generate(:name) }
8
- end
9
-
10
- factory :invalid_app, class: Application do
11
- name 'Lorem ipsum dolor sit amet'
12
- end
13
-
14
- end
@@ -1,10 +0,0 @@
1
- FactoryGirl.define do
2
- factory :valid_component, class: Component do
3
- name 'web'
4
- command 'bundle exec rails server -p 3000'
5
- end
6
-
7
- factory :invalid_component, class: Component do
8
- # TODO
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- FactoryGirl.define do
2
- factory :valid_datastore, class: Datastore do
3
- name 'postgresql'
4
- role 'master'
5
- end
6
-
7
- factory :invalid_datastore, class: Datastore do
8
- # TODO
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- FactoryGirl.define do
2
- factory :valid_key, class: Key do
3
- public 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXwZsqptW/1sxBvT6FAukbGsDKzqoBwwaAj6yUgM1ygdupF3NHhpf3huenu9X09SQTjvGDUjLCn6MgIREumrn3JaIEceqRVI5wtAd2c8S1kwJxZLYqTJT4iifW/ydTocz94FADwrLYWHIjlGLh/FY6xDHhloL0Ymvv+iiEg4cWhdC23zenEUOBS7khnw2FeXxLag4/tcinEYR1+Z3PrhRvfg964Rlf1BdspRwuF26GbiRqgo2M1bj9tBH5PZyL17R06adOpBAh1UzT8X9qSXi9OYE9C2HDIGH3MRpCdpJWU36FWqg8iG/DnFzlxzheRJ78A5R8WdDL2oMFE/BrkM9d'
4
- end
5
-
6
- factory :invalid_key, class: Key do
7
- public 'Lorem ipsum dolor sit amet'
8
- end
9
-
10
- end
@@ -1,10 +0,0 @@
1
- FactoryGirl.define do
2
- factory :valid_user do
3
- cli = Mozzn::Cli.new
4
- cli.options = {
5
- email:'test@mozzn.com',
6
- password: '12345678'
7
- }
8
- cli.login
9
- end
10
- end