aptible-cli 0.26.4 → 0.26.6
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/aptible/cli/helpers/app.rb +18 -16
- data/lib/aptible/cli/helpers/database.rb +20 -19
- data/lib/aptible/cli/helpers/environment.rb +5 -4
- data/lib/aptible/cli/helpers/vhost/option_set_builder.rb +154 -1
- data/lib/aptible/cli/helpers/vhost.rb +5 -2
- data/lib/aptible/cli/renderer/text.rb +3 -1
- data/lib/aptible/cli/resource_formatter.rb +6 -0
- data/lib/aptible/cli/subcommands/backup.rb +1 -1
- data/lib/aptible/cli/subcommands/endpoints.rb +27 -9
- data/lib/aptible/cli/version.rb +1 -1
- data/spec/aptible/cli/helpers/vhost/option_set_builder_spec.rb +94 -0
- data/spec/aptible/cli/resource_formatter_spec.rb +3 -0
- data/spec/aptible/cli/subcommands/apps_spec.rb +34 -21
- data/spec/aptible/cli/subcommands/backup_retention_policy_spec.rb +3 -1
- data/spec/aptible/cli/subcommands/backup_spec.rb +28 -3
- data/spec/aptible/cli/subcommands/config_spec.rb +3 -3
- data/spec/aptible/cli/subcommands/db_spec.rb +46 -44
- data/spec/aptible/cli/subcommands/deploy_spec.rb +8 -3
- data/spec/aptible/cli/subcommands/endpoints_spec.rb +198 -8
- data/spec/aptible/cli/subcommands/environment_spec.rb +4 -0
- data/spec/aptible/cli/subcommands/log_drain_spec.rb +9 -0
- data/spec/aptible/cli/subcommands/logs_spec.rb +16 -4
- data/spec/aptible/cli/subcommands/maintenance_spec.rb +7 -2
- data/spec/aptible/cli/subcommands/metric_drain_spec.rb +10 -2
- data/spec/aptible/cli/subcommands/services_spec.rb +3 -4
- data/spec/fabricators/setting_fabricator.rb +8 -0
- data/spec/fabricators/vhost_fabricator.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- metadata +6 -2
|
@@ -12,6 +12,9 @@ describe Aptible::CLI::Agent do
|
|
|
12
12
|
.to receive(:all)
|
|
13
13
|
.with(token: token, href: '/accounts?per_page=5000&no_embed=true')
|
|
14
14
|
.and_return([a1, a2])
|
|
15
|
+
allow(Aptible::Api::Account).to receive(:find_by_url)
|
|
16
|
+
.with("/find/account?handle=#{a2.handle}", token: token)
|
|
17
|
+
.and_return(a2)
|
|
15
18
|
end
|
|
16
19
|
|
|
17
20
|
def expect_create_certificate(account, options)
|
|
@@ -22,12 +25,12 @@ describe Aptible::CLI::Agent do
|
|
|
22
25
|
end
|
|
23
26
|
end
|
|
24
27
|
|
|
25
|
-
def expect_create_vhost(service, options)
|
|
28
|
+
def expect_create_vhost(service, options, settings: nil)
|
|
26
29
|
expect(service).to receive(:create_vhost!).with(
|
|
27
30
|
hash_including(options)
|
|
28
31
|
) do |args|
|
|
29
32
|
Fabricate(:vhost, service: service, **args).tap do |v|
|
|
30
|
-
expect_operation(v, 'provision')
|
|
33
|
+
expect_operation(v, 'provision', settings: settings)
|
|
31
34
|
expect(v).to receive(:reload).and_return(v)
|
|
32
35
|
expect(Aptible::CLI::ResourceFormatter).to receive(:inject_vhost)
|
|
33
36
|
.with(an_instance_of(Aptible::CLI::Formatter::Object), v, service)
|
|
@@ -46,8 +49,16 @@ describe Aptible::CLI::Agent do
|
|
|
46
49
|
end
|
|
47
50
|
end
|
|
48
51
|
|
|
49
|
-
def expect_operation(vhost, type)
|
|
50
|
-
expect(vhost).to receive(:create_operation!)
|
|
52
|
+
def expect_operation(vhost, type, settings: nil)
|
|
53
|
+
expect(vhost).to receive(:create_operation!) do |args|
|
|
54
|
+
expect(args[:type]).to eq(type)
|
|
55
|
+
|
|
56
|
+
if settings.nil?
|
|
57
|
+
expect(args).not_to have_key(:settings)
|
|
58
|
+
else
|
|
59
|
+
expect(args[:settings]).to eq(settings)
|
|
60
|
+
end
|
|
61
|
+
|
|
51
62
|
Fabricate(:operation).tap do |o|
|
|
52
63
|
expect(subject).to receive(:attach_to_operation_logs).with(o)
|
|
53
64
|
end
|
|
@@ -67,10 +78,12 @@ describe Aptible::CLI::Agent do
|
|
|
67
78
|
end
|
|
68
79
|
|
|
69
80
|
before do
|
|
70
|
-
allow(Aptible::Api::Database)
|
|
71
|
-
.
|
|
72
|
-
.
|
|
73
|
-
|
|
81
|
+
allow(Aptible::Api::Database).to receive(:find_by_url)
|
|
82
|
+
.with("/find/database?handle=#{incomplete.handle}", token: token)
|
|
83
|
+
.and_return(incomplete)
|
|
84
|
+
allow(Aptible::Api::Database).to receive(:find_by_url)
|
|
85
|
+
.with("/find/database?handle=#{db.handle}", token: token)
|
|
86
|
+
.and_return(db)
|
|
74
87
|
allow(db).to receive(:class).and_return(Aptible::Api::Database)
|
|
75
88
|
allow(incomplete).to receive(:class).and_return(Aptible::Api::Database)
|
|
76
89
|
stub_options
|
|
@@ -78,6 +91,7 @@ describe Aptible::CLI::Agent do
|
|
|
78
91
|
|
|
79
92
|
describe 'endpoints:database:create' do
|
|
80
93
|
it 'fails if the DB does not exist' do
|
|
94
|
+
allow(Aptible::Api::Database).to receive(:find_by_url).and_return(nil)
|
|
81
95
|
expect { subject.send('endpoints:database:create', 'some') }
|
|
82
96
|
.to raise_error(/could not find database some/im)
|
|
83
97
|
end
|
|
@@ -90,6 +104,9 @@ describe Aptible::CLI::Agent do
|
|
|
90
104
|
|
|
91
105
|
it 'fails if the DB is not in the account' do
|
|
92
106
|
stub_options(environment: 'bar')
|
|
107
|
+
expect(Aptible::Api::Database).to receive(:find_by_url)
|
|
108
|
+
.with("/find/database?handle=#{db.handle}&environment=bar", token: token)
|
|
109
|
+
.and_return(nil)
|
|
93
110
|
expect { subject.send('endpoints:database:create', 'mydb') }
|
|
94
111
|
.to raise_error(/could not find database mydb/im)
|
|
95
112
|
end
|
|
@@ -161,7 +178,13 @@ describe Aptible::CLI::Agent do
|
|
|
161
178
|
it 'lists Endpoints' do
|
|
162
179
|
s = Fabricate(:service, database: db)
|
|
163
180
|
v1 = Fabricate(:vhost, service: s)
|
|
181
|
+
v1.current_setting = Fabricate(:setting,
|
|
182
|
+
settings: { 'IDLE_TIMEOUT' => '123' },
|
|
183
|
+
vhost: v1)
|
|
164
184
|
v2 = Fabricate(:vhost, service: s)
|
|
185
|
+
v2.current_setting = Fabricate(:setting,
|
|
186
|
+
settings: { 'FORCE_SSL' => 'true' },
|
|
187
|
+
vhost: v2)
|
|
165
188
|
|
|
166
189
|
stub_options(database: db.handle)
|
|
167
190
|
subject.send('endpoints:list')
|
|
@@ -170,6 +193,8 @@ describe Aptible::CLI::Agent do
|
|
|
170
193
|
|
|
171
194
|
expect(lines).to include("Hostname: #{v1.external_host}")
|
|
172
195
|
expect(lines).to include("Hostname: #{v2.external_host}")
|
|
196
|
+
expect(lines).to include('Idle Timeout: 123')
|
|
197
|
+
expect(lines).to include('Force SSL: true')
|
|
173
198
|
|
|
174
199
|
expect(lines[0]).not_to eq("\n")
|
|
175
200
|
expect(lines[-1]).not_to eq("\n")
|
|
@@ -223,10 +248,116 @@ describe Aptible::CLI::Agent do
|
|
|
223
248
|
.to receive(:all)
|
|
224
249
|
.with(token: token, href: '/apps?per_page=5000&no_embed=true')
|
|
225
250
|
.and_return([app])
|
|
251
|
+
|
|
252
|
+
allow(Aptible::Api::App).to receive(:find_by_url)
|
|
253
|
+
.and_return(nil)
|
|
254
|
+
allow(Aptible::Api::App).to receive(:find_by_url)
|
|
255
|
+
.with("/find/app?handle=#{app.handle}", token: token)
|
|
256
|
+
.and_return(app)
|
|
257
|
+
|
|
226
258
|
allow(app).to receive(:class).and_return(Aptible::Api::App)
|
|
227
259
|
stub_options
|
|
228
260
|
end
|
|
229
261
|
|
|
262
|
+
shared_examples 'shared create and modify ALB settings examples' do |method|
|
|
263
|
+
context 'App Vhost Settings (string)' do
|
|
264
|
+
string_options = %i(
|
|
265
|
+
idle_timeout
|
|
266
|
+
maintenance_page_url
|
|
267
|
+
release_healthcheck_timeout
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
let(:value) { 'some value' }
|
|
271
|
+
|
|
272
|
+
string_options.each do |option|
|
|
273
|
+
context "--#{option.to_s.tr('_', '-')}" do
|
|
274
|
+
it 'passes a value if provided' do
|
|
275
|
+
wanted = { option.to_s.upcase => value }
|
|
276
|
+
expect_create_vhost(service, {}, { settings: wanted })
|
|
277
|
+
stub_options(option => value)
|
|
278
|
+
subject.send(method, 'web')
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
it 'passes nothing if not provided' do
|
|
282
|
+
expect_create_vhost(service, {})
|
|
283
|
+
subject.send(method, 'web')
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
context 'reverting to default' do
|
|
287
|
+
it 'sends an empty string if passed an empty string' do
|
|
288
|
+
wanted = { option.to_s.upcase => '' }
|
|
289
|
+
expect_create_vhost(service, {}, { settings: wanted })
|
|
290
|
+
stub_options(option => '')
|
|
291
|
+
subject.send(method, 'web')
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
it 'sends an empty string if passed the string "default"' do
|
|
295
|
+
wanted = { option.to_s.upcase => '' }
|
|
296
|
+
expect_create_vhost(service, {}, { settings: wanted })
|
|
297
|
+
stub_options(option => 'default')
|
|
298
|
+
subject.send(method, 'web')
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
context '--ssl-protocols-override' do
|
|
306
|
+
it 'passes a valid non-PFS value' do
|
|
307
|
+
wanted = { 'SSL_PROTOCOLS_OVERRIDE' => 'TLSv1.2' }
|
|
308
|
+
expect_create_vhost(service, {}, { settings: wanted })
|
|
309
|
+
stub_options(ssl_protocols_override: 'TLSv1.2')
|
|
310
|
+
subject.send(method, 'web')
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
it 'passes a valid PFS value' do
|
|
314
|
+
wanted = { 'SSL_PROTOCOLS_OVERRIDE' => 'TLSv1.2 PFS' }
|
|
315
|
+
expect_create_vhost(service, {}, { settings: wanted })
|
|
316
|
+
stub_options(ssl_protocols_override: 'TLSv1.2 PFS')
|
|
317
|
+
subject.send(method, 'web')
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
it 'raises an error for an invalid value' do
|
|
321
|
+
stub_options(ssl_protocols_override: 'TLSv1.0')
|
|
322
|
+
expect { subject.send(method, 'web') }
|
|
323
|
+
.to raise_error(/invalid --ssl-protocols-override/im)
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
it 'passes nothing if not provided' do
|
|
327
|
+
expect_create_vhost(service, {})
|
|
328
|
+
subject.send(method, 'web')
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
it 'sends an empty string if passed the string "default"' do
|
|
332
|
+
wanted = { 'SSL_PROTOCOLS_OVERRIDE' => '' }
|
|
333
|
+
expect_create_vhost(service, {}, { settings: wanted })
|
|
334
|
+
stub_options(ssl_protocols_override: 'default')
|
|
335
|
+
subject.send(method, 'web')
|
|
336
|
+
end
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
context 'App Vhost Settings (boolean)' do
|
|
340
|
+
boolean_options = %i(
|
|
341
|
+
force_ssl
|
|
342
|
+
show_elb_healthchecks
|
|
343
|
+
strict_health_checks
|
|
344
|
+
)
|
|
345
|
+
|
|
346
|
+
boolean_options.each do |option|
|
|
347
|
+
[true, false].each do |value|
|
|
348
|
+
context "--#{value ? '' : 'no-'}#{option.to_s.tr('_', '-')}" do
|
|
349
|
+
it "sets the value to the string '#{value}'" do
|
|
350
|
+
wanted = { option.to_s.upcase => value.to_s }
|
|
351
|
+
expect_create_vhost(service, {}, { settings: wanted })
|
|
352
|
+
stub_options(option => value)
|
|
353
|
+
subject.send(method, 'web')
|
|
354
|
+
end
|
|
355
|
+
end
|
|
356
|
+
end
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
end
|
|
360
|
+
|
|
230
361
|
shared_examples 'shared create app vhost examples' do |method|
|
|
231
362
|
context 'App Vhost Options' do
|
|
232
363
|
it 'fails if the app does not exist' do
|
|
@@ -424,10 +555,64 @@ describe Aptible::CLI::Agent do
|
|
|
424
555
|
end
|
|
425
556
|
end
|
|
426
557
|
|
|
558
|
+
shared_examples 'shared create idle timeout examples' do |method|
|
|
559
|
+
context 'IDLE_TIMEOUT' do
|
|
560
|
+
it 'passes idle_timeout if provided' do
|
|
561
|
+
expect_create_vhost(service, {}, { settings: { 'IDLE_TIMEOUT' => '30' } })
|
|
562
|
+
stub_options(idle_timeout: '30')
|
|
563
|
+
subject.send(method, 'web')
|
|
564
|
+
end
|
|
565
|
+
end
|
|
566
|
+
end
|
|
567
|
+
|
|
568
|
+
shared_examples 'shared create non-alb tls settings examples' do |method|
|
|
569
|
+
context '--ssl-protocols-override' do
|
|
570
|
+
it 'passes a valid non-PFS value' do
|
|
571
|
+
wanted = { 'SSL_PROTOCOLS_OVERRIDE' => 'TLSv1.2' }
|
|
572
|
+
expect_create_vhost(service, {}, { settings: wanted })
|
|
573
|
+
stub_options(ssl_protocols_override: 'TLSv1.2')
|
|
574
|
+
subject.send(method, 'web')
|
|
575
|
+
end
|
|
576
|
+
|
|
577
|
+
it 'raises an error for a PFS value' do
|
|
578
|
+
stub_options(ssl_protocols_override: 'TLSv1.2 PFS')
|
|
579
|
+
expect { subject.send(method, 'web') }
|
|
580
|
+
.to raise_error(/pfs.*only.*alb/im)
|
|
581
|
+
end
|
|
582
|
+
|
|
583
|
+
it 'raises an error for an invalid value' do
|
|
584
|
+
stub_options(ssl_protocols_override: 'TLSv1.0')
|
|
585
|
+
expect { subject.send(method, 'web') }
|
|
586
|
+
.to raise_error(/invalid --ssl-protocols-override/im)
|
|
587
|
+
end
|
|
588
|
+
end
|
|
589
|
+
|
|
590
|
+
context 'SSL_CIPHERS_OVERRIDE' do
|
|
591
|
+
it 'passes ssl_ciphers_override if provided' do
|
|
592
|
+
wanted = { 'SSL_CIPHERS_OVERRIDE' => 'HIGH:!aNULL' }
|
|
593
|
+
expect_create_vhost(service, {}, { settings: wanted })
|
|
594
|
+
stub_options(ssl_ciphers_override: 'HIGH:!aNULL')
|
|
595
|
+
subject.send(method, 'web')
|
|
596
|
+
end
|
|
597
|
+
end
|
|
598
|
+
|
|
599
|
+
context 'DISABLE_WEAK_CIPHER_SUITES' do
|
|
600
|
+
[true, false].each do |value|
|
|
601
|
+
it "sets disable_weak_cipher_suites to '#{value}'" do
|
|
602
|
+
wanted = { 'DISABLE_WEAK_CIPHER_SUITES' => value.to_s }
|
|
603
|
+
expect_create_vhost(service, {}, { settings: wanted })
|
|
604
|
+
stub_options(disable_weak_cipher_suites: value)
|
|
605
|
+
subject.send(method, 'web')
|
|
606
|
+
end
|
|
607
|
+
end
|
|
608
|
+
end
|
|
609
|
+
end
|
|
610
|
+
|
|
427
611
|
describe 'endpoints:tcp:create' do
|
|
428
612
|
m = 'endpoints:tcp:create'
|
|
429
613
|
include_examples 'shared create app vhost examples', m
|
|
430
614
|
include_examples 'shared create tcp vhost examples', m
|
|
615
|
+
include_examples 'shared create idle timeout examples', m
|
|
431
616
|
|
|
432
617
|
it 'creates a TCP Endpoint' do
|
|
433
618
|
expect_create_vhost(
|
|
@@ -449,6 +634,8 @@ describe Aptible::CLI::Agent do
|
|
|
449
634
|
include_examples 'shared create app vhost examples', m
|
|
450
635
|
include_examples 'shared create tcp vhost examples', m
|
|
451
636
|
include_examples 'shared create tls vhost examples', m
|
|
637
|
+
include_examples 'shared create idle timeout examples', m
|
|
638
|
+
include_examples 'shared create non-alb tls settings examples', m
|
|
452
639
|
|
|
453
640
|
it 'creates a TLS Endpoint' do
|
|
454
641
|
expect_create_vhost(
|
|
@@ -468,6 +655,7 @@ describe Aptible::CLI::Agent do
|
|
|
468
655
|
m = 'endpoints:https:create'
|
|
469
656
|
include_examples 'shared create app vhost examples', m
|
|
470
657
|
include_examples 'shared create tls vhost examples', m
|
|
658
|
+
include_examples 'shared create and modify ALB settings examples', m
|
|
471
659
|
|
|
472
660
|
it 'creates a HTTP Endpoint' do
|
|
473
661
|
expect_create_vhost(
|
|
@@ -500,6 +688,8 @@ describe Aptible::CLI::Agent do
|
|
|
500
688
|
m = 'endpoints:grpc:create'
|
|
501
689
|
include_examples 'shared create app vhost examples', m
|
|
502
690
|
include_examples 'shared create tls vhost examples', m
|
|
691
|
+
include_examples 'shared create idle timeout examples', m
|
|
692
|
+
include_examples 'shared create non-alb tls settings examples', m
|
|
503
693
|
|
|
504
694
|
it 'creates a gRPC Endpoint' do
|
|
505
695
|
expect_create_vhost(
|
|
@@ -16,6 +16,9 @@ describe Aptible::CLI::Agent do
|
|
|
16
16
|
.to receive(:all)
|
|
17
17
|
.with(token: token, href: '/accounts?per_page=5000&no_embed=true')
|
|
18
18
|
.and_return([a1, a2])
|
|
19
|
+
allow(Aptible::Api::Account).to receive(:find_by_url)
|
|
20
|
+
.with("/find/account?handle=#{a1.handle}", token: token)
|
|
21
|
+
.and_return(a1)
|
|
19
22
|
end
|
|
20
23
|
|
|
21
24
|
describe('#environment:list') do
|
|
@@ -123,6 +126,7 @@ describe Aptible::CLI::Agent do
|
|
|
123
126
|
)
|
|
124
127
|
end
|
|
125
128
|
it 'should fail if env does not exist' do
|
|
129
|
+
allow(Aptible::Api::Account).to receive(:find_by_url).and_return(nil)
|
|
126
130
|
expect { subject.send('environment:rename', 'foo1', 'foo2') }
|
|
127
131
|
.to raise_error(/Could not find environment foo1/)
|
|
128
132
|
end
|
|
@@ -22,6 +22,10 @@ describe Aptible::CLI::Agent do
|
|
|
22
22
|
.with(token: token, href: '/accounts?per_page=5000&no_embed=true')
|
|
23
23
|
.and_return([account])
|
|
24
24
|
|
|
25
|
+
allow(Aptible::Api::Account).to receive(:find_by_url)
|
|
26
|
+
.with("/find/account?handle=#{account.handle}", token: token)
|
|
27
|
+
.and_return(account)
|
|
28
|
+
|
|
25
29
|
allow(account).to receive(:reload).and_return(account)
|
|
26
30
|
end
|
|
27
31
|
|
|
@@ -87,6 +91,11 @@ describe Aptible::CLI::Agent do
|
|
|
87
91
|
|
|
88
92
|
context 'elasticsearch' do
|
|
89
93
|
let(:db) { Fabricate(:database, account: account, id: 5) }
|
|
94
|
+
before do
|
|
95
|
+
allow(Aptible::Api::Database).to receive(:find_by_url)
|
|
96
|
+
.with("/find/database?handle=#{db.handle}&environment=#{db.account.handle}", token: token)
|
|
97
|
+
.and_return(db)
|
|
98
|
+
end
|
|
90
99
|
|
|
91
100
|
it 'creates a new Elasticsearch log drain' do
|
|
92
101
|
opts = {
|
|
@@ -4,18 +4,23 @@ describe Aptible::CLI::Agent do
|
|
|
4
4
|
before do
|
|
5
5
|
allow(subject).to receive(:ask)
|
|
6
6
|
allow(subject).to receive(:save_token)
|
|
7
|
-
allow(subject).to receive(:fetch_token) {
|
|
7
|
+
allow(subject).to receive(:fetch_token) { token }
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
+
let(:token) { 'some token' }
|
|
10
11
|
let(:app) { Fabricate(:app, handle: 'foo') }
|
|
11
12
|
let(:database) { Fabricate(:database, handle: 'bar', status: 'provisioned') }
|
|
12
13
|
let(:service) { Fabricate(:service, app: app) }
|
|
13
14
|
|
|
14
15
|
describe '#logs' do
|
|
15
|
-
before
|
|
16
|
+
before do
|
|
17
|
+
allow(Aptible::Api::Account).to receive(:all) { [app.account] }
|
|
18
|
+
allow(Aptible::Api::App).to receive(:find_by_url)
|
|
19
|
+
.with("/find/app?handle=#{app.handle}", token: 'some token')
|
|
20
|
+
.and_return(app)
|
|
21
|
+
end
|
|
16
22
|
|
|
17
23
|
context 'App resource' do
|
|
18
|
-
before { allow(Aptible::Api::App).to receive(:all) { [app] } }
|
|
19
24
|
before { subject.options = { app: app.handle } }
|
|
20
25
|
|
|
21
26
|
it 'should fail if the app is unprovisioned' do
|
|
@@ -35,7 +40,14 @@ describe Aptible::CLI::Agent do
|
|
|
35
40
|
end
|
|
36
41
|
|
|
37
42
|
context 'Database resource' do
|
|
38
|
-
before
|
|
43
|
+
before do
|
|
44
|
+
allow(Aptible::Api::Database).to receive(:find_by_url)
|
|
45
|
+
.with("/find/database?handle=#{database.handle}&environment=#{database.account.handle}", token: token)
|
|
46
|
+
.and_return(database)
|
|
47
|
+
allow(Aptible::Api::Database).to receive(:find_by_url)
|
|
48
|
+
.with("/find/database?handle=#{database.handle}", token: token)
|
|
49
|
+
.and_return(database)
|
|
50
|
+
end
|
|
39
51
|
before { subject.options = { database: database.handle } }
|
|
40
52
|
|
|
41
53
|
it 'should fail if the database is unprovisioned' do
|
|
@@ -9,6 +9,9 @@ describe Aptible::CLI::Agent do
|
|
|
9
9
|
allow(subject).to receive(:ask)
|
|
10
10
|
allow(subject).to receive(:save_token)
|
|
11
11
|
allow(subject).to receive(:fetch_token) { token }
|
|
12
|
+
allow(Aptible::Api::Account).to receive(:find_by_url)
|
|
13
|
+
.with("/find/account?handle=#{staging.handle}", token: token)
|
|
14
|
+
.and_return(staging)
|
|
12
15
|
end
|
|
13
16
|
|
|
14
17
|
let(:handle) { 'foobar' }
|
|
@@ -52,7 +55,6 @@ describe Aptible::CLI::Agent do
|
|
|
52
55
|
|
|
53
56
|
describe '#maintenance:dbs' do
|
|
54
57
|
before do
|
|
55
|
-
token = 'the-token'
|
|
56
58
|
allow(subject).to receive(:fetch_token) { token }
|
|
57
59
|
allow(Aptible::Api::Account).to receive(:all)
|
|
58
60
|
.with(token: token, href: '/accounts?per_page=5000&no_embed=true')
|
|
@@ -112,6 +114,8 @@ describe Aptible::CLI::Agent do
|
|
|
112
114
|
end
|
|
113
115
|
|
|
114
116
|
context 'when an invalid account is specified' do
|
|
117
|
+
before { allow(Aptible::Api::Account).to receive(:find_by_url).and_return(nil) }
|
|
118
|
+
|
|
115
119
|
it 'prints out an error' do
|
|
116
120
|
subject.options = { environment: 'foo' }
|
|
117
121
|
expect { subject.send('maintenance:dbs') }
|
|
@@ -121,7 +125,6 @@ describe Aptible::CLI::Agent do
|
|
|
121
125
|
end
|
|
122
126
|
describe '#maintenance:apps' do
|
|
123
127
|
before do
|
|
124
|
-
token = 'the-token'
|
|
125
128
|
allow(subject).to receive(:fetch_token) { token }
|
|
126
129
|
allow(Aptible::Api::Account).to receive(:all)
|
|
127
130
|
.with(token: token, href: '/accounts?per_page=5000&no_embed=true')
|
|
@@ -180,6 +183,8 @@ describe Aptible::CLI::Agent do
|
|
|
180
183
|
end
|
|
181
184
|
|
|
182
185
|
context 'when an invalid account is specified' do
|
|
186
|
+
before { allow(Aptible::Api::Account).to receive(:find_by_url).and_return(nil) }
|
|
187
|
+
|
|
183
188
|
it 'prints out an error' do
|
|
184
189
|
subject.options = { environment: 'foo' }
|
|
185
190
|
expect { subject.send('maintenance:apps') }
|
|
@@ -21,6 +21,10 @@ describe Aptible::CLI::Agent do
|
|
|
21
21
|
allow(Aptible::Api::Account).to receive(:all)
|
|
22
22
|
.with(token: token, href: '/accounts?per_page=5000&no_embed=true')
|
|
23
23
|
.and_return([account])
|
|
24
|
+
|
|
25
|
+
allow(Aptible::Api::Account).to receive(:find_by_url)
|
|
26
|
+
.with("/find/account?handle=#{account.handle}", token: token)
|
|
27
|
+
.and_return(account)
|
|
24
28
|
end
|
|
25
29
|
|
|
26
30
|
describe '#metric_drain:list' do
|
|
@@ -57,8 +61,6 @@ describe Aptible::CLI::Agent do
|
|
|
57
61
|
it 'lists metric drains for a single account with --environment' do
|
|
58
62
|
other_account = Fabricate(:account)
|
|
59
63
|
Fabricate(:metric_drain, handle: 'test2', account: other_account)
|
|
60
|
-
accounts = [account, other_account]
|
|
61
|
-
allow(Aptible::Api::Account).to receive(:all).and_return(accounts)
|
|
62
64
|
|
|
63
65
|
subject.options = { environment: account.handle }
|
|
64
66
|
subject.send('metric_drain:list')
|
|
@@ -86,6 +88,12 @@ describe Aptible::CLI::Agent do
|
|
|
86
88
|
context 'influxdb' do
|
|
87
89
|
let(:db) { Fabricate(:database, account: account, id: 5) }
|
|
88
90
|
|
|
91
|
+
before do
|
|
92
|
+
allow(Aptible::Api::Database).to receive(:find_by_url)
|
|
93
|
+
.with("/find/database?handle=#{db.handle}&environment=#{db.account.handle}", token: token)
|
|
94
|
+
.and_return(db)
|
|
95
|
+
end
|
|
96
|
+
|
|
89
97
|
it 'creates a new InfluxDB metric drain' do
|
|
90
98
|
opts = {
|
|
91
99
|
handle: 'test-influxdb',
|
|
@@ -6,10 +6,9 @@ describe Aptible::CLI::Agent do
|
|
|
6
6
|
|
|
7
7
|
before do
|
|
8
8
|
allow(subject).to receive(:fetch_token) { token }
|
|
9
|
-
allow(Aptible::Api::App)
|
|
10
|
-
.
|
|
11
|
-
.
|
|
12
|
-
.and_return([app])
|
|
9
|
+
allow(Aptible::Api::App).to receive(:find_by_url)
|
|
10
|
+
.with("/find/app?handle=#{app.handle}", token: token)
|
|
11
|
+
.and_return(app)
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
describe '#services' do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: aptible-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.26.
|
|
4
|
+
version: 0.26.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Frank Macreery
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-05-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -563,6 +563,7 @@ files:
|
|
|
563
563
|
- spec/aptible/cli/helpers/ssh_spec.rb
|
|
564
564
|
- spec/aptible/cli/helpers/token_spec.rb
|
|
565
565
|
- spec/aptible/cli/helpers/tunnel_spec.rb
|
|
566
|
+
- spec/aptible/cli/helpers/vhost/option_set_builder_spec.rb
|
|
566
567
|
- spec/aptible/cli/renderer/json_spec.rb
|
|
567
568
|
- spec/aptible/cli/renderer/text_spec.rb
|
|
568
569
|
- spec/aptible/cli/resource_formatter_spec.rb
|
|
@@ -608,6 +609,7 @@ files:
|
|
|
608
609
|
- spec/fabricators/operation_fabricator.rb
|
|
609
610
|
- spec/fabricators/service_fabricator.rb
|
|
610
611
|
- spec/fabricators/service_sizing_policy_fabricator.rb
|
|
612
|
+
- spec/fabricators/setting_fabricator.rb
|
|
611
613
|
- spec/fabricators/stack_fabricator.rb
|
|
612
614
|
- spec/fabricators/vhost_fabricator.rb
|
|
613
615
|
- spec/mock/git
|
|
@@ -657,6 +659,7 @@ test_files:
|
|
|
657
659
|
- spec/aptible/cli/helpers/ssh_spec.rb
|
|
658
660
|
- spec/aptible/cli/helpers/token_spec.rb
|
|
659
661
|
- spec/aptible/cli/helpers/tunnel_spec.rb
|
|
662
|
+
- spec/aptible/cli/helpers/vhost/option_set_builder_spec.rb
|
|
660
663
|
- spec/aptible/cli/renderer/json_spec.rb
|
|
661
664
|
- spec/aptible/cli/renderer/text_spec.rb
|
|
662
665
|
- spec/aptible/cli/resource_formatter_spec.rb
|
|
@@ -702,6 +705,7 @@ test_files:
|
|
|
702
705
|
- spec/fabricators/operation_fabricator.rb
|
|
703
706
|
- spec/fabricators/service_fabricator.rb
|
|
704
707
|
- spec/fabricators/service_sizing_policy_fabricator.rb
|
|
708
|
+
- spec/fabricators/setting_fabricator.rb
|
|
705
709
|
- spec/fabricators/stack_fabricator.rb
|
|
706
710
|
- spec/fabricators/vhost_fabricator.rb
|
|
707
711
|
- spec/mock/git
|