dnsimple 2.0.0.alpha3 → 2.0.0.alpha4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/CHANGELOG.markdown +5 -3
- data/lib/dnsimple/client.rb +6 -55
- data/lib/dnsimple/client/{certificates_service.rb → certificates.rb} +1 -1
- data/lib/dnsimple/client/clients.rb +121 -0
- data/lib/dnsimple/client/{contacts_service.rb → contacts.rb} +1 -1
- data/lib/dnsimple/client/domains.rb +65 -0
- data/lib/dnsimple/client/domains_autorenewals.rb +35 -0
- data/lib/dnsimple/client/domains_forwards.rb +70 -0
- data/lib/dnsimple/client/domains_privacy.rb +35 -0
- data/lib/dnsimple/client/domains_records.rb +89 -0
- data/lib/dnsimple/client/domains_sharing.rb +53 -0
- data/lib/dnsimple/client/domains_zones.rb +22 -0
- data/lib/dnsimple/client/{name_servers_service.rb → name_servers.rb} +1 -1
- data/lib/dnsimple/client/{registrars_service.rb → registrar.rb} +1 -1
- data/lib/dnsimple/client/services.rb +34 -0
- data/lib/dnsimple/client/{services_service.rb → services_domains.rb} +1 -28
- data/lib/dnsimple/client/templates.rb +98 -0
- data/lib/dnsimple/client/{templates_service.rb → templates_records.rb} +1 -93
- data/lib/dnsimple/client/{users_service.rb → users.rb} +1 -1
- data/lib/dnsimple/version.rb +1 -1
- data/spec/dnsimple/client/{certificates_service_spec.rb → certificates_spec.rb} +0 -0
- data/spec/dnsimple/client/{contacts_service_spec.rb → contacts_spec.rb} +0 -0
- data/spec/dnsimple/client/domains_autorenewals_spec.rb +72 -0
- data/spec/dnsimple/client/domains_forwards_spec.rb +146 -0
- data/spec/dnsimple/client/domains_privacy_spec.rb +74 -0
- data/spec/dnsimple/client/domains_records_spec.rb +191 -0
- data/spec/dnsimple/client/domains_sharing_spec.rb +109 -0
- data/spec/dnsimple/client/domains_spec.rb +139 -0
- data/spec/dnsimple/client/domains_zones_spec.rb +40 -0
- data/spec/dnsimple/client/{name_servers_service_spec.rb → name_servers_spec.rb} +0 -0
- data/spec/dnsimple/client/{registrars_service_spec.rb → registrar_spec.rb} +9 -9
- data/spec/dnsimple/client/{services_service_spec.rb → services_domains_spec.rb} +1 -62
- data/spec/dnsimple/client/services_spec.rb +69 -0
- data/spec/dnsimple/client/{templates_service_spec.rb → templates_records_spec.rb} +1 -192
- data/spec/dnsimple/client/templates_spec.rb +198 -0
- data/spec/dnsimple/client/{users_service_spec.rb → users_spec.rb} +0 -0
- data/spec/files/{domains_whois_privacy → domains_privacy}/disable/success.http +0 -0
- data/spec/files/{domains_whois_privacy → domains_privacy}/enable/success.http +0 -0
- data/spec/files/domains_privacy/notfound-domain.http +19 -0
- data/spec/files/{registrars → registrar}/check/available.http +0 -0
- data/spec/files/{registrars → registrar}/check/registered.http +0 -0
- data/spec/files/{registrars → registrar}/register/badrequest-missingdomain.http +0 -0
- data/spec/files/{registrars → registrar}/register/badrequest-missingregistrant.http +0 -0
- data/spec/files/{registrars → registrar}/register/success.http +0 -0
- data/spec/files/{registrars → registrar}/renew/badrequest-missingrenewal.http +0 -0
- data/spec/files/{registrars → registrar}/renew/badrequest-unable.http +0 -0
- data/spec/files/{registrars → registrar}/renew/success.http +0 -0
- data/spec/files/{registrars → registrar}/transfer/success.http +0 -0
- data/spec/files/{registrars_extended_attributes → registrar_extended_attributes}/list/success.http +0 -0
- data/spec/files/{registrars_prices → registrar_prices}/list/success.http +0 -0
- data/spec/files/{subscription → subscriptions}/show/success.http +0 -0
- metadata +82 -56
- data/lib/dnsimple/client/client_service.rb +0 -8
- data/lib/dnsimple/client/domains_service.rb +0 -333
- data/spec/dnsimple/client/domains_service_spec.rb +0 -662
@@ -1,662 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Dnsimple::Client, ".domains" do
|
4
|
-
|
5
|
-
subject { described_class.new(api_endpoint: "https://api.zone", username: "user", api_token: "token").domains }
|
6
|
-
|
7
|
-
|
8
|
-
describe "#list" do
|
9
|
-
before do
|
10
|
-
stub_request(:get, %r[/v1/domains$]).
|
11
|
-
to_return(read_fixture("domains/index/success.http"))
|
12
|
-
end
|
13
|
-
|
14
|
-
it "builds the correct request" do
|
15
|
-
subject.list
|
16
|
-
|
17
|
-
expect(WebMock).to have_requested(:get, "https://api.zone/v1/domains").
|
18
|
-
with(headers: { 'Accept' => 'application/json' })
|
19
|
-
end
|
20
|
-
|
21
|
-
it "returns the domains" do
|
22
|
-
results = subject.list
|
23
|
-
|
24
|
-
expect(results).to be_a(Array)
|
25
|
-
expect(results.size).to eq(2)
|
26
|
-
|
27
|
-
results.each do |result|
|
28
|
-
expect(result).to be_a(Dnsimple::Struct::Domain)
|
29
|
-
expect(result.id).to be_a(Fixnum)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "#create" do
|
35
|
-
before do
|
36
|
-
stub_request(:post, %r[/v1/domains]).
|
37
|
-
to_return(read_fixture("domains/create/created.http"))
|
38
|
-
end
|
39
|
-
|
40
|
-
let(:attributes) { { name: "example.com" } }
|
41
|
-
|
42
|
-
it "builds the correct request" do
|
43
|
-
subject.create(attributes)
|
44
|
-
|
45
|
-
expect(WebMock).to have_requested(:post, "https://api.zone/v1/domains").
|
46
|
-
with(body: { domain: attributes }).
|
47
|
-
with(headers: { 'Accept' => 'application/json' })
|
48
|
-
end
|
49
|
-
|
50
|
-
it "returns the domain" do
|
51
|
-
result = subject.create(attributes)
|
52
|
-
|
53
|
-
expect(result).to be_a(Dnsimple::Struct::Domain)
|
54
|
-
expect(result.id).to be_a(Fixnum)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "#find" do
|
59
|
-
before do
|
60
|
-
stub_request(:get, %r[/v1/domains/.+$]).
|
61
|
-
to_return(read_fixture("domains/show/success.http"))
|
62
|
-
end
|
63
|
-
|
64
|
-
it "builds the correct request" do
|
65
|
-
subject.find("example.com")
|
66
|
-
|
67
|
-
expect(WebMock).to have_requested(:get, "https://api.zone/v1/domains/example.com").
|
68
|
-
with(headers: { 'Accept' => 'application/json' })
|
69
|
-
end
|
70
|
-
|
71
|
-
it "returns the domain" do
|
72
|
-
result = subject.find("example.com")
|
73
|
-
|
74
|
-
expect(result).to be_a(Dnsimple::Struct::Domain)
|
75
|
-
expect(result.id).to eq(1)
|
76
|
-
expect(result.user_id).to eq(21)
|
77
|
-
expect(result.registrant_id).to eq(321)
|
78
|
-
expect(result.name).to eq("example.com")
|
79
|
-
expect(result.state).to eq("registered")
|
80
|
-
expect(result.auto_renew).to eq(true)
|
81
|
-
expect(result.whois_protected).to eq(false)
|
82
|
-
expect(result.expires_on).to eq("2015-09-27")
|
83
|
-
expect(result.created_at).to eq("2012-09-27T14:25:57.646Z")
|
84
|
-
expect(result.updated_at).to eq("2014-12-15T20:27:04.552Z")
|
85
|
-
end
|
86
|
-
|
87
|
-
context "when something does not exist" do
|
88
|
-
it "raises RecordNotFound" do
|
89
|
-
stub_request(:get, %r[/v1]).
|
90
|
-
to_return(read_fixture("domains/notfound.http"))
|
91
|
-
|
92
|
-
expect {
|
93
|
-
subject.find("example.com")
|
94
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
describe "#delete" do
|
100
|
-
before do
|
101
|
-
stub_request(:delete, %r[/v1/domains/.+$]).
|
102
|
-
to_return(read_fixture("domains/delete/success.http"))
|
103
|
-
end
|
104
|
-
|
105
|
-
it "builds the correct request" do
|
106
|
-
subject.delete("example.com")
|
107
|
-
|
108
|
-
expect(WebMock).to have_requested(:delete, "https://api.zone/v1/domains/example.com").
|
109
|
-
with(headers: { 'Accept' => 'application/json' })
|
110
|
-
end
|
111
|
-
|
112
|
-
it "returns nothing" do
|
113
|
-
result = subject.delete("example.com")
|
114
|
-
|
115
|
-
expect(result).to be_truthy
|
116
|
-
end
|
117
|
-
|
118
|
-
it "supports HTTP 204" do
|
119
|
-
stub_request(:delete, %r[/v1]).
|
120
|
-
to_return(read_fixture("domains/delete/success-204.http"))
|
121
|
-
|
122
|
-
result = subject.delete("example.com")
|
123
|
-
|
124
|
-
expect(result).to be_truthy
|
125
|
-
end
|
126
|
-
|
127
|
-
context "when something does not exist" do
|
128
|
-
it "raises RecordNotFound" do
|
129
|
-
stub_request(:delete, %r[/v1]).
|
130
|
-
to_return(read_fixture("domains/notfound.http"))
|
131
|
-
|
132
|
-
expect {
|
133
|
-
subject.delete("example.com")
|
134
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
|
140
|
-
describe "#list_records" do
|
141
|
-
before do
|
142
|
-
stub_request(:get, %r[/v1/domains/.+/records$]).
|
143
|
-
to_return(read_fixture("domains_records/index/success.http"))
|
144
|
-
end
|
145
|
-
|
146
|
-
it "builds the correct request" do
|
147
|
-
subject.list_records("example.com")
|
148
|
-
|
149
|
-
expect(WebMock).to have_requested(:get, "https://api.zone/v1/domains/example.com/records").
|
150
|
-
with(headers: { 'Accept' => 'application/json' })
|
151
|
-
end
|
152
|
-
|
153
|
-
it "returns the records" do
|
154
|
-
results = subject.list_records("example.com")
|
155
|
-
|
156
|
-
expect(results).to be_a(Array)
|
157
|
-
expect(results.size).to eq(7)
|
158
|
-
|
159
|
-
results.each do |result|
|
160
|
-
expect(result).to be_a(Dnsimple::Struct::Record)
|
161
|
-
expect(result.id).to be_a(Fixnum)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
context "when something does not exist" do
|
166
|
-
it "raises RecordNotFound" do
|
167
|
-
stub_request(:get, %r[/v1]).
|
168
|
-
to_return(read_fixture("domains_records/notfound.http"))
|
169
|
-
|
170
|
-
expect {
|
171
|
-
subject.list_records("example.com")
|
172
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
describe "#create_record" do
|
178
|
-
before do
|
179
|
-
stub_request(:post, %r[/v1/domains/.+/records$]).
|
180
|
-
to_return(read_fixture("domains_records/create/created.http"))
|
181
|
-
end
|
182
|
-
|
183
|
-
it "builds the correct request" do
|
184
|
-
subject.create_record("example.com", { name: "", record_type: "A", content: "127.0.0.1", prio: "1" })
|
185
|
-
|
186
|
-
expect(WebMock).to have_requested(:post, "https://api.zone/v1/domains/example.com/records").
|
187
|
-
with(body: { record: { name: "", record_type: "A", content: "127.0.0.1", prio: "1" } }).
|
188
|
-
with(headers: { 'Accept' => 'application/json' })
|
189
|
-
end
|
190
|
-
|
191
|
-
it "returns the record" do
|
192
|
-
result = subject.create_record("example.com", { name: "", record_type: "", content: "" })
|
193
|
-
|
194
|
-
expect(result).to be_a(Dnsimple::Struct::Record)
|
195
|
-
expect(result.id).to be_a(Fixnum)
|
196
|
-
end
|
197
|
-
|
198
|
-
context "when something does not exist" do
|
199
|
-
it "raises RecordNotFound" do
|
200
|
-
stub_request(:post, %r[/v1]).
|
201
|
-
to_return(read_fixture("domains/notfound.http"))
|
202
|
-
|
203
|
-
expect {
|
204
|
-
subject.create_record("example.com", { name: "", record_type: "", content: "" })
|
205
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
describe "#find_record" do
|
211
|
-
before do
|
212
|
-
stub_request(:get, %r[/v1/domains/.+/records/.+$]).
|
213
|
-
to_return(read_fixture("domains_records/show/success.http"))
|
214
|
-
end
|
215
|
-
|
216
|
-
it "builds the correct request" do
|
217
|
-
subject.find_record("example.com", 2)
|
218
|
-
|
219
|
-
expect(WebMock).to have_requested(:get, "https://api.zone/v1/domains/example.com/records/2").
|
220
|
-
with(headers: { 'Accept' => 'application/json' })
|
221
|
-
end
|
222
|
-
|
223
|
-
it "returns the record" do
|
224
|
-
result = subject.find_record("example.com", 2)
|
225
|
-
|
226
|
-
expect(result).to be_a(Dnsimple::Struct::Record)
|
227
|
-
expect(result.id).to eq(1495)
|
228
|
-
expect(result.domain_id).to eq(6)
|
229
|
-
expect(result.name).to eq("www")
|
230
|
-
expect(result.content).to eq("1.2.3.4")
|
231
|
-
expect(result.ttl).to eq(3600)
|
232
|
-
expect(result.prio).to be_nil
|
233
|
-
expect(result.record_type).to eq("A")
|
234
|
-
expect(result.created_at).to eq("2014-01-14T18:25:56Z")
|
235
|
-
expect(result.updated_at).to eq("2014-01-14T18:26:04Z")
|
236
|
-
end
|
237
|
-
|
238
|
-
context "when something does not exist" do
|
239
|
-
it "raises RecordNotFound" do
|
240
|
-
stub_request(:get, %r[/v1]).
|
241
|
-
to_return(read_fixture("domains_records/notfound.http"))
|
242
|
-
|
243
|
-
expect {
|
244
|
-
subject.find_record("example.com", 2)
|
245
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
246
|
-
end
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
describe "#update_record" do
|
251
|
-
before do
|
252
|
-
stub_request(:put, %r[/v1/domains/.+/records/.+$]).
|
253
|
-
to_return(read_fixture("domains_records/update/success.http"))
|
254
|
-
end
|
255
|
-
|
256
|
-
it "builds the correct request" do
|
257
|
-
subject.update_record("example.com", 2, { content: "127.0.0.1", prio: "1" })
|
258
|
-
|
259
|
-
expect(WebMock).to have_requested(:put, "https://api.zone/v1/domains/example.com/records/2").
|
260
|
-
with(body: { record: { content: "127.0.0.1", prio: "1" } }).
|
261
|
-
with(headers: { 'Accept' => 'application/json' })
|
262
|
-
end
|
263
|
-
|
264
|
-
it "returns the record" do
|
265
|
-
result = subject.update_record("example.com", 2, {})
|
266
|
-
|
267
|
-
expect(result).to be_a(Dnsimple::Struct::Record)
|
268
|
-
expect(result.id).to be_a(Fixnum)
|
269
|
-
end
|
270
|
-
|
271
|
-
context "when something does not exist" do
|
272
|
-
it "raises RecordNotFound" do
|
273
|
-
stub_request(:put, %r[/v1]).
|
274
|
-
to_return(read_fixture("domains_records/notfound.http"))
|
275
|
-
|
276
|
-
expect {
|
277
|
-
subject.update_record("example.com", 2, {})
|
278
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
279
|
-
end
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
describe "#delete_record" do
|
284
|
-
before do
|
285
|
-
stub_request(:delete, %r[/v1/domains/.+/records/.+$]).
|
286
|
-
to_return(read_fixture("domains/delete/success.http"))
|
287
|
-
end
|
288
|
-
|
289
|
-
it "builds the correct request" do
|
290
|
-
subject.delete_record("example.com", 2)
|
291
|
-
|
292
|
-
expect(WebMock).to have_requested(:delete, "https://api.zone/v1/domains/example.com/records/2").
|
293
|
-
with(headers: { 'Accept' => 'application/json' })
|
294
|
-
end
|
295
|
-
|
296
|
-
it "returns nothing" do
|
297
|
-
result = subject.delete_record("example.com", 2)
|
298
|
-
|
299
|
-
expect(result).to be_truthy
|
300
|
-
end
|
301
|
-
|
302
|
-
it "supports HTTP 204" do
|
303
|
-
stub_request(:delete, %r[/v1]).
|
304
|
-
to_return(read_fixture("domains_records/delete/success-204.http"))
|
305
|
-
|
306
|
-
result = subject.delete_record("example.com", 2)
|
307
|
-
|
308
|
-
expect(result).to be_truthy
|
309
|
-
end
|
310
|
-
|
311
|
-
context "when something does not exist" do
|
312
|
-
it "raises RecordNotFound" do
|
313
|
-
stub_request(:delete, %r[/v1]).
|
314
|
-
to_return(read_fixture("domains_records/notfound.http"))
|
315
|
-
|
316
|
-
expect {
|
317
|
-
subject.delete_record("example.com", 2)
|
318
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
319
|
-
end
|
320
|
-
end
|
321
|
-
end
|
322
|
-
|
323
|
-
|
324
|
-
describe "#enable_auto_renewal" do
|
325
|
-
before do
|
326
|
-
stub_request(:post, %r[/v1/domains/.+/auto_renewal]).
|
327
|
-
to_return(read_fixture("domains_autorenewal/enable/success.http"))
|
328
|
-
end
|
329
|
-
|
330
|
-
it "builds the correct request" do
|
331
|
-
subject.enable_auto_renewal("example.com")
|
332
|
-
|
333
|
-
expect(WebMock).to have_requested(:post, "https://api.zone/v1/domains/example.com/auto_renewal").
|
334
|
-
with(headers: { 'Accept' => 'application/json' })
|
335
|
-
end
|
336
|
-
|
337
|
-
it "returns the domain" do
|
338
|
-
result = subject.enable_auto_renewal("example.com")
|
339
|
-
|
340
|
-
expect(result).to be_a(Dnsimple::Struct::Domain)
|
341
|
-
expect(result.id).to be_a(Fixnum)
|
342
|
-
end
|
343
|
-
|
344
|
-
context "when the domain does not exist" do
|
345
|
-
it "raises RecordNotFound" do
|
346
|
-
stub_request(:post, %r[/v1]).
|
347
|
-
to_return(read_fixture("domains_autorenewal/notfound-domain.http"))
|
348
|
-
|
349
|
-
expect {
|
350
|
-
subject.enable_auto_renewal("example.com")
|
351
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
352
|
-
end
|
353
|
-
end
|
354
|
-
end
|
355
|
-
|
356
|
-
describe "#disable_auto_renewal" do
|
357
|
-
before do
|
358
|
-
stub_request(:delete, %r[/v1/domains/.+/auto_renewal]).
|
359
|
-
to_return(read_fixture("domains_autorenewal/disable/success.http"))
|
360
|
-
end
|
361
|
-
|
362
|
-
it "builds the correct request" do
|
363
|
-
subject.disable_auto_renewal("example.com")
|
364
|
-
|
365
|
-
expect(WebMock).to have_requested(:delete, "https://api.zone/v1/domains/example.com/auto_renewal").
|
366
|
-
with(headers: { 'Accept' => 'application/json' })
|
367
|
-
end
|
368
|
-
|
369
|
-
it "returns the domain" do
|
370
|
-
result = subject.disable_auto_renewal("example.com")
|
371
|
-
|
372
|
-
expect(result).to be_a(Dnsimple::Struct::Domain)
|
373
|
-
expect(result.id).to be_a(Fixnum)
|
374
|
-
end
|
375
|
-
|
376
|
-
context "when the domain does not exist" do
|
377
|
-
it "raises RecordNotFound" do
|
378
|
-
stub_request(:delete, %r[/v1]).
|
379
|
-
to_return(read_fixture("domains_autorenewal/notfound-domain.http"))
|
380
|
-
|
381
|
-
expect {
|
382
|
-
subject.disable_auto_renewal("example.com")
|
383
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
384
|
-
end
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
|
389
|
-
describe "#list_memberships" do
|
390
|
-
before do
|
391
|
-
stub_request(:get, %r[/v1/domains/.+/memberships]).
|
392
|
-
to_return(read_fixture("domains_sharing/list/success.http"))
|
393
|
-
end
|
394
|
-
|
395
|
-
it "builds the correct request" do
|
396
|
-
subject.list_memberships("example.com")
|
397
|
-
|
398
|
-
expect(WebMock).to have_requested(:get, "https://api.zone/v1/domains/example.com/memberships").
|
399
|
-
with(headers: { 'Accept' => 'application/json' })
|
400
|
-
end
|
401
|
-
|
402
|
-
it "returns the records" do
|
403
|
-
results = subject.list_memberships("example.com")
|
404
|
-
|
405
|
-
expect(results).to be_a(Array)
|
406
|
-
expect(results.size).to eq(2)
|
407
|
-
|
408
|
-
results.each do |result|
|
409
|
-
expect(result).to be_a(Dnsimple::Struct::Membership)
|
410
|
-
expect(result.id).to be_a(Fixnum)
|
411
|
-
end
|
412
|
-
end
|
413
|
-
|
414
|
-
context "when the domain does not exist" do
|
415
|
-
it "raises RecordNotFound" do
|
416
|
-
stub_request(:get, %r[/v1]).
|
417
|
-
to_return(read_fixture("domains_sharing/notfound-domain.http"))
|
418
|
-
|
419
|
-
expect {
|
420
|
-
subject.list_memberships("example.com")
|
421
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
422
|
-
end
|
423
|
-
end
|
424
|
-
end
|
425
|
-
|
426
|
-
describe "#create_membership" do
|
427
|
-
before do
|
428
|
-
stub_request(:post, %r[/v1/domains/.+/memberships]).
|
429
|
-
to_return(read_fixture("domains_sharing/create/success.http"))
|
430
|
-
end
|
431
|
-
|
432
|
-
it "builds the correct request" do
|
433
|
-
subject.create_membership("example.com", "someone@example.com")
|
434
|
-
|
435
|
-
expect(WebMock).to have_requested(:post, "https://api.zone/v1/domains/example.com/memberships").
|
436
|
-
with(body: { membership: { email: "someone@example.com" } }).
|
437
|
-
with(headers: { 'Accept' => 'application/json' })
|
438
|
-
end
|
439
|
-
|
440
|
-
it "returns the record" do
|
441
|
-
result = subject.create_membership("example.com", "someone@example.com")
|
442
|
-
|
443
|
-
expect(result).to be_a(Dnsimple::Struct::Membership)
|
444
|
-
expect(result.id).to be_a(Fixnum)
|
445
|
-
end
|
446
|
-
|
447
|
-
context "when the domain does not exist" do
|
448
|
-
it "raises RecordNotFound" do
|
449
|
-
stub_request(:post, %r[/v1]).
|
450
|
-
to_return(read_fixture("domains_forwards/notfound-domain.http"))
|
451
|
-
|
452
|
-
expect {
|
453
|
-
subject.create_membership("example.com", "someone@example.com")
|
454
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
455
|
-
end
|
456
|
-
end
|
457
|
-
end
|
458
|
-
|
459
|
-
describe "#delete_membership" do
|
460
|
-
before do
|
461
|
-
stub_request(:delete, %r[/v1/domains/.+/memberships/.+$]).
|
462
|
-
to_return(read_fixture("domains_sharing/delete/success.http"))
|
463
|
-
end
|
464
|
-
|
465
|
-
it "builds the correct request" do
|
466
|
-
subject.delete_membership("example.com", 2)
|
467
|
-
|
468
|
-
expect(WebMock).to have_requested(:delete, "https://api.zone/v1/domains/example.com/memberships/2").
|
469
|
-
with(headers: { 'Accept' => 'application/json' })
|
470
|
-
end
|
471
|
-
|
472
|
-
it "returns nothing" do
|
473
|
-
result = subject.delete_membership("example.com", 2)
|
474
|
-
|
475
|
-
expect(result).to be_truthy
|
476
|
-
end
|
477
|
-
|
478
|
-
context "when the membership does not exist" do
|
479
|
-
it "raises RecordNotFound" do
|
480
|
-
stub_request(:delete, %r[/v1]).
|
481
|
-
to_return(read_fixture("domains_sharing/notfound.http"))
|
482
|
-
|
483
|
-
expect {
|
484
|
-
subject.delete_membership("example.com", 2)
|
485
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
486
|
-
end
|
487
|
-
end
|
488
|
-
end
|
489
|
-
|
490
|
-
|
491
|
-
describe "#list_email_forwards" do
|
492
|
-
before do
|
493
|
-
stub_request(:get, %r[/v1/domains/.+/email_forwards]).
|
494
|
-
to_return(read_fixture("domains_forwards/list/success.http"))
|
495
|
-
end
|
496
|
-
|
497
|
-
it "builds the correct request" do
|
498
|
-
subject.list_email_forwards("example.com")
|
499
|
-
|
500
|
-
expect(WebMock).to have_requested(:get, "https://api.zone/v1/domains/example.com/email_forwards").
|
501
|
-
with(headers: { 'Accept' => 'application/json' })
|
502
|
-
end
|
503
|
-
|
504
|
-
it "returns the records" do
|
505
|
-
results = subject.list_email_forwards("example.com")
|
506
|
-
|
507
|
-
expect(results).to be_a(Array)
|
508
|
-
expect(results.size).to eq(2)
|
509
|
-
|
510
|
-
results.each do |result|
|
511
|
-
expect(result).to be_a(Dnsimple::Struct::EmailForward)
|
512
|
-
expect(result.id).to be_a(Fixnum)
|
513
|
-
end
|
514
|
-
end
|
515
|
-
|
516
|
-
context "when the domain does not exist" do
|
517
|
-
it "raises RecordNotFound" do
|
518
|
-
stub_request(:get, %r[/v1]).
|
519
|
-
to_return(read_fixture("domains_forwards/notfound-domain.http"))
|
520
|
-
|
521
|
-
expect {
|
522
|
-
subject.list_email_forwards("example.com")
|
523
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
524
|
-
end
|
525
|
-
end
|
526
|
-
end
|
527
|
-
|
528
|
-
describe "#create_email_forward" do
|
529
|
-
before do
|
530
|
-
stub_request(:post, %r[/v1/domains/.+/email_forwards$]).
|
531
|
-
to_return(read_fixture("domains_forwards/create/created.http"))
|
532
|
-
end
|
533
|
-
|
534
|
-
it "builds the correct request" do
|
535
|
-
subject.create_email_forward("example.com", { from: "john", to: "someone@example.com" })
|
536
|
-
|
537
|
-
expect(WebMock).to have_requested(:post, "https://api.zone/v1/domains/example.com/email_forwards").
|
538
|
-
with(body: { email_forward: { from: "john", to: "someone@example.com" } }).
|
539
|
-
with(headers: { 'Accept' => 'application/json' })
|
540
|
-
end
|
541
|
-
|
542
|
-
it "returns the record" do
|
543
|
-
result = subject.create_email_forward("example.com", { from: "", to: "" })
|
544
|
-
|
545
|
-
expect(result).to be_a(Dnsimple::Struct::EmailForward)
|
546
|
-
expect(result.id).to be_a(Fixnum)
|
547
|
-
end
|
548
|
-
|
549
|
-
context "when the domain does not exist" do
|
550
|
-
it "raises RecordNotFound" do
|
551
|
-
stub_request(:post, %r[/v1]).
|
552
|
-
to_return(read_fixture("domains_forwards/notfound-domain.http"))
|
553
|
-
|
554
|
-
expect {
|
555
|
-
subject.create_email_forward("example.com", { from: "", to: "" })
|
556
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
557
|
-
end
|
558
|
-
end
|
559
|
-
end
|
560
|
-
|
561
|
-
describe "#find_email_forward" do
|
562
|
-
before do
|
563
|
-
stub_request(:get, %r[/v1/domains/.+/email_forwards/.+$]).
|
564
|
-
to_return(read_fixture("domains_forwards/get/success.http"))
|
565
|
-
end
|
566
|
-
|
567
|
-
it "builds the correct request" do
|
568
|
-
subject.find_email_forward("example.com", 2)
|
569
|
-
|
570
|
-
expect(WebMock).to have_requested(:get, "https://api.zone/v1/domains/example.com/email_forwards/2").
|
571
|
-
with(headers: { 'Accept' => 'application/json' })
|
572
|
-
end
|
573
|
-
|
574
|
-
it "returns the record" do
|
575
|
-
result = subject.find_email_forward("example.com", 2)
|
576
|
-
|
577
|
-
expect(result).to be_a(Dnsimple::Struct::EmailForward)
|
578
|
-
expect(result.id).to eq(1)
|
579
|
-
expect(result.domain_id).to eq(1111)
|
580
|
-
expect(result.from).to eq("sender@dnsimple-sandbox.com")
|
581
|
-
expect(result.to).to eq("receiver@example.com")
|
582
|
-
expect(result.created_at).to eq("2014-12-16T12:55:13.697Z")
|
583
|
-
expect(result.updated_at).to eq("2014-12-16T12:55:13.697Z")
|
584
|
-
end
|
585
|
-
|
586
|
-
context "when forward does not exist" do
|
587
|
-
it "raises RecordNotFound" do
|
588
|
-
stub_request(:get, %r[/v1]).
|
589
|
-
to_return(read_fixture("domains_forwards/notfound.http"))
|
590
|
-
|
591
|
-
expect {
|
592
|
-
subject.find_email_forward("example.com", 2)
|
593
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
594
|
-
end
|
595
|
-
end
|
596
|
-
end
|
597
|
-
|
598
|
-
describe "#delete_email_forward" do
|
599
|
-
before do
|
600
|
-
stub_request(:delete, %r[/v1/domains/.+/email_forwards/.+$]).
|
601
|
-
to_return(read_fixture("domains_forwards/delete/success.http"))
|
602
|
-
end
|
603
|
-
|
604
|
-
it "builds the correct request" do
|
605
|
-
subject.delete_email_forward("example.com", 2)
|
606
|
-
|
607
|
-
expect(WebMock).to have_requested(:delete, "https://api.zone/v1/domains/example.com/email_forwards/2").
|
608
|
-
with(headers: { 'Accept' => 'application/json' })
|
609
|
-
end
|
610
|
-
|
611
|
-
it "returns nothing" do
|
612
|
-
result = subject.delete_email_forward("example.com", 2)
|
613
|
-
|
614
|
-
expect(result).to be_truthy
|
615
|
-
end
|
616
|
-
|
617
|
-
context "when the forward does not exist" do
|
618
|
-
it "raises RecordNotFound" do
|
619
|
-
stub_request(:delete, %r[/v1]).
|
620
|
-
to_return(read_fixture("domains_forwards/notfound.http"))
|
621
|
-
|
622
|
-
expect {
|
623
|
-
subject.delete_email_forward("example.com", 2)
|
624
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
625
|
-
end
|
626
|
-
end
|
627
|
-
end
|
628
|
-
|
629
|
-
|
630
|
-
describe "#zone" do
|
631
|
-
before do
|
632
|
-
stub_request(:get, %r[/v1/domains/.+/zone$]).
|
633
|
-
to_return(read_fixture("domains_zones/get/success.http"))
|
634
|
-
end
|
635
|
-
|
636
|
-
it "builds the correct request" do
|
637
|
-
subject.zone("example.com")
|
638
|
-
|
639
|
-
expect(WebMock).to have_requested(:get, "https://api.zone/v1/domains/example.com/zone").
|
640
|
-
with(headers: { 'Accept' => 'application/json' })
|
641
|
-
end
|
642
|
-
|
643
|
-
it "returns the record" do
|
644
|
-
result = subject.zone("example.com")
|
645
|
-
|
646
|
-
expect(result).to be_a(String)
|
647
|
-
expect(result).to match(/^#{Regexp.escape("$ORIGIN")}/)
|
648
|
-
end
|
649
|
-
|
650
|
-
context "when domain does not exist" do
|
651
|
-
it "raises RecordNotFound" do
|
652
|
-
stub_request(:get, %r[/v1]).
|
653
|
-
to_return(read_fixture("domains_zones/notfound-domain.http"))
|
654
|
-
|
655
|
-
expect {
|
656
|
-
subject.zone("example.com")
|
657
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
658
|
-
end
|
659
|
-
end
|
660
|
-
end
|
661
|
-
|
662
|
-
end
|