gandi_v5 0.5.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +69 -5
- data/LICENSE.md +2 -6
- data/README.md +67 -18
- data/lib/gandi_v5.rb +137 -70
- data/lib/gandi_v5/billing/info/prepaid.rb +1 -0
- data/lib/gandi_v5/data.rb +3 -2
- data/lib/gandi_v5/data/converter.rb +3 -2
- data/lib/gandi_v5/data/converter/array_of.rb +3 -2
- data/lib/gandi_v5/data/converter/integer.rb +3 -2
- data/lib/gandi_v5/data/converter/symbol.rb +3 -2
- data/lib/gandi_v5/data/converter/time.rb +3 -2
- data/lib/gandi_v5/domain.rb +16 -17
- data/lib/gandi_v5/domain/availability/product/period.rb +1 -1
- data/lib/gandi_v5/domain/contact.rb +5 -5
- data/lib/gandi_v5/domain/tld.rb +2 -2
- data/lib/gandi_v5/domain/transfer_in.rb +170 -0
- data/lib/gandi_v5/domain/transfer_in/availability.rb +51 -0
- data/lib/gandi_v5/email.rb +1 -0
- data/lib/gandi_v5/email/forward.rb +2 -8
- data/lib/gandi_v5/email/mailbox.rb +4 -10
- data/lib/gandi_v5/email/slot.rb +11 -3
- data/lib/gandi_v5/error/gandi_error.rb +1 -0
- data/lib/gandi_v5/live_dns.rb +2 -12
- data/lib/gandi_v5/live_dns/domain.rb +340 -29
- data/lib/gandi_v5/live_dns/domain/dnssec_key.rb +120 -0
- data/lib/gandi_v5/live_dns/domain/record.rb +81 -0
- data/lib/gandi_v5/live_dns/domain/snapshot.rb +111 -0
- data/lib/gandi_v5/live_dns/domain/tsig_key.rb +74 -0
- data/lib/gandi_v5/sharing_space.rb +27 -0
- data/lib/gandi_v5/simple_hosting.rb +13 -0
- data/lib/gandi_v5/simple_hosting/instance.rb +245 -0
- data/lib/gandi_v5/simple_hosting/instance/application.rb +45 -0
- data/lib/gandi_v5/simple_hosting/instance/database.rb +20 -0
- data/lib/gandi_v5/simple_hosting/instance/language.rb +22 -0
- data/lib/gandi_v5/simple_hosting/instance/upgrade.rb +22 -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 +75 -0
- data/lib/gandi_v5/version.rb +1 -1
- data/spec/.rubocop.yml +9 -9
- data/spec/features/list_domain_renewals_spec.rb +16 -0
- data/spec/features/list_email_addresses_spec.rb +39 -0
- data/spec/fixtures/bodies/GandiV5_Domain/fetch.yml +8 -0
- data/spec/fixtures/bodies/GandiV5_Domain_TransferIn/fetch.yml +21 -0
- data/spec/fixtures/bodies/GandiV5_Domain_TransferIn_Availability/fetch.yml +10 -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_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/fixtures/vcr/Examples/List_domain_renewals.yml +54 -0
- data/spec/fixtures/vcr/Examples/List_email_addresses.yml +103 -0
- data/spec/units/gandi_v5/domain/transfer_in/availability_spec.rb +49 -0
- data/spec/units/gandi_v5/domain/transfer_in_spec.rb +143 -0
- data/spec/units/gandi_v5/domain_spec.rb +13 -39
- data/spec/units/gandi_v5/email/forward_spec.rb +5 -34
- data/spec/units/gandi_v5/email/mailbox_spec.rb +4 -34
- 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/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 +111 -14
- metadata +174 -53
- data/.gitignore +0 -26
- data/.rspec +0 -3
- data/.rubocop.yml +0 -30
- data/.travis.yml +0 -38
- data/FUNDING.yml +0 -10
- data/Gemfile +0 -6
- data/Guardfile +0 -39
- data/Rakefile +0 -3
- data/bin/console +0 -13
- data/gandi_v5.gemspec +0 -42
- 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 -44
- 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
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe GandiV5::Domain::TransferIn::Availability do
|
4
|
+
describe '.fetch' do
|
5
|
+
let(:body_fixture) do
|
6
|
+
File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain_TransferIn_Availability', 'fetch.yml'))
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'Without auth_code' do
|
10
|
+
subject { described_class.fetch 'example.com' }
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
url = 'https://api.gandi.net/v5/domain/transferin/example.com/available'
|
14
|
+
expect(GandiV5).to receive(:post).with(url, {})
|
15
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
16
|
+
end
|
17
|
+
|
18
|
+
its('available') { should be true }
|
19
|
+
its('fqdn') { should eq 'example.com' }
|
20
|
+
its('fqdn_unicode') { should eq 'EXAMPLE.COM' }
|
21
|
+
its('corporate') { should be false }
|
22
|
+
its('internal') { should be false }
|
23
|
+
its('durations') { should eq [1, 2, 3] }
|
24
|
+
its('minimum_duration') { should eq 1 }
|
25
|
+
its('maximum_duration') { should eq 3 }
|
26
|
+
its('message') { should eq 'This is a message' }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'With auth_code' do
|
30
|
+
subject { described_class.fetch 'example.com', 'auth-code' }
|
31
|
+
|
32
|
+
before(:each) do
|
33
|
+
url = 'https://api.gandi.net/v5/domain/transferin/example.com/available'
|
34
|
+
expect(GandiV5).to receive(:post).with(url, { 'authinfo' => 'auth-code' })
|
35
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
36
|
+
end
|
37
|
+
|
38
|
+
its('available') { should be true }
|
39
|
+
its('fqdn') { should eq 'example.com' }
|
40
|
+
its('fqdn_unicode') { should eq 'EXAMPLE.COM' }
|
41
|
+
its('corporate') { should be false }
|
42
|
+
its('internal') { should be false }
|
43
|
+
its('durations') { should eq [1, 2, 3] }
|
44
|
+
its('minimum_duration') { should eq 1 }
|
45
|
+
its('maximum_duration') { should eq 3 }
|
46
|
+
its('message') { should eq 'This is a message' }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe GandiV5::Domain::TransferIn do
|
4
|
+
subject { described_class.new fqdn: 'example.com' }
|
5
|
+
|
6
|
+
describe '.fetch' do
|
7
|
+
subject { described_class.fetch 'example.com' }
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain_TransferIn', 'fetch.yml'))
|
11
|
+
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/transferin/example.com')
|
12
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
13
|
+
end
|
14
|
+
|
15
|
+
its('fqdn') { should eq 'example.com' }
|
16
|
+
its('created_at') { should eq Time.new(2011, 2, 21, 10, 39, 0, 0) }
|
17
|
+
its('owner_contact') { should eq 'owner contact' }
|
18
|
+
its('duration') { should eq 1 }
|
19
|
+
its('reseller_uuid') { should eq 'reseller-uuid' }
|
20
|
+
its('version') { should eq 0 }
|
21
|
+
its('step') { should eq 'step text' }
|
22
|
+
its('step_number') { should eq 2 }
|
23
|
+
its('updated_at') { should eq Time.new(2011, 2, 22, 10, 39, 0, 0) }
|
24
|
+
its('errortype') { should eq 'error-type' }
|
25
|
+
its('errortype_label') { should eq 'error label' }
|
26
|
+
its('inner_step') { should eq 'inner-step' }
|
27
|
+
its('regac_at') { should eq Time.new(2011, 2, 23, 10, 39, 0, 0) }
|
28
|
+
its('start_at') { should eq Time.new(2011, 2, 24, 10, 39, 0, 0) }
|
29
|
+
its('transfer_procedure') { should eq 'transfer-procedure' }
|
30
|
+
its('foa_status') { should eq({ 'user@example.com' => 'ans' }) }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '.create' do
|
34
|
+
let(:url) { 'https://api.gandi.net/v5/domain/transferin' }
|
35
|
+
|
36
|
+
describe 'Sets dry-run header' do
|
37
|
+
let(:body) { '{"owner":{},"fqdn":"example.com"}' }
|
38
|
+
|
39
|
+
it 'False by default' do
|
40
|
+
expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 0).and_return([nil, { 'message' => 'confirmation' }])
|
41
|
+
described_class.create 'example.com', owner: {}
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'True' do
|
45
|
+
expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 1).and_return([nil, nil])
|
46
|
+
described_class.create 'example.com', owner: {}, dry_run: true
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'False' do
|
50
|
+
expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 0).and_return([nil, { 'message' => 'confirmation' }])
|
51
|
+
described_class.create 'example.com', owner: {}, dry_run: false
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'Dry run was successful' do
|
55
|
+
returns = { 'status' => 'success' }
|
56
|
+
expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 1)
|
57
|
+
.and_return([nil, returns])
|
58
|
+
expect(described_class.create('example.com', owner: {}, dry_run: true)).to be returns
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'Dry run has errors' do
|
62
|
+
returns = {
|
63
|
+
'status' => 'error',
|
64
|
+
'errors' => [{ 'description' => 'd', 'location' => 'l', 'name' => 'n' }]
|
65
|
+
}
|
66
|
+
expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 1)
|
67
|
+
.and_return([nil, returns])
|
68
|
+
expect(described_class.create('example.com', owner: {}, dry_run: true)).to be returns
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'Sets sharing_id' do
|
73
|
+
it 'Absent by default' do
|
74
|
+
expect(GandiV5).to receive(:post).with(url, any_args).and_return([nil, { 'message' => 'confirmation' }])
|
75
|
+
described_class.create('example.com', owner: {})
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'Paying as another organization' do
|
79
|
+
expect(GandiV5).to receive(:post).with("#{url}?sharing_id=organization_id", any_args)
|
80
|
+
.and_return([nil, { 'message' => 'confirmation' }])
|
81
|
+
described_class.create('example.com', sharing_id: 'organization_id', owner: {})
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'Buy as a reseller' do
|
85
|
+
expect(GandiV5).to receive(:post).with("#{url}?sharing_id=reseller_id", any_args)
|
86
|
+
.and_return([nil, { 'message' => 'confirmation' }])
|
87
|
+
described_class.create('example.com', sharing_id: 'reseller_id', owner: {})
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'Success' do
|
92
|
+
body = '{"owner":{},"fqdn":"example.com"}'
|
93
|
+
expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 0)
|
94
|
+
.and_return([nil, { 'message' => 'confirmation' }])
|
95
|
+
expect(described_class.create('example.com', owner: {})).to eq 'confirmation'
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'Errors on missing owner' do
|
99
|
+
expect { described_class.create 'example.com' }.to raise_error ArgumentError, 'missing keyword: owner'
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'Given contact as hash' do
|
103
|
+
body = '{"owner":{"email":"owner@example.com"},"fqdn":"example.com"}'
|
104
|
+
expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 0)
|
105
|
+
.and_return([nil, { 'message' => 'confirmation' }])
|
106
|
+
described_class.create 'example.com', owner: { email: 'owner@example.com' }
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'Given contact as GandiV5::Domain::Contact' do
|
110
|
+
body = '{"owner":{"email":"owner@example.com"},"fqdn":"example.com"}'
|
111
|
+
expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 0)
|
112
|
+
.and_return([nil, { 'message' => 'confirmation' }])
|
113
|
+
owner = double GandiV5::Domain::Contact, to_gandi: { 'email' => 'owner@example.com' }
|
114
|
+
described_class.create 'example.com', owner: owner
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
it '.relaunch' do
|
119
|
+
expect(GandiV5).to receive(:put).with('https://api.gandi.net/v5/domain/transferin/example.com')
|
120
|
+
.and_return([nil, { 'message' => 'confirmation' }])
|
121
|
+
expect(described_class.relaunch('example.com')).to eq 'confirmation'
|
122
|
+
end
|
123
|
+
|
124
|
+
it '.resend_foa_emails' do
|
125
|
+
url = 'https://api.gandi.net/v5/domain/transferin/example.com/foa'
|
126
|
+
body = '{"email":"user@example.com"}'
|
127
|
+
expect(GandiV5).to receive(:post).with(url, body)
|
128
|
+
.and_return([nil, { 'message' => 'confirmation' }])
|
129
|
+
expect(described_class.resend_foa_emails('example.com', 'user@example.com')).to eq 'confirmation'
|
130
|
+
end
|
131
|
+
|
132
|
+
it '#relaunch' do
|
133
|
+
returned = double String
|
134
|
+
expect(described_class).to receive(:relaunch).with('example.com').and_return(returned)
|
135
|
+
expect(subject.relaunch).to be returned
|
136
|
+
end
|
137
|
+
|
138
|
+
it '#resend_foa_emails' do
|
139
|
+
returned = double String
|
140
|
+
expect(described_class).to receive(:resend_foa_emails).with('example.com', 'user@example.com').and_return(returned)
|
141
|
+
expect(subject.resend_foa_emails('user@example.com')).to be returned
|
142
|
+
end
|
143
|
+
end
|
@@ -5,14 +5,14 @@ describe GandiV5::Domain do
|
|
5
5
|
|
6
6
|
describe '.list' do
|
7
7
|
let(:body_fixture) { File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain', 'list.yml')) }
|
8
|
+
let(:url) { 'https://api.gandi.net/v5/domain/domains' }
|
8
9
|
|
9
10
|
describe 'With default values' do
|
10
11
|
subject { described_class.list }
|
11
12
|
|
12
13
|
before :each do
|
13
|
-
|
14
|
-
|
15
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
14
|
+
expect(GandiV5).to receive(:paginated_get).with(url, (1..), 100, params: {})
|
15
|
+
.and_yield(YAML.load_file(body_fixture))
|
16
16
|
end
|
17
17
|
|
18
18
|
its('count') { should eq 1 }
|
@@ -44,42 +44,11 @@ describe GandiV5::Domain do
|
|
44
44
|
its('first.contacts?') { should be false }
|
45
45
|
end
|
46
46
|
|
47
|
-
it 'Keeps fetching until no more to get' do
|
48
|
-
headers1 = { params: { page: 1, per_page: 1 } }
|
49
|
-
headers2 = { params: { page: 2, per_page: 1 } }
|
50
|
-
# https://github.com/rubocop-hq/rubocop/issues/7088
|
51
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains', headers1)
|
52
|
-
.ordered
|
53
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
54
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains', headers2)
|
55
|
-
.ordered
|
56
|
-
.and_return([nil, []])
|
57
|
-
|
58
|
-
expect(described_class.list(per_page: 1).count).to eq 1
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'Given a range as page number' do
|
62
|
-
headers1 = { params: { page: 1, per_page: 1 } }
|
63
|
-
headers2 = { params: { page: 2, per_page: 1 } }
|
64
|
-
# https://github.com/rubocop-hq/rubocop/issues/7088
|
65
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains', headers1)
|
66
|
-
.ordered
|
67
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
68
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains', headers2)
|
69
|
-
.ordered
|
70
|
-
.and_return([nil, []])
|
71
|
-
|
72
|
-
expect(described_class.list(page: (1..2), per_page: 1).count).to eq 1
|
73
|
-
end
|
74
|
-
|
75
47
|
describe 'Passes optional query params' do
|
76
|
-
%i[fqdn
|
48
|
+
%i[fqdn sort_by tld resellee_id].each do |param|
|
77
49
|
it param.to_s do
|
78
|
-
|
79
|
-
|
80
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains', headers)
|
81
|
-
.and_return([nil, []])
|
82
|
-
expect(described_class.list(**param)).to eq []
|
50
|
+
expect(GandiV5).to receive(:paginated_get).with(url, (1..), 100, params: { param => 5 })
|
51
|
+
expect(described_class.list(param => 5)).to eq []
|
83
52
|
end
|
84
53
|
end
|
85
54
|
end
|
@@ -108,7 +77,12 @@ describe GandiV5::Domain do
|
|
108
77
|
its('domain_owner') { should be_nil }
|
109
78
|
its('name_servers') { should match_array %w[192.168.0.1 192.168.0.2] }
|
110
79
|
its('services') { should match_array %i[gandilivedns dnssec] }
|
111
|
-
its('sharing_space') { should
|
80
|
+
its('sharing_space.uuid') { should eq 'SHARING-UUID' }
|
81
|
+
its('sharing_space.name') { should eq 'User' }
|
82
|
+
its('sharing_space.type') { should eq 'user' }
|
83
|
+
its('sharing_space.reseller') { should be true }
|
84
|
+
its('sharing_space.reseller_details.uuid') { should eq 'RESELLER-UUID' }
|
85
|
+
its('sharing_space.reseller_details.name') { should eq 'Reseller' }
|
112
86
|
its('dates.created_at') { should eq Time.new(2011, 2, 21, 10, 39, 0) }
|
113
87
|
its('dates.registry_created_at') { should eq Time.new(2003, 3, 12, 12, 2, 11) }
|
114
88
|
its('dates.registry_ends_at') { should eq Time.new(2020, 3, 12, 12, 2, 11) }
|
@@ -268,7 +242,7 @@ describe GandiV5::Domain do
|
|
268
242
|
its('domain_owner') { should be_nil }
|
269
243
|
its('name_servers') { should match_array %w[192.168.0.1 192.168.0.2] }
|
270
244
|
its('services') { should match_array %i[gandilivedns dnssec] }
|
271
|
-
its('sharing_space') {
|
245
|
+
its('sharing_space') { should_not be_nil }
|
272
246
|
its('dates.created_at') { should eq Time.new(2011, 2, 21, 10, 39, 0) }
|
273
247
|
its('dates.registry_created_at') { should eq Time.new(2003, 3, 12, 12, 2, 11) }
|
274
248
|
its('dates.registry_ends_at') { should eq Time.new(2020, 3, 12, 12, 2, 11) }
|
@@ -63,14 +63,14 @@ describe GandiV5::Email::Forward do
|
|
63
63
|
let(:body_fixture) do
|
64
64
|
File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Email_Forward', 'list.yml'))
|
65
65
|
end
|
66
|
+
let(:url) { 'https://api.gandi.net/v5/email/forwards/example.com' }
|
66
67
|
|
67
68
|
describe 'With default values' do
|
68
69
|
subject { described_class.list 'example.com' }
|
69
70
|
|
70
71
|
before :each do
|
71
|
-
|
72
|
-
|
73
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
72
|
+
expect(GandiV5).to receive(:paginated_get).with(url, (1..), 100, params: {})
|
73
|
+
.and_yield(YAML.load_file(body_fixture))
|
74
74
|
end
|
75
75
|
|
76
76
|
its('count') { should eq 1 }
|
@@ -79,40 +79,11 @@ describe GandiV5::Email::Forward do
|
|
79
79
|
its('first.fqdn') { should eq 'example.com' }
|
80
80
|
end
|
81
81
|
|
82
|
-
it 'Keeps fetching until no more to get' do
|
83
|
-
headers1 = { params: { page: 1, per_page: 1 } }
|
84
|
-
headers2 = { params: { page: 2, per_page: 1 } }
|
85
|
-
# https://github.com/rubocop-hq/rubocop/issues/7088
|
86
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/forwards/example.com', headers1)
|
87
|
-
.ordered
|
88
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
89
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/forwards/example.com', headers2)
|
90
|
-
.ordered
|
91
|
-
.and_return([nil, []])
|
92
|
-
|
93
|
-
expect(described_class.list('example.com', per_page: 1).count).to eq 1
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'Given a range as page number' do
|
97
|
-
headers1 = { params: { page: 1, per_page: 1 } }
|
98
|
-
headers2 = { params: { page: 2, per_page: 1 } }
|
99
|
-
# https://github.com/rubocop-hq/rubocop/issues/7088
|
100
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/forwards/example.com', headers1)
|
101
|
-
.ordered
|
102
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
103
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/forwards/example.com', headers2)
|
104
|
-
.ordered
|
105
|
-
.and_return([nil, []])
|
106
|
-
|
107
|
-
expect(described_class.list('example.com', page: (1..2), per_page: 1).count).to eq 1
|
108
|
-
end
|
109
|
-
|
110
82
|
describe 'Passes optional query params' do
|
111
83
|
%i[source sort_by].each do |param|
|
112
84
|
it param.to_s do
|
113
|
-
headers = { params: {
|
114
|
-
expect(GandiV5).to receive(:
|
115
|
-
.and_return([nil, []])
|
85
|
+
headers = { params: { param => 'value' } }
|
86
|
+
expect(GandiV5).to receive(:paginated_get).with(url, (1..), 100, **headers)
|
116
87
|
expect(described_class.list('example.com', param => 'value')).to eq []
|
117
88
|
end
|
118
89
|
end
|
@@ -395,14 +395,14 @@ describe GandiV5::Email::Mailbox do
|
|
395
395
|
let(:body_fixture) do
|
396
396
|
File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Email_Mailbox', 'list.yml'))
|
397
397
|
end
|
398
|
+
let(:url) { 'https://api.gandi.net/v5/email/mailboxes/example.com' }
|
398
399
|
|
399
400
|
describe 'With default values' do
|
400
401
|
subject { described_class.list 'example.com' }
|
401
402
|
|
402
403
|
before :each do
|
403
|
-
|
404
|
-
|
405
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
404
|
+
expect(GandiV5).to receive(:paginated_get).with(url, (1..), 100, params: {})
|
405
|
+
.and_yield(YAML.load_file(body_fixture))
|
406
406
|
end
|
407
407
|
|
408
408
|
its('count') { should eq 1 }
|
@@ -414,43 +414,13 @@ describe GandiV5::Email::Mailbox do
|
|
414
414
|
its('first.quota_used') { should eq 1_000_000 }
|
415
415
|
end
|
416
416
|
|
417
|
-
it 'Keeps fetching until no more to get' do
|
418
|
-
headers1 = { params: { page: 1, per_page: 1 } }
|
419
|
-
headers2 = { params: { page: 2, per_page: 1 } }
|
420
|
-
# https://github.com/rubocop-hq/rubocop/issues/7088
|
421
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/mailboxes/example.com', headers1)
|
422
|
-
.ordered
|
423
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
424
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/mailboxes/example.com', headers2)
|
425
|
-
.ordered
|
426
|
-
.and_return([nil, []])
|
427
|
-
|
428
|
-
expect(described_class.list('example.com', per_page: 1).count).to eq 1
|
429
|
-
end
|
430
|
-
|
431
|
-
it 'Given a range as page number' do
|
432
|
-
headers1 = { params: { page: 1, per_page: 1 } }
|
433
|
-
headers2 = { params: { page: 2, per_page: 1 } }
|
434
|
-
# https://github.com/rubocop-hq/rubocop/issues/7088
|
435
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/mailboxes/example.com', headers1)
|
436
|
-
.ordered
|
437
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
438
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/mailboxes/example.com', headers2)
|
439
|
-
.ordered
|
440
|
-
.and_return([nil, []])
|
441
|
-
|
442
|
-
expect(described_class.list('example.com', page: (1..2), per_page: 1).count).to eq 1
|
443
|
-
end
|
444
|
-
|
445
417
|
describe 'Passes optional query params' do
|
446
418
|
{
|
447
419
|
login: '~login',
|
448
420
|
sort_by: :sort_by
|
449
421
|
}.each do |param, query_param|
|
450
422
|
it param.to_s do
|
451
|
-
|
452
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/mailboxes/example.com', headers)
|
453
|
-
.and_return([nil, []])
|
423
|
+
expect(GandiV5).to receive(:paginated_get).with(url, (1..), 100, params: { query_param => 'value' })
|
454
424
|
expect(described_class.list('example.com', param => 'value')).to eq []
|
455
425
|
end
|
456
426
|
end
|
@@ -130,7 +130,7 @@ describe GandiV5::Email::Slot do
|
|
130
130
|
end
|
131
131
|
let(:created_slot) { double GandiV5::Email::Slot }
|
132
132
|
|
133
|
-
it 'With default type' do
|
133
|
+
it 'With default type and no sharingID' do
|
134
134
|
expect(GandiV5).to receive(:post).with(url, '{"mailbox_type":"standard"}')
|
135
135
|
.and_return([created_response, { 'message' => 'Confirmation message.' }])
|
136
136
|
expect(described_class).to receive(:fetch).with('example.com', 'created-slot-uuid').and_return(created_slot)
|
@@ -143,7 +143,15 @@ describe GandiV5::Email::Slot do
|
|
143
143
|
.and_return([created_response, { 'message' => 'Confirmation message.' }])
|
144
144
|
expect(described_class).to receive(:fetch).with('example.com', 'created-slot-uuid').and_return(created_slot)
|
145
145
|
|
146
|
-
expect(described_class.create('example.com', :premium)).to be created_slot
|
146
|
+
expect(described_class.create('example.com', type: :premium)).to be created_slot
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'With sharingID' do
|
150
|
+
expect(GandiV5).to receive(:post).with("#{url}?sharing_id=SHARING-ID", '{"mailbox_type":"standard"}')
|
151
|
+
.and_return([created_response, { 'message' => 'Confirmation message.' }])
|
152
|
+
expect(described_class).to receive(:fetch).with('example.com', 'created-slot-uuid').and_return(created_slot)
|
153
|
+
|
154
|
+
expect(described_class.create('example.com', sharing_id: 'SHARING-ID')).to be created_slot
|
147
155
|
end
|
148
156
|
end
|
149
157
|
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe GandiV5::LiveDNS::Domain::DnssecKey do
|
4
|
+
subject do
|
5
|
+
described_class.new(
|
6
|
+
uuid: 'key-uuid',
|
7
|
+
status: 'status',
|
8
|
+
fqdn: 'example.com',
|
9
|
+
algorithm_id: 2,
|
10
|
+
algorithm_name: 'Diffie-Hellman',
|
11
|
+
deleted: false,
|
12
|
+
ds: 'ds-record',
|
13
|
+
flags: 256,
|
14
|
+
fingerprint: 'fp',
|
15
|
+
public_key: 'pub-key',
|
16
|
+
tag: 'tag'
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
it '#delete' do
|
21
|
+
expect(GandiV5).to receive(:delete).with('https://api.gandi.net/v5/livedns/domains/example.com/keys/key-uuid')
|
22
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
23
|
+
expect(subject.delete).to eq 'Confirmation message.'
|
24
|
+
expect(subject.deleted).to be true
|
25
|
+
end
|
26
|
+
|
27
|
+
it '#undelete' do
|
28
|
+
subject = described_class.new deleted: true, uuid: 'key-uuid', fqdn: 'example.com'
|
29
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/keys/key-uuid'
|
30
|
+
expect(GandiV5).to receive(:patch).with(url, '{"deleted":false}')
|
31
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
32
|
+
expect(subject.undelete).to eq 'Confirmation message.'
|
33
|
+
expect(subject.deleted).to be false
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'flags helper methods' do
|
37
|
+
describe '256 (zone signing key)' do
|
38
|
+
before(:each) { subject.instance_exec { @flags = 256 } }
|
39
|
+
its('zone_signing_key?') { should be true }
|
40
|
+
its('key_signing_key?') { should be false }
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '257 (key signing key)' do
|
44
|
+
before(:each) { subject.instance_exec { @flags = 257 } }
|
45
|
+
its('zone_signing_key?') { should be false }
|
46
|
+
its('key_signing_key?') { should be true }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '.create' do
|
51
|
+
let(:url) { 'https://api.gandi.net/v5/livedns/domains/example.com/keys' }
|
52
|
+
let(:response) do
|
53
|
+
double RestClient::Response, headers: {
|
54
|
+
location: 'https://api.gandi.net/v5/livedns/domains/example.com/keys/created-key-uuid'
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'Accepts integer for flags' do
|
59
|
+
returns = double described_class
|
60
|
+
expect(GandiV5).to receive(:post).with(url, '{"flags":256}').and_return([response, nil])
|
61
|
+
expect(described_class).to receive(:fetch).with('example.com', 'created-key-uuid')
|
62
|
+
.and_return(returns)
|
63
|
+
expect(described_class.create('example.com', :zone_signing_key)).to be returns
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'Accepts :zone_signing_key for flags' do
|
67
|
+
expect(GandiV5).to receive(:post).with(url, '{"flags":256}').and_return([response, nil])
|
68
|
+
expect(described_class).to receive(:fetch)
|
69
|
+
described_class.create('example.com', :zone_signing_key)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'Accepts :key_signing_key for flags' do
|
73
|
+
expect(GandiV5).to receive(:post).with(url, '{"flags":257}').and_return([response, nil])
|
74
|
+
expect(described_class).to receive(:fetch)
|
75
|
+
described_class.create('example.com', :key_signing_key)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'Fails on invalid flags' do
|
79
|
+
expect { described_class.create('example.com', :invalid) }.to raise_error ArgumentError, 'flags is invalid'
|
80
|
+
expect { described_class.create('example.com', '0') }.to raise_error ArgumentError, 'flags is invalid'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
it '.list' do
|
85
|
+
body_fixture = File.expand_path(
|
86
|
+
File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Domain_DnssecKey', 'list.yml')
|
87
|
+
)
|
88
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/keys'
|
89
|
+
|
90
|
+
expect(GandiV5).to receive(:get).with(url).and_return([nil, YAML.load_file(body_fixture)])
|
91
|
+
results = described_class.list('example.com')
|
92
|
+
result = results.first
|
93
|
+
expect(results.count).to eq 1
|
94
|
+
expect(result.uuid).to eq 'key-uuid'
|
95
|
+
expect(result.status).to eq 'status'
|
96
|
+
expect(result.fqdn).to eq 'example.com'
|
97
|
+
expect(result.algorithm_id).to eq 2
|
98
|
+
expect(result.algorithm_name).to eq 'Diffie-Hellman'
|
99
|
+
expect(result.deleted).to be false
|
100
|
+
expect(result.ds).to eq 'ds-record'
|
101
|
+
expect(result.flags).to eq 256
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '.fetch' do
|
105
|
+
subject { described_class.fetch 'example.com', 'key-uuid' }
|
106
|
+
|
107
|
+
before :each do
|
108
|
+
body_fixture = File.expand_path(
|
109
|
+
File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Domain_DnssecKey', 'fetch.yml')
|
110
|
+
)
|
111
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/keys/key-uuid'
|
112
|
+
expect(GandiV5).to receive(:get).with(url)
|
113
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
114
|
+
end
|
115
|
+
|
116
|
+
its('uuid') { should eq 'key-uuid' }
|
117
|
+
its('status') { should eq 'status' }
|
118
|
+
its('fqdn') { should eq 'example.com' }
|
119
|
+
its('algorithm_id') { should eq 2 }
|
120
|
+
its('algorithm_name') { should eq 'Diffie-Hellman' }
|
121
|
+
its('deleted') { should be false }
|
122
|
+
its('ds') { should eq 'ds-record' }
|
123
|
+
its('flags') { should eq 256 }
|
124
|
+
its('fingerprint') { should eq 'fp' }
|
125
|
+
its('public_key') { should eq 'pub-key' }
|
126
|
+
its('tag') { should eq 'tag' }
|
127
|
+
end
|
128
|
+
end
|