rhc 1.15.6 → 1.16.9
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.
- data/autocomplete/rhc_bash +168 -24
- data/features/assets/deploy.tar.gz +0 -0
- data/features/core_feature.rb +6 -0
- data/features/deployments_feature.rb +127 -0
- data/features/keys_feature.rb +37 -0
- data/features/members_feature.rb +36 -1
- data/lib/rhc/commands/app.rb +79 -2
- data/lib/rhc/commands/deployment.rb +82 -0
- data/lib/rhc/commands/snapshot.rb +6 -1
- data/lib/rhc/commands/sshkey.rb +29 -14
- data/lib/rhc/commands/tail.rb +1 -1
- data/lib/rhc/deployment_helpers.rb +88 -0
- data/lib/rhc/exceptions.rb +24 -0
- data/lib/rhc/git_helpers.rb +1 -1
- data/lib/rhc/helpers.rb +17 -14
- data/lib/rhc/highline_extensions.rb +15 -15
- data/lib/rhc/output_helpers.rb +51 -9
- data/lib/rhc/rest.rb +1 -0
- data/lib/rhc/rest/activation.rb +11 -0
- data/lib/rhc/rest/application.rb +53 -1
- data/lib/rhc/rest/client.rb +16 -12
- data/lib/rhc/rest/deployment.rb +18 -0
- data/lib/rhc/rest/key.rb +14 -2
- data/lib/rhc/rest/mock.rb +90 -5
- data/lib/rhc/ssh_helpers.rb +82 -21
- data/lib/rhc/wizard.rb +2 -2
- data/spec/direct_execution_helper.rb +93 -26
- data/spec/rhc/commands/deployment_spec.rb +286 -0
- data/spec/rhc/commands/snapshot_spec.rb +12 -0
- data/spec/rhc/commands/sshkey_spec.rb +37 -0
- data/spec/rhc/commands/tail_spec.rb +2 -2
- data/spec/rhc/rest_client_spec.rb +6 -2
- data/spec/spec_helper.rb +1 -1
- metadata +17 -5
@@ -0,0 +1,286 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rest_spec_helper'
|
3
|
+
require 'rhc/commands/deployment'
|
4
|
+
|
5
|
+
describe RHC::Commands::Deployment do
|
6
|
+
|
7
|
+
DEPLOYMENT_APP_NAME = 'mock_app_deploy'
|
8
|
+
|
9
|
+
let!(:rest_client) { MockRestClient.new }
|
10
|
+
|
11
|
+
before do
|
12
|
+
user_config
|
13
|
+
@rest_app = rest_client.add_domain("mock_domain").add_application(DEPLOYMENT_APP_NAME, 'ruby-1.8.7')
|
14
|
+
@rest_app.stub(:ssh_url).and_return("ssh://user@test.domain.com")
|
15
|
+
@targz_filename = File.dirname(__FILE__) + '/' + DEPLOYMENT_APP_NAME + '.tar.gz'
|
16
|
+
FileUtils.cp(File.expand_path('../../assets/targz_sample.tar.gz', __FILE__), @targz_filename)
|
17
|
+
File.chmod 0644, @targz_filename unless File.executable? @targz_filename
|
18
|
+
end
|
19
|
+
|
20
|
+
after do
|
21
|
+
File.delete @targz_filename if File.exist? @targz_filename
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "configure app" do
|
25
|
+
context "manual deployment keeping a history of 10" do
|
26
|
+
let(:arguments) {['app', 'configure', '--app', DEPLOYMENT_APP_NAME, '--no-auto-deploy', '--keep-deployments', '10']}
|
27
|
+
it "should succeed" do
|
28
|
+
expect{ run }.to exit_with_code(0)
|
29
|
+
run_output.should match(/Configuring application '#{DEPLOYMENT_APP_NAME}' .../)
|
30
|
+
run_output.should match(/done/)
|
31
|
+
@rest_app.auto_deploy.should == false
|
32
|
+
@rest_app.keep_deployments.should == 10
|
33
|
+
run_output.should match(/Your application '#{DEPLOYMENT_APP_NAME}' is now configured as listed above/)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "with no configuration options" do
|
38
|
+
let(:arguments) {['app', 'configure', '--app', DEPLOYMENT_APP_NAME]}
|
39
|
+
it "should display the current configuration" do
|
40
|
+
expect{ run }.to exit_with_code(0)
|
41
|
+
run_output.should_not match(/Configuring application '#{DEPLOYMENT_APP_NAME}' .../)
|
42
|
+
run_output.should_not match(/done/)
|
43
|
+
run_output.should match(/Your application '#{DEPLOYMENT_APP_NAME}' is configured as listed above/)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "deploy" do
|
49
|
+
context "git ref successfully" do
|
50
|
+
before { Net::SSH.should_receive(:start).exactly(3).times.with('test.domain.com', 'user', :compression=>false) }
|
51
|
+
let(:arguments) {['app', 'deploy', 'master', '--app', DEPLOYMENT_APP_NAME]}
|
52
|
+
it "should succeed" do
|
53
|
+
expect{ run }.to exit_with_code(0)
|
54
|
+
run_output.should match(/Deployment of git ref 'master' in progress for application #{DEPLOYMENT_APP_NAME} .../)
|
55
|
+
run_output.should match(/Success/)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "binary file successfully" do
|
60
|
+
before do
|
61
|
+
ssh = double(Net::SSH)
|
62
|
+
session = double(Net::SSH::Connection::Session)
|
63
|
+
channel = double(Net::SSH::Connection::Channel)
|
64
|
+
exit_status = double(Net::SSH::Buffer)
|
65
|
+
exit_status.stub(:read_long).and_return(0)
|
66
|
+
Net::SSH.should_receive(:start).exactly(3).times.with('test.domain.com', 'user', :compression=>false).and_yield(session)
|
67
|
+
session.should_receive(:open_channel).exactly(3).times.and_yield(channel)
|
68
|
+
channel.should_receive(:exec).exactly(3).times.with("oo-binary-deploy").and_yield(nil, nil)
|
69
|
+
channel.should_receive(:on_data).exactly(3).times.and_yield(nil, 'foo')
|
70
|
+
channel.should_receive(:on_extended_data).exactly(3).times.and_yield(nil, nil, '')
|
71
|
+
channel.should_receive(:on_close).exactly(3).times.and_yield(nil)
|
72
|
+
channel.should_receive(:on_request).exactly(3).times.with("exit-status").and_yield(nil, exit_status)
|
73
|
+
lines = ''
|
74
|
+
File.open(@targz_filename, 'rb') do |file|
|
75
|
+
file.chunk(1024) do |chunk|
|
76
|
+
lines << chunk
|
77
|
+
end
|
78
|
+
end
|
79
|
+
channel.should_receive(:send_data).exactly(3).times.with(lines)
|
80
|
+
channel.should_receive(:eof!).exactly(3).times
|
81
|
+
session.should_receive(:loop).exactly(3).times
|
82
|
+
end
|
83
|
+
let(:arguments) {['app', 'deploy', @targz_filename, '--app', DEPLOYMENT_APP_NAME]}
|
84
|
+
it "should succeed" do
|
85
|
+
expect{ run }.to exit_with_code(0)
|
86
|
+
run_output.should match(/Deployment of file '#{@targz_filename}' in progress for application #{DEPLOYMENT_APP_NAME} .../)
|
87
|
+
run_output.should match(/Success/)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
[URI('http://foo.com/path/to/file/' + DEPLOYMENT_APP_NAME + '.tar.gz'),
|
92
|
+
URI('https://foo.com/path/to/file/' + DEPLOYMENT_APP_NAME + '.tar.gz')].each do |uri|
|
93
|
+
context "url file successfully" do
|
94
|
+
before do
|
95
|
+
ssh = double(Net::SSH)
|
96
|
+
session = double(Net::SSH::Connection::Session)
|
97
|
+
channel = double(Net::SSH::Connection::Channel)
|
98
|
+
exit_status = double(Net::SSH::Buffer)
|
99
|
+
exit_status.stub(:read_long).and_return(0)
|
100
|
+
Net::SSH.should_receive(:start).exactly(3).times.with('test.domain.com', 'user', :compression=>false).and_yield(session)
|
101
|
+
session.should_receive(:open_channel).exactly(3).times.and_yield(channel)
|
102
|
+
channel.should_receive(:exec).exactly(3).times.with("oo-binary-deploy").and_yield(nil, nil)
|
103
|
+
channel.should_receive(:on_data).exactly(3).times.and_yield(nil, 'foo')
|
104
|
+
channel.should_receive(:on_extended_data).exactly(3).times.and_yield(nil, nil, '')
|
105
|
+
channel.should_receive(:on_close).exactly(3).times.and_yield(nil)
|
106
|
+
channel.should_receive(:on_request).exactly(3).times.with("exit-status").and_yield(nil, exit_status)
|
107
|
+
lines = ''
|
108
|
+
File.open(@targz_filename, 'rb') do |file|
|
109
|
+
file.chunk(1024) do |chunk|
|
110
|
+
lines << chunk
|
111
|
+
end
|
112
|
+
end
|
113
|
+
stub_request(:get, uri.to_s).to_return(:status => 200, :body => lines, :headers => {})
|
114
|
+
channel.should_receive(:send_data).exactly(3).times.with(lines)
|
115
|
+
channel.should_receive(:eof!).exactly(3).times
|
116
|
+
session.should_receive(:loop).exactly(3).times
|
117
|
+
end
|
118
|
+
let(:arguments) {['app', 'deploy', uri.to_s, '--app', DEPLOYMENT_APP_NAME]}
|
119
|
+
it "should succeed" do
|
120
|
+
expect{ run }.to exit_with_code(0)
|
121
|
+
run_output.should match(/Deployment of file '#{uri.to_s}' in progress for application #{DEPLOYMENT_APP_NAME} .../)
|
122
|
+
run_output.should match(/Success/)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
context "binary file with corrupted file" do
|
128
|
+
before do
|
129
|
+
ssh = double(Net::SSH)
|
130
|
+
session = double(Net::SSH::Connection::Session)
|
131
|
+
channel = double(Net::SSH::Connection::Channel)
|
132
|
+
exit_status = double(Net::SSH::Buffer)
|
133
|
+
exit_status.stub(:read_long).and_return(255)
|
134
|
+
Net::SSH.should_receive(:start).exactly(3).times.with('test.domain.com', 'user', :compression=>false).and_yield(session)
|
135
|
+
session.should_receive(:open_channel).exactly(3).times.and_yield(channel)
|
136
|
+
channel.should_receive(:exec).exactly(3).times.with("oo-binary-deploy").and_yield(nil, nil)
|
137
|
+
channel.should_receive(:on_data).exactly(3).times.and_yield(nil, 'foo')
|
138
|
+
channel.should_receive(:on_extended_data).exactly(3).times.and_yield(nil, nil, 'Invalid file')
|
139
|
+
channel.should_receive(:on_close).exactly(3).times.and_yield(nil)
|
140
|
+
channel.should_receive(:on_request).exactly(3).times.with("exit-status").and_yield(nil, exit_status)
|
141
|
+
lines = ''
|
142
|
+
File.open(@targz_filename, 'rb') do |file|
|
143
|
+
file.chunk(1024) do |chunk|
|
144
|
+
lines << chunk
|
145
|
+
end
|
146
|
+
end
|
147
|
+
channel.should_receive(:send_data).exactly(3).times.with(lines)
|
148
|
+
channel.should_receive(:eof!).exactly(3).times
|
149
|
+
session.should_receive(:loop).exactly(3).times
|
150
|
+
end
|
151
|
+
let(:arguments) {['app', 'deploy', @targz_filename, '--app', DEPLOYMENT_APP_NAME]}
|
152
|
+
it "should not succeed" do
|
153
|
+
expect{ run }.to exit_with_code(133)
|
154
|
+
run_output.should match(/Deployment of file '#{@targz_filename}' in progress for application #{DEPLOYMENT_APP_NAME} .../)
|
155
|
+
run_output.should match(/Invalid file/)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context "fails when deploying git ref" do
|
160
|
+
before (:each) { Net::SSH.should_receive(:start).and_raise(Errno::ECONNREFUSED) }
|
161
|
+
let(:arguments) {['app', 'deploy', 'master', '--app', DEPLOYMENT_APP_NAME]}
|
162
|
+
it "should exit with error" do
|
163
|
+
expect{ run }.to exit_with_code(1)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
context "fails when deploying binary file" do
|
168
|
+
before (:each) { Net::SSH.should_receive(:start).and_raise(Errno::ECONNREFUSED) }
|
169
|
+
let(:arguments) {['app', 'deploy', @targz_filename, '--app', DEPLOYMENT_APP_NAME]}
|
170
|
+
it "should exit with error" do
|
171
|
+
expect{ run }.to exit_with_code(1)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
context "fails when deploying binary file" do
|
176
|
+
before (:each) { Net::SSH.should_receive(:start).and_raise(SocketError) }
|
177
|
+
let(:arguments) {['app', 'deploy', @targz_filename, '--app', DEPLOYMENT_APP_NAME]}
|
178
|
+
it "should exit with error" do
|
179
|
+
expect{ run }.to exit_with_code(1)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
context "fails when deploying url file" do
|
184
|
+
before (:each) { Net::SSH.should_receive(:start).and_raise(Errno::ECONNREFUSED) }
|
185
|
+
let(:arguments) {['app', 'deploy', 'http://foo.com/deploy.tar.gz', '--app', DEPLOYMENT_APP_NAME]}
|
186
|
+
it "should exit with error" do
|
187
|
+
expect{ run }.to exit_with_code(1)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
context "fails when deploying url file" do
|
192
|
+
before (:each) { Net::SSH.should_receive(:start).and_raise(SocketError) }
|
193
|
+
let(:arguments) {['app', 'deploy', 'http://foo.com/deploy.tar.gz', '--app', DEPLOYMENT_APP_NAME]}
|
194
|
+
it "should exit with error" do
|
195
|
+
expect{ run }.to exit_with_code(1)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
context 'when run against an unsupported server' do
|
200
|
+
before {
|
201
|
+
@rest_app.links.delete 'UPDATE'
|
202
|
+
@rest_app.links.delete 'DEPLOY'
|
203
|
+
}
|
204
|
+
let(:arguments) {['app', 'deploy', 'master', '--app', DEPLOYMENT_APP_NAME]}
|
205
|
+
it "should raise not supported exception" do
|
206
|
+
expect{ run }.to exit_with_code(132)
|
207
|
+
run_output.should match(/The server does not support deployments/)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context "ssh authentication failure" do
|
212
|
+
before (:each) { Net::SSH.should_receive(:start).exactly(2).times.and_raise(Net::SSH::AuthenticationFailed) }
|
213
|
+
let(:arguments) {['app', 'deploy', 'master', '--app', DEPLOYMENT_APP_NAME]}
|
214
|
+
it "should exit with error" do
|
215
|
+
expect{ run }.to exit_with_code(1)
|
216
|
+
run_output.should match(/Authentication to server test.domain.com with user user failed/)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
|
222
|
+
describe "activate deployment" do
|
223
|
+
context "activates 123456" do
|
224
|
+
before { Net::SSH.should_receive(:start).exactly(3).times.with('test.domain.com', 'user', :compression => false) }
|
225
|
+
let(:arguments) {['deployment', 'activate', '123456', '--app', DEPLOYMENT_APP_NAME]}
|
226
|
+
it "should succeed" do
|
227
|
+
expect{ run }.to exit_with_code(0)
|
228
|
+
run_output.should match(/Activating deployment '123456' on application #{DEPLOYMENT_APP_NAME} .../)
|
229
|
+
run_output.should match(/Success/)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
context "fails with ssh error" do
|
234
|
+
before (:each) { Net::SSH.should_receive(:start).and_raise(Errno::ECONNREFUSED) }
|
235
|
+
let(:arguments) {['deployment', 'activate', '123456', '--app', DEPLOYMENT_APP_NAME]}
|
236
|
+
it "should exit with error" do
|
237
|
+
expect{ run }.to exit_with_code(1)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
describe "list deployments" do
|
243
|
+
context "simple" do
|
244
|
+
let(:arguments) {['deployment', 'list', DEPLOYMENT_APP_NAME]}
|
245
|
+
it "should succeed" do
|
246
|
+
expect{ run }.to exit_with_code(0)
|
247
|
+
run_output.should match(/Jan 01\, 2000 1\:00 AM\, deployment 0000001/)
|
248
|
+
run_output.should match(/Jan 01\, 2000 2\:00 AM\, deployment 0000002/)
|
249
|
+
run_output.should match(/Jan 01\, 2000 3\:00 AM\, deployment 0000003 \(rolled back\)/)
|
250
|
+
run_output.should match(/Jan 01\, 2000 4\:00 AM\, deployment 0000004 \(rolled back\)/)
|
251
|
+
run_output.should match(/Jan 01\, 2000 5\:00 AM\, deployment 0000003 \(rollback to Jan 01\, 2000 3\:00 AM\, rolled back\)/)
|
252
|
+
run_output.should match(/Jan 01\, 2000 5\:00 AM\, deployment 0000005 \(rolled back\)/)
|
253
|
+
run_output.should match(/Jan 01\, 2000 6\:00 AM\, deployment 0000002 \(rollback to Jan 01\, 2000 2\:00 AM\)/)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
describe "show deployment" do
|
259
|
+
context "simple" do
|
260
|
+
let(:arguments) {['deployment', 'show', '0000001', '--app', DEPLOYMENT_APP_NAME]}
|
261
|
+
it "should succeed" do
|
262
|
+
expect{ run }.to exit_with_code(0)
|
263
|
+
run_output.should match(/Deployment ID 0000001/)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
context "fails when deployment is not found" do
|
268
|
+
let(:arguments) {['deployment', 'show', 'zee', '--app', DEPLOYMENT_APP_NAME]}
|
269
|
+
it "should succeed" do
|
270
|
+
expect{ run }.to exit_with_code(131)
|
271
|
+
run_output.should match(/Deployment ID 'zee' not found for application #{DEPLOYMENT_APP_NAME}/)
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
describe "show configuration" do
|
277
|
+
context "simple" do
|
278
|
+
let(:arguments) {['app', 'show', '--app', DEPLOYMENT_APP_NAME, '--configuration']}
|
279
|
+
it "should succeed" do
|
280
|
+
expect{ run }.to exit_with_code(0)
|
281
|
+
#run_output.should match(/Deployment ID 1/)
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
end
|
@@ -71,6 +71,18 @@ describe RHC::Commands::Snapshot do
|
|
71
71
|
it { expect { run }.to exit_with_code(130) }
|
72
72
|
end
|
73
73
|
|
74
|
+
describe 'snapshot save deployment' do
|
75
|
+
let(:arguments) {['snapshot', 'save', '--app', 'mockapp', '--deployment', '-d']}
|
76
|
+
|
77
|
+
context 'when saving a deployment snapshot' do
|
78
|
+
before do
|
79
|
+
subject.class.any_instance.should_receive(:exec).with("ssh #{@ssh_uri.user}@#{@ssh_uri.host} 'gear archive-deployment' > #{@app.name}.tar.gz").and_return([0, 'some save output'])
|
80
|
+
end
|
81
|
+
it { expect { run }.to exit_with_code(0) }
|
82
|
+
it { run_output.should_not match 'some save output' }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
74
86
|
end
|
75
87
|
|
76
88
|
describe 'snapshot save with invalid ssh executable' do
|
@@ -14,7 +14,13 @@ describe RHC::Commands::Sshkey do
|
|
14
14
|
let(:arguments) { %w[sshkey list --noprompt --config test.conf -l test@test.foo -p password --trace] }
|
15
15
|
|
16
16
|
it { expect { run }.to exit_with_code(0) }
|
17
|
+
|
17
18
|
it { run_output.should match(/mockkey1 \(type: ssh-rsa\)/) }
|
19
|
+
it { run_output.should match(/Fingerprint:.*0f:ce:86:80:df:a0:81:ca:db:f1:a7:0c:70:85:ce:00/) }
|
20
|
+
|
21
|
+
it { run_output.should match(/mockkey3 \(type: krb5-principal\)/) }
|
22
|
+
it { run_output.should match(/Principal:.* mockuser@mockdomain/) }
|
23
|
+
it { run_output.should_not match(/Fingerprint:.*Invalid key/) }
|
18
24
|
end
|
19
25
|
end
|
20
26
|
|
@@ -44,6 +50,17 @@ describe RHC::Commands::Sshkey do
|
|
44
50
|
end
|
45
51
|
end
|
46
52
|
|
53
|
+
context "when adding a valid key via command line arguments" do
|
54
|
+
let(:arguments) { %w[sshkey add --noprompt --config test.conf -l test@test.foo -p password foobar --type ssh-rsa --content AAAAB3NzaC1yc2EAAAADAQABAAABAQCnCOqK7/mmvZ9AtCAerxjAasJ1rSpfuWT4vNm1+O/Fh0Di3chTWjY9a0M2hEnqkqnVG589L9CqCUeT0kdc3Vgw3JEcacSUr1z7tLr9kO+p/D5lSdQYzDGGRFOZ0H6lc/y8iNxWV1VO/sJvKx6cr5zvKIn8Q6GvhVNOxlai0IOb9FJxLGK95GLpZ+elzh8Tc9giy7KfwheAwhV2JoF9uRltE5JP/CNs7w/E29i1Z+jlueuu8RVotLmhSVNJm91Ey7OCtoI1iBE0Wv/SucFe32Qi08RWTM/MaGGz93KQNOVRGjNkosJjPmP1qU6WGBfliDkJAZXB0b6sEcnx1fbVikwZ] }
|
55
|
+
|
56
|
+
it 'adds the key' do
|
57
|
+
keys = rest_client.sshkeys
|
58
|
+
num_keys = keys.length
|
59
|
+
expect { run }.to exit_with_code(0)
|
60
|
+
rest_client.sshkeys.length.should == num_keys + 1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
47
64
|
context "when adding an invalid key" do
|
48
65
|
let(:arguments) { %w[sshkey add --noprompt --config test.conf -l test@test.foo -p password foobar id_rsa.pub] }
|
49
66
|
|
@@ -79,6 +96,18 @@ describe RHC::Commands::Sshkey do
|
|
79
96
|
end
|
80
97
|
end
|
81
98
|
|
99
|
+
context "when adding an invalid key via command line arguments" do
|
100
|
+
let(:arguments) { %w[sshkey add --noprompt --config test.conf -l test@test.foo -p password foobar --type ssh-rsa --content abcdef] }
|
101
|
+
|
102
|
+
it "fails to add the key" do
|
103
|
+
keys = rest_client.sshkeys
|
104
|
+
num_keys = keys.length
|
105
|
+
expect { run }.to exit_with_code(128)
|
106
|
+
expect { run_output.should match(/Name:.* mockkey/) }
|
107
|
+
rest_client.sshkeys.length.should == num_keys
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
82
111
|
context "when adding an invalid key with --confirm" do
|
83
112
|
let(:arguments) { %w[sshkey add --noprompt --confirm --config test.conf -l test@test.foo -p password foobar id_rsa.pub] }
|
84
113
|
|
@@ -123,6 +152,14 @@ describe RHC::Commands::Sshkey do
|
|
123
152
|
end
|
124
153
|
|
125
154
|
end
|
155
|
+
|
156
|
+
context "when adding a key without correct arguments" do
|
157
|
+
let(:arguments) { %w[sshkey add --noprompt --config test.conf -l test@test.foo -p password foobar] }
|
158
|
+
|
159
|
+
it "exits with argument error" do
|
160
|
+
expect { run }.to exit_with_code(1)
|
161
|
+
end
|
162
|
+
end
|
126
163
|
end
|
127
164
|
|
128
165
|
describe "remove" do
|
@@ -27,7 +27,7 @@ describe RHC::Commands::Tail do
|
|
27
27
|
let(:arguments) { ['tail', 'mock-app-0'] }
|
28
28
|
|
29
29
|
context 'when ssh connects' do
|
30
|
-
before (:each) {Net::SSH.should_receive(:start).with('test.domain.com', 'user') }
|
30
|
+
before (:each) {Net::SSH.should_receive(:start).with('test.domain.com', 'user', :compression => false) }
|
31
31
|
it { expect { run }.to exit_with_code(0) }
|
32
32
|
end
|
33
33
|
|
@@ -49,7 +49,7 @@ describe RHC::Commands::Tail do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
context 'succeeds when a gear is specified' do
|
52
|
-
before (:each) {Net::SSH.should_receive(:start).with('fakesshurl.com', 'fakegearid0') }
|
52
|
+
before (:each) {Net::SSH.should_receive(:start).with('fakesshurl.com', 'fakegearid0', :compression => false) }
|
53
53
|
let(:arguments) { ['tail', 'mock-app-0', '--gear', 'fakegearid0' ] }
|
54
54
|
|
55
55
|
it { run_output.should_not =~ /Connecting to fakesshurl.com/ }
|
@@ -267,7 +267,7 @@ module RHC
|
|
267
267
|
:status => 200
|
268
268
|
})
|
269
269
|
stub_api_request(:any, api_links['SHOW_DOMAIN']['relative'].gsub(/:name/, 'mock_domain_2')).
|
270
|
-
to_return({ :body => {:messages => [{:exit_code => 127}]}.to_json,
|
270
|
+
to_return({ :body => {:messages => [{:exit_code => 127}, {:severity => 'warning', :text => 'A warning'}]}.to_json,
|
271
271
|
:status => 404
|
272
272
|
})
|
273
273
|
end
|
@@ -284,7 +284,11 @@ module RHC
|
|
284
284
|
match.class.should == RHC::Rest::Domain
|
285
285
|
end
|
286
286
|
it "raise an error when no matching domain IDs can be found" do
|
287
|
-
expect
|
287
|
+
expect{ client.find_domain('mock_domain_2') }.to raise_error(RHC::Rest::DomainNotFoundException)
|
288
|
+
end
|
289
|
+
it "prints a warning when an error is returned" do
|
290
|
+
client.should_receive(:warn).with('A warning')
|
291
|
+
expect{ client.find_domain('mock_domain_2') }.to raise_error(RHC::Rest::DomainNotFoundException)
|
288
292
|
end
|
289
293
|
end
|
290
294
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -420,7 +420,7 @@ module ClassSpecHelpers
|
|
420
420
|
session.should_receive(:loop) unless hosts.empty?
|
421
421
|
Net::SSH::Multi.should_receive(:start).and_yield(session).with do |opts|
|
422
422
|
opts.should have_key(:on_error)
|
423
|
-
capture_all{ opts[:on_error].call('test') }.should
|
423
|
+
capture_all{ opts[:on_error].call('test') }.should =~ /Unable to connect to gear test/ if check_error
|
424
424
|
true
|
425
425
|
end
|
426
426
|
session
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 69
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 16
|
9
|
+
- 9
|
10
|
+
version: 1.16.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Red Hat
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-
|
18
|
+
date: 2013-11-05 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: net-ssh
|
@@ -253,6 +253,7 @@ files:
|
|
253
253
|
- lib/rhc/helpers.rb
|
254
254
|
- lib/rhc/coverage_helper.rb
|
255
255
|
- lib/rhc/json.rb
|
256
|
+
- lib/rhc/deployment_helpers.rb
|
256
257
|
- lib/rhc/git_helpers.rb
|
257
258
|
- lib/rhc/auth.rb
|
258
259
|
- lib/rhc/exceptions.rb
|
@@ -270,6 +271,7 @@ files:
|
|
270
271
|
- lib/rhc/commands/authorization.rb
|
271
272
|
- lib/rhc/commands/member.rb
|
272
273
|
- lib/rhc/commands/sshkey.rb
|
274
|
+
- lib/rhc/commands/deployment.rb
|
273
275
|
- lib/rhc/commands/snapshot.rb
|
274
276
|
- lib/rhc/commands/server.rb
|
275
277
|
- lib/rhc/commands/app.rb
|
@@ -289,6 +291,7 @@ files:
|
|
289
291
|
- lib/rhc/rest/user.rb
|
290
292
|
- lib/rhc/rest/attributes.rb
|
291
293
|
- lib/rhc/rest/environment_variable.rb
|
294
|
+
- lib/rhc/rest/activation.rb
|
292
295
|
- lib/rhc/rest/api.rb
|
293
296
|
- lib/rhc/rest/alias.rb
|
294
297
|
- lib/rhc/rest/domain.rb
|
@@ -296,6 +299,7 @@ files:
|
|
296
299
|
- lib/rhc/rest/cartridge.rb
|
297
300
|
- lib/rhc/rest/membership.rb
|
298
301
|
- lib/rhc/rest/authorization.rb
|
302
|
+
- lib/rhc/rest/deployment.rb
|
299
303
|
- lib/rhc/rest/gear_group.rb
|
300
304
|
- lib/rhc/rest/mock.rb
|
301
305
|
- lib/rhc/rest/client.rb
|
@@ -338,6 +342,7 @@ files:
|
|
338
342
|
- spec/rhc/commands/tail_spec.rb
|
339
343
|
- spec/rhc/commands/port_forward_spec.rb
|
340
344
|
- spec/rhc/commands/app_spec.rb
|
345
|
+
- spec/rhc/commands/deployment_spec.rb
|
341
346
|
- spec/rhc/commands/domain_spec.rb
|
342
347
|
- spec/rhc/commands/sshkey_spec.rb
|
343
348
|
- spec/rhc/commands/threaddump_spec.rb
|
@@ -363,8 +368,11 @@ files:
|
|
363
368
|
- spec/keys/example.pem
|
364
369
|
- spec/keys/example_private.pem
|
365
370
|
- features/core_feature.rb
|
371
|
+
- features/assets/deploy.tar.gz
|
372
|
+
- features/keys_feature.rb
|
366
373
|
- features/domains_feature.rb
|
367
374
|
- features/members_feature.rb
|
375
|
+
- features/deployments_feature.rb
|
368
376
|
- bin/rhc
|
369
377
|
homepage: https://github.com/openshift/rhc
|
370
378
|
licenses: []
|
@@ -428,6 +436,7 @@ test_files:
|
|
428
436
|
- spec/rhc/commands/tail_spec.rb
|
429
437
|
- spec/rhc/commands/port_forward_spec.rb
|
430
438
|
- spec/rhc/commands/app_spec.rb
|
439
|
+
- spec/rhc/commands/deployment_spec.rb
|
431
440
|
- spec/rhc/commands/domain_spec.rb
|
432
441
|
- spec/rhc/commands/sshkey_spec.rb
|
433
442
|
- spec/rhc/commands/threaddump_spec.rb
|
@@ -453,5 +462,8 @@ test_files:
|
|
453
462
|
- spec/keys/example.pem
|
454
463
|
- spec/keys/example_private.pem
|
455
464
|
- features/core_feature.rb
|
465
|
+
- features/assets/deploy.tar.gz
|
466
|
+
- features/keys_feature.rb
|
456
467
|
- features/domains_feature.rb
|
457
468
|
- features/members_feature.rb
|
469
|
+
- features/deployments_feature.rb
|