gandi_v5 0.1.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +14 -4
- data/.travis.yml +16 -1
- data/CHANGELOG.md +80 -2
- data/FUNDING.yml +10 -0
- data/Guardfile +5 -6
- data/LICENSE.md +2 -6
- data/README.md +17 -23
- data/gandi_v5.gemspec +4 -3
- data/lib/gandi_v5.rb +54 -15
- data/lib/gandi_v5/billing.rb +2 -4
- data/lib/gandi_v5/billing/info.rb +0 -2
- data/lib/gandi_v5/data.rb +1 -2
- data/lib/gandi_v5/data/converter.rb +0 -4
- data/lib/gandi_v5/data/converter/integer.rb +26 -0
- data/lib/gandi_v5/domain.rb +201 -101
- data/lib/gandi_v5/domain/auto_renew.rb +4 -4
- data/lib/gandi_v5/domain/availability.rb +46 -0
- data/lib/gandi_v5/domain/availability/product.rb +49 -0
- data/lib/gandi_v5/domain/availability/product/period.rb +24 -0
- data/lib/gandi_v5/domain/availability/product/price.rb +36 -0
- data/lib/gandi_v5/domain/availability/tax.rb +20 -0
- data/lib/gandi_v5/domain/live_dns.rb +42 -0
- data/lib/gandi_v5/domain/renewal_information.rb +0 -3
- data/lib/gandi_v5/domain/sharing_space.rb +10 -2
- data/lib/gandi_v5/domain/tld.rb +57 -0
- data/lib/gandi_v5/email.rb +0 -4
- data/lib/gandi_v5/email/forward.rb +108 -0
- data/lib/gandi_v5/email/mailbox.rb +85 -24
- data/lib/gandi_v5/email/mailbox/responder.rb +43 -2
- data/lib/gandi_v5/email/offer.rb +2 -2
- data/lib/gandi_v5/email/slot.rb +52 -18
- data/lib/gandi_v5/error.rb +0 -2
- data/lib/gandi_v5/error/gandi_error.rb +2 -2
- data/lib/gandi_v5/live_dns.rb +20 -4
- data/lib/gandi_v5/live_dns/domain.rb +21 -150
- data/lib/gandi_v5/live_dns/has_zone_records.rb +153 -0
- data/lib/gandi_v5/live_dns/record_set.rb +1 -1
- data/lib/gandi_v5/live_dns/zone.rb +24 -165
- data/lib/gandi_v5/live_dns/zone/snapshot.rb +27 -8
- data/lib/gandi_v5/organization.rb +39 -6
- data/lib/gandi_v5/organization/customer.rb +90 -0
- data/lib/gandi_v5/version.rb +1 -1
- data/spec/.rubocop.yml +9 -2
- data/spec/features/domain_spec.rb +2 -2
- data/spec/features/livedns_zone_spec.rb +12 -13
- data/spec/fixtures/bodies/GandiV5_Billing/{info.yaml → info.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Domain/{get.yaml → fetch.yml} +8 -0
- data/spec/fixtures/bodies/GandiV5_Domain/{fetch_contacts.yaml → fetch_contacts.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Domain/fetch_glue_records.yml +7 -0
- data/spec/fixtures/bodies/GandiV5_Domain/fetch_livedns.yml +6 -0
- data/spec/fixtures/bodies/GandiV5_Domain/fetch_name_servers.yml +2 -0
- data/spec/fixtures/bodies/GandiV5_Domain/{renewal_info.yaml → fetch_renewal_info.yml} +0 -3
- data/spec/fixtures/bodies/GandiV5_Domain/{restore_info.yaml → fetch_restore_info.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Domain/{list.yaml → list.yml} +1 -0
- data/spec/fixtures/bodies/{GandiV5_Domain/availability.yaml → GandiV5_Domain_Availability/fetch.yml} +0 -0
- data/spec/fixtures/bodies/{GandiV5_Domain/tld.yaml → GandiV5_Domain_TLD/fetch.yml} +0 -0
- data/spec/fixtures/bodies/{GandiV5_Domain/tlds.yaml → GandiV5_Domain_TLD/list.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Email_Forward/list.yml +6 -0
- data/spec/fixtures/bodies/GandiV5_Email_Mailbox/{get.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Email_Mailbox/{list.yaml → list.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Email_Slot/{get.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Email_Slot/{list.yaml → list.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/{get.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/{list.yaml → list.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/{get.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/{list.yaml → list.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/{get.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/list.yml +3 -0
- data/spec/fixtures/bodies/GandiV5_Organization/{get.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Organization/list.yml +7 -0
- data/spec/fixtures/bodies/GandiV5_Organization_Customer/list.yml +8 -0
- data/spec/fixtures/vcr/Domain_features/List_domains.yml +2 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/units/gandi_v5/billing_spec.rb +4 -4
- data/spec/units/gandi_v5/data/converter/integer_spec.rb +16 -0
- data/spec/units/gandi_v5/domain/auto_renew_spec.rb +5 -5
- data/spec/units/gandi_v5/domain/availability/product/period_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/availability/product/price_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/availability/product_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/availability/tax_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/availability_spec.rb +43 -0
- data/spec/units/gandi_v5/domain/live_dns_spec.rb +45 -0
- data/spec/units/gandi_v5/domain/tld_spec.rb +29 -0
- data/spec/units/gandi_v5/domain_spec.rb +359 -91
- data/spec/units/gandi_v5/email/forward_spec.rb +121 -0
- data/spec/units/gandi_v5/email/mailbox/responder_spec.rb +52 -0
- data/spec/units/gandi_v5/email/mailbox_spec.rb +174 -33
- data/spec/units/gandi_v5/email/offer_spec.rb +1 -1
- data/spec/units/gandi_v5/email/slot_spec.rb +113 -17
- data/spec/units/gandi_v5/live_dns/domain_spec.rb +73 -43
- data/spec/units/gandi_v5/live_dns/zone/snapshot_spec.rb +32 -3
- data/spec/units/gandi_v5/live_dns/zone_spec.rb +70 -52
- data/spec/units/gandi_v5/live_dns_spec.rb +24 -0
- data/spec/units/gandi_v5/organization/customer_spec.rb +81 -0
- data/spec/units/gandi_v5/organization_spec.rb +52 -1
- data/spec/units/gandi_v5_spec.rb +56 -19
- metadata +71 -29
- data/TODO.md +0 -29
@@ -30,14 +30,14 @@ describe GandiV5::LiveDNS::Zone do
|
|
30
30
|
describe '#fetch_records' do
|
31
31
|
it 'All of them' do
|
32
32
|
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/records')
|
33
|
-
.and_return([])
|
33
|
+
.and_return([nil, []])
|
34
34
|
|
35
35
|
expect(subject.fetch_records).to eq []
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'All for a name' do
|
39
39
|
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name')
|
40
|
-
.and_return([])
|
40
|
+
.and_return([nil, []])
|
41
41
|
|
42
42
|
expect(subject.fetch_records('name')).to eq []
|
43
43
|
end
|
@@ -46,12 +46,15 @@ describe GandiV5::LiveDNS::Zone do
|
|
46
46
|
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT')
|
47
47
|
.and_return(
|
48
48
|
[
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
49
|
+
nil,
|
50
|
+
[
|
51
|
+
{
|
52
|
+
'rrset_type' => 'TXT',
|
53
|
+
'rrset_name' => 'name',
|
54
|
+
'rrset_ttl' => 600,
|
55
|
+
'rrset_values' => %w[a b]
|
56
|
+
}
|
57
|
+
]
|
55
58
|
]
|
56
59
|
)
|
57
60
|
|
@@ -71,19 +74,19 @@ describe GandiV5::LiveDNS::Zone do
|
|
71
74
|
describe '#fetch_zone_lines' do
|
72
75
|
it 'All of them' do
|
73
76
|
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
|
74
|
-
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return('returned')
|
77
|
+
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
|
75
78
|
expect(subject.fetch_zone_lines).to eq 'returned'
|
76
79
|
end
|
77
80
|
|
78
81
|
it 'All for a name' do
|
79
82
|
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name'
|
80
|
-
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return('returned')
|
83
|
+
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
|
81
84
|
expect(subject.fetch_zone_lines('name')).to eq 'returned'
|
82
85
|
end
|
83
86
|
|
84
87
|
it 'A type for a name' do
|
85
88
|
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT'
|
86
|
-
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return('returned')
|
89
|
+
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
|
87
90
|
expect(subject.fetch_zone_lines('name', 'TXT')).to eq 'returned'
|
88
91
|
end
|
89
92
|
|
@@ -96,7 +99,7 @@ describe GandiV5::LiveDNS::Zone do
|
|
96
99
|
it 'Success' do
|
97
100
|
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
|
98
101
|
body = '{"rrset_name":"name","rrset_type":"TXT","rrset_ttl":900,"rrset_values":["a","b"]}'
|
99
|
-
expect(GandiV5).to receive(:post).with(url, body).and_return('message' => 'Confirmation message.')
|
102
|
+
expect(GandiV5).to receive(:post).with(url, body).and_return([nil, { 'message' => 'Confirmation message.' }])
|
100
103
|
expect(subject.add_record('name', 'TXT', 900, 'a', 'b')).to eq 'Confirmation message.'
|
101
104
|
end
|
102
105
|
|
@@ -122,19 +125,19 @@ describe GandiV5::LiveDNS::Zone do
|
|
122
125
|
describe '#delete_records' do
|
123
126
|
it 'All of them' do
|
124
127
|
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
|
125
|
-
expect(GandiV5).to receive(:delete).with(url)
|
128
|
+
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
126
129
|
subject.delete_records
|
127
130
|
end
|
128
131
|
|
129
132
|
it 'All for a name' do
|
130
133
|
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name'
|
131
|
-
expect(GandiV5).to receive(:delete).with(url)
|
134
|
+
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
132
135
|
subject.delete_records 'name'
|
133
136
|
end
|
134
137
|
|
135
138
|
it 'A type for a name' do
|
136
139
|
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT'
|
137
|
-
expect(GandiV5).to receive(:delete).with(url)
|
140
|
+
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
138
141
|
subject.delete_records 'name', 'TXT'
|
139
142
|
end
|
140
143
|
|
@@ -152,7 +155,7 @@ describe GandiV5::LiveDNS::Zone do
|
|
152
155
|
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
|
153
156
|
body = '{"items":[{"rrset_name":"name","rrset_ttl":600,"rrset_type":"TXT","rrset_values":["a"]}]}'
|
154
157
|
expect(GandiV5).to receive(:put).with(url, body)
|
155
|
-
.and_return('message' => 'Confirmation message.')
|
158
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
156
159
|
expect(subject.replace_records(records: records)).to eq 'Confirmation message.'
|
157
160
|
end
|
158
161
|
|
@@ -164,7 +167,7 @@ describe GandiV5::LiveDNS::Zone do
|
|
164
167
|
|
165
168
|
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
|
166
169
|
expect(GandiV5).to receive(:put).with(url, records, 'content-type': 'text/plain')
|
167
|
-
.and_return('message' => 'Confirmation message.')
|
170
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
168
171
|
expect(subject.replace_records(text: records)).to eq 'Confirmation message.'
|
169
172
|
end
|
170
173
|
|
@@ -180,36 +183,41 @@ describe GandiV5::LiveDNS::Zone do
|
|
180
183
|
end
|
181
184
|
end
|
182
185
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
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
|
191
195
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
body = '{"rrset_ttl":600,"rrset_values":["192.168.0.1","192.168.0.2"]}'
|
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}'
|
196
199
|
expect(GandiV5).to receive(:put).with(url, body)
|
197
|
-
.and_return('message' => 'Confirmation message.')
|
198
|
-
expect(subject.
|
200
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
201
|
+
expect(subject.replace_records_for('name', ['a'], type: 'TXT', ttl: 600)).to eq 'Confirmation message.'
|
199
202
|
end
|
200
203
|
|
201
|
-
it '
|
204
|
+
it 'Given type but no ttl' do
|
202
205
|
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT'
|
203
|
-
body = '{"
|
206
|
+
body = '{"rrset_values":["a"],"rrset_ttl":null}'
|
204
207
|
expect(GandiV5).to receive(:put).with(url, body)
|
205
|
-
.and_return('message' => 'Confirmation message.')
|
206
|
-
expect(subject.
|
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'
|
207
215
|
end
|
208
216
|
end
|
209
217
|
|
210
218
|
it '#list_domains' do
|
211
219
|
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/domains')
|
212
|
-
.and_return([{ 'fqdn' => 'example.com' }])
|
220
|
+
.and_return([nil, [{ 'fqdn' => 'example.com' }]])
|
213
221
|
expect(subject.list_domains).to match_array ['example.com']
|
214
222
|
end
|
215
223
|
|
@@ -218,7 +226,7 @@ describe GandiV5::LiveDNS::Zone do
|
|
218
226
|
url = 'https://dns.api.gandi.net/api/v5/domains/example.com'
|
219
227
|
body = '{"zone_uuid":"zone-uuid"}'
|
220
228
|
expect(GandiV5).to receive(:patch).with(url, body)
|
221
|
-
.and_return('message' => 'Confirmation message.')
|
229
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
222
230
|
expect(subject.attach_domain('example.com')).to eq 'Confirmation message.'
|
223
231
|
end
|
224
232
|
|
@@ -226,17 +234,17 @@ describe GandiV5::LiveDNS::Zone do
|
|
226
234
|
url = 'https://dns.api.gandi.net/api/v5/domains/example.com'
|
227
235
|
body = '{"zone_uuid":"zone-uuid"}'
|
228
236
|
expect(GandiV5).to receive(:patch).with(url, body)
|
229
|
-
.and_return('message' => 'Confirmation message.')
|
237
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
230
238
|
domain = double GandiV5::LiveDNS::Domain, fqdn: 'example.com'
|
231
239
|
expect(subject.attach_domain(domain)).to eq 'Confirmation message.'
|
232
240
|
end
|
233
241
|
end
|
234
242
|
|
235
243
|
it '#snapshots' do
|
236
|
-
returns =
|
237
|
-
expect(GandiV5).to receive(:
|
238
|
-
|
239
|
-
expect(subject.snapshots).to
|
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
|
240
248
|
end
|
241
249
|
|
242
250
|
it '#snapshot' do
|
@@ -249,7 +257,7 @@ describe GandiV5::LiveDNS::Zone do
|
|
249
257
|
it '#take_snapshot' do
|
250
258
|
returns = double GandiV5::LiveDNS::Zone::Snapshot
|
251
259
|
expect(GandiV5).to receive(:post).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/snapshots')
|
252
|
-
.and_return('message' => 'Confirmation message.', 'uuid' => 'snapshot-uuid')
|
260
|
+
.and_return([nil, { 'message' => 'Confirmation message.', 'uuid' => 'snapshot-uuid' }])
|
253
261
|
expect(GandiV5::LiveDNS::Zone::Snapshot).to receive(:fetch).with('zone-uuid', 'snapshot-uuid')
|
254
262
|
.and_return(returns)
|
255
263
|
expect(subject.take_snapshot).to be returns
|
@@ -258,7 +266,7 @@ describe GandiV5::LiveDNS::Zone do
|
|
258
266
|
it '#update' do
|
259
267
|
body = '{"name":"new-name"}'
|
260
268
|
expect(GandiV5).to receive(:patch).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid', body)
|
261
|
-
.and_return('message' => 'Confirmation message.')
|
269
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
262
270
|
expect(subject.update(name: 'new-name')).to eq 'Confirmation message.'
|
263
271
|
end
|
264
272
|
|
@@ -268,19 +276,29 @@ describe GandiV5::LiveDNS::Zone do
|
|
268
276
|
end
|
269
277
|
|
270
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
|
+
|
271
287
|
it 'With sharing-id' do
|
272
288
|
body = '{"name":"Name"}'
|
273
289
|
params = { sharing_id: 'sharing-id' }
|
274
290
|
expect(GandiV5).to receive(:post).with('https://dns.api.gandi.net/api/v5/zones', body, params: params)
|
275
|
-
.and_return('message' => 'Confirmation message.')
|
276
|
-
expect(described_class.
|
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
|
277
294
|
end
|
278
295
|
|
279
296
|
it 'Without sharing-id' do
|
280
297
|
body = '{"name":"Name"}'
|
281
298
|
expect(GandiV5).to receive(:post).with('https://dns.api.gandi.net/api/v5/zones', body, params: {})
|
282
|
-
.and_return('message' => 'Confirmation message.')
|
283
|
-
expect(described_class.
|
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
|
284
302
|
end
|
285
303
|
end
|
286
304
|
|
@@ -288,9 +306,9 @@ describe GandiV5::LiveDNS::Zone do
|
|
288
306
|
subject { described_class.list }
|
289
307
|
|
290
308
|
before :each do
|
291
|
-
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Zone', 'list.
|
309
|
+
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Zone', 'list.yml'))
|
292
310
|
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones')
|
293
|
-
.and_return(YAML.load_file(body_fixture))
|
311
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
294
312
|
end
|
295
313
|
|
296
314
|
its('count') { should eq 1 }
|
@@ -310,9 +328,9 @@ describe GandiV5::LiveDNS::Zone do
|
|
310
328
|
subject { described_class.fetch 'zone-uuid' }
|
311
329
|
|
312
330
|
before :each do
|
313
|
-
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Zone', '
|
331
|
+
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Zone', 'fetch.yml'))
|
314
332
|
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid')
|
315
|
-
.and_return(YAML.load_file(body_fixture))
|
333
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
316
334
|
end
|
317
335
|
|
318
336
|
its('uuid') { should eq 'zone-uuid' }
|
@@ -1,6 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe GandiV5::LiveDNS do
|
4
|
+
it '.domain' do
|
5
|
+
returns = double GandiV5::LiveDNS::Domain
|
6
|
+
expect(GandiV5::LiveDNS::Domain).to receive(:fetch).with('example.com').and_return(returns)
|
7
|
+
expect(described_class.domain('example.com')).to be returns
|
8
|
+
end
|
9
|
+
|
10
|
+
it '.domains' do
|
11
|
+
returns = double Array
|
12
|
+
expect(GandiV5::LiveDNS::Domain).to receive(:list).and_return(returns)
|
13
|
+
expect(described_class.domains).to be returns
|
14
|
+
end
|
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
|
+
|
4
28
|
describe '.require_valid_record_type' do
|
5
29
|
it 'Does nothing for valid type' do
|
6
30
|
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
|
@@ -3,11 +3,48 @@
|
|
3
3
|
describe GandiV5::Organization do
|
4
4
|
let(:body_fixtures) { File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Organization')) }
|
5
5
|
|
6
|
+
describe '.list' do
|
7
|
+
describe 'With default values' do
|
8
|
+
subject { described_class.list }
|
9
|
+
|
10
|
+
before :each do
|
11
|
+
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/organization/organizations', params: {})
|
12
|
+
.and_return([nil, YAML.load_file(File.join(body_fixtures, 'list.yml'))])
|
13
|
+
end
|
14
|
+
|
15
|
+
its('count') { should eq 1 }
|
16
|
+
its('first.uuid') { should eq 'organization-uuid' }
|
17
|
+
its('first.name') { should eq 'FirstLast' }
|
18
|
+
its('first.first_name') { should eq 'First' }
|
19
|
+
its('first.last_name') { should eq 'Last' }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'Passes optional query params' do
|
23
|
+
it 'name' do
|
24
|
+
expect(GandiV5).to receive(:get).with(
|
25
|
+
'https://api.gandi.net/v5/organization/organizations',
|
26
|
+
params: { '~name' => '5' }
|
27
|
+
)
|
28
|
+
.and_return([nil, []])
|
29
|
+
expect(described_class.list(name: '5')).to eq []
|
30
|
+
end
|
31
|
+
|
32
|
+
%i[type permission sort_by].each do |param|
|
33
|
+
it param.to_s do
|
34
|
+
headers = { param => 5 }
|
35
|
+
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/organization/organizations', params: headers)
|
36
|
+
.and_return([nil, []])
|
37
|
+
expect(described_class.list(**headers)).to eq []
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
6
43
|
describe '.fetch' do
|
7
44
|
subject { described_class.fetch }
|
8
45
|
before :each do
|
9
46
|
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/organization/user-info')
|
10
|
-
.and_return(YAML.load_file(File.join(body_fixtures, '
|
47
|
+
.and_return([nil, YAML.load_file(File.join(body_fixtures, 'fetch.yml'))])
|
11
48
|
end
|
12
49
|
|
13
50
|
its('uuid') { should eq 'organization-uuid' }
|
@@ -27,4 +64,18 @@ describe GandiV5::Organization do
|
|
27
64
|
its('security_email_validated') { should eq true }
|
28
65
|
its('security_email_validation_deadline') { should eq Time.new(2017, 11, 22, 17, 13, 33) }
|
29
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
|
30
81
|
end
|