shelly 0.0.22 → 0.0.23

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.
@@ -47,8 +47,12 @@ module Shelly
47
47
  user = Shelly::User.new(email || ask_for_email, ask_for_password(:with_confirmation => false))
48
48
  user.login
49
49
  say "Login successful"
50
- say "Uploading your public SSH key"
51
- user.upload_ssh_key
50
+ begin user.upload_ssh_key
51
+ conflict = false
52
+ rescue RestClient::Conflict
53
+ conflict = true
54
+ end
55
+ say "Uploading your public SSH key" if conflict == false
52
56
  say "You have following clouds available:", :green
53
57
  user.apps.each do |app|
54
58
  say " #{app["code_name"]}"
@@ -56,14 +60,13 @@ module Shelly
56
60
  rescue Client::APIError => e
57
61
  if e.validation?
58
62
  e.each_error { |error| say_error "#{error}", :with_exit => false }
59
- exit 1
60
63
  end
61
64
  if e.unauthorized?
62
65
  say_error "Wrong email or password", :with_exit => false
63
66
  say_error "You can reset password by using link:", :with_exit => false
64
67
  say_error "#{e.url}", :with_exit => false
65
- exit 1
66
68
  end
69
+ exit 1
67
70
  end
68
71
 
69
72
  method_option "code-name", :type => :string, :aliases => "-c",
@@ -1,3 +1,5 @@
1
+ require "shelly/cli/command"
2
+
1
3
  module Shelly
2
4
  module CLI
3
5
  class User < Command
data/lib/shelly/client.rb CHANGED
@@ -64,8 +64,8 @@ module Shelly
64
64
  post("/apps", :app => attributes)
65
65
  end
66
66
 
67
- def update_ssh_key(ssh_key)
68
- put("/ssh_key", :ssh_key => ssh_key)
67
+ def add_ssh_key(ssh_key)
68
+ post("/ssh_key", :ssh_key => ssh_key)
69
69
  end
70
70
 
71
71
  def apps
@@ -41,7 +41,8 @@ module Shelly
41
41
  response = shelly.apps_users(clouds)
42
42
  response.inject({}) do |result, app|
43
43
  result[app['code_name']] = app['users'].map do |user|
44
- user['name'] ? "#{user['email']} (#{user['name']})" : user['email']
44
+ #user['name'] ? "#{user['email']} (#{user['name']})" : user['email']
45
+ user['email']
45
46
  end
46
47
  result
47
48
  end
data/lib/shelly/user.rb CHANGED
@@ -66,8 +66,8 @@ module Shelly
66
66
  end
67
67
 
68
68
  def upload_ssh_key
69
- key = File.read(ssh_key_path)
70
- shelly.update_ssh_key(key)
69
+ key = File.read(ssh_key_path).strip
70
+ shelly.add_ssh_key(key)
71
71
  end
72
72
 
73
73
  protected
@@ -1,3 +1,3 @@
1
1
  module Shelly
2
- VERSION = "0.0.22"
2
+ VERSION = "0.0.23"
3
3
  end
@@ -191,6 +191,14 @@ OUT
191
191
  end
192
192
  end
193
193
 
194
+ it "should upload user's public SSH key and raise HTTP status 409 Conflict when SSH key exists in database" do
195
+ @user.should_receive(:upload_ssh_key).and_raise(RestClient::Conflict)
196
+ $stdout.should_receive(:puts).with("\e[32mYou have following clouds available:\e[0m")
197
+ fake_stdin(["megan@example.com", "secret"]) do
198
+ @main.login
199
+ end
200
+ end
201
+
194
202
  it "should display list of applications to which user has access" do
195
203
  $stdout.should_receive(:puts).with("\e[32mYou have following clouds available:\e[0m")
196
204
  $stdout.should_receive(:puts).with(" abc")
@@ -58,7 +58,7 @@ describe Shelly::CLI::User do
58
58
  $stdout.should_receive(:puts).with("Cloud foo-production:")
59
59
  $stdout.should_receive(:puts).with(" user@example.com")
60
60
  $stdout.should_receive(:puts).with("Cloud foo-staging:")
61
- $stdout.should_receive(:puts).with(" user2@example.com (username2)")
61
+ $stdout.should_receive(:puts).with(" user2@example.com")
62
62
  @cli_user.list
63
63
  end
64
64
  end
@@ -125,10 +125,10 @@ describe Shelly::Client do
125
125
  end
126
126
  end
127
127
 
128
- describe "#update_ssh_key" do
128
+ describe "#add_ssh_key" do
129
129
  it "should send put with give SSH key" do
130
- @client.should_receive(:put).with("/ssh_key", {:ssh_key => "abc"})
131
- @client.update_ssh_key("abc")
130
+ @client.should_receive(:post).with("/ssh_key", {:ssh_key => "abc"})
131
+ @client.add_ssh_key("abc")
132
132
  end
133
133
  end
134
134
 
@@ -27,11 +27,11 @@ describe Shelly::Cloudfile do
27
27
  @cloudfile.write(@hash)
28
28
  @client.should_receive(:apps_users).and_return(response)
29
29
  response = @cloudfile.fetch_users
30
- response.should == {"foo-staging" => ["user@example.com (username)"]}
30
+ response.should == {"foo-staging" => ["user@example.com"]}
31
31
  end
32
32
 
33
33
  def response
34
- [{'code_name' => 'foo-staging','users' => [{'name' => 'username','email' => 'user@example.com'}]}]
34
+ [{'code_name' => 'foo-staging','users' => [{'email' => 'user@example.com'}]}]
35
35
  end
