startapp 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/COPYRIGHT +1 -0
- data/LICENSE +11 -0
- data/README.md +95 -0
- data/Rakefile +6 -0
- data/autocomplete/rhc_bash +1672 -0
- data/bin/app +37 -0
- data/conf/express.conf +8 -0
- data/features/assets/deploy.tar.gz +0 -0
- data/features/core_feature.rb +191 -0
- data/features/deployments_feature.rb +129 -0
- data/features/domains_feature.rb +58 -0
- data/features/keys_feature.rb +37 -0
- data/features/members_feature.rb +166 -0
- data/lib/rhc/auth/basic.rb +64 -0
- data/lib/rhc/auth/token.rb +102 -0
- data/lib/rhc/auth/token_store.rb +53 -0
- data/lib/rhc/auth.rb +5 -0
- data/lib/rhc/autocomplete.rb +66 -0
- data/lib/rhc/autocomplete_templates/bash.erb +39 -0
- data/lib/rhc/cartridge_helpers.rb +118 -0
- data/lib/rhc/cli.rb +40 -0
- data/lib/rhc/command_runner.rb +185 -0
- data/lib/rhc/commands/account.rb +25 -0
- data/lib/rhc/commands/alias.rb +124 -0
- data/lib/rhc/commands/app.rb +726 -0
- data/lib/rhc/commands/apps.rb +20 -0
- data/lib/rhc/commands/authorization.rb +115 -0
- data/lib/rhc/commands/base.rb +174 -0
- data/lib/rhc/commands/cartridge.rb +329 -0
- data/lib/rhc/commands/clone.rb +66 -0
- data/lib/rhc/commands/configure.rb +20 -0
- data/lib/rhc/commands/create.rb +100 -0
- data/lib/rhc/commands/delete.rb +19 -0
- data/lib/rhc/commands/deploy.rb +32 -0
- data/lib/rhc/commands/deployment.rb +82 -0
- data/lib/rhc/commands/domain.rb +172 -0
- data/lib/rhc/commands/env.rb +142 -0
- data/lib/rhc/commands/force_stop.rb +17 -0
- data/lib/rhc/commands/git_clone.rb +34 -0
- data/lib/rhc/commands/logout.rb +51 -0
- data/lib/rhc/commands/logs.rb +21 -0
- data/lib/rhc/commands/member.rb +148 -0
- data/lib/rhc/commands/port_forward.rb +197 -0
- data/lib/rhc/commands/reload.rb +17 -0
- data/lib/rhc/commands/restart.rb +17 -0
- data/lib/rhc/commands/scp.rb +54 -0
- data/lib/rhc/commands/server.rb +40 -0
- data/lib/rhc/commands/setup.rb +60 -0
- data/lib/rhc/commands/show.rb +43 -0
- data/lib/rhc/commands/snapshot.rb +137 -0
- data/lib/rhc/commands/ssh.rb +51 -0
- data/lib/rhc/commands/sshkey.rb +97 -0
- data/lib/rhc/commands/start.rb +17 -0
- data/lib/rhc/commands/stop.rb +17 -0
- data/lib/rhc/commands/tail.rb +47 -0
- data/lib/rhc/commands/threaddump.rb +14 -0
- data/lib/rhc/commands/tidy.rb +17 -0
- data/lib/rhc/commands.rb +396 -0
- data/lib/rhc/config.rb +321 -0
- data/lib/rhc/context_helper.rb +121 -0
- data/lib/rhc/core_ext.rb +202 -0
- data/lib/rhc/coverage_helper.rb +33 -0
- data/lib/rhc/deployment_helpers.rb +111 -0
- data/lib/rhc/exceptions.rb +256 -0
- data/lib/rhc/git_helpers.rb +106 -0
- data/lib/rhc/help_formatter.rb +55 -0
- data/lib/rhc/helpers.rb +481 -0
- data/lib/rhc/highline_extensions.rb +479 -0
- data/lib/rhc/json.rb +51 -0
- data/lib/rhc/output_helpers.rb +260 -0
- data/lib/rhc/rest/activation.rb +11 -0
- data/lib/rhc/rest/alias.rb +42 -0
- data/lib/rhc/rest/api.rb +87 -0
- data/lib/rhc/rest/application.rb +348 -0
- data/lib/rhc/rest/attributes.rb +36 -0
- data/lib/rhc/rest/authorization.rb +8 -0
- data/lib/rhc/rest/base.rb +79 -0
- data/lib/rhc/rest/cartridge.rb +162 -0
- data/lib/rhc/rest/client.rb +650 -0
- data/lib/rhc/rest/deployment.rb +18 -0
- data/lib/rhc/rest/domain.rb +98 -0
- data/lib/rhc/rest/environment_variable.rb +15 -0
- data/lib/rhc/rest/gear_group.rb +16 -0
- data/lib/rhc/rest/httpclient.rb +145 -0
- data/lib/rhc/rest/key.rb +44 -0
- data/lib/rhc/rest/membership.rb +105 -0
- data/lib/rhc/rest/mock.rb +1042 -0
- data/lib/rhc/rest/user.rb +32 -0
- data/lib/rhc/rest.rb +148 -0
- data/lib/rhc/scp_helpers.rb +27 -0
- data/lib/rhc/ssh_helpers.rb +380 -0
- data/lib/rhc/tar_gz.rb +51 -0
- data/lib/rhc/usage_templates/command_help.erb +51 -0
- data/lib/rhc/usage_templates/command_syntax_help.erb +11 -0
- data/lib/rhc/usage_templates/help.erb +61 -0
- data/lib/rhc/usage_templates/missing_help.erb +1 -0
- data/lib/rhc/usage_templates/options_help.erb +12 -0
- data/lib/rhc/vendor/okjson.rb +600 -0
- data/lib/rhc/vendor/parseconfig.rb +178 -0
- data/lib/rhc/vendor/sshkey.rb +253 -0
- data/lib/rhc/vendor/zliby.rb +628 -0
- data/lib/rhc/version.rb +5 -0
- data/lib/rhc/wizard.rb +637 -0
- data/lib/rhc.rb +34 -0
- data/spec/coverage_helper.rb +82 -0
- data/spec/direct_execution_helper.rb +339 -0
- 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 +31 -0
- data/spec/rhc/assets/cert.crt +22 -0
- data/spec/rhc/assets/cert_key_rsa +27 -0
- data/spec/rhc/assets/empty.txt +0 -0
- data/spec/rhc/assets/env_vars.txt +7 -0
- data/spec/rhc/assets/env_vars_2.txt +1 -0
- data/spec/rhc/assets/foo.txt +1 -0
- data/spec/rhc/assets/targz_corrupted.tar.gz +1 -0
- data/spec/rhc/assets/targz_sample.tar.gz +0 -0
- data/spec/rhc/auth_spec.rb +442 -0
- data/spec/rhc/cli_spec.rb +186 -0
- data/spec/rhc/command_spec.rb +435 -0
- data/spec/rhc/commands/account_spec.rb +42 -0
- data/spec/rhc/commands/alias_spec.rb +333 -0
- data/spec/rhc/commands/app_spec.rb +777 -0
- data/spec/rhc/commands/apps_spec.rb +39 -0
- data/spec/rhc/commands/authorization_spec.rb +157 -0
- data/spec/rhc/commands/cartridge_spec.rb +665 -0
- data/spec/rhc/commands/clone_spec.rb +41 -0
- data/spec/rhc/commands/deployment_spec.rb +327 -0
- data/spec/rhc/commands/domain_spec.rb +401 -0
- data/spec/rhc/commands/env_spec.rb +493 -0
- data/spec/rhc/commands/git_clone_spec.rb +102 -0
- data/spec/rhc/commands/logout_spec.rb +86 -0
- data/spec/rhc/commands/member_spec.rb +247 -0
- data/spec/rhc/commands/port_forward_spec.rb +217 -0
- data/spec/rhc/commands/scp_spec.rb +77 -0
- data/spec/rhc/commands/server_spec.rb +69 -0
- data/spec/rhc/commands/setup_spec.rb +118 -0
- data/spec/rhc/commands/snapshot_spec.rb +179 -0
- data/spec/rhc/commands/ssh_spec.rb +163 -0
- data/spec/rhc/commands/sshkey_spec.rb +188 -0
- data/spec/rhc/commands/tail_spec.rb +81 -0
- data/spec/rhc/commands/threaddump_spec.rb +84 -0
- data/spec/rhc/config_spec.rb +407 -0
- data/spec/rhc/helpers_spec.rb +531 -0
- data/spec/rhc/highline_extensions_spec.rb +314 -0
- data/spec/rhc/json_spec.rb +30 -0
- data/spec/rhc/rest_application_spec.rb +258 -0
- data/spec/rhc/rest_client_spec.rb +752 -0
- data/spec/rhc/rest_spec.rb +740 -0
- data/spec/rhc/targz_spec.rb +55 -0
- data/spec/rhc/wizard_spec.rb +756 -0
- data/spec/spec_helper.rb +575 -0
- data/spec/wizard_spec_helper.rb +330 -0
- metadata +469 -0
@@ -0,0 +1,401 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rest_spec_helper'
|
3
|
+
require 'rhc/commands/domain'
|
4
|
+
|
5
|
+
describe RHC::Commands::Domain do
|
6
|
+
let(:rest_client){ MockRestClient.new }
|
7
|
+
before{ user_config }
|
8
|
+
|
9
|
+
describe 'default action' do
|
10
|
+
before{ rest_client }
|
11
|
+
context 'when run with no domains' do
|
12
|
+
let(:arguments) { ['domain'] }
|
13
|
+
|
14
|
+
it { expect { run }.to exit_with_code(1) }
|
15
|
+
it { run_output.should match(/To create your first domain.*app create-domain/m) }
|
16
|
+
end
|
17
|
+
context 'when help is shown' do
|
18
|
+
let(:arguments) { ['domain', '--noprompt', '--help'] }
|
19
|
+
|
20
|
+
it { expect { run }.to exit_with_code(0) }
|
21
|
+
it { run_output.should match(/configure.*delete.*leave.*list.*rename/m) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'show' do
|
26
|
+
before{ rest_client }
|
27
|
+
let(:arguments) { ['domain', 'show'] }
|
28
|
+
|
29
|
+
context 'when run with no domains' do
|
30
|
+
it { expect { run }.to exit_with_code(1) }
|
31
|
+
it { run_output.should match(/In order to deploy applications, you must create a domain/m) }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when run with one domain no apps' do
|
35
|
+
before{ rest_client.add_domain("onedomain") }
|
36
|
+
|
37
|
+
it { expect { run }.to exit_with_code(0) }
|
38
|
+
it "should match output" do
|
39
|
+
output = run_output
|
40
|
+
output.should match("The domain onedomain exists but has no applications. You can use")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when run with multiple domain no apps' do
|
45
|
+
before do
|
46
|
+
rest_client.add_domain("firstdomain")
|
47
|
+
rest_client.add_domain("seconddomain")
|
48
|
+
end
|
49
|
+
it { expect { run }.to exit_with_code(0) }
|
50
|
+
it "should match output" do
|
51
|
+
output = run_output
|
52
|
+
output.should match("The domain firstdomain exists but has no applications. You can use")
|
53
|
+
output.should_not match("Applications in seconddomain")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'when run with one domain multiple apps' do
|
58
|
+
before do
|
59
|
+
d = rest_client.add_domain("appdomain")
|
60
|
+
a = d.add_application("app_no_carts", "testframework-1.0")
|
61
|
+
a = d.add_application("app_multi_carts", "testframework-1.0")
|
62
|
+
a.add_cartridge("testcart-1")
|
63
|
+
a.add_cartridge("testcart-2")
|
64
|
+
a.add_cartridge("testcart-3")
|
65
|
+
end
|
66
|
+
it { expect { run }.to exit_with_code(0) }
|
67
|
+
it "should match output" do
|
68
|
+
output = run_output
|
69
|
+
output.should match("app_no_carts")
|
70
|
+
output.should match("app_multi_carts")
|
71
|
+
output.should match("testframework-1.0")
|
72
|
+
output.should match("testcart-1")
|
73
|
+
output.should match("testcart-2")
|
74
|
+
output.should match("testcart-3")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'when run with an app without cartridges' do
|
79
|
+
before do
|
80
|
+
d = rest_client.add_domain("appdomain")
|
81
|
+
a = d.add_application("app_no_carts")
|
82
|
+
end
|
83
|
+
it { expect { run }.to exit_with_code(0) }
|
84
|
+
it "should match output" do
|
85
|
+
output = run_output
|
86
|
+
output.should match("app_no_carts")
|
87
|
+
output.should match(/127.0.0.1\s*$/m)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
describe 'list' do
|
94
|
+
before{ rest_client }
|
95
|
+
let(:arguments) { ['domain', 'list'] }
|
96
|
+
|
97
|
+
context 'when run with no domains' do
|
98
|
+
it { expect { run }.to exit_with_code(1) }
|
99
|
+
it { run_output.should match(/In order to deploy applications.*app create-domain/) }
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'when run with one domain no apps' do
|
103
|
+
before{ rest_client.add_domain("onedomain") }
|
104
|
+
|
105
|
+
it { expect { run }.to exit_with_code(0) }
|
106
|
+
it "should match output" do
|
107
|
+
output = run_output
|
108
|
+
output.should match("You have access to 1 domain\\.")
|
109
|
+
output.should match("onedomain")
|
110
|
+
end
|
111
|
+
|
112
|
+
context 'when has no creation date, members, or allowed_gear_sizes' do
|
113
|
+
before{ rest_client.domains.first.attributes.merge(:creation_date => nil, :allowed_gear_sizes => nil, :members => nil, :id => '123') }
|
114
|
+
it { expect { run }.to exit_with_code(0) }
|
115
|
+
it "should match output" do
|
116
|
+
output = run_output
|
117
|
+
output.should match("onedomain")
|
118
|
+
output.should_not match ("Allowed Gear Sizes:")
|
119
|
+
output.should_not match ("Created:")
|
120
|
+
output.should_not match ("Members:")
|
121
|
+
output.should_not match ("ID:.*")
|
122
|
+
end
|
123
|
+
end
|
124
|
+
context 'when an ID is present and differs from name' do
|
125
|
+
let(:arguments) { ['domain', 'list', '--ids'] }
|
126
|
+
before{ rest_client.domains.first.attributes['id'] = '123' }
|
127
|
+
it { expect { run }.to exit_with_code(0) }
|
128
|
+
it "should match output" do
|
129
|
+
output = run_output
|
130
|
+
output.should match("onedomain")
|
131
|
+
output.should match ("ID:.*123")
|
132
|
+
end
|
133
|
+
end
|
134
|
+
context 'when an ID is present and identical to name' do
|
135
|
+
let(:arguments) { ['domain', 'list', '--ids'] }
|
136
|
+
before{ rest_client.domains.first.attributes['id'] = 'onedomain' }
|
137
|
+
it { expect { run }.to exit_with_code(0) }
|
138
|
+
it "should not match output" do
|
139
|
+
run_output.should_not match ("ID:.*123")
|
140
|
+
end
|
141
|
+
end
|
142
|
+
context 'when an ID is present and name is not' do
|
143
|
+
let(:arguments) { ['domain', 'list', '--ids'] }
|
144
|
+
before{ rest_client.domains.first.attributes['id'] = 'onedomain' }
|
145
|
+
before{ rest_client.domains.first.instance_variable_set(:@name, nil) }
|
146
|
+
it { expect { run }.to exit_with_code(0) }
|
147
|
+
it "should match output" do
|
148
|
+
run_output.should match ("onedomain")
|
149
|
+
run_output.should_not match ("ID:.*")
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context 'when run with one owned domain' do
|
155
|
+
let(:arguments) { ['domains', '--mine'] }
|
156
|
+
before{ d = rest_client.add_domain('mine', true); rest_client.stub(:owned_domains).and_return([d]) }
|
157
|
+
|
158
|
+
it { expect { run }.to exit_with_code(0) }
|
159
|
+
it "should match output" do
|
160
|
+
output = run_output
|
161
|
+
output.should match("You have access to 1 domain\\.")
|
162
|
+
output.should match("mine")
|
163
|
+
output.should match("Created")
|
164
|
+
output.should match("Allowed Gear Sizes: small")
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
context 'when run with multiple domains and extra domain info' do
|
169
|
+
before do
|
170
|
+
rest_client.add_domain("firstdomain")
|
171
|
+
rest_client.add_domain("seconddomain", true)
|
172
|
+
end
|
173
|
+
it { expect { run }.to exit_with_code(0) }
|
174
|
+
it "should match output" do
|
175
|
+
output = run_output
|
176
|
+
output.should match("You have access to 2 domains")
|
177
|
+
output.should match("seconddomain \\(owned by a_user_name\\)")
|
178
|
+
output.should match("Created")
|
179
|
+
output.should match("Allowed Gear Sizes: small")
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
describe 'create' do
|
185
|
+
before{ rest_client }
|
186
|
+
let(:arguments) { ['domain', 'create', 'testnamespace'] }
|
187
|
+
|
188
|
+
context 'when no issues with ' do
|
189
|
+
|
190
|
+
it "should create a domain" do
|
191
|
+
expect { run }.to exit_with_code(0)
|
192
|
+
rest_client.domains[0].name.should == 'testnamespace'
|
193
|
+
end
|
194
|
+
it { run_output.should match(/Creating.*'testnamespace'.*done/m) }
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
describe 'rename' do
|
199
|
+
before{ rest_client }
|
200
|
+
let(:arguments) { ['domain', 'rename', 'olddomain', 'alterednamespace'] }
|
201
|
+
|
202
|
+
context 'when no issues with ' do
|
203
|
+
before{ rest_client.add_domain("olddomain") }
|
204
|
+
|
205
|
+
it "should update a domain" do
|
206
|
+
expect { run }.to exit_with_code(0)
|
207
|
+
rest_client.domains[0].name.should == 'alterednamespace'
|
208
|
+
end
|
209
|
+
it { run_output.should match(/Renaming domain 'olddomain' to 'alterednamespace'.*done.*?Applications in this domain will use the new name in their URL./m) }
|
210
|
+
end
|
211
|
+
|
212
|
+
context 'when there is no domain' do
|
213
|
+
it "should not create a domain" do
|
214
|
+
expect { run }.to exit_with_code(127)
|
215
|
+
rest_client.domains.empty?.should be_true
|
216
|
+
end
|
217
|
+
it { run_output.should match("not found") }
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe 'update' do
|
222
|
+
before{ rest_client }
|
223
|
+
let(:arguments) { ['domain', 'update', 'olddomain', 'alterednamespace'] }
|
224
|
+
|
225
|
+
before{ rest_client.add_domain("olddomain") }
|
226
|
+
it "should update a domain" do
|
227
|
+
expect { run }.to exit_with_code(0)
|
228
|
+
rest_client.domains[0].name.should == 'alterednamespace'
|
229
|
+
end
|
230
|
+
it { run_output.should match(/This command is deprecated.*Renaming domain 'olddomain' to 'alterednamespace'.*done.*?Applications in this domain will use the new name in their URL./m) }
|
231
|
+
end
|
232
|
+
|
233
|
+
describe 'alter alias has been removed' do
|
234
|
+
let(:arguments) { ['domain', 'alter', 'olddomain', 'alterednamespace'] }
|
235
|
+
it{ expect { run }.to exit_with_code(1) }
|
236
|
+
end
|
237
|
+
|
238
|
+
describe 'configure' do
|
239
|
+
context "no settings" do
|
240
|
+
before{ rest_client.add_domain("domain1") }
|
241
|
+
let(:arguments) { ['domain', 'configure', '-n', 'domain1'] }
|
242
|
+
it("should succeed"){ expect { run }.to exit_with_code(0) }
|
243
|
+
it("should display the domain config"){ run_output.should match(/Domain domain1 configuration/m) }
|
244
|
+
it("should not display the domain config without gear sizes"){ run_output.should_not match(/Allowed Gear Sizes/) }
|
245
|
+
|
246
|
+
context "server supports allowed gear sizes" do
|
247
|
+
before{ rest_client.domains.first.should_receive(:allowed_gear_sizes).and_return([]) }
|
248
|
+
it("should display the domain config"){ run_output.should match(/Domain domain1 configuration.*Allowed Gear Sizes:\s+<none>/m) }
|
249
|
+
end
|
250
|
+
context "server supports allowed gear sizes" do
|
251
|
+
before{ rest_client.domains.first.should_receive(:allowed_gear_sizes).and_return(['small', 'medium']) }
|
252
|
+
it("should display the domain config"){ run_output.should match(/Domain domain1 configuration.*Allowed Gear Sizes:\s+small, medium/m) }
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
context "when server does not support allowed-gear-sizes" do
|
257
|
+
before do
|
258
|
+
rest_client.add_domain("domain1")
|
259
|
+
rest_client.api.should_receive(:has_param?).with(:add_domain, 'allowed_gear_sizes').and_return(false)
|
260
|
+
end
|
261
|
+
let(:arguments) { ['domain', 'configure', '--allowed-gear-sizes', 'small'] }
|
262
|
+
it("display a message"){ run_output.should match 'The server does not support --allowed-gear-sizes' }
|
263
|
+
end
|
264
|
+
|
265
|
+
context "against a server that supports gear sizes" do
|
266
|
+
let(:username){ 'test_user' }
|
267
|
+
let(:password){ 'password' }
|
268
|
+
let(:server){ 'test.domain.com' }
|
269
|
+
let(:supports_allowed_gear_sizes?){ true }
|
270
|
+
before{ subject.class.any_instance.stub(:namespace_context).and_return('domain1') }
|
271
|
+
before do
|
272
|
+
stub_api
|
273
|
+
challenge{ stub_one_domain('domain1', nil, mock_user_auth) }
|
274
|
+
end
|
275
|
+
|
276
|
+
context "with --allowed-gear-sizes singular" do
|
277
|
+
before do
|
278
|
+
stub_api_request(:put, "domains/domain1/update", nil).
|
279
|
+
with(:body => {:allowed_gear_sizes => ['valid']}).
|
280
|
+
to_return({:body => {:type => 'domain', :data => {:name => 'domain1', :allowed_gear_sizes => ['valid']}, :messages => [{:severity => 'info', :text => 'Updated allowed gear sizes'},]}.to_json, :status => 200})
|
281
|
+
end
|
282
|
+
let(:arguments) { ['domain', 'configure', '--trace', '--allowed-gear-sizes', 'valid'] }
|
283
|
+
it("should succeed"){ expect { run }.to exit_with_code(0) }
|
284
|
+
it("should display the domain config"){ run_output.should match(/Domain domain1 configuration.*Allowed Gear Sizes:\s+valid/m) }
|
285
|
+
end
|
286
|
+
|
287
|
+
context "with --allowed-gear-sizes multiple" do
|
288
|
+
before do
|
289
|
+
stub_api_request(:put, "domains/domain1/update", nil).
|
290
|
+
with(:body => {:allowed_gear_sizes => ['one', 'two']}).
|
291
|
+
to_return({:body => {:type => 'domain', :data => {:name => 'domain1', :allowed_gear_sizes => ['one', 'two']}, :messages => [{:severity => 'info', :text => 'Updated allowed gear sizes'},]}.to_json, :status => 200})
|
292
|
+
end
|
293
|
+
let(:arguments) { ['domain', 'configure', '--trace', '--allowed-gear-sizes', 'one,two'] }
|
294
|
+
it("should succeed"){ expect { run }.to exit_with_code(0) }
|
295
|
+
it("should display the domain config"){ run_output.should match(/Domain domain1 configuration.*Allowed Gear Sizes:\s+one, two/m) }
|
296
|
+
end
|
297
|
+
|
298
|
+
context "with --allowed-gear-sizes" do
|
299
|
+
let(:arguments) { ['domain', 'configure', 'domain1', '--trace', '--allowed-gear-sizes'] }
|
300
|
+
it("raise an invalid option"){ expect{ run }.to raise_error(OptionParser::InvalidOption, /Provide a comma delimited list of valid gear/) }
|
301
|
+
end
|
302
|
+
|
303
|
+
context "with --allowed-gear-sizes=false" do
|
304
|
+
before do
|
305
|
+
stub_api_request(:put, "domains/domain1/update", nil).
|
306
|
+
with(:body => {:allowed_gear_sizes => ['false']}).
|
307
|
+
to_return({:body => {:type => 'domain', :messages => [{:field => 'allowed_gear_sizes', :exit_code => 10, :severity => 'error', :text => 'The specified gear size is invalid: false'},]}.to_json, :status => 422})
|
308
|
+
end
|
309
|
+
let(:arguments) { ['domain', 'configure', '--allowed-gear-sizes=false'] }
|
310
|
+
it("should succeed"){ expect { run }.to exit_with_code(1) }
|
311
|
+
it("should display the domain config"){ run_output.should match(/Updating domain configuration.*The specified gear size is invalid/m) }
|
312
|
+
end
|
313
|
+
|
314
|
+
context "with --no-allowed-gear-sizes" do
|
315
|
+
before do
|
316
|
+
stub_api_request(:put, "domains/domain1/update", nil).
|
317
|
+
with(:body => {:allowed_gear_sizes => []}).
|
318
|
+
to_return({:body => {:type => 'domain', :data => {:name => 'domain1', :allowed_gear_sizes => []}, :messages => [{:severity => 'info', :text => 'Updated allowed gear sizes'},]}.to_json, :status => 200})
|
319
|
+
end
|
320
|
+
let(:arguments) { ['domain', 'configure', '--no-allowed-gear-sizes'] }
|
321
|
+
it("should succeed"){ expect { run }.to exit_with_code(0) }
|
322
|
+
it("should display the domain config"){ run_output.should match(/Domain domain1 configuration.*Allowed Gear Sizes:\s+<none>/m) }
|
323
|
+
end
|
324
|
+
|
325
|
+
context "with --allowed-gear-sizes and --no-allowed-gear-sizes" do
|
326
|
+
let(:arguments) { ['domain', 'configure', 'domain1', '--trace', '--no-allowed-gear-sizes', '--allowed-gear-sizes', 'small'] }
|
327
|
+
it("raise an invalid option"){ expect{ run }.to raise_error(OptionParser::InvalidOption, /--allowed-gear-sizes.*--no-allowed-gear-sizes/) }
|
328
|
+
end
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
describe 'leave' do
|
333
|
+
before{ rest_client.add_domain("deleteme") }
|
334
|
+
let(:arguments) { ['domain', 'leave', '-n', 'deleteme'] }
|
335
|
+
|
336
|
+
it "should leave the domain" do
|
337
|
+
rest_client.domains.first.should_receive(:leave)
|
338
|
+
expect { run }.to exit_with_code(0)
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
describe 'delete' do
|
343
|
+
before{ rest_client }
|
344
|
+
let(:arguments) { ['domain', 'delete', 'deleteme'] }
|
345
|
+
|
346
|
+
context 'when no issues with ' do
|
347
|
+
before{ rest_client.add_domain("deleteme") }
|
348
|
+
|
349
|
+
it "should delete a domain" do
|
350
|
+
expect { run }.to exit_with_code(0)
|
351
|
+
rest_client.domains.empty?.should be_true
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
context 'when there is a different domain' do
|
356
|
+
before{ rest_client.add_domain("dontdelete") }
|
357
|
+
|
358
|
+
it "should error out" do
|
359
|
+
expect { run }.to exit_with_code(127)
|
360
|
+
rest_client.domains[0].name.should == 'dontdelete'
|
361
|
+
end
|
362
|
+
it { run_output.should match("Domain deleteme not found") }
|
363
|
+
end
|
364
|
+
|
365
|
+
context 'when there are applications on the domain' do
|
366
|
+
before do
|
367
|
+
domain = rest_client.add_domain("deleteme")
|
368
|
+
domain.add_application 'testapp1', 'mock-1.0'
|
369
|
+
end
|
370
|
+
it "should error out" do
|
371
|
+
expect { run }.to exit_with_code(1)
|
372
|
+
rest_client.domains[0].name.should == 'deleteme'
|
373
|
+
end
|
374
|
+
it { run_output.should match("Applications must be empty") }
|
375
|
+
end
|
376
|
+
|
377
|
+
context 'when delete is forced' do
|
378
|
+
let(:arguments) { ['domain', 'delete', 'deleteme', '--force'] }
|
379
|
+
before do
|
380
|
+
domain = rest_client.add_domain("deleteme")
|
381
|
+
domain.add_application 'testapp1', 'mock-1.0'
|
382
|
+
end
|
383
|
+
it "should delete successfully" do
|
384
|
+
expect { run }.to exit_with_code(0)
|
385
|
+
rest_client.domains.empty?.should be_true
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
end
|
390
|
+
|
391
|
+
describe 'help' do
|
392
|
+
let(:arguments) { ['domain', '--help'] }
|
393
|
+
|
394
|
+
context 'help is run' do
|
395
|
+
it "should display help" do
|
396
|
+
expect { run }.to exit_with_code(0)
|
397
|
+
end
|
398
|
+
it('should output usage') { run_output.should match("Usage: app domain") }
|
399
|
+
end
|
400
|
+
end
|
401
|
+
end
|