gandi_v5 0.6.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +81 -5
- data/README.md +65 -14
- data/lib/gandi_v5.rb +139 -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 +55 -18
- 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 +172 -0
- data/lib/gandi_v5/domain/transfer_in/availability.rb +51 -0
- data/lib/gandi_v5/domain/web_forwarding.rb +182 -0
- data/lib/gandi_v5/email.rb +3 -0
- data/lib/gandi_v5/email/forward.rb +3 -9
- data/lib/gandi_v5/email/mailbox.rb +5 -11
- 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 +251 -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 +272 -0
- data/lib/gandi_v5/simple_hosting/instance/virtual_host/linked_dns_zone.rb +75 -0
- data/lib/gandi_v5/template.rb +271 -0
- data/lib/gandi_v5/template/dispatch.rb +109 -0
- data/lib/gandi_v5/template/payload.rb +64 -0
- data/lib/gandi_v5/template/payload/dns_record.rb +23 -0
- data/lib/gandi_v5/template/payload/web_forwarding.rb +82 -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_TransferIn/fetch.yml +21 -0
- data/spec/fixtures/bodies/GandiV5_Domain_TransferIn_Availability/fetch.yml +10 -0
- data/spec/fixtures/bodies/GandiV5_Domain_WebForwarding/fetch.yml +9 -0
- data/spec/fixtures/bodies/GandiV5_Domain_WebForwarding/list.yml +9 -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/bodies/GandiV5_Template/fetch.yml +41 -0
- data/spec/fixtures/bodies/GandiV5_Template/list.yml +20 -0
- data/spec/fixtures/bodies/GandiV5_Template_Dispatch/fetch.yml +49 -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/spec_helper.rb +8 -7
- 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/web_forwarding_spec.rb +150 -0
- data/spec/units/gandi_v5/domain_spec.rb +56 -37
- 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/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/simple_hosting/instance/application_spec.rb +37 -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 +324 -0
- data/spec/units/gandi_v5/simple_hosting/instance_spec.rb +190 -0
- data/spec/units/gandi_v5/simple_hosting_spec.rb +9 -0
- data/spec/units/gandi_v5/template/dispatch_spec.rb +70 -0
- data/spec/units/gandi_v5/template/payload/web_forwarding_spec.rb +44 -0
- data/spec/units/gandi_v5/template_spec.rb +341 -0
- data/spec/units/gandi_v5_spec.rb +111 -14
- metadata +226 -79
- 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 -29
- 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/billing/info_spec.rb +0 -4
- data/spec/units/gandi_v5/domain/availability/product/period_spec.rb +0 -4
- data/spec/units/gandi_v5/domain/availability/product/price_spec.rb +0 -4
- data/spec/units/gandi_v5/domain/availability/product_spec.rb +0 -4
- data/spec/units/gandi_v5/domain/availability/tax_spec.rb +0 -4
- data/spec/units/gandi_v5/domain/contract_spec.rb +0 -4
- data/spec/units/gandi_v5/domain/dates_spec.rb +0 -4
- data/spec/units/gandi_v5/domain/restore_information_spec.rb +0 -4
- data/spec/units/gandi_v5/domain/sharing_space_spec.rb +0 -4
- data/spec/units/gandi_v5/error_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
@@ -1,347 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe GandiV5::LiveDNS::Zone do
|
4
|
-
subject do
|
5
|
-
described_class.new(
|
6
|
-
name: 'Zone Name',
|
7
|
-
uuid: 'zone-uuid',
|
8
|
-
soa_retry: 1,
|
9
|
-
soa_minimum: 2,
|
10
|
-
soa_refresh: 3,
|
11
|
-
soa_expire: 4,
|
12
|
-
soa_serial: 5,
|
13
|
-
soa_email: 'admin.example.com',
|
14
|
-
soa_primary_ns: '192.168.0.1'
|
15
|
-
)
|
16
|
-
end
|
17
|
-
|
18
|
-
it '#to_s' do
|
19
|
-
expect(subject.to_s).to eq [
|
20
|
-
'@ IN SOA 192.168.0.1 admin.example.com (',
|
21
|
-
"\t5\t;Serial",
|
22
|
-
"\t3\t\t;Refresh",
|
23
|
-
"\t1\t\t;Retry",
|
24
|
-
"\t4\t\t;Expire",
|
25
|
-
"\t2\t\t;Minimum & Negative TTL",
|
26
|
-
')'
|
27
|
-
].join("\n")
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#fetch_records' do
|
31
|
-
it 'All of them' do
|
32
|
-
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/records')
|
33
|
-
.and_return([nil, []])
|
34
|
-
|
35
|
-
expect(subject.fetch_records).to eq []
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'All for a name' do
|
39
|
-
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name')
|
40
|
-
.and_return([nil, []])
|
41
|
-
|
42
|
-
expect(subject.fetch_records('name')).to eq []
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'A type for a name' do
|
46
|
-
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT')
|
47
|
-
.and_return(
|
48
|
-
[
|
49
|
-
nil,
|
50
|
-
[
|
51
|
-
{
|
52
|
-
'rrset_type' => 'TXT',
|
53
|
-
'rrset_name' => 'name',
|
54
|
-
'rrset_ttl' => 600,
|
55
|
-
'rrset_values' => %w[a b]
|
56
|
-
}
|
57
|
-
]
|
58
|
-
]
|
59
|
-
)
|
60
|
-
|
61
|
-
records = subject.fetch_records('name', 'TXT')
|
62
|
-
expect(records.count).to eq 1
|
63
|
-
expect(records.first.type).to eq 'TXT'
|
64
|
-
expect(records.first.ttl).to eq 600
|
65
|
-
expect(records.first.name).to eq 'name'
|
66
|
-
expect(records.first.values).to match_array %w[a b]
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'Invalid type' do
|
70
|
-
expect { subject.fetch_records 'name', 'INVALID-TYPE' }.to raise_error ArgumentError
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '#fetch_zone_lines' do
|
75
|
-
it 'All of them' do
|
76
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
|
77
|
-
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
|
78
|
-
expect(subject.fetch_zone_lines).to eq 'returned'
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'All for a name' do
|
82
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name'
|
83
|
-
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
|
84
|
-
expect(subject.fetch_zone_lines('name')).to eq 'returned'
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'A type for a name' do
|
88
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT'
|
89
|
-
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
|
90
|
-
expect(subject.fetch_zone_lines('name', 'TXT')).to eq 'returned'
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'Invalid type' do
|
94
|
-
expect { subject.fetch_zone_lines 'name', 'INVALID-TYPE' }.to raise_error ArgumentError
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe '#add_record' do
|
99
|
-
it 'Success' do
|
100
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
|
101
|
-
body = '{"rrset_name":"name","rrset_type":"TXT","rrset_ttl":900,"rrset_values":["a","b"]}'
|
102
|
-
expect(GandiV5).to receive(:post).with(url, body).and_return([nil, { 'message' => 'Confirmation message.' }])
|
103
|
-
expect(subject.add_record('name', 'TXT', 900, 'a', 'b')).to eq 'Confirmation message.'
|
104
|
-
end
|
105
|
-
|
106
|
-
it 'Bad type' do
|
107
|
-
expect { subject.add_record 'name', 'INVALID-TYPE', 900, 'a' }.to raise_error ArgumentError
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'Bad TTL' do
|
111
|
-
expect { subject.add_record 'name', 'TXT', -900, 'a' }.to raise_error(
|
112
|
-
ArgumentError,
|
113
|
-
'ttl must be positive and non-zero'
|
114
|
-
)
|
115
|
-
end
|
116
|
-
|
117
|
-
it 'No values' do
|
118
|
-
expect { subject.add_record 'name', 'TXT', 900 }.to raise_error(
|
119
|
-
ArgumentError,
|
120
|
-
'there must be at least one value'
|
121
|
-
)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
describe '#delete_records' do
|
126
|
-
it 'All of them' do
|
127
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
|
128
|
-
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
129
|
-
subject.delete_records
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'All for a name' do
|
133
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name'
|
134
|
-
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
135
|
-
subject.delete_records 'name'
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'A type for a name' do
|
139
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT'
|
140
|
-
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
141
|
-
subject.delete_records 'name', 'TXT'
|
142
|
-
end
|
143
|
-
|
144
|
-
it 'Invalid type' do
|
145
|
-
expect { subject.delete_records 'name', 'INVALID-TYPE' }.to raise_error ArgumentError
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
describe '#replace_records' do
|
150
|
-
it 'Given array of GandiV5::LiveDNS::RecordSet' do
|
151
|
-
records = [
|
152
|
-
{ name: 'name', ttl: 600, type: 'TXT', values: ['a'] }
|
153
|
-
]
|
154
|
-
|
155
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
|
156
|
-
body = '{"items":[{"rrset_name":"name","rrset_ttl":600,"rrset_type":"TXT","rrset_values":["a"]}]}'
|
157
|
-
expect(GandiV5).to receive(:put).with(url, body)
|
158
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
159
|
-
expect(subject.replace_records(records: records)).to eq 'Confirmation message.'
|
160
|
-
end
|
161
|
-
|
162
|
-
it 'Given string' do
|
163
|
-
records = [
|
164
|
-
'@ 86400 IN A 192.168.0.1',
|
165
|
-
'* 86400 IN A 192.168.0.1'
|
166
|
-
].join("\n")
|
167
|
-
|
168
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
|
169
|
-
expect(GandiV5).to receive(:put).with(url, records, 'content-type': 'text/plain')
|
170
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
171
|
-
expect(subject.replace_records(text: records)).to eq 'Confirmation message.'
|
172
|
-
end
|
173
|
-
|
174
|
-
it 'Given both' do
|
175
|
-
expect { subject.replace_records text: '', records: [] }.to raise_error(
|
176
|
-
ArgumentError,
|
177
|
-
'you must pass ONE of records: or text:'
|
178
|
-
)
|
179
|
-
end
|
180
|
-
|
181
|
-
it 'Given nothing' do
|
182
|
-
expect { subject.replace_records }.to raise_error ArgumentError, 'you must pass ONE of records: or text:'
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
describe '#replace_records_for' do
|
187
|
-
it 'Given no type or ttl' do
|
188
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name'
|
189
|
-
body = '{"items":[{"rrset_type":"TXT","rrset_values":["a"]}]}'
|
190
|
-
expect(GandiV5).to receive(:put).with(url, body)
|
191
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
192
|
-
records = [{ type: 'TXT', values: ['a'] }]
|
193
|
-
expect(subject.replace_records_for('name', records)).to eq 'Confirmation message.'
|
194
|
-
end
|
195
|
-
|
196
|
-
it 'Given type and ttl' do
|
197
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT'
|
198
|
-
body = '{"rrset_values":["a"],"rrset_ttl":600}'
|
199
|
-
expect(GandiV5).to receive(:put).with(url, body)
|
200
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
201
|
-
expect(subject.replace_records_for('name', ['a'], type: 'TXT', ttl: 600)).to eq 'Confirmation message.'
|
202
|
-
end
|
203
|
-
|
204
|
-
it 'Given type but no ttl' do
|
205
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT'
|
206
|
-
body = '{"rrset_values":["a"],"rrset_ttl":null}'
|
207
|
-
expect(GandiV5).to receive(:put).with(url, body)
|
208
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
209
|
-
expect(subject.replace_records_for('name', ['a'], type: 'TXT')).to eq 'Confirmation message.'
|
210
|
-
end
|
211
|
-
|
212
|
-
it 'Given ttl but no type' do
|
213
|
-
expect(GandiV5).to_not receive(:put)
|
214
|
-
expect { subject.replace_records_for 'name', 'a', ttl: 600 }.to raise_error ArgumentError, 'missing keyword: type'
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
it '#list_domains' do
|
219
|
-
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/domains')
|
220
|
-
.and_return([nil, [{ 'fqdn' => 'example.com' }]])
|
221
|
-
expect(subject.list_domains).to match_array ['example.com']
|
222
|
-
end
|
223
|
-
|
224
|
-
describe '#attach_domain' do
|
225
|
-
it 'Given a fqdn' do
|
226
|
-
url = 'https://dns.api.gandi.net/api/v5/domains/example.com'
|
227
|
-
body = '{"zone_uuid":"zone-uuid"}'
|
228
|
-
expect(GandiV5).to receive(:patch).with(url, body)
|
229
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
230
|
-
expect(subject.attach_domain('example.com')).to eq 'Confirmation message.'
|
231
|
-
end
|
232
|
-
|
233
|
-
it 'Given something with a fqdn method' do
|
234
|
-
url = 'https://dns.api.gandi.net/api/v5/domains/example.com'
|
235
|
-
body = '{"zone_uuid":"zone-uuid"}'
|
236
|
-
expect(GandiV5).to receive(:patch).with(url, body)
|
237
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
238
|
-
domain = double GandiV5::LiveDNS::Domain, fqdn: 'example.com'
|
239
|
-
expect(subject.attach_domain(domain)).to eq 'Confirmation message.'
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
it '#snapshots' do
|
244
|
-
returns = double Hash
|
245
|
-
expect(GandiV5::LiveDNS::Zone::Snapshot).to receive(:list).with('zone-uuid')
|
246
|
-
.and_return(returns)
|
247
|
-
expect(subject.snapshots).to be returns
|
248
|
-
end
|
249
|
-
|
250
|
-
it '#snapshot' do
|
251
|
-
returns = double GandiV5::LiveDNS::Zone::Snapshot
|
252
|
-
expect(GandiV5::LiveDNS::Zone::Snapshot).to receive(:fetch).with('zone-uuid', 'snapshot-uuid')
|
253
|
-
.and_return(returns)
|
254
|
-
expect(subject.snapshot('snapshot-uuid')).to be returns
|
255
|
-
end
|
256
|
-
|
257
|
-
it '#take_snapshot' do
|
258
|
-
returns = double GandiV5::LiveDNS::Zone::Snapshot
|
259
|
-
expect(GandiV5).to receive(:post).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/snapshots')
|
260
|
-
.and_return([nil, { 'message' => 'Confirmation message.', 'uuid' => 'snapshot-uuid' }])
|
261
|
-
expect(GandiV5::LiveDNS::Zone::Snapshot).to receive(:fetch).with('zone-uuid', 'snapshot-uuid')
|
262
|
-
.and_return(returns)
|
263
|
-
expect(subject.take_snapshot).to be returns
|
264
|
-
end
|
265
|
-
|
266
|
-
it '#update' do
|
267
|
-
body = '{"name":"new-name"}'
|
268
|
-
expect(GandiV5).to receive(:patch).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid', body)
|
269
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
270
|
-
expect(subject.update(name: 'new-name')).to eq 'Confirmation message.'
|
271
|
-
end
|
272
|
-
|
273
|
-
it '#delete' do
|
274
|
-
expect(GandiV5).to receive(:delete).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid')
|
275
|
-
subject.delete
|
276
|
-
end
|
277
|
-
|
278
|
-
describe '.create' do
|
279
|
-
let(:created_response) do
|
280
|
-
double(
|
281
|
-
RestClient::Response,
|
282
|
-
headers: { location: 'https://dns.api.gandi.net/v5/zones/created-zone-uuid' }
|
283
|
-
)
|
284
|
-
end
|
285
|
-
let(:created_zone) { double GandiV5::LiveDNS::Zone }
|
286
|
-
|
287
|
-
it 'With sharing-id' do
|
288
|
-
body = '{"name":"Name"}'
|
289
|
-
params = { sharing_id: 'sharing-id' }
|
290
|
-
expect(GandiV5).to receive(:post).with('https://dns.api.gandi.net/api/v5/zones', body, params: params)
|
291
|
-
.and_return([created_response, { 'message' => 'Confirmation message.' }])
|
292
|
-
expect(described_class).to receive(:fetch).with('created-zone-uuid').and_return(created_zone)
|
293
|
-
expect(described_class.create('Name', sharing_id: 'sharing-id')).to be created_zone
|
294
|
-
end
|
295
|
-
|
296
|
-
it 'Without sharing-id' do
|
297
|
-
body = '{"name":"Name"}'
|
298
|
-
expect(GandiV5).to receive(:post).with('https://dns.api.gandi.net/api/v5/zones', body, params: {})
|
299
|
-
.and_return([created_response, { 'message' => 'Confirmation message.' }])
|
300
|
-
expect(described_class).to receive(:fetch).with('created-zone-uuid').and_return(created_zone)
|
301
|
-
expect(described_class.create('Name')).to be created_zone
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
describe '.list' do
|
306
|
-
subject { described_class.list }
|
307
|
-
|
308
|
-
before :each do
|
309
|
-
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Zone', 'list.yml'))
|
310
|
-
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones')
|
311
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
312
|
-
end
|
313
|
-
|
314
|
-
its('count') { should eq 1 }
|
315
|
-
its('first.uuid') { should eq 'zone-uuid' }
|
316
|
-
its('first.name') { should eq 'Name' }
|
317
|
-
its('first.sharing_uuid') { should be nil }
|
318
|
-
its('first.soa_retry') { should eq 3_600 }
|
319
|
-
its('first.soa_minimum') { should eq 900 }
|
320
|
-
its('first.soa_refresh') { should eq 10_800 }
|
321
|
-
its('first.soa_expire') { should eq 604_800 }
|
322
|
-
its('first.soa_serial') { should eq 1_432_798_405 }
|
323
|
-
its('first.soa_email') { should eq 'hostmaster.gandi.net.' }
|
324
|
-
its('first.soa_primary_ns') { should eq 'a.dns.gandi.net.' }
|
325
|
-
end
|
326
|
-
|
327
|
-
describe '.fetch' do
|
328
|
-
subject { described_class.fetch 'zone-uuid' }
|
329
|
-
|
330
|
-
before :each do
|
331
|
-
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Zone', 'fetch.yml'))
|
332
|
-
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid')
|
333
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
334
|
-
end
|
335
|
-
|
336
|
-
its('uuid') { should eq 'zone-uuid' }
|
337
|
-
its('name') { should eq 'Name' }
|
338
|
-
its('sharing_uuid') { should be nil }
|
339
|
-
its('soa_retry') { should eq 3_600 }
|
340
|
-
its('soa_minimum') { should eq 900 }
|
341
|
-
its('soa_refresh') { should eq 10_800 }
|
342
|
-
its('soa_expire') { should eq 604_800 }
|
343
|
-
its('soa_serial') { should eq 1_432_798_405 }
|
344
|
-
its('soa_email') { should eq 'hostmaster.gandi.net.' }
|
345
|
-
its('soa_primary_ns') { should eq 'a.dns.gandi.net.' }
|
346
|
-
end
|
347
|
-
end
|