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
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe GandiV5::LiveDNS::Domain::TsigKey do
|
4
|
+
subject do
|
5
|
+
described_class.new(
|
6
|
+
uuid: 'key-uuid',
|
7
|
+
name: 'key-name',
|
8
|
+
secret: 'key-secret',
|
9
|
+
config_examples: { test: 'test config sample' }
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.create' do
|
14
|
+
it 'Without sharing_id' do
|
15
|
+
url = 'https://api.gandi.net/v5/livedns/axfr/tsig'
|
16
|
+
created = { 'href' => '', 'id' => 'created-key-uuid', 'key_name' => 'based on id' }
|
17
|
+
returns = double described_class
|
18
|
+
|
19
|
+
expect(GandiV5).to receive(:post).with(url).and_return([nil, created])
|
20
|
+
expect(described_class).to receive(:fetch).with('created-key-uuid')
|
21
|
+
.and_return(returns)
|
22
|
+
expect(described_class.create).to be returns
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'With sharing_id' do
|
26
|
+
url = 'https://api.gandi.net/v5/livedns/axfr/tsig?sharing_id=sharing-id'
|
27
|
+
created = { 'href' => '', 'id' => 'created-key-uuid', 'key_name' => 'based on id' }
|
28
|
+
returns = double described_class
|
29
|
+
|
30
|
+
expect(GandiV5).to receive(:post).with(url).and_return([nil, created])
|
31
|
+
expect(described_class).to receive(:fetch).with('created-key-uuid')
|
32
|
+
.and_return(returns)
|
33
|
+
expect(described_class.create('sharing-id')).to be returns
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it '.list' do
|
38
|
+
body_fixture = File.expand_path(
|
39
|
+
File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Domain_TsigKey', 'list.yml')
|
40
|
+
)
|
41
|
+
url = 'https://api.gandi.net/v5/livedns/axfr/tsig'
|
42
|
+
|
43
|
+
expect(GandiV5).to receive(:get).with(url).and_return([nil, YAML.load_file(body_fixture)])
|
44
|
+
results = described_class.list
|
45
|
+
result = results.first
|
46
|
+
expect(results.count).to eq 1
|
47
|
+
expect(result.uuid).to eq 'key-uuid'
|
48
|
+
expect(result.name).to eq 'key-name'
|
49
|
+
expect(result.secret).to eq 'key-secret'
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '.fetch' do
|
53
|
+
subject { described_class.fetch 'key-uuid' }
|
54
|
+
|
55
|
+
before :each do
|
56
|
+
body_fixture = File.expand_path(
|
57
|
+
File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Domain_TsigKey', 'fetch.yml')
|
58
|
+
)
|
59
|
+
url = 'https://api.gandi.net/v5/livedns/axfr/tsig/key-uuid'
|
60
|
+
expect(GandiV5).to receive(:get).with(url)
|
61
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
62
|
+
end
|
63
|
+
|
64
|
+
its('uuid') { should eq 'key-uuid' }
|
65
|
+
its('name') { should eq 'key-name' }
|
66
|
+
its('secret') { should eq 'key-secret' }
|
67
|
+
its('config_examples') do
|
68
|
+
should eq(
|
69
|
+
{
|
70
|
+
bind: 'bind-sample',
|
71
|
+
knot: 'knot-sample',
|
72
|
+
nsd: 'nsd-sample',
|
73
|
+
powerdns: 'powerdns-sample'
|
74
|
+
}
|
75
|
+
)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -2,51 +2,53 @@
|
|
2
2
|
|
3
3
|
describe GandiV5::LiveDNS::Domain do
|
4
4
|
subject do
|
5
|
-
described_class.new fqdn: 'example.com',
|
5
|
+
described_class.new fqdn: 'example.com', automatic_snapshots: false
|
6
6
|
end
|
7
7
|
|
8
8
|
describe '#refresh' do
|
9
9
|
before :each do
|
10
10
|
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Domain', 'fetch.yml'))
|
11
|
-
expect(GandiV5).to receive(:get).with('https://
|
11
|
+
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/livedns/domains/example.com')
|
12
12
|
.and_return([nil, YAML.load_file(body_fixture)])
|
13
13
|
subject.refresh
|
14
14
|
end
|
15
15
|
|
16
16
|
its('fqdn') { should eq 'example.com' }
|
17
|
-
its('
|
17
|
+
its('automatic_snapshots') { should be true }
|
18
|
+
end
|
19
|
+
|
20
|
+
it '#update' do
|
21
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com'
|
22
|
+
body = '{"automatic_snapshots":true}'
|
23
|
+
expect(GandiV5).to receive(:patch).with(url, body)
|
24
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
25
|
+
expect(subject.update(automatic_snapshots: true)).to eq 'Confirmation message.'
|
26
|
+
expect(subject.automatic_snapshots).to be true
|
18
27
|
end
|
19
28
|
|
20
29
|
describe '#fetch_records' do
|
30
|
+
let(:url) { 'https://api.gandi.net/v5/livedns/domains/example.com/records' }
|
21
31
|
it 'All of them' do
|
22
|
-
expect(GandiV5).to receive(:
|
23
|
-
|
24
|
-
|
32
|
+
expect(GandiV5).to receive(:paginated_get).with(url, (1..), 100)
|
33
|
+
.and_yield([])
|
25
34
|
expect(subject.fetch_records).to eq []
|
26
35
|
end
|
27
36
|
|
28
37
|
it 'All for a name' do
|
29
|
-
expect(GandiV5).to receive(:
|
30
|
-
|
31
|
-
|
38
|
+
expect(GandiV5).to receive(:paginated_get).with("#{url}/name", (1..), 100)
|
39
|
+
.and_yield([])
|
32
40
|
expect(subject.fetch_records('name')).to eq []
|
33
41
|
end
|
34
42
|
|
35
43
|
it 'A type for a name' do
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
'rrset_ttl' => 600,
|
45
|
-
'rrset_values' => %w[a b]
|
46
|
-
}
|
47
|
-
]
|
48
|
-
]
|
49
|
-
)
|
44
|
+
record = {
|
45
|
+
'rrset_type' => 'TXT',
|
46
|
+
'rrset_name' => 'name',
|
47
|
+
'rrset_ttl' => 600,
|
48
|
+
'rrset_values' => %w[a b]
|
49
|
+
}
|
50
|
+
expect(GandiV5).to receive(:paginated_get).with("#{url}/name/TXT", (1..), 100)
|
51
|
+
.and_yield([record])
|
50
52
|
|
51
53
|
records = subject.fetch_records('name', 'TXT')
|
52
54
|
expect(records.count).to eq 1
|
@@ -63,19 +65,19 @@ describe GandiV5::LiveDNS::Domain do
|
|
63
65
|
|
64
66
|
describe '#fetch_zone_lines' do
|
65
67
|
it 'All of them' do
|
66
|
-
url = 'https://
|
68
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/records'
|
67
69
|
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
|
68
70
|
expect(subject.fetch_zone_lines).to eq 'returned'
|
69
71
|
end
|
70
72
|
|
71
73
|
it 'All for a name' do
|
72
|
-
url = 'https://
|
74
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/records/name'
|
73
75
|
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
|
74
76
|
expect(subject.fetch_zone_lines('name')).to eq 'returned'
|
75
77
|
end
|
76
78
|
|
77
79
|
it 'A type for a name' do
|
78
|
-
url = 'https://
|
80
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/records/name/TXT'
|
79
81
|
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
|
80
82
|
expect(subject.fetch_zone_lines('name', 'TXT')).to eq 'returned'
|
81
83
|
end
|
@@ -87,7 +89,7 @@ describe GandiV5::LiveDNS::Domain do
|
|
87
89
|
|
88
90
|
describe '#add_record' do
|
89
91
|
it 'Success' do
|
90
|
-
url = 'https://
|
92
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/records'
|
91
93
|
body = '{"rrset_name":"name","rrset_type":"TXT","rrset_ttl":900,"rrset_values":["a","b"]}'
|
92
94
|
expect(GandiV5).to receive(:post).with(url, body).and_return([nil, { 'message' => 'Confirmation message.' }])
|
93
95
|
expect(subject.add_record('name', 'TXT', 900, 'a', 'b')).to eq 'Confirmation message.'
|
@@ -114,19 +116,19 @@ describe GandiV5::LiveDNS::Domain do
|
|
114
116
|
|
115
117
|
describe '#delete_records' do
|
116
118
|
it 'All of them' do
|
117
|
-
url = 'https://
|
119
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/records'
|
118
120
|
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
119
121
|
subject.delete_records
|
120
122
|
end
|
121
123
|
|
122
124
|
it 'All for a name' do
|
123
|
-
url = 'https://
|
125
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/records/name'
|
124
126
|
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
125
127
|
subject.delete_records 'name'
|
126
128
|
end
|
127
129
|
|
128
130
|
it 'A type for a name' do
|
129
|
-
url = 'https://
|
131
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/records/name/TXT'
|
130
132
|
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
131
133
|
subject.delete_records 'name', 'TXT'
|
132
134
|
end
|
@@ -137,129 +139,254 @@ describe GandiV5::LiveDNS::Domain do
|
|
137
139
|
end
|
138
140
|
|
139
141
|
describe '#replace_records' do
|
140
|
-
it '
|
141
|
-
|
142
|
-
|
143
|
-
]
|
144
|
-
|
145
|
-
url = 'https://dns.api.gandi.net/api/v5/domains/example.com/records'
|
146
|
-
body = '{"items":[{"rrset_name":"name","rrset_ttl":600,"rrset_type":"TXT","rrset_values":["a"]}]}'
|
142
|
+
it 'All of them' do
|
143
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/records'
|
144
|
+
body = '{"items":[{"rrset_name":"name","rrset_type":"TXT","rrset_values":["a"]}]}'
|
147
145
|
expect(GandiV5).to receive(:put).with(url, body)
|
148
146
|
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
149
|
-
|
147
|
+
records = [{ name: 'name', type: 'TXT', values: ['a'] }]
|
148
|
+
expect(subject.replace_records(records)).to eq 'Confirmation message.'
|
150
149
|
end
|
151
150
|
|
152
|
-
it '
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
151
|
+
it 'All for a name' do
|
152
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/records/name'
|
153
|
+
body = '{"items":[{"rrset_type":"TXT","rrset_values":["a"]}]}'
|
154
|
+
expect(GandiV5).to receive(:put).with(url, body)
|
155
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
156
|
+
records = [{ type: 'TXT', values: ['a'] }]
|
157
|
+
expect(subject.replace_records(records, name: 'name')).to eq 'Confirmation message.'
|
158
|
+
end
|
157
159
|
|
158
|
-
|
159
|
-
|
160
|
+
it 'All of a type for a name' do
|
161
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/records/name/TXT'
|
162
|
+
body = '{"rrset_values":["a"]}'
|
163
|
+
expect(GandiV5).to receive(:put).with(url, body)
|
160
164
|
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
161
|
-
expect(subject.replace_records(
|
165
|
+
expect(subject.replace_records(['a'], name: 'name', type: 'TXT')).to eq 'Confirmation message.'
|
162
166
|
end
|
163
167
|
|
164
|
-
it 'Given
|
165
|
-
expect
|
166
|
-
|
167
|
-
|
168
|
-
|
168
|
+
it 'Given type but no name' do
|
169
|
+
expect(GandiV5).to_not receive(:put)
|
170
|
+
expect { subject.replace_records(['a'], type: 'TXT') }.to raise_error ArgumentError, 'missing keyword: name'
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
it '#replace_zone_lines' do
|
175
|
+
records = [
|
176
|
+
'@ 86400 IN A 192.168.0.1',
|
177
|
+
'* 86400 IN A 192.168.0.1'
|
178
|
+
].join("\n")
|
179
|
+
|
180
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/records'
|
181
|
+
expect(GandiV5).to receive(:put).with(url, records, 'content-type': 'text/plain')
|
182
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
183
|
+
expect(subject.replace_zone_lines(records)).to eq 'Confirmation message.'
|
184
|
+
end
|
185
|
+
|
186
|
+
describe '#name_servers' do
|
187
|
+
let(:nameservers) { double Array }
|
188
|
+
|
189
|
+
it 'Already fetched' do
|
190
|
+
subject.instance_exec(nameservers) { |ns| @name_servers = ns }
|
191
|
+
expect(subject).to_not receive(:fetch_name_servers)
|
192
|
+
expect(subject.name_servers).to be nameservers
|
169
193
|
end
|
170
194
|
|
171
|
-
it '
|
172
|
-
expect
|
195
|
+
it 'Not already fetched' do
|
196
|
+
expect(subject).to receive(:fetch_name_servers).and_return(nameservers)
|
197
|
+
expect(subject.name_servers).to be nameservers
|
173
198
|
end
|
174
199
|
end
|
175
200
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
201
|
+
it '#fetch_name_servers' do
|
202
|
+
body_fixture = File.expand_path(
|
203
|
+
File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Domain', 'nameservers.yml')
|
204
|
+
)
|
205
|
+
|
206
|
+
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/livedns/domains/example.com/nameservers')
|
207
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
208
|
+
|
209
|
+
expect(subject.fetch_name_servers).to match_array ['a.example.com', 'b.example.com']
|
210
|
+
end
|
211
|
+
|
212
|
+
describe '#dnssec_keys' do
|
213
|
+
let(:dnsseckeys) { double Array }
|
214
|
+
|
215
|
+
it 'Already fetched' do
|
216
|
+
subject.instance_exec(dnsseckeys) { |k| @dnssec_keys = k }
|
217
|
+
expect(subject).to_not receive(:fetch_dnssec_keys)
|
218
|
+
expect(subject.dnssec_keys).to be dnsseckeys
|
184
219
|
end
|
185
220
|
|
186
|
-
it '
|
187
|
-
|
188
|
-
|
189
|
-
expect(GandiV5).to receive(:put).with(url, body)
|
190
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
191
|
-
expect(subject.replace_records_for('name', ['a'], type: 'TXT', ttl: 600)).to eq 'Confirmation message.'
|
221
|
+
it 'Not already fetched' do
|
222
|
+
expect(subject).to receive(:fetch_dnssec_keys).and_return(dnsseckeys)
|
223
|
+
expect(subject.dnssec_keys).to be dnsseckeys
|
192
224
|
end
|
225
|
+
end
|
193
226
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
227
|
+
it '#fetch_dnssec_keys' do
|
228
|
+
keys = double Array
|
229
|
+
expect(GandiV5::LiveDNS::Domain::DnssecKey).to receive(:list).with('example.com')
|
230
|
+
.and_return(keys)
|
231
|
+
|
232
|
+
expect(subject.fetch_dnssec_keys).to be keys
|
233
|
+
expect(subject.instance_exec { @dnssec_keys }).to be keys
|
234
|
+
end
|
235
|
+
|
236
|
+
describe '#tsig_keys' do
|
237
|
+
let(:tsigkeys) { double Array }
|
238
|
+
|
239
|
+
it 'Already fetched' do
|
240
|
+
subject.instance_exec(tsigkeys) { |k| @tsig_keys = k }
|
241
|
+
expect(subject).to_not receive(:fetch_tsig_keys)
|
242
|
+
expect(subject.tsig_keys).to be tsigkeys
|
200
243
|
end
|
201
244
|
|
202
|
-
it '
|
203
|
-
expect(
|
204
|
-
expect
|
245
|
+
it 'Not already fetched' do
|
246
|
+
expect(subject).to receive(:fetch_tsig_keys).and_return(tsigkeys)
|
247
|
+
expect(subject.tsig_keys).to be tsigkeys
|
205
248
|
end
|
206
249
|
end
|
207
250
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
251
|
+
it '#fetch_tsig_keys' do
|
252
|
+
body_fixture = File.expand_path(
|
253
|
+
File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Domain', 'list_tsig.yml')
|
254
|
+
)
|
255
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/axfr/tsig'
|
256
|
+
|
257
|
+
expect(GandiV5).to receive(:get).with(url).and_return([nil, YAML.load_file(body_fixture)])
|
258
|
+
results = subject.fetch_tsig_keys
|
259
|
+
result = results.first
|
260
|
+
expect(results.count).to eq 1
|
261
|
+
expect(result.uuid).to eq 'key-uuid'
|
262
|
+
expect(result.name).to eq 'key-name'
|
263
|
+
end
|
264
|
+
|
265
|
+
describe '#add_tsig_key' do
|
266
|
+
let(:url) { 'https://api.gandi.net/v5/livedns/domains/example.com/axfr/tsig/key-uuid' }
|
267
|
+
|
268
|
+
it 'Passed a key' do
|
269
|
+
key = GandiV5::LiveDNS::Domain::TsigKey.new uuid: 'key-uuid'
|
270
|
+
expect(GandiV5).to receive(:put).with(url).and_return([nil, nil])
|
271
|
+
subject.add_tsig_key key
|
272
|
+
end
|
273
|
+
|
274
|
+
it 'Passed a string' do
|
275
|
+
expect(GandiV5).to receive(:put).with(url).and_return([nil, nil])
|
276
|
+
subject.add_tsig_key 'key-uuid'
|
277
|
+
end
|
278
|
+
|
279
|
+
it 'With sharing_id' do
|
280
|
+
expect(GandiV5).to receive(:put).with("#{url}?sharing_id=sharing-id").and_return([nil, nil])
|
281
|
+
subject.add_tsig_key 'key-uuid', sharing_id: 'sharing-id'
|
226
282
|
end
|
227
283
|
end
|
228
284
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
285
|
+
describe '#remove_tsig_key' do
|
286
|
+
let(:url) { 'https://api.gandi.net/v5/livedns/domains/example.com/axfr/tsig/key-uuid' }
|
287
|
+
|
288
|
+
it 'Passed a key' do
|
289
|
+
key = GandiV5::LiveDNS::Domain::TsigKey.new uuid: 'key-uuid'
|
290
|
+
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
291
|
+
subject.remove_tsig_key key
|
292
|
+
end
|
293
|
+
|
294
|
+
it 'Passed a string' do
|
295
|
+
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
296
|
+
subject.remove_tsig_key 'key-uuid'
|
297
|
+
end
|
298
|
+
|
299
|
+
it 'With sharing_id' do
|
300
|
+
expect(GandiV5).to receive(:delete).with("#{url}?sharing_id=sharing-id").and_return([nil, nil])
|
301
|
+
subject.remove_tsig_key 'key-uuid', sharing_id: 'sharing-id'
|
302
|
+
end
|
234
303
|
end
|
235
304
|
|
236
|
-
describe '#
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
305
|
+
describe '#axfr_clients' do
|
306
|
+
let(:clients) { double Array }
|
307
|
+
|
308
|
+
it 'Already fetched' do
|
309
|
+
subject.instance_exec(clients) { |k| @axfr_clients = k }
|
310
|
+
expect(subject).to_not receive(:fetch_axfr_clients)
|
311
|
+
expect(subject.axfr_clients).to be clients
|
241
312
|
end
|
242
313
|
|
243
|
-
it '
|
244
|
-
|
245
|
-
subject.
|
246
|
-
expect(subject).to_not receive(:fetch_zone)
|
247
|
-
expect(subject.zone).to be returns
|
314
|
+
it 'Not already fetched' do
|
315
|
+
expect(subject).to receive(:fetch_axfr_clients).and_return(clients)
|
316
|
+
expect(subject.axfr_clients).to be clients
|
248
317
|
end
|
249
318
|
end
|
250
319
|
|
320
|
+
it '#fetch_axfr_clients' do
|
321
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/axfr/slaves'
|
322
|
+
expect(GandiV5).to receive(:get).with(url).and_return([nil, ['1.2.3.4']])
|
323
|
+
expect(subject.fetch_axfr_clients).to match_array ['1.2.3.4']
|
324
|
+
end
|
325
|
+
|
326
|
+
it '#add_axfr_client' do
|
327
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/axfr/slaves/1.2.3.4'
|
328
|
+
expect(GandiV5).to receive(:put).with(url).and_return([nil, nil])
|
329
|
+
subject.add_axfr_client '1.2.3.4'
|
330
|
+
end
|
331
|
+
|
332
|
+
it '#remove_axfr_client' do
|
333
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/axfr/slaves/1.2.3.4'
|
334
|
+
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
335
|
+
subject.remove_axfr_client '1.2.3.4'
|
336
|
+
end
|
337
|
+
|
251
338
|
describe '.list' do
|
252
|
-
|
339
|
+
let(:body_fixture) do
|
340
|
+
File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Domain', 'list.yml'))
|
341
|
+
end
|
342
|
+
let(:url) { 'https://api.gandi.net/v5/livedns/domains' }
|
253
343
|
|
254
|
-
|
255
|
-
|
256
|
-
expect(GandiV5).to receive(:get).with(
|
344
|
+
it 'With default parameters' do
|
345
|
+
headers = { params: { page: 1, per_page: 100 } }
|
346
|
+
expect(GandiV5).to receive(:get).with(url, headers)
|
257
347
|
.and_return([nil, YAML.load_file(body_fixture)])
|
348
|
+
|
349
|
+
subject = described_class.list
|
350
|
+
expect(subject.count).to eq 1
|
351
|
+
expect(subject.first).to eq 'example.com'
|
258
352
|
end
|
259
353
|
|
260
|
-
|
261
|
-
|
262
|
-
|
354
|
+
it 'Keeps fetching until no more to get' do
|
355
|
+
headers1 = { params: { page: 1, per_page: 1 } }
|
356
|
+
headers2 = { params: { page: 2, per_page: 1 } }
|
357
|
+
expect(GandiV5).to receive(:get).with(url, headers1)
|
358
|
+
.ordered
|
359
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
360
|
+
expect(GandiV5).to receive(:get).with(url, headers2)
|
361
|
+
.ordered
|
362
|
+
.and_return([nil, []])
|
363
|
+
|
364
|
+
expect(described_class.list(per_page: 1).count).to eq 1
|
365
|
+
end
|
366
|
+
|
367
|
+
it 'Given a range as page number' do
|
368
|
+
headers = { params: { page: 1, per_page: 1 } }
|
369
|
+
expect(GandiV5).to receive(:get).with(url, headers)
|
370
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
371
|
+
|
372
|
+
described_class.list(page: (1..1), per_page: 1)
|
373
|
+
end
|
374
|
+
|
375
|
+
describe 'Passes optional query params' do
|
376
|
+
it 'per_page' do
|
377
|
+
headers = { params: { page: 1, per_page: 10 } }
|
378
|
+
expect(GandiV5).to receive(:get).with(url, headers)
|
379
|
+
.and_return([nil, []])
|
380
|
+
described_class.list(per_page: 10)
|
381
|
+
end
|
382
|
+
|
383
|
+
it 'sharing_id' do
|
384
|
+
headers = { params: { sharing_id: 'SHARING-UUID', page: 1, per_page: 100 } }
|
385
|
+
expect(GandiV5).to receive(:get).with(url, headers)
|
386
|
+
.and_return([nil, []])
|
387
|
+
described_class.list(sharing_id: 'SHARING-UUID')
|
388
|
+
end
|
389
|
+
end
|
263
390
|
end
|
264
391
|
|
265
392
|
describe '.fetch' do
|
@@ -267,11 +394,63 @@ describe GandiV5::LiveDNS::Domain do
|
|
267
394
|
|
268
395
|
before :each do
|
269
396
|
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Domain', 'fetch.yml'))
|
270
|
-
expect(GandiV5).to receive(:get).with('https://
|
397
|
+
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/livedns/domains/example.com')
|
271
398
|
.and_return([nil, YAML.load_file(body_fixture)])
|
272
399
|
end
|
273
400
|
|
274
401
|
its('fqdn') { should eq 'example.com' }
|
275
|
-
its('
|
402
|
+
its('automatic_snapshots') { should be true }
|
403
|
+
end
|
404
|
+
|
405
|
+
describe '.create' do
|
406
|
+
let(:url) { 'https://api.gandi.net/v5/livedns/domains' }
|
407
|
+
let(:response) do
|
408
|
+
double RestClient::Response, headers: { location: 'https://api.gandi.net/v5/livedns/domains/example.com' }
|
409
|
+
end
|
410
|
+
|
411
|
+
it 'When passed only fqdn' do
|
412
|
+
returns = double described_class
|
413
|
+
body = '{"fqdn":"example.com","zone":{}}'
|
414
|
+
expect(GandiV5).to receive(:post).with(url, body).and_return([response, nil])
|
415
|
+
expect(described_class).to receive(:fetch).with('example.com').and_return(returns)
|
416
|
+
expect(described_class.create('example.com')).to be returns
|
417
|
+
end
|
418
|
+
|
419
|
+
it 'When passed soa_ttl' do
|
420
|
+
body = '{"fqdn":"example.com","zone":{"ttl":123}}'
|
421
|
+
expect(GandiV5).to receive(:post).with(url, body).and_return([response, nil])
|
422
|
+
expect(described_class).to receive(:fetch).with('example.com').and_return(nil)
|
423
|
+
described_class.create('example.com', soa_ttl: 123)
|
424
|
+
end
|
425
|
+
|
426
|
+
it 'When passed records' do
|
427
|
+
body = '{"fqdn":"example.com","zone":{"items":' \
|
428
|
+
'[{"rrset_type":"TXT","rrset_ttl":234,"rrset_name":"test","rrset_values":["value"]}]}}'
|
429
|
+
record = GandiV5::LiveDNS::Domain::Record.new name: 'test', type: 'TXT', ttl: 234, values: ['value']
|
430
|
+
expect(GandiV5).to receive(:post).with(url, body).and_return([response, nil])
|
431
|
+
expect(described_class).to receive(:fetch).with('example.com').and_return(nil)
|
432
|
+
described_class.create('example.com', [record])
|
433
|
+
end
|
434
|
+
|
435
|
+
it 'When passed sharing_id' do
|
436
|
+
body = '{"fqdn":"example.com","zone":{}}'
|
437
|
+
expect(GandiV5).to receive(:post).with("#{url}?sharing_id=organization_id", body).and_return([response, nil])
|
438
|
+
expect(described_class).to receive(:fetch).with('example.com').and_return(nil)
|
439
|
+
described_class.create('example.com', sharing_id: 'organization_id')
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
443
|
+
it '.record_types' do
|
444
|
+
list = double Array
|
445
|
+
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/livedns/dns/rrtypes')
|
446
|
+
.and_return([nil, list])
|
447
|
+
expect(described_class.record_types).to be list
|
448
|
+
end
|
449
|
+
|
450
|
+
it '.generic_name_servers' do
|
451
|
+
list = double Array
|
452
|
+
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/livedns/nameservers/example.com')
|
453
|
+
.and_return([nil, list])
|
454
|
+
expect(described_class.generic_name_servers('example.com')).to be list
|
276
455
|
end
|
277
456
|
end
|