rhc 1.2.7 → 1.3.8
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/bin/rhc +6 -8
- data/bin/rhc-chk +23 -10
- data/features/domain.feature +1 -1
- data/features/lib/rhc_helper.rb +3 -2
- data/features/lib/rhc_helper/api.rb +7 -0
- data/features/lib/rhc_helper/app.rb +8 -10
- data/features/lib/rhc_helper/domain.rb +2 -1
- data/features/lib/rhc_helper/runnable.rb +2 -24
- data/features/sshkey.feature +3 -3
- data/features/step_definitions/cartridge_steps.rb +6 -6
- data/features/step_definitions/client_steps.rb +0 -1
- data/features/step_definitions/sshkey_steps.rb +2 -2
- data/features/support/before_hooks.rb +0 -1
- data/features/support/env.rb +5 -3
- data/lib/rhc-common.rb +1 -1
- data/lib/rhc.rb +9 -8
- data/lib/rhc/auth.rb +3 -0
- data/lib/rhc/auth/basic.rb +54 -0
- data/lib/rhc/cartridge_helpers.rb +11 -5
- data/lib/rhc/cli.rb +4 -2
- data/lib/rhc/command_runner.rb +35 -30
- data/lib/rhc/commands.rb +127 -18
- data/lib/rhc/commands/account.rb +24 -0
- data/lib/rhc/commands/alias.rb +1 -1
- data/lib/rhc/commands/app.rb +210 -209
- data/lib/rhc/commands/apps.rb +22 -0
- data/lib/rhc/commands/base.rb +10 -77
- data/lib/rhc/commands/cartridge.rb +35 -35
- data/lib/rhc/commands/domain.rb +20 -13
- data/lib/rhc/commands/git_clone.rb +30 -0
- data/lib/rhc/commands/{port-forward.rb → port_forward.rb} +3 -3
- data/lib/rhc/commands/server.rb +28 -16
- data/lib/rhc/commands/setup.rb +18 -1
- data/lib/rhc/commands/snapshot.rb +4 -4
- data/lib/rhc/commands/sshkey.rb +4 -18
- data/lib/rhc/commands/tail.rb +32 -9
- data/lib/rhc/config.rb +168 -99
- data/lib/rhc/context_helper.rb +22 -9
- data/lib/rhc/core_ext.rb +41 -1
- data/lib/rhc/exceptions.rb +21 -5
- data/lib/rhc/git_helpers.rb +81 -0
- data/lib/rhc/help_formatter.rb +21 -1
- data/lib/rhc/helpers.rb +222 -87
- data/lib/rhc/output_helpers.rb +94 -110
- data/lib/rhc/rest.rb +15 -198
- data/lib/rhc/rest/api.rb +88 -0
- data/lib/rhc/rest/application.rb +29 -30
- data/lib/rhc/rest/attributes.rb +27 -0
- data/lib/rhc/rest/base.rb +29 -33
- data/lib/rhc/rest/cartridge.rb +42 -20
- data/lib/rhc/rest/client.rb +351 -89
- data/lib/rhc/rest/domain.rb +7 -13
- data/lib/rhc/rest/gear_group.rb +1 -1
- data/lib/rhc/rest/key.rb +7 -2
- data/lib/rhc/rest/mock.rb +609 -0
- data/lib/rhc/rest/user.rb +6 -2
- data/lib/rhc/{ssh_key_helpers.rb → ssh_helpers.rb} +58 -28
- data/lib/rhc/{targz.rb → tar_gz.rb} +0 -0
- data/lib/rhc/usage_templates/command_help.erb +4 -1
- data/lib/rhc/usage_templates/help.erb +24 -11
- data/lib/rhc/usage_templates/options_help.erb +14 -0
- data/lib/rhc/wizard.rb +283 -213
- data/spec/keys/example.pem +23 -0
- data/spec/keys/example_private.pem +27 -0
- data/spec/keys/server.pem +19 -0
- data/spec/rest_spec_helper.rb +3 -371
- data/spec/rhc/auth_spec.rb +226 -0
- data/spec/rhc/cli_spec.rb +41 -14
- data/spec/rhc/command_spec.rb +44 -15
- data/spec/rhc/commands/account_spec.rb +41 -0
- data/spec/rhc/commands/alias_spec.rb +16 -15
- data/spec/rhc/commands/app_spec.rb +115 -92
- data/spec/rhc/commands/apps_spec.rb +39 -0
- data/spec/rhc/commands/cartridge_spec.rb +134 -112
- data/spec/rhc/commands/domain_spec.rb +31 -86
- data/spec/rhc/commands/git_clone_spec.rb +56 -0
- data/spec/rhc/commands/{port-forward_spec.rb → port_forward_spec.rb} +27 -32
- data/spec/rhc/commands/server_spec.rb +28 -3
- data/spec/rhc/commands/setup_spec.rb +29 -11
- data/spec/rhc/commands/snapshot_spec.rb +4 -3
- data/spec/rhc/commands/sshkey_spec.rb +24 -56
- data/spec/rhc/commands/tail_spec.rb +26 -9
- data/spec/rhc/commands/threaddump_spec.rb +12 -11
- data/spec/rhc/config_spec.rb +211 -164
- data/spec/rhc/context_spec.rb +2 -0
- data/spec/rhc/helpers_spec.rb +242 -46
- data/spec/rhc/rest_application_spec.rb +42 -28
- data/spec/rhc/rest_client_spec.rb +110 -93
- data/spec/rhc/rest_spec.rb +220 -131
- data/spec/rhc/targz_spec.rb +1 -1
- data/spec/rhc/wizard_spec.rb +435 -624
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +140 -6
- data/spec/wizard_spec_helper.rb +326 -0
- metadata +163 -143
- data/lib/rhc/client.rb +0 -17
- data/lib/rhc/git_helper.rb +0 -59
@@ -1,24 +1,21 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'rest_spec_helper'
|
3
3
|
require 'rhc/commands/domain'
|
4
|
-
require 'rhc/config'
|
5
4
|
|
6
5
|
describe RHC::Commands::Domain do
|
7
|
-
|
8
|
-
|
9
|
-
end
|
6
|
+
let!(:rest_client){ MockRestClient.new }
|
7
|
+
before{ user_config }
|
10
8
|
|
11
9
|
describe 'default action' do
|
12
10
|
context 'when run with no domains' do
|
13
11
|
let(:arguments) { ['domain', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
it { expect { run }.should exit_with_code(0) }
|
18
|
-
it { run_output.should match(/No domain exists. You can use/) }
|
12
|
+
|
13
|
+
it { expect { run }.should exit_with_code(1) }
|
14
|
+
it { run_output.should match(/In order to deploy applications.*rhc domain create/) }
|
19
15
|
end
|
20
16
|
context 'when help is shown' do
|
21
17
|
let(:arguments) { ['domain', '--noprompt', '--help'] }
|
18
|
+
|
22
19
|
it { expect { run }.should exit_with_code(0) }
|
23
20
|
it { run_output.should match(/The default action for this resource is 'show'/) }
|
24
21
|
end
|
@@ -28,44 +25,36 @@ describe RHC::Commands::Domain do
|
|
28
25
|
let(:arguments) { ['domain', 'show', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
29
26
|
|
30
27
|
context 'when run with no domains' do
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
it { expect { run }.should exit_with_code(0) }
|
35
|
-
it { run_output.should match(/No domain exists. You can use/) }
|
28
|
+
it { expect { run }.should exit_with_code(1) }
|
29
|
+
it { run_output.should match(/In order to deploy applications.*rhc domain create/) }
|
36
30
|
end
|
37
31
|
|
38
32
|
context 'when run with one domain no apps' do
|
39
|
-
before(
|
40
|
-
|
41
|
-
@rc.add_domain("onedomain")
|
42
|
-
end
|
33
|
+
before{ rest_client.add_domain("onedomain") }
|
34
|
+
|
43
35
|
it { expect { run }.should exit_with_code(0) }
|
44
36
|
it "should match output" do
|
45
37
|
output = run_output
|
46
|
-
output.should match(
|
47
|
-
output.should match(/No applications. You can use/)
|
38
|
+
output.should match("The domain onedomain exists but has no applications. You can use")
|
48
39
|
end
|
49
40
|
end
|
50
41
|
|
51
42
|
context 'when run with multiple domain no apps' do
|
52
43
|
before(:each) do
|
53
|
-
|
54
|
-
|
55
|
-
@rc.add_domain("seconddomain")
|
44
|
+
rest_client.add_domain("firstdomain")
|
45
|
+
rest_client.add_domain("seconddomain")
|
56
46
|
end
|
57
47
|
it { expect { run }.should exit_with_code(0) }
|
58
48
|
it "should match output" do
|
59
49
|
output = run_output
|
60
|
-
output.should match("
|
50
|
+
output.should match("The domain firstdomain exists but has no applications. You can use")
|
61
51
|
output.should_not match("Applications in seconddomain")
|
62
52
|
end
|
63
53
|
end
|
64
54
|
|
65
55
|
context 'when run with one domain multiple apps' do
|
66
56
|
before(:each) do
|
67
|
-
|
68
|
-
d = @rc.add_domain("appdomain")
|
57
|
+
d = rest_client.add_domain("appdomain")
|
69
58
|
a = d.add_application("app_no_carts", "testframework-1.0")
|
70
59
|
a = d.add_application("app_multi_carts", "testframework-1.0")
|
71
60
|
a.add_cartridge("testcart-1")
|
@@ -86,15 +75,14 @@ describe RHC::Commands::Domain do
|
|
86
75
|
|
87
76
|
context 'when run with an app without cartridges' do
|
88
77
|
before(:each) do
|
89
|
-
|
90
|
-
d = @rc.add_domain("appdomain")
|
78
|
+
d = rest_client.add_domain("appdomain")
|
91
79
|
a = d.add_application("app_no_carts")
|
92
80
|
end
|
93
81
|
it { expect { run }.should exit_with_code(0) }
|
94
82
|
it "should match output" do
|
95
83
|
output = run_output
|
96
84
|
output.should match("app_no_carts")
|
97
|
-
output.should match(/
|
85
|
+
output.should match(/127.0.0.1\s*$/m)
|
98
86
|
end
|
99
87
|
end
|
100
88
|
end
|
@@ -103,13 +91,10 @@ describe RHC::Commands::Domain do
|
|
103
91
|
let(:arguments) { ['domain', 'create', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password', 'testnamespace'] }
|
104
92
|
|
105
93
|
context 'when no issues with ' do
|
106
|
-
before(:each) do
|
107
|
-
@rc = MockRestClient.new
|
108
|
-
end
|
109
94
|
|
110
95
|
it "should create a domain" do
|
111
96
|
expect { run }.should exit_with_code(0)
|
112
|
-
|
97
|
+
rest_client.domains[0].id.should == 'testnamespace'
|
113
98
|
end
|
114
99
|
it { run_output.should match(/'testnamespace'.*?RESULT:.*?Success/m) }
|
115
100
|
end
|
@@ -119,26 +104,19 @@ describe RHC::Commands::Domain do
|
|
119
104
|
let(:arguments) { ['domain', 'update', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password', 'olddomain', 'alterednamespace'] }
|
120
105
|
|
121
106
|
context 'when no issues with ' do
|
122
|
-
before(
|
123
|
-
@rc = MockRestClient.new
|
124
|
-
@rc.add_domain("olddomain")
|
125
|
-
end
|
107
|
+
before{ rest_client.add_domain("olddomain") }
|
126
108
|
|
127
109
|
it "should update a domain" do
|
128
110
|
expect { run }.should exit_with_code(0)
|
129
|
-
|
111
|
+
rest_client.domains[0].id.should == 'alterednamespace'
|
130
112
|
end
|
131
113
|
it { run_output.should match(/Changing namespace 'olddomain' to 'alterednamespace'.*?RESULT:.*?Success/m) }
|
132
114
|
end
|
133
115
|
|
134
116
|
context 'when there is no domain' do
|
135
|
-
before(:each) do
|
136
|
-
@rc = MockRestClient.new
|
137
|
-
end
|
138
|
-
|
139
117
|
it "should not create a domain" do
|
140
118
|
expect { run }.should exit_with_code(127)
|
141
|
-
|
119
|
+
rest_client.domains.empty?.should be_true
|
142
120
|
end
|
143
121
|
it { run_output.should match("does not exist") }
|
144
122
|
end
|
@@ -148,14 +126,11 @@ describe RHC::Commands::Domain do
|
|
148
126
|
let(:arguments) { ['domain', 'alter', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password', 'olddomain', 'alterednamespace'] }
|
149
127
|
|
150
128
|
context 'when no issues with ' do
|
151
|
-
before(
|
152
|
-
@rc = MockRestClient.new
|
153
|
-
@rc.add_domain("olddomain")
|
154
|
-
end
|
129
|
+
before{ rest_client.add_domain("olddomain") }
|
155
130
|
|
156
131
|
it "should update a domain" do
|
157
132
|
expect { run }.should exit_with_code(0)
|
158
|
-
|
133
|
+
rest_client.domains[0].id.should == 'alterednamespace'
|
159
134
|
end
|
160
135
|
it { run_output.should match(/Changing namespace 'olddomain' to 'alterednamespace'.*?RESULT:.*?Success/m) }
|
161
136
|
end
|
@@ -165,39 +140,32 @@ describe RHC::Commands::Domain do
|
|
165
140
|
let(:arguments) { ['domain', 'delete', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password', 'deleteme'] }
|
166
141
|
|
167
142
|
context 'when no issues with ' do
|
168
|
-
before(
|
169
|
-
@rc = MockRestClient.new
|
170
|
-
@rc.add_domain("deleteme")
|
171
|
-
end
|
143
|
+
before{ rest_client.add_domain("deleteme") }
|
172
144
|
|
173
145
|
it "should delete a domain" do
|
174
146
|
expect { run }.should exit_with_code(0)
|
175
|
-
|
147
|
+
rest_client.domains.empty?.should be_true
|
176
148
|
end
|
177
149
|
end
|
178
150
|
|
179
151
|
context 'when there is a different domain' do
|
180
|
-
before(
|
181
|
-
@rc = MockRestClient.new
|
182
|
-
@rc.add_domain("dontdelete")
|
183
|
-
end
|
152
|
+
before{ rest_client.add_domain("dontdelete") }
|
184
153
|
|
185
154
|
it "should error out" do
|
186
155
|
expect { run }.should exit_with_code(127)
|
187
|
-
|
156
|
+
rest_client.domains[0].id.should == 'dontdelete'
|
188
157
|
end
|
189
158
|
it { run_output.should match("Domain deleteme does not exist") }
|
190
159
|
end
|
191
160
|
|
192
161
|
context 'when there are applications on the domain' do
|
193
162
|
before(:each) do
|
194
|
-
|
195
|
-
domain = @rc.add_domain("deleteme")
|
163
|
+
domain = rest_client.add_domain("deleteme")
|
196
164
|
domain.add_application 'testapp1', 'mock-1.0'
|
197
165
|
end
|
198
166
|
it "should error out" do
|
199
167
|
expect { run }.should exit_with_code(128)
|
200
|
-
|
168
|
+
rest_client.domains[0].id.should == 'deleteme'
|
201
169
|
end
|
202
170
|
it { run_output.should match("Domain contains applications.*?Delete applications first.") }
|
203
171
|
end
|
@@ -207,34 +175,11 @@ describe RHC::Commands::Domain do
|
|
207
175
|
let(:arguments) { ['domain', 'destroy', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password', 'deleteme'] }
|
208
176
|
|
209
177
|
context 'when no issues with ' do
|
210
|
-
before(
|
211
|
-
@rc = MockRestClient.new
|
212
|
-
@rc.add_domain("deleteme")
|
213
|
-
end
|
178
|
+
before{ rest_client.add_domain("deleteme") }
|
214
179
|
|
215
180
|
it "should delete a domain" do
|
216
181
|
expect { run }.should exit_with_code(0)
|
217
|
-
|
218
|
-
end
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
describe 'status' do
|
223
|
-
let(:arguments) { ['domain', 'status', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
224
|
-
|
225
|
-
before(:each) do
|
226
|
-
Kernel.stub!(:system) do |cmd|
|
227
|
-
@cmd = cmd
|
228
|
-
# run the true command to get $?.exitstatus == 0
|
229
|
-
system("true")
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
context 'rhc-chk should be executed' do
|
234
|
-
it "runs" do
|
235
|
-
expect { run }.should exit_with_code(0)
|
236
|
-
# check lengths here because different versions of ruby output the switches in different order
|
237
|
-
@cmd.length.should == "rhc-chk --noprompt true --config test.conf --rhlogin test@test.foo --password password 2>&1".length
|
182
|
+
rest_client.domains.empty?.should be_true
|
238
183
|
end
|
239
184
|
end
|
240
185
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rest_spec_helper'
|
3
|
+
require 'rhc/commands/git_clone'
|
4
|
+
|
5
|
+
describe RHC::Commands::GitClone do
|
6
|
+
before(:each) do
|
7
|
+
FakeFS.activate!
|
8
|
+
FakeFS::FileSystem.clear
|
9
|
+
user_config
|
10
|
+
@instance = RHC::Commands::GitClone.new
|
11
|
+
RHC::Commands::GitClone.stub(:new) do
|
12
|
+
@instance.stub(:git_config_get) { "" }
|
13
|
+
@instance.stub(:git_config_set) { "" }
|
14
|
+
Kernel.stub(:sleep) { }
|
15
|
+
@instance.stub(:host_exists?) do |host|
|
16
|
+
host.match("dnserror") ? false : true
|
17
|
+
end
|
18
|
+
@instance
|
19
|
+
end
|
20
|
+
end
|
21
|
+
let!(:rest_client){ MockRestClient.new }
|
22
|
+
before(:each) do
|
23
|
+
@domain = rest_client.add_domain("mockdomain")
|
24
|
+
@app = @domain.add_application("app1", "mock_unique_standalone_cart")
|
25
|
+
end
|
26
|
+
|
27
|
+
after(:each) do
|
28
|
+
FakeFS.deactivate!
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'git-clone' do
|
32
|
+
let(:arguments) { ['app', 'git-clone', 'app1'] }
|
33
|
+
|
34
|
+
context "stubbing git_clone_repo" do
|
35
|
+
context "reports success successfully" do
|
36
|
+
before do
|
37
|
+
@instance.stub(:git_clone_repo) do |git_url, repo_dir|
|
38
|
+
Dir::mkdir(repo_dir)
|
39
|
+
say "Cloned"
|
40
|
+
true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it { expect { run }.should exit_with_code(0) }
|
45
|
+
it { run_output.should match("Cloned") }
|
46
|
+
end
|
47
|
+
|
48
|
+
context "reports failure" do
|
49
|
+
before{ @instance.stub(:git_clone_repo).and_raise(RHC::GitException) }
|
50
|
+
|
51
|
+
it { expect { run }.should exit_with_code(216) }
|
52
|
+
it { run_output.should match("Git returned an error") }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -1,20 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require '
|
3
|
-
require 'rhc/
|
4
|
-
require 'uri'
|
2
|
+
require 'rest_spec_helper'
|
3
|
+
require 'rhc/commands/port_forward'
|
5
4
|
|
6
5
|
describe RHC::Commands::PortForward do
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
end
|
7
|
+
let!(:rest_client){ MockRestClient.new }
|
8
|
+
before{ user_config }
|
11
9
|
|
12
10
|
describe 'run' do
|
13
11
|
let(:arguments) { ['port-forward', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password', '--app', 'mockapp'] }
|
14
12
|
|
15
13
|
before :each do
|
16
|
-
@
|
17
|
-
@domain = @rc.add_domain("mockdomain")
|
14
|
+
@domain = rest_client.add_domain("mockdomain")
|
18
15
|
@app = @domain.add_application 'mockapp', 'mock-1.0'
|
19
16
|
@uri = URI.parse @app.ssh_url
|
20
17
|
@ssh = mock(Net::SSH)
|
@@ -24,7 +21,7 @@ describe RHC::Commands::PortForward do
|
|
24
21
|
before(:each) do
|
25
22
|
Net::SSH.should_receive(:start).with(@uri.host, @uri.user).and_yield(@ssh)
|
26
23
|
@ssh.should_receive(:exec!).with("rhc-list-ports").and_yield(nil, :stderr, '127.0.0.1:3306')
|
27
|
-
@gg = MockRestGearGroup.new
|
24
|
+
@gg = MockRestGearGroup.new(rest_client)
|
28
25
|
@app.should_receive(:gear_groups).and_return([@gg])
|
29
26
|
@gg.should_receive(:gears).and_return([{'state' => 'stopped', 'id' => 'fakegearid'}])
|
30
27
|
end
|
@@ -41,9 +38,9 @@ describe RHC::Commands::PortForward do
|
|
41
38
|
end
|
42
39
|
it "should error out as no ports to forward" do
|
43
40
|
expect { run }.should exit_with_code(102)
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
rest_client.domains[0].id.should == 'mockdomain'
|
42
|
+
rest_client.domains[0].applications.size.should == 1
|
43
|
+
rest_client.domains[0].applications[0].name.should == 'mockapp'
|
47
44
|
end
|
48
45
|
it { run_output.should match("no available ports to forward.") }
|
49
46
|
end
|
@@ -55,9 +52,9 @@ describe RHC::Commands::PortForward do
|
|
55
52
|
end
|
56
53
|
it "should error out as permission denied" do
|
57
54
|
expect { run }.should exit_with_code(129)
|
58
|
-
|
59
|
-
|
60
|
-
|
55
|
+
rest_client.domains[0].id.should == 'mockdomain'
|
56
|
+
rest_client.domains[0].applications.size.should == 1
|
57
|
+
rest_client.domains[0].applications[0].name.should == 'mockapp'
|
61
58
|
end
|
62
59
|
it { run_output.should match("Permission denied") }
|
63
60
|
end
|
@@ -77,9 +74,9 @@ describe RHC::Commands::PortForward do
|
|
77
74
|
end
|
78
75
|
it "should run successfully" do
|
79
76
|
expect { run }.should exit_with_code(0)
|
80
|
-
|
81
|
-
|
82
|
-
|
77
|
+
rest_client.domains[0].id.should == 'mockdomain'
|
78
|
+
rest_client.domains[0].applications.size.should == 1
|
79
|
+
rest_client.domains[0].applications[0].name.should == 'mockapp'
|
83
80
|
end
|
84
81
|
it { run_output.should match(/Forwarding ports.*Press CTRL-C/m) }
|
85
82
|
end
|
@@ -90,21 +87,19 @@ describe RHC::Commands::PortForward do
|
|
90
87
|
end
|
91
88
|
it "should error out" do
|
92
89
|
expect { run }.should exit_with_code(1)
|
93
|
-
|
94
|
-
|
95
|
-
|
90
|
+
rest_client.domains[0].id.should == 'mockdomain'
|
91
|
+
rest_client.domains[0].applications.size.should == 1
|
92
|
+
rest_client.domains[0].applications[0].name.should == 'mockapp'
|
96
93
|
end
|
97
94
|
it { run_output.should include("Error trying to forward ports.") }
|
98
95
|
end
|
99
96
|
|
100
97
|
context 'when REST client connection times out' do
|
101
98
|
before(:each) do
|
102
|
-
|
103
|
-
end
|
104
|
-
it "should error out" do
|
105
|
-
expect { run }.should exit_with_code(1)
|
99
|
+
rest_client.should_receive(:find_domain).and_raise(RHC::Rest::ConnectionException)
|
106
100
|
end
|
107
|
-
it {
|
101
|
+
it("should error out") { expect { run }.should exit_with_code(1) }
|
102
|
+
it{ run_output.should match("Connection.*failed:") }
|
108
103
|
end
|
109
104
|
|
110
105
|
context 'when port forwarding an app with ports to forward' do
|
@@ -122,9 +117,9 @@ describe RHC::Commands::PortForward do
|
|
122
117
|
end
|
123
118
|
it "should exit when user interrupts" do
|
124
119
|
expect { run }.should exit_with_code(0)
|
125
|
-
|
126
|
-
|
127
|
-
|
120
|
+
rest_client.domains[0].id.should == 'mockdomain'
|
121
|
+
rest_client.domains[0].applications.size.should == 1
|
122
|
+
rest_client.domains[0].applications[0].name.should == 'mockapp'
|
128
123
|
end
|
129
124
|
it { run_output.should include("Ending port forward") }
|
130
125
|
end
|
@@ -162,9 +157,9 @@ describe RHC::Commands::PortForward do
|
|
162
157
|
end
|
163
158
|
it "should exit when user interrupts" do
|
164
159
|
expect { run }.should exit_with_code(0)
|
165
|
-
|
166
|
-
|
167
|
-
|
160
|
+
rest_client.domains[0].id.should == 'mockdomain'
|
161
|
+
rest_client.domains[0].applications.size.should == 1
|
162
|
+
rest_client.domains[0].applications[0].name.should == 'mockapp'
|
168
163
|
end
|
169
164
|
it { run_output.should include("Ending port forward") }
|
170
165
|
end
|
@@ -1,14 +1,39 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'rest_spec_helper'
|
2
3
|
require 'rhc/commands/server'
|
3
4
|
require 'rhc/config'
|
4
5
|
|
5
6
|
describe RHC::Commands::Server do
|
6
|
-
before(:each)
|
7
|
-
|
7
|
+
before(:each){ user_config }
|
8
|
+
let(:rest_client) { MockRestClient.new }
|
9
|
+
|
10
|
+
describe 'run against a different server' do
|
11
|
+
let(:arguments) { ['server', '--server', 'foo.com', '-l', 'person', '-p', ''] }
|
12
|
+
|
13
|
+
context 'when server refuses connection' do
|
14
|
+
before { stub_request(:get, 'https://person:@foo.com/broker/rest/api').with(&user_agent_header).to_raise(SocketError) }
|
15
|
+
it('should output an error') { run_output.should =~ /Connected to foo.com.*Unable to connect to the server/m }
|
16
|
+
it { expect { run }.should exit_with_code(1) }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when API is missing' do
|
20
|
+
before { stub_request(:get, 'https://person:@foo.com/broker/rest/api').with(&user_agent_header).to_return(:status => 404) }
|
21
|
+
it('should output an error') { run_output.should =~ /Connected to foo.com.*server is not responding correctly/m }
|
22
|
+
it { expect { run }.should exit_with_code(1) }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when API is at version 1.2' do
|
26
|
+
before do
|
27
|
+
rest_client.stub(:api_version_negotiated).and_return('1.2')
|
28
|
+
end
|
29
|
+
it('should output an error') { run_output.should =~ /Connected to foo.com.*Using API version 1.2/m }
|
30
|
+
it { expect { run }.should exit_with_code(0) }
|
31
|
+
end
|
8
32
|
end
|
9
33
|
|
10
34
|
describe 'run' do
|
11
35
|
let(:arguments) { ['server'] }
|
36
|
+
before{ rest_client.stub(:auth).and_return(nil) }
|
12
37
|
|
13
38
|
context 'when no issues' do
|
14
39
|
before { stub_request(:get, 'https://openshift.redhat.com/app/status/status.json').with(&user_agent_header).to_return(:body => {'issues' => []}.to_json) }
|
@@ -17,7 +42,7 @@ describe RHC::Commands::Server do
|
|
17
42
|
end
|
18
43
|
|
19
44
|
context 'when 1 issue' do
|
20
|
-
before do
|
45
|
+
before do
|
21
46
|
stub_request(:get, 'https://openshift.redhat.com/app/status/status.json').with(&user_agent_header).to_return(:body =>
|
22
47
|
{'open' => [
|
23
48
|
{'issue' => {
|