36
36
  end
37
37
 
@@ -122,7 +122,7 @@ describe Shelly::User do
122
122
 
123
123
  describe "#upload_ssh_key" do
124
124
  it "should read and upload user's public SSH key" do
125
- @client.should_receive(:update_ssh_key).with("ssh-key AAbbcc")
125
+ @client.should_receive(:add_ssh_key).with("ssh-key AAbbcc")
126
126
  @user.upload_ssh_key
127
127
  end
128
128
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shelly
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
4
+ hash: 49
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 22
10
- version: 0.0.22
9
+ - 23
10
+ version: 0.0.23
11
11
  platform: ruby
12
12
  authors:
13
13
  - Shelly Cloud team
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-21 00:00:00 Z
18
+ date: 2011-11-25 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rspec
@@ -74,7 +74,7 @@ dependencies:
74
74
  type: :development
75
75
  version_requirements: *id004
76
76
  - !ruby/object:Gem::Dependency
77
- name: growl_notify
77
+ name: fakefs
78
78
  prerelease: false
79
79
  requirement: &id005 !ruby/object:Gem::Requirement
80
80
  none: false
@@ -88,7 +88,7 @@ dependencies:
88
88
  type: :development
89
89
  version_requirements: *id005
90
90
  - !ruby/object:Gem::Dependency
91
- name: rb-fsevent
91
+ name: fakeweb
92
92
  prerelease: false
93
93
  requirement: &id006 !ruby/object:Gem::Requirement
94
94
  none: false
@@ -101,38 +101,10 @@ dependencies:
101
101
  version: "0"
102
102
  type: :development
103
103
  version_requirements: *id006
104
- - !ruby/object:Gem::Dependency
105
- name: fakefs
106
- prerelease: false
107
- requirement: &id007 !ruby/object:Gem::Requirement
108
- none: false
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- hash: 3
113
- segments:
114
- - 0
115
- version: "0"
116
- type: :development
117
- version_requirements: *id007
118
- - !ruby/object:Gem::Dependency
119
- name: fakeweb
120
- prerelease: false
121
- requirement: &id008 !ruby/object:Gem::Requirement
122
- none: false
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- hash: 3
127
- segments:
128
- - 0
129
- version: "0"
130
- type: :development
131
- version_requirements: *id008
132
104
  - !ruby/object:Gem::Dependency
133
105
  name: wijet-thor
134
106
  prerelease: false
135
- requirement: &id009 !ruby/object:Gem::Requirement
107
+ requirement: &id007 !ruby/object:Gem::Requirement
136
108
  none: false
137
109
  requirements:
138
110
  - - ~>
@@ -144,11 +116,11 @@ dependencies:
144
116
  - 7
145
117
  version: 0.14.7
146
118
  type: :runtime
147
- version_requirements: *id009
119
+ version_requirements: *id007
148
120
  - !ruby/object:Gem::Dependency
149
121
  name: rest-client
150
122
  prerelease: false
151
- requirement: &id010 !ruby/object:Gem::Requirement
123
+ requirement: &id008 !ruby/object:Gem::Requirement
152
124
  none: false
153
125
  requirements:
154
126
  - - ">="
@@ -158,11 +130,11 @@ dependencies:
158
130
  - 0
159
131
  version: "0"
160
132
  type: :runtime
161
- version_requirements: *id010
133
+ version_requirements: *id008
162
134
  - !ruby/object:Gem::Dependency
163
135
  name: json
164
136
  prerelease: false
165
- requirement: &id011 !ruby/object:Gem::Requirement
137
+ requirement: &id009 !ruby/object:Gem::Requirement
166
138
  none: false
167
139
  requirements:
168
140
  - - ">="
@@ -172,11 +144,11 @@ dependencies:
172
144
  - 0
173
145
  version: "0"
174
146
  type: :runtime
175
- version_requirements: *id011
147
+ version_requirements: *id009
176
148
  - !ruby/object:Gem::Dependency
177
149
  name: launchy
178
150
  prerelease: false
179
- requirement: &id012 !ruby/object:Gem::Requirement
151
+ requirement: &id010 !ruby/object:Gem::Requirement
180
152
  none: false
181
153
  requirements:
182
154
  - - ">="
@@ -186,7 +158,7 @@ dependencies:
186
158
  - 0
187
159
  version: "0"
188
160
  type: :runtime
189
- version_requirements: *id012
161
+ version_requirements: *id010
190
162
  description: Tool for managing applications and clouds at shellycloud.com
191
163
  email:
192
164
  - support@shellycloud.com
@@ -267,16 +239,5 @@ rubygems_version: 1.8.10
267
239
  signing_key:
268
240
  specification_version: 3
269
241
  summary: Shelly Cloud command line tool
270
- test_files:
271
- - spec/helpers.rb
272
- - spec/input_faker.rb
273
- - spec/shelly/app_spec.rb
274
- - spec/shelly/cli/main_spec.rb
275
- - spec/shelly/cli/runner_spec.rb
276
- - spec/shelly/cli/user_spec.rb
277
- - spec/shelly/client_spec.rb
278
- - spec/shelly/cloudfile_spec.rb
279
- - spec/shelly/model_spec.rb
280
- - spec/shelly/user_spec.rb
281
- - spec/spec_helper.rb
282
- - spec/thor/options_spec.rb
242
+ test_files: []
243
+