gandi_v5 0.3.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +56 -2
- data/.travis.yml +6 -1
- data/CHANGELOG.md +61 -0
- data/LICENSE.md +2 -6
- data/README.md +15 -9
- data/gandi_v5.gemspec +2 -2
- data/lib/gandi_v5.rb +40 -14
- data/lib/gandi_v5/data.rb +1 -2
- data/lib/gandi_v5/data/converter/integer.rb +26 -0
- data/lib/gandi_v5/domain.rb +13 -14
- data/lib/gandi_v5/email/forward.rb +2 -8
- data/lib/gandi_v5/email/mailbox.rb +57 -11
- data/lib/gandi_v5/email/slot.rb +11 -3
- data/lib/gandi_v5/live_dns.rb +0 -12
- data/lib/gandi_v5/live_dns/domain.rb +313 -29
- data/lib/gandi_v5/live_dns/domain/dnssec_key.rb +115 -0
- data/lib/gandi_v5/live_dns/domain/record.rb +81 -0
- data/lib/gandi_v5/live_dns/domain/snapshot.rb +107 -0
- data/lib/gandi_v5/live_dns/domain/tsig_key.rb +71 -0
- data/lib/gandi_v5/organization.rb +10 -0
- data/lib/gandi_v5/organization/customer.rb +90 -0
- data/lib/gandi_v5/sharing_space.rb +27 -0
- data/lib/gandi_v5/simple_hosting.rb +12 -0
- data/lib/gandi_v5/simple_hosting/instance.rb +242 -0
- data/lib/gandi_v5/simple_hosting/instance/application.rb +44 -0
- data/lib/gandi_v5/simple_hosting/instance/database.rb +19 -0
- data/lib/gandi_v5/simple_hosting/instance/language.rb +22 -0
- data/lib/gandi_v5/simple_hosting/instance/upgrade.rb +21 -0
- data/lib/gandi_v5/simple_hosting/instance/virtual_host.rb +187 -0
- data/lib/gandi_v5/simple_hosting/instance/virtual_host/linked_dns_zone.rb +74 -0
- data/lib/gandi_v5/version.rb +1 -1
- data/spec/.rubocop.yml +56 -2
- data/spec/fixtures/bodies/GandiV5_Domain/fetch.yml +8 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/fetch.yml +1 -2
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/list_tsig.yml +3 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/nameservers.yml +3 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_DnssecKey/fetch.yml +12 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_DnssecKey/list.yml +9 -0
- data/spec/fixtures/bodies/{GandiV5_LiveDNS_Zone_Snapshot → GandiV5_LiveDNS_Domain_Snapshot}/fetch.yml +4 -3
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_Snapshot/list.yml +5 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_TsigKey/fetch.yml +9 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_TsigKey/list.yml +4 -0
- data/spec/fixtures/bodies/GandiV5_Organization_Customer/list.yml +8 -0
- data/spec/fixtures/bodies/GandiV5_SimpleHosting_Instance/fetch.yml +80 -0
- data/spec/fixtures/bodies/GandiV5_SimpleHosting_Instance/list.yml +38 -0
- data/spec/fixtures/bodies/GandiV5_SimpleHosting_Instance_VirtualHost/fetch.yml +26 -0
- data/spec/fixtures/bodies/GandiV5_SimpleHosting_Instance_VirtualHost/list.yml +18 -0
- data/spec/units/gandi_v5/data/converter/integer_spec.rb +16 -0
- data/spec/units/gandi_v5/domain_spec.rb +53 -43
- data/spec/units/gandi_v5/email/forward_spec.rb +5 -34
- data/spec/units/gandi_v5/email/mailbox_spec.rb +119 -37
- data/spec/units/gandi_v5/email/slot_spec.rb +10 -2
- data/spec/units/gandi_v5/live_dns/domain/dnssec_key_spec.rb +128 -0
- data/spec/units/gandi_v5/live_dns/{record_set_spec.rb → domain/record_spec.rb} +1 -1
- data/spec/units/gandi_v5/live_dns/domain/snapshot_spec.rb +101 -0
- data/spec/units/gandi_v5/live_dns/domain/tsig_key_spec.rb +78 -0
- data/spec/units/gandi_v5/live_dns/domain_spec.rb +297 -118
- data/spec/units/gandi_v5/live_dns_spec.rb +0 -12
- data/spec/units/gandi_v5/organization/customer_spec.rb +81 -0
- data/spec/units/gandi_v5/organization_spec.rb +14 -0
- data/spec/units/gandi_v5/sharing_space_spec.rb +4 -0
- data/spec/units/gandi_v5/simple_hosting/instance/application_spec.rb +37 -0
- data/spec/units/gandi_v5/simple_hosting/instance/database_spec.rb +4 -0
- data/spec/units/gandi_v5/simple_hosting/instance/language_spec.rb +4 -0
- data/spec/units/gandi_v5/simple_hosting/instance/upgrade_spec.rb +4 -0
- data/spec/units/gandi_v5/simple_hosting/instance/virtual_host/linked_dns_zone_spec.rb +50 -0
- data/spec/units/gandi_v5/simple_hosting/instance/virtual_host_spec.rb +199 -0
- data/spec/units/gandi_v5/simple_hosting/instance_spec.rb +182 -0
- data/spec/units/gandi_v5/simple_hosting_spec.rb +9 -0
- data/spec/units/gandi_v5_spec.rb +139 -30
- metadata +50 -31
- data/lib/gandi_v5/domain/sharing_space.rb +0 -21
- data/lib/gandi_v5/live_dns/has_zone_records.rb +0 -153
- data/lib/gandi_v5/live_dns/record_set.rb +0 -79
- data/lib/gandi_v5/live_dns/zone.rb +0 -160
- data/lib/gandi_v5/live_dns/zone/snapshot.rb +0 -81
- data/spec/features/domain_spec.rb +0 -45
- data/spec/features/livedns_domain_spec.rb +0 -8
- data/spec/features/livedns_zone_spec.rb +0 -45
- data/spec/features/mailbox_spec.rb +0 -18
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/fetch.yml +0 -11
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/list.yml +0 -11
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/list.yml +0 -3
- data/spec/fixtures/vcr/Domain_features/List_domains.yml +0 -55
- data/spec/fixtures/vcr/Domain_features/Renew_domain.yml +0 -133
- data/spec/fixtures/vcr/LiveDNS_Domain_features/List_domains.yml +0 -32
- data/spec/fixtures/vcr/LiveDNS_Zone_features/List_zones.yml +0 -42
- data/spec/fixtures/vcr/LiveDNS_Zone_features/Make_and_save_snapshot.yml +0 -72
- data/spec/fixtures/vcr/LiveDNS_Zone_features/Save_zone_to_file.yml +0 -28
- data/spec/fixtures/vcr/Mailbox_features/List_mailboxes.yml +0 -39
- data/spec/units/gandi_v5/domain/sharing_space_spec.rb +0 -4
- data/spec/units/gandi_v5/live_dns/zone/snapshot_spec.rb +0 -66
- data/spec/units/gandi_v5/live_dns/zone_spec.rb +0 -347
@@ -13,18 +13,6 @@ describe GandiV5::LiveDNS do
|
|
13
13
|
expect(described_class.domains).to be returns
|
14
14
|
end
|
15
15
|
|
16
|
-
it '.zone' do
|
17
|
-
returns = double GandiV5::LiveDNS::Zone
|
18
|
-
expect(GandiV5::LiveDNS::Zone).to receive(:fetch).with('zone-uuid').and_return(returns)
|
19
|
-
expect(described_class.zone('zone-uuid')).to be returns
|
20
|
-
end
|
21
|
-
|
22
|
-
it '.zones' do
|
23
|
-
returns = double Array
|
24
|
-
expect(GandiV5::LiveDNS::Zone).to receive(:list).and_return(returns)
|
25
|
-
expect(described_class.zones).to be returns
|
26
|
-
end
|
27
|
-
|
28
16
|
describe '.require_valid_record_type' do
|
29
17
|
it 'Does nothing for valid type' do
|
30
18
|
expect { described_class.require_valid_record_type 'A' }.to_not raise_error
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe GandiV5::Organization::Customer do
|
4
|
+
let(:body_fixtures) { File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Organization_Customer')) }
|
5
|
+
|
6
|
+
describe '.create' do
|
7
|
+
let(:url) { 'https://api.gandi.net/v5/organization/organizations/uuid/customers' }
|
8
|
+
let(:attrs) do
|
9
|
+
{
|
10
|
+
city: 'Ci',
|
11
|
+
country: 'Co',
|
12
|
+
email: 'a@e',
|
13
|
+
firstname: 'f',
|
14
|
+
lastname: 'l',
|
15
|
+
phone: '0',
|
16
|
+
streetaddr: 'sa',
|
17
|
+
type: :individual
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'Success' do
|
22
|
+
response = double RestClient::Response, headers: { location: '' }
|
23
|
+
expect(GandiV5).to receive(:post).with(url, attrs.to_json).and_return([response, nil])
|
24
|
+
expect(described_class.create('uuid', **attrs)).to be nil
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'Checks for required attributes' do
|
28
|
+
%i[city country email firstname lastname phone streetaddr type].each do |attr|
|
29
|
+
it attr do
|
30
|
+
attrs.delete attr
|
31
|
+
expect { described_class.new('org_uuid', **attrs) }.to raise_exception ArgumentError
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'Invalid type' do
|
37
|
+
attrs[:type] = :invalid
|
38
|
+
expect { described_class.new('org_uuid', **attrs) }.to raise_exception ArgumentError
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '.list' do
|
43
|
+
describe 'With default values' do
|
44
|
+
subject { described_class.list('uuid') }
|
45
|
+
|
46
|
+
before :each do
|
47
|
+
url = 'https://api.gandi.net/v5/organization/organizations/uuid/customers'
|
48
|
+
expect(GandiV5).to receive(:get).with(url, params: {})
|
49
|
+
.and_return([nil, YAML.load_file(File.join(body_fixtures, 'list.yml'))])
|
50
|
+
end
|
51
|
+
|
52
|
+
its('count') { should eq 1 }
|
53
|
+
its('first.uuid') { should eq 'customer-uuid' }
|
54
|
+
its('first.name') { should eq 'FirstLast' }
|
55
|
+
its('first.first_name') { should eq 'First' }
|
56
|
+
its('first.last_name') { should eq 'Last' }
|
57
|
+
its('first.email') { should eq 'first.last@example.com' }
|
58
|
+
its('first.type') { should eq :individual }
|
59
|
+
its('first.org_name') { should eq 'Org' }
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'Passes optional query params' do
|
63
|
+
let(:url) { 'https://api.gandi.net/v5/organization/organizations/org_uuid/customers' }
|
64
|
+
|
65
|
+
it 'name' do
|
66
|
+
expect(GandiV5).to receive(:get).with(url, params: { '~name' => '5' })
|
67
|
+
.and_return([nil, []])
|
68
|
+
expect(described_class.list('org_uuid', name: '5')).to eq []
|
69
|
+
end
|
70
|
+
|
71
|
+
%i[permission sort_by].each do |param|
|
72
|
+
it param.to_s do
|
73
|
+
headers = { param => 5 }
|
74
|
+
expect(GandiV5).to receive(:get).with(url, params: headers)
|
75
|
+
.and_return([nil, []])
|
76
|
+
expect(described_class.list('org_uuid', **headers)).to eq []
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -64,4 +64,18 @@ describe GandiV5::Organization do
|
|
64
64
|
its('security_email_validated') { should eq true }
|
65
65
|
its('security_email_validation_deadline') { should eq Time.new(2017, 11, 22, 17, 13, 33) }
|
66
66
|
end
|
67
|
+
|
68
|
+
it '#customers' do
|
69
|
+
subject = described_class.new uuid: 'org_uuid'
|
70
|
+
returns = double Array
|
71
|
+
expect(GandiV5::Organization::Customer).to receive(:list).with('org_uuid', param: :value).and_return(returns)
|
72
|
+
expect(subject.customers('org_uuid', param: :value)).to be returns
|
73
|
+
end
|
74
|
+
|
75
|
+
it '#create_customer' do
|
76
|
+
subject = described_class.new uuid: 'org_uuid'
|
77
|
+
returns = double Object
|
78
|
+
expect(GandiV5::Organization::Customer).to receive(:create).with('org_uuid', param: :value).and_return(returns)
|
79
|
+
expect(subject.create_customer('org_uuid', param: :value)).to be returns
|
80
|
+
end
|
67
81
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe GandiV5::SimpleHosting::Instance::Application do
|
4
|
+
describe 'Helper methods' do
|
5
|
+
context 'being_created' do
|
6
|
+
subject { described_class.new status: :being_created }
|
7
|
+
its('being_created?') { should be true }
|
8
|
+
its('cancelled?') { should be false }
|
9
|
+
its('running?') { should be false }
|
10
|
+
its('error?') { should be false }
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'cancelled' do
|
14
|
+
subject { described_class.new status: :cancelled }
|
15
|
+
its('being_created?') { should be false }
|
16
|
+
its('cancelled?') { should be true }
|
17
|
+
its('running?') { should be false }
|
18
|
+
its('error?') { should be false }
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'running' do
|
22
|
+
subject { described_class.new status: :running }
|
23
|
+
its('being_created?') { should be false }
|
24
|
+
its('cancelled?') { should be false }
|
25
|
+
its('running?') { should be true }
|
26
|
+
its('error?') { should be false }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'error' do
|
30
|
+
subject { described_class.new status: :error }
|
31
|
+
its('being_created?') { should be false }
|
32
|
+
its('cancelled?') { should be false }
|
33
|
+
its('running?') { should be false }
|
34
|
+
its('error?') { should be true }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe GandiV5::SimpleHosting::Instance::VirtualHost::LinkedDnsZone do
|
4
|
+
describe 'Helper methods' do
|
5
|
+
context 'altered' do
|
6
|
+
subject { described_class.new status: :altered }
|
7
|
+
its('altered?') { should be true }
|
8
|
+
its('livedns_conflict?') { should be false }
|
9
|
+
its('livedns_done?') { should be false }
|
10
|
+
its('livedns_error?') { should be false }
|
11
|
+
its('unknown?') { should be false }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'altered' do
|
15
|
+
subject { described_class.new status: :livedns_conflict }
|
16
|
+
its('altered?') { should be false }
|
17
|
+
its('livedns_conflict?') { should be true }
|
18
|
+
its('livedns_done?') { should be false }
|
19
|
+
its('livedns_error?') { should be false }
|
20
|
+
its('unknown?') { should be false }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'livedns_done' do
|
24
|
+
subject { described_class.new status: :livedns_done }
|
25
|
+
its('altered?') { should be false }
|
26
|
+
its('livedns_conflict?') { should be false }
|
27
|
+
its('livedns_done?') { should be true }
|
28
|
+
its('livedns_error?') { should be false }
|
29
|
+
its('unknown?') { should be false }
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'livedns_error' do
|
33
|
+
subject { described_class.new status: :livedns_error }
|
34
|
+
its('altered?') { should be false }
|
35
|
+
its('livedns_conflict?') { should be false }
|
36
|
+
its('livedns_done?') { should be false }
|
37
|
+
its('livedns_error?') { should be true }
|
38
|
+
its('unknown?') { should be false }
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'unknown' do
|
42
|
+
subject { described_class.new status: :unknown }
|
43
|
+
its('altered?') { should be false }
|
44
|
+
its('livedns_conflict?') { should be false }
|
45
|
+
its('livedns_done?') { should be false }
|
46
|
+
its('livedns_error?') { should be false }
|
47
|
+
its('unknown?') { should be true }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe GandiV5::SimpleHosting::Instance::VirtualHost do
|
4
|
+
let :body_list do
|
5
|
+
YAML.load_file(
|
6
|
+
File.expand_path(
|
7
|
+
File.join('spec', 'fixtures', 'bodies', 'GandiV5_SimpleHosting_Instance_VirtualHost', 'list.yml')
|
8
|
+
)
|
9
|
+
)
|
10
|
+
end
|
11
|
+
let :body_fetch do
|
12
|
+
YAML.load_file(
|
13
|
+
File.expand_path(
|
14
|
+
File.join('spec', 'fixtures', 'bodies', 'GandiV5_SimpleHosting_Instance_VirtualHost', 'fetch.yml')
|
15
|
+
)
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
subject do
|
20
|
+
described_class.new instance_uuid: 'instance-uuid', fqdn: 'vh.example.com'
|
21
|
+
end
|
22
|
+
|
23
|
+
it '#refresh' do
|
24
|
+
url = 'https://api.gandi.net/v5/simplehosting/instances/instance-uuid/vhosts/vh.example.com'
|
25
|
+
expect(GandiV5).to receive(:get).with(url)
|
26
|
+
.and_return([nil, body_fetch])
|
27
|
+
subject.refresh
|
28
|
+
expect(subject.linked_dns_zone.cname).to_not be nil
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'Helper methods' do
|
32
|
+
describe 'Status' do
|
33
|
+
context 'being_created' do
|
34
|
+
subject { described_class.new status: :being_created }
|
35
|
+
its('being_created?') { should be true }
|
36
|
+
its('running?') { should be false }
|
37
|
+
its('being_deleted?') { should be false }
|
38
|
+
its('locked?') { should be false }
|
39
|
+
its('waiting_ownership?') { should be false }
|
40
|
+
its('ownership_validated?') { should be false }
|
41
|
+
its('validation_failed?') { should be false }
|
42
|
+
end
|
43
|
+
context 'running' do
|
44
|
+
subject { described_class.new status: :running }
|
45
|
+
its('being_created?') { should be false }
|
46
|
+
its('running?') { should be true }
|
47
|
+
its('being_deleted?') { should be false }
|
48
|
+
its('locked?') { should be false }
|
49
|
+
its('waiting_ownership?') { should be false }
|
50
|
+
its('ownership_validated?') { should be false }
|
51
|
+
its('validation_failed?') { should be false }
|
52
|
+
end
|
53
|
+
context 'being_deleted' do
|
54
|
+
subject { described_class.new status: :being_deleted }
|
55
|
+
its('being_created?') { should be false }
|
56
|
+
its('running?') { should be false }
|
57
|
+
its('being_deleted?') { should be true }
|
58
|
+
its('locked?') { should be false }
|
59
|
+
its('waiting_ownership?') { should be false }
|
60
|
+
its('ownership_validated?') { should be false }
|
61
|
+
its('validation_failed?') { should be false }
|
62
|
+
end
|
63
|
+
context 'locked' do
|
64
|
+
subject { described_class.new status: :locked }
|
65
|
+
its('being_created?') { should be false }
|
66
|
+
its('running?') { should be false }
|
67
|
+
its('being_deleted?') { should be false }
|
68
|
+
its('locked?') { should be true }
|
69
|
+
its('waiting_ownership?') { should be false }
|
70
|
+
its('ownership_validated?') { should be false }
|
71
|
+
its('validation_failed?') { should be false }
|
72
|
+
end
|
73
|
+
context 'waiting_ownership' do
|
74
|
+
subject { described_class.new status: :waiting_ownership }
|
75
|
+
its('being_created?') { should be false }
|
76
|
+
its('running?') { should be false }
|
77
|
+
its('being_deleted?') { should be false }
|
78
|
+
its('locked?') { should be false }
|
79
|
+
its('waiting_ownership?') { should be true }
|
80
|
+
its('ownership_validated?') { should be false }
|
81
|
+
its('validation_failed?') { should be false }
|
82
|
+
end
|
83
|
+
context 'ownership_validated' do
|
84
|
+
subject { described_class.new status: :ownership_validated }
|
85
|
+
its('being_created?') { should be false }
|
86
|
+
its('running?') { should be false }
|
87
|
+
its('being_deleted?') { should be false }
|
88
|
+
its('locked?') { should be false }
|
89
|
+
its('waiting_ownership?') { should be false }
|
90
|
+
its('ownership_validated?') { should be true }
|
91
|
+
its('validation_failed?') { should be false }
|
92
|
+
end
|
93
|
+
context 'validation_failed' do
|
94
|
+
subject { described_class.new status: :validation_failed }
|
95
|
+
its('being_created?') { should be false }
|
96
|
+
its('running?') { should be false }
|
97
|
+
its('being_deleted?') { should be false }
|
98
|
+
its('locked?') { should be false }
|
99
|
+
its('waiting_ownership?') { should be false }
|
100
|
+
its('ownership_validated?') { should be false }
|
101
|
+
its('validation_failed?') { should be true }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe 'HTTP(S)' do
|
106
|
+
context 'HTTP_only' do
|
107
|
+
subject { described_class.new https_strategy: :http_only }
|
108
|
+
its('http_only?') { should be true }
|
109
|
+
its('http_and_https?') { should be false }
|
110
|
+
its('redirect_http_to_https?') { should be false }
|
111
|
+
its('http?') { should be true }
|
112
|
+
its('https?') { should be false }
|
113
|
+
end
|
114
|
+
context 'HTTP_and_HTTPS' do
|
115
|
+
subject { described_class.new https_strategy: :http_and_https }
|
116
|
+
its('http_only?') { should be false }
|
117
|
+
its('http_and_https?') { should be true }
|
118
|
+
its('redirect_http_to_https?') { should be false }
|
119
|
+
its('http?') { should be true }
|
120
|
+
its('https?') { should be true }
|
121
|
+
end
|
122
|
+
context 'redirect_HTTP_to_HTTPS' do
|
123
|
+
subject { described_class.new https_strategy: :redirect_http_to_https }
|
124
|
+
its('http_only?') { should be false }
|
125
|
+
its('http_and_https?') { should be false }
|
126
|
+
its('redirect_http_to_https?') { should be true }
|
127
|
+
its('http?') { should be false }
|
128
|
+
its('https?') { should be false }
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe '.list' do
|
134
|
+
subject { described_class.list('instance-uuid') }
|
135
|
+
let(:url) { 'https://api.gandi.net/v5/simplehosting/instances/instance-uuid/vhosts' }
|
136
|
+
|
137
|
+
describe 'With default parameters' do
|
138
|
+
before :each do
|
139
|
+
expect(GandiV5).to receive(:paginated_get).with(url, (1..), 100, params: {})
|
140
|
+
.and_yield(body_list)
|
141
|
+
end
|
142
|
+
|
143
|
+
its('count') { should eq 1 }
|
144
|
+
its('first.created_at') { should eq Time.new(2020, 1, 2, 12, 34, 56, 0) }
|
145
|
+
its('first.fqdn') { should eq 'vh.example.com' }
|
146
|
+
its('first.is_a_test_virtual_host') { should be false }
|
147
|
+
its('first.linked_dns_zone.allow_alteration') { should be true }
|
148
|
+
its('first.linked_dns_zone.status') { should eq :unknown }
|
149
|
+
its('first.linked_dns_zone.last_checked_at') { should eq Time.new(2020, 2, 3, 23, 45, 56, 0) }
|
150
|
+
its('first.status') { should eq :running }
|
151
|
+
its('first.application.name') { should eq 'app-name' }
|
152
|
+
its('first.application.status') { should eq :being_created }
|
153
|
+
its('first.application.parameters') { should eq({}) }
|
154
|
+
its('first.certificates') { should eq({ 'cert-id' => true }) }
|
155
|
+
its('first.https_strategy') { should eq :redirect_http_to_https }
|
156
|
+
end
|
157
|
+
|
158
|
+
describe 'Passes optional query params' do
|
159
|
+
%i[fqdn status sort_by].each do |param|
|
160
|
+
it param do
|
161
|
+
expect(GandiV5).to receive(:paginated_get).with(url, (1..), 100, params: { param => 'value' })
|
162
|
+
.and_return([nil, []])
|
163
|
+
described_class.list('instance-uuid', param => 'value')
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe '.fetch' do
|
170
|
+
subject { described_class.fetch 'instance-uuid', 'vh.example.com' }
|
171
|
+
|
172
|
+
before :each do
|
173
|
+
url = 'https://api.gandi.net/v5/simplehosting/instances/instance-uuid/vhosts/vh.example.com'
|
174
|
+
expect(GandiV5).to receive(:get).with(url)
|
175
|
+
.and_return([nil, body_fetch])
|
176
|
+
end
|
177
|
+
|
178
|
+
its('created_at') { should eq Time.new(2020, 1, 2, 12, 34, 56, 0) }
|
179
|
+
its('fqdn') { should eq 'vh.example.com' }
|
180
|
+
its('is_a_test_virtual_host') { should be false }
|
181
|
+
its('linked_dns_zone.allow_alteration') { should be true }
|
182
|
+
its('linked_dns_zone.cname') { should eq 'cn' }
|
183
|
+
its('linked_dns_zone.domain') { should eq 'example.com' }
|
184
|
+
its('linked_dns_zone.ipv4') { should eq '1.2.3.4' }
|
185
|
+
its('linked_dns_zone.ipv6') { should eq '1:2::3:4' }
|
186
|
+
its('linked_dns_zone.is_alterable') { should be true }
|
187
|
+
its('linked_dns_zone.is_root') { should be true }
|
188
|
+
its('linked_dns_zone.key') { should eq 'www' }
|
189
|
+
its('linked_dns_zone.txt') { should eq 'abcd1234' }
|
190
|
+
its('linked_dns_zone.status') { should eq :unknown }
|
191
|
+
its('linked_dns_zone.last_checked_at') { should eq Time.new(2020, 2, 3, 23, 45, 56, 0) }
|
192
|
+
its('status') { should eq :running }
|
193
|
+
its('application.name') { should eq 'app-name' }
|
194
|
+
its('application.status') { should eq :being_created }
|
195
|
+
its('application.parameters') { should eq({}) }
|
196
|
+
its('certificates') { should eq({ 'cert-id' => true }) }
|
197
|
+
its('https_strategy') { should eq :redirect_http_to_https }
|
198
|
+
end
|
199
|
+
end
|
@@ -0,0 +1,182 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe GandiV5::SimpleHosting::Instance do
|
4
|
+
let :body_list do
|
5
|
+
YAML.load_file(
|
6
|
+
File.expand_path(
|
7
|
+
File.join('spec', 'fixtures', 'bodies', 'GandiV5_SimpleHosting_Instance', 'list.yml')
|
8
|
+
)
|
9
|
+
)
|
10
|
+
end
|
11
|
+
let :body_fetch do
|
12
|
+
YAML.load_file(
|
13
|
+
File.expand_path(
|
14
|
+
File.join('spec', 'fixtures', 'bodies', 'GandiV5_SimpleHosting_Instance', 'fetch.yml')
|
15
|
+
)
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
subject do
|
20
|
+
described_class.new uuid: 'instance-uuid'
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'Actions' do
|
24
|
+
let(:url) { 'https://api.gandi.net/v5/simplehosting/instances/instance-uuid/action' }
|
25
|
+
|
26
|
+
%i[restart console reset_database_password].each do |action|
|
27
|
+
it ".#{action}" do
|
28
|
+
expect(GandiV5).to receive(:post).with(url, "{\"action\":\"#{action}\"}")
|
29
|
+
.and_return([nil, 'Confirmation message'])
|
30
|
+
expect(subject.send(action)).to eq 'Confirmation message'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it '#refresh' do
|
36
|
+
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/simplehosting/instances/instance-uuid')
|
37
|
+
.and_return([nil, body_fetch])
|
38
|
+
subject.refresh
|
39
|
+
expect(subject.access_information).to_not be nil
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'Helper methods' do
|
43
|
+
describe 'Status' do
|
44
|
+
context 'waiting_bill' do
|
45
|
+
subject { described_class.new status: :waiting_bill }
|
46
|
+
its('waiting_bill?') { should be true }
|
47
|
+
its('being_created?') { should be false }
|
48
|
+
its('active?') { should be false }
|
49
|
+
its('paused?') { should be false }
|
50
|
+
its('locked?') { should be false }
|
51
|
+
its('being_deleted?') { should be false }
|
52
|
+
end
|
53
|
+
context 'being_created' do
|
54
|
+
subject { described_class.new status: :being_created }
|
55
|
+
its('waiting_bill?') { should be false }
|
56
|
+
its('being_created?') { should be true }
|
57
|
+
its('active?') { should be false }
|
58
|
+
its('paused?') { should be false }
|
59
|
+
its('locked?') { should be false }
|
60
|
+
its('being_deleted?') { should be false }
|
61
|
+
end
|
62
|
+
context 'active' do
|
63
|
+
subject { described_class.new status: :active }
|
64
|
+
its('waiting_bill?') { should be false }
|
65
|
+
its('being_created?') { should be false }
|
66
|
+
its('active?') { should be true }
|
67
|
+
its('paused?') { should be false }
|
68
|
+
its('locked?') { should be false }
|
69
|
+
its('being_deleted?') { should be false }
|
70
|
+
end
|
71
|
+
context 'paused' do
|
72
|
+
subject { described_class.new status: :paused }
|
73
|
+
its('waiting_bill?') { should be false }
|
74
|
+
its('being_created?') { should be false }
|
75
|
+
its('active?') { should be false }
|
76
|
+
its('paused?') { should be true }
|
77
|
+
its('locked?') { should be false }
|
78
|
+
its('being_deleted?') { should be false }
|
79
|
+
end
|
80
|
+
context 'locked' do
|
81
|
+
subject { described_class.new status: :locked }
|
82
|
+
its('waiting_bill?') { should be false }
|
83
|
+
its('being_created?') { should be false }
|
84
|
+
its('active?') { should be false }
|
85
|
+
its('paused?') { should be false }
|
86
|
+
its('locked?') { should be true }
|
87
|
+
its('being_deleted?') { should be false }
|
88
|
+
end
|
89
|
+
context 'being_deleted' do
|
90
|
+
subject { described_class.new status: :being_deleted }
|
91
|
+
its('waiting_bill?') { should be false }
|
92
|
+
its('being_created?') { should be false }
|
93
|
+
its('active?') { should be false }
|
94
|
+
its('paused?') { should be false }
|
95
|
+
its('locked?') { should be false }
|
96
|
+
its('being_deleted?') { should be true }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe '.list' do
|
102
|
+
subject { described_class.list }
|
103
|
+
let(:url) { 'https://api.gandi.net/v5/simplehosting/instances' }
|
104
|
+
|
105
|
+
describe 'With default parameters' do
|
106
|
+
before :each do
|
107
|
+
expect(GandiV5).to receive(:paginated_get).with(url, (1..), 100, params: {})
|
108
|
+
.and_yield(body_list)
|
109
|
+
end
|
110
|
+
|
111
|
+
its('count') { should eq 1 }
|
112
|
+
its('first.created_at') { should eq Time.new(2020, 1, 2, 12, 34, 56) }
|
113
|
+
its('first.database.name') { should eq 'database name' }
|
114
|
+
its('first.database.status') { should eq 'database status' }
|
115
|
+
its('first.database.version') { should eq 'database version' }
|
116
|
+
its('first.data_center') { should eq 'FR-SD5' }
|
117
|
+
its('first.expire_at') { should eq Time.new(2021, 1, 2, 12, 34, 56) }
|
118
|
+
its('first.uuid') { should eq 'instance-uuid' }
|
119
|
+
its('first.language.name') { should eq 'ruby' }
|
120
|
+
its('first.language.single_application') { should be true }
|
121
|
+
its('first.language.status') { should eq 'great' }
|
122
|
+
its('first.language.version') { should eq '2.7' }
|
123
|
+
its('first.name') { should eq 'instance name' }
|
124
|
+
its('first.sharing_space.uuid') { should eq 'sharing-space-uuid' }
|
125
|
+
its('first.sharing_space.name') { should eq 'sharing space name' }
|
126
|
+
its('first.size') { should eq 's+' }
|
127
|
+
its('first.snapshot_enabled') { should be true }
|
128
|
+
its('first.status') { should eq 'active' }
|
129
|
+
its('first.storage') { should eq({ base: '20 GB', additional: '10 GB', total: '30 GB' }) }
|
130
|
+
its('first.auto_renew') { should eq '1 m' }
|
131
|
+
end
|
132
|
+
|
133
|
+
describe 'Passes optional query params' do
|
134
|
+
%i[sharing_id name fqdn size status sort_by].each do |param|
|
135
|
+
it param do
|
136
|
+
expect(GandiV5).to receive(:paginated_get).with(url, (1..), 100, params: { param => 'value' })
|
137
|
+
.and_return([nil, []])
|
138
|
+
described_class.list(param => 'value')
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe '.fetch' do
|
145
|
+
subject { described_class.fetch 'instance-uuid' }
|
146
|
+
|
147
|
+
before :each do
|
148
|
+
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/simplehosting/instances/instance-uuid')
|
149
|
+
.and_return([nil, body_fetch])
|
150
|
+
end
|
151
|
+
|
152
|
+
its('access_information') { should be_a Hash }
|
153
|
+
its('created_at') { should eq Time.new(2020, 1, 2, 12, 34, 56, 0) }
|
154
|
+
its('database.name') { should eq 'database name' }
|
155
|
+
its('database.status') { should eq 'database status' }
|
156
|
+
its('database.version') { should eq 'database version' }
|
157
|
+
its('data_center') { should eq 'FR-SD5' }
|
158
|
+
its('expire_at') { should eq Time.new(2021, 1, 2, 12, 34, 56, 0) }
|
159
|
+
its('uuid') { should eq 'instance-uuid' }
|
160
|
+
its('is_trial') { should be false }
|
161
|
+
its('language.name') { should eq 'ruby' }
|
162
|
+
its('language.single_application') { should be true }
|
163
|
+
its('language.status') { should eq 'great' }
|
164
|
+
its('language.version') { should eq '2.7' }
|
165
|
+
its('name') { should eq 'instance name' }
|
166
|
+
its('sharing_space.uuid') { should eq 'sharing-space-uuid' }
|
167
|
+
its('sharing_space.name') { should eq 'sharing space name' }
|
168
|
+
its('size') { should eq 's+' }
|
169
|
+
its('snapshot_enabled') { should be true }
|
170
|
+
its('status') { should eq 'active' }
|
171
|
+
its('storage') { should eq({ base: '20 GB', additional: '10 GB', total: '30 GB' }) }
|
172
|
+
its('virtual_hosts.first.fqdn') { should eq 'vhost1.example.com' }
|
173
|
+
its('auto_renew') { should eq '1 m' }
|
174
|
+
its('compatible_applications.first.name') { should eq 'compatable name' }
|
175
|
+
its('compatible_applications.first.parameters') { should be_a Hash }
|
176
|
+
its('password_updated_at') { should eq Time.new(2020, 6, 2, 12, 34, 56, 0) }
|
177
|
+
its('upgrade_to.first.name') { should eq 'upgrade to name' }
|
178
|
+
its('upgrade_to.first.status') { should eq 'upgrade to status' }
|
179
|
+
its('upgrade_to.first.type') { should eq 'database' }
|
180
|
+
its('upgrade_to.first.version') { should eq 'upgrade to version' }
|
181
|
+
end
|
182
|
+
end
|