dnsimple 3.1.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.rubocop_dnsimple.yml +24 -18
- data/CHANGELOG.md +17 -5
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +0 -1
- data/README.md +14 -3
- data/dnsimple.gemspec +1 -1
- data/lib/dnsimple/client.rb +5 -5
- data/lib/dnsimple/client/certificates.rb +89 -0
- data/lib/dnsimple/client/clients.rb +37 -0
- data/lib/dnsimple/client/collaborators.rb +76 -0
- data/lib/dnsimple/client/domains_pushes.rb +97 -0
- data/lib/dnsimple/client/registrar.rb +2 -2
- data/lib/dnsimple/client/registrar_delegation.rb +42 -0
- data/lib/dnsimple/client/services_domains.rb +82 -0
- data/lib/dnsimple/client/templates.rb +0 -5
- data/lib/dnsimple/client/templates_domains.rb +29 -0
- data/lib/dnsimple/client/vanity_name_servers.rb +47 -0
- data/lib/dnsimple/client/zones.rb +17 -0
- data/lib/dnsimple/client/zones_records.rb +9 -9
- data/lib/dnsimple/struct.rb +6 -1
- data/lib/dnsimple/struct/certificate.rb +37 -0
- data/lib/dnsimple/struct/certificate_bundle.rb +24 -0
- data/lib/dnsimple/struct/collaborator.rb +34 -0
- data/lib/dnsimple/struct/domain_push.rb +28 -0
- data/lib/dnsimple/struct/tld.rb +12 -0
- data/lib/dnsimple/struct/zone_file.rb +10 -0
- data/lib/dnsimple/struct/{record.rb → zone_record.rb} +4 -1
- data/lib/dnsimple/version.rb +1 -1
- data/spec/dnsimple/client/accounts_spec.rb +1 -1
- data/spec/dnsimple/client/certificates_spec.rb +206 -0
- data/spec/dnsimple/client/collaborators_spec.rb +162 -0
- data/spec/dnsimple/client/contacts_spec.rb +5 -5
- data/spec/dnsimple/client/domains_email_forwards_spec.rb +5 -5
- data/spec/dnsimple/client/domains_pushes_spec.rb +162 -0
- data/spec/dnsimple/client/domains_spec.rb +6 -6
- data/spec/dnsimple/client/registrar_delegation_spec.rb +51 -0
- data/spec/dnsimple/client/registrar_spec.rb +6 -6
- data/spec/dnsimple/client/registrar_whois_privacy_spec.rb +4 -4
- data/spec/dnsimple/client/services_domains_spec.rb +115 -0
- data/spec/dnsimple/client/services_spec.rb +1 -1
- data/spec/dnsimple/client/templates_domains_spec.rb +32 -0
- data/spec/dnsimple/client/templates_records_spec.rb +1 -1
- data/spec/dnsimple/client/templates_spec.rb +25 -1
- data/spec/dnsimple/client/tlds_spec.rb +8 -4
- data/spec/dnsimple/client/vanity_name_servers_spec.rb +54 -0
- data/spec/dnsimple/client/webhooks_spec.rb +2 -2
- data/spec/dnsimple/client/zones_records_spec.rb +34 -23
- data/spec/dnsimple/client/zones_spec.rb +40 -4
- data/spec/fixtures.http/acceptPush/success.http +17 -0
- data/spec/fixtures.http/addCollaborator/invite-success.http +21 -0
- data/spec/fixtures.http/addCollaborator/success.http +21 -0
- data/spec/fixtures.http/appliedServices/success.http +21 -0
- data/spec/fixtures.http/applyService/created.http +17 -0
- data/spec/fixtures.http/applyTemplate/success.http +13 -0
- data/spec/fixtures.http/changeDomainDelegationFromVanity/success.http +17 -0
- data/spec/fixtures.http/changeDomainDelegationToVanity/success.http +21 -0
- data/spec/fixtures.http/createZoneRecord/created.http +13 -9
- data/spec/fixtures.http/disableVanityNameServers/success.http +17 -0
- data/spec/fixtures.http/downloadCertificate/success.http +21 -0
- data/spec/fixtures.http/enableVanityNameServers/success.http +21 -0
- data/spec/fixtures.http/getCertificate/success.http +21 -0
- data/spec/fixtures.http/getCertificatePrivateKey/success.http +21 -0
- data/spec/fixtures.http/getTld/success.http +13 -9
- data/spec/fixtures.http/getZoneFile/success.http +21 -0
- data/spec/fixtures.http/getZoneRecord/success.http +13 -9
- data/spec/fixtures.http/initiatePush/success.http +21 -0
- data/spec/fixtures.http/{accounts → listAccounts}/success-account.http +0 -0
- data/spec/fixtures.http/{accounts → listAccounts}/success-user.http +0 -0
- data/spec/fixtures.http/listCertificates/success.http +21 -0
- data/spec/fixtures.http/listCollaborators/success.http +21 -0
- data/spec/fixtures.http/listPushes/success.http +21 -0
- data/spec/fixtures.http/listTlds/success.http +13 -9
- data/spec/fixtures.http/listZoneRecords/success.http +13 -9
- data/spec/fixtures.http/notfound-certificate.http +16 -0
- data/spec/fixtures.http/notfound-collaborator.http +16 -0
- data/spec/fixtures.http/notfound-contact.http +1 -1
- data/spec/fixtures.http/notfound-domainpush.http +12 -0
- data/spec/fixtures.http/rejectPush/success.http +17 -0
- data/spec/fixtures.http/removeCollaborator/success.http +17 -0
- data/spec/fixtures.http/unapplyService/success.http +17 -0
- data/spec/fixtures.http/updateZoneRecord/success.http +13 -9
- metadata +80 -10
@@ -42,7 +42,7 @@ describe Dnsimple::Client, ".services" do
|
|
42
42
|
|
43
43
|
response.data.each do |service|
|
44
44
|
expect(service).to be_a(Dnsimple::Struct::Service)
|
45
|
-
expect(service.id).to be_a(
|
45
|
+
expect(service.id).to be_a(Integer)
|
46
46
|
expect(service.name).to be_a(String)
|
47
47
|
expect(service.short_name).to be_a(String)
|
48
48
|
expect(service.description).to be_a(String)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dnsimple::Client, ".templates" do
|
4
|
+
|
5
|
+
subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").templates }
|
6
|
+
|
7
|
+
|
8
|
+
describe "#apply_template" do
|
9
|
+
let(:account_id) { 1010 }
|
10
|
+
let(:template_id) { 5410 }
|
11
|
+
let(:domain_id) { 'example.com' }
|
12
|
+
|
13
|
+
before do
|
14
|
+
stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/templates/#{template_id}$}).
|
15
|
+
to_return(read_http_fixture("applyTemplate/success.http"))
|
16
|
+
end
|
17
|
+
|
18
|
+
it "builds the correct request" do
|
19
|
+
subject.apply_template(account_id, template_id, domain_id)
|
20
|
+
|
21
|
+
expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/templates/#{template_id}").
|
22
|
+
with(headers: { "Accept" => "application/json" })
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns nil" do
|
26
|
+
response = subject.apply_template(account_id, template_id, domain_id)
|
27
|
+
expect(response).to be_a(Dnsimple::Response)
|
28
|
+
expect(response.data).to be_nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -45,7 +45,7 @@ describe Dnsimple::Client, ".templates" do
|
|
45
45
|
|
46
46
|
response.data.each do |result|
|
47
47
|
expect(result).to be_a(Dnsimple::Struct::TemplateRecord)
|
48
|
-
expect(result.id).to be_a(
|
48
|
+
expect(result.id).to be_a(Integer)
|
49
49
|
expect(result.type).to be_a(String)
|
50
50
|
expect(result.name).to be_a(String)
|
51
51
|
expect(result.content).to be_a(String)
|
@@ -182,11 +182,35 @@ describe Dnsimple::Client, ".templates" do
|
|
182
182
|
with(headers: { "Accept" => "application/json" })
|
183
183
|
end
|
184
184
|
|
185
|
-
it "returns
|
185
|
+
it "returns nil" do
|
186
186
|
response = subject.delete_template(account_id, template_id)
|
187
187
|
expect(response).to be_a(Dnsimple::Response)
|
188
188
|
expect(response.data).to be_nil
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
192
|
+
describe "#apply_template" do
|
193
|
+
let(:account_id) { 1010 }
|
194
|
+
let(:template_id) { 5410 }
|
195
|
+
let(:domain_id) { 'example.com' }
|
196
|
+
|
197
|
+
before do
|
198
|
+
stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/templates/#{template_id}$}).
|
199
|
+
to_return(read_http_fixture("applyTemplate/success.http"))
|
200
|
+
end
|
201
|
+
|
202
|
+
it "builds the correct request" do
|
203
|
+
subject.apply_template(account_id, template_id, domain_id)
|
204
|
+
|
205
|
+
expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/templates/#{template_id}").
|
206
|
+
with(headers: { "Accept" => "application/json" })
|
207
|
+
end
|
208
|
+
|
209
|
+
it "returns nil" do
|
210
|
+
response = subject.apply_template(account_id, template_id, domain_id)
|
211
|
+
expect(response).to be_a(Dnsimple::Response)
|
212
|
+
expect(response.data).to be_nil
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
192
216
|
end
|
@@ -43,7 +43,7 @@ describe Dnsimple::Client, ".tlds" do
|
|
43
43
|
|
44
44
|
response.data.each do |result|
|
45
45
|
expect(result).to be_a(Dnsimple::Struct::Tld)
|
46
|
-
expect(result.tld_type).to be_a(
|
46
|
+
expect(result.tld_type).to be_a(Integer)
|
47
47
|
expect(result.tld).to be_a(String)
|
48
48
|
end
|
49
49
|
end
|
@@ -53,9 +53,9 @@ describe Dnsimple::Client, ".tlds" do
|
|
53
53
|
|
54
54
|
expect(response.respond_to?(:page)).to be_truthy
|
55
55
|
expect(response.page).to eq(1)
|
56
|
-
expect(response.per_page).to be_a(
|
57
|
-
expect(response.total_entries).to be_a(
|
58
|
-
expect(response.total_pages).to be_a(
|
56
|
+
expect(response.per_page).to be_a(Integer)
|
57
|
+
expect(response.total_entries).to be_a(Integer)
|
58
|
+
expect(response.total_pages).to be_a(Integer)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -101,6 +101,10 @@ describe Dnsimple::Client, ".tlds" do
|
|
101
101
|
expect(result.whois_privacy).to eq(true)
|
102
102
|
expect(result.auto_renew_only).to eq(false)
|
103
103
|
expect(result.idn).to eq(true)
|
104
|
+
expect(result.minimum_registration).to eq(1)
|
105
|
+
expect(result.registration_enabled).to eq(true)
|
106
|
+
expect(result.renewal_enabled).to eq(true)
|
107
|
+
expect(result.transfer_enabled).to eq(true)
|
104
108
|
end
|
105
109
|
end
|
106
110
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dnsimple::Client, ".vanity_name_servers" do
|
4
|
+
|
5
|
+
subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").vanity_name_servers }
|
6
|
+
|
7
|
+
describe "#enable_vanity_name_servers" do
|
8
|
+
let(:account_id) { 1010 }
|
9
|
+
|
10
|
+
before do
|
11
|
+
stub_request(:put, %r{/v2/#{account_id}/vanity/.+$}).
|
12
|
+
to_return(read_http_fixture("enableVanityNameServers/success.http"))
|
13
|
+
end
|
14
|
+
|
15
|
+
it "builds the correct request" do
|
16
|
+
subject.enable_vanity_name_servers(account_id, domain_name = "example.com")
|
17
|
+
|
18
|
+
expect(WebMock).to have_requested(:put, "https://api.dnsimple.test/v2/#{account_id}/vanity/#{domain_name}").
|
19
|
+
with(headers: { "Accept" => "application/json" })
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns vanity name servers of the domain" do
|
23
|
+
response = subject.enable_vanity_name_servers(account_id, "example.com")
|
24
|
+
expect(response).to be_a(Dnsimple::Response)
|
25
|
+
|
26
|
+
vanity_name_servers = response.data.map { |ns| ns["name"] }
|
27
|
+
expect(vanity_name_servers).to match_array(%w(ns1.example.com ns2.example.com ns3.example.com ns4.example.com))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#disable_vanity_name_servers" do
|
32
|
+
let(:account_id) { 1010 }
|
33
|
+
|
34
|
+
before do
|
35
|
+
stub_request(:delete, %r{/v2/#{account_id}/vanity/.+$}).
|
36
|
+
to_return(read_http_fixture("disableVanityNameServers/success.http"))
|
37
|
+
end
|
38
|
+
|
39
|
+
it "builds the correct request" do
|
40
|
+
subject.disable_vanity_name_servers(account_id, domain_name = "example.com")
|
41
|
+
|
42
|
+
expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/vanity/#{domain_name}").
|
43
|
+
with(headers: { "Accept" => "application/json" })
|
44
|
+
end
|
45
|
+
|
46
|
+
it "returns empty response" do
|
47
|
+
response = subject.disable_vanity_name_servers(account_id, "example.com")
|
48
|
+
expect(response).to be_a(Dnsimple::Response)
|
49
|
+
|
50
|
+
result = response.data
|
51
|
+
expect(result).to be_nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -40,7 +40,7 @@ describe Dnsimple::Client, ".webhooks" do
|
|
40
40
|
|
41
41
|
response.data.each do |result|
|
42
42
|
expect(result).to be_a(Dnsimple::Struct::Webhook)
|
43
|
-
expect(result.id).to be_a(
|
43
|
+
expect(result.id).to be_a(Integer)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -69,7 +69,7 @@ describe Dnsimple::Client, ".webhooks" do
|
|
69
69
|
|
70
70
|
result = response.data
|
71
71
|
expect(result).to be_a(Dnsimple::Struct::Webhook)
|
72
|
-
expect(result.id).to be_a(
|
72
|
+
expect(result.id).to be_a(Integer)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -53,8 +53,9 @@ describe Dnsimple::Client, ".zones" do
|
|
53
53
|
expect(response.data.size).to eq(5)
|
54
54
|
|
55
55
|
response.data.each do |result|
|
56
|
-
expect(result).to be_a(Dnsimple::Struct::
|
57
|
-
expect(result.id).to be_a(
|
56
|
+
expect(result).to be_a(Dnsimple::Struct::ZoneRecord)
|
57
|
+
expect(result.id).to be_a(Integer)
|
58
|
+
expect(result.regions).to be_a(Array)
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
@@ -63,9 +64,9 @@ describe Dnsimple::Client, ".zones" do
|
|
63
64
|
|
64
65
|
expect(response.respond_to?(:page)).to be_truthy
|
65
66
|
expect(response.page).to eq(1)
|
66
|
-
expect(response.per_page).to be_a(
|
67
|
-
expect(response.total_entries).to be_a(
|
68
|
-
expect(response.total_pages).to be_a(
|
67
|
+
expect(response.per_page).to be_a(Integer)
|
68
|
+
expect(response.total_entries).to be_a(Integer)
|
69
|
+
expect(response.total_pages).to be_a(Integer)
|
69
70
|
end
|
70
71
|
|
71
72
|
context "when the zone does not exist" do
|
@@ -116,7 +117,7 @@ describe Dnsimple::Client, ".zones" do
|
|
116
117
|
to_return(read_http_fixture("createZoneRecord/created.http"))
|
117
118
|
end
|
118
119
|
|
119
|
-
let(:attributes) { { type: "
|
120
|
+
let(:attributes) { { type: "MX", name: "", content: "mxa.example.com", regions: %w(SV1 IAD) } }
|
120
121
|
|
121
122
|
it "builds the correct request" do
|
122
123
|
subject.create_record(account_id, zone_id, attributes)
|
@@ -131,8 +132,12 @@ describe Dnsimple::Client, ".zones" do
|
|
131
132
|
expect(response).to be_a(Dnsimple::Response)
|
132
133
|
|
133
134
|
result = response.data
|
134
|
-
expect(result).to be_a(Dnsimple::Struct::
|
135
|
-
expect(result.id).to eq(
|
135
|
+
expect(result).to be_a(Dnsimple::Struct::ZoneRecord)
|
136
|
+
expect(result.id).to eq(5)
|
137
|
+
expect(result.type).to eq(attributes.fetch(:type))
|
138
|
+
expect(result.name).to eq(attributes.fetch(:name))
|
139
|
+
expect(result.content).to eq(attributes.fetch(:content))
|
140
|
+
expect(result.regions).to eq(attributes.fetch(:regions))
|
136
141
|
end
|
137
142
|
|
138
143
|
context "when the zone does not exist" do
|
@@ -150,6 +155,7 @@ describe Dnsimple::Client, ".zones" do
|
|
150
155
|
describe "#record" do
|
151
156
|
let(:account_id) { 1010 }
|
152
157
|
let(:zone_id) { "example.com" }
|
158
|
+
let(:record_id) { 5 }
|
153
159
|
|
154
160
|
before do
|
155
161
|
stub_request(:get, %r{/v2/#{account_id}/zones/#{zone_id}/records/.+$}).
|
@@ -157,29 +163,30 @@ describe Dnsimple::Client, ".zones" do
|
|
157
163
|
end
|
158
164
|
|
159
165
|
it "builds the correct request" do
|
160
|
-
subject.record(account_id, zone_id, record_id
|
166
|
+
subject.record(account_id, zone_id, record_id)
|
161
167
|
|
162
168
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records/#{record_id}").
|
163
169
|
with(headers: { 'Accept' => 'application/json' })
|
164
170
|
end
|
165
171
|
|
166
172
|
it "returns the record" do
|
167
|
-
response = subject.record(account_id, zone_id,
|
173
|
+
response = subject.record(account_id, zone_id, record_id)
|
168
174
|
expect(response).to be_a(Dnsimple::Response)
|
169
175
|
|
170
176
|
result = response.data
|
171
|
-
expect(result).to be_a(Dnsimple::Struct::
|
172
|
-
expect(result.id).to eq(
|
177
|
+
expect(result).to be_a(Dnsimple::Struct::ZoneRecord)
|
178
|
+
expect(result.id).to eq(record_id)
|
173
179
|
expect(result.zone_id).to eq("example.com")
|
174
180
|
expect(result.parent_id).to eq(nil)
|
175
|
-
expect(result.type).to eq("
|
176
|
-
expect(result.name).to eq("
|
177
|
-
expect(result.content).to eq("
|
181
|
+
expect(result.type).to eq("MX")
|
182
|
+
expect(result.name).to eq("")
|
183
|
+
expect(result.content).to eq("mxa.example.com")
|
178
184
|
expect(result.ttl).to eq(600)
|
179
|
-
expect(result.priority).to eq(
|
185
|
+
expect(result.priority).to eq(10)
|
180
186
|
expect(result.system_record).to eq(false)
|
181
|
-
expect(result.
|
182
|
-
expect(result.
|
187
|
+
expect(result.regions).to eq(%w(SV1 IAD))
|
188
|
+
expect(result.created_at).to eq("2016-10-05T09:51:35.313Z")
|
189
|
+
expect(result.updated_at).to eq("2016-10-05T09:51:35.313Z")
|
183
190
|
end
|
184
191
|
|
185
192
|
context "when the zone does not exist" do
|
@@ -208,16 +215,17 @@ describe Dnsimple::Client, ".zones" do
|
|
208
215
|
describe "#update_record" do
|
209
216
|
let(:account_id) { 1010 }
|
210
217
|
let(:zone_id) { "example.com" }
|
218
|
+
let(:record_id) { 5 }
|
211
219
|
|
212
220
|
before do
|
213
221
|
stub_request(:patch, %r{/v2/#{account_id}/zones/#{zone_id}/records/.+$}).
|
214
222
|
to_return(read_http_fixture("updateZoneRecord/success.http"))
|
215
223
|
end
|
216
224
|
|
217
|
-
let(:attributes) { { content: "
|
225
|
+
let(:attributes) { { content: "mxb.example.com", priority: "20", regions: ['global'] } }
|
218
226
|
|
219
227
|
it "builds the correct request" do
|
220
|
-
subject.update_record(account_id, zone_id, record_id
|
228
|
+
subject.update_record(account_id, zone_id, record_id, attributes)
|
221
229
|
|
222
230
|
expect(WebMock).to have_requested(:patch, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records/#{record_id}").
|
223
231
|
with(body: attributes).
|
@@ -225,12 +233,15 @@ describe Dnsimple::Client, ".zones" do
|
|
225
233
|
end
|
226
234
|
|
227
235
|
it "returns the record" do
|
228
|
-
response = subject.update_record(account_id, zone_id,
|
236
|
+
response = subject.update_record(account_id, zone_id, record_id, attributes)
|
229
237
|
expect(response).to be_a(Dnsimple::Response)
|
230
238
|
|
231
239
|
result = response.data
|
232
|
-
expect(result).to be_a(Dnsimple::Struct::
|
233
|
-
expect(result.id).to eq(
|
240
|
+
expect(result).to be_a(Dnsimple::Struct::ZoneRecord)
|
241
|
+
expect(result.id).to eq(record_id)
|
242
|
+
expect(result.content).to eq(attributes.fetch(:content))
|
243
|
+
expect(result.priority).to eq(attributes.fetch(:priority).to_i)
|
244
|
+
expect(result.regions).to eq(attributes.fetch(:regions))
|
234
245
|
end
|
235
246
|
|
236
247
|
context "when the zone does not exist" do
|
@@ -53,7 +53,7 @@ describe Dnsimple::Client, ".zones" do
|
|
53
53
|
|
54
54
|
response.data.each do |result|
|
55
55
|
expect(result).to be_a(Dnsimple::Struct::Zone)
|
56
|
-
expect(result.id).to be_a(
|
56
|
+
expect(result.id).to be_a(Integer)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -62,9 +62,9 @@ describe Dnsimple::Client, ".zones" do
|
|
62
62
|
|
63
63
|
expect(response.respond_to?(:page)).to be_truthy
|
64
64
|
expect(response.page).to eq(1)
|
65
|
-
expect(response.per_page).to be_a(
|
66
|
-
expect(response.total_entries).to be_a(
|
67
|
-
expect(response.total_pages).to be_a(
|
65
|
+
expect(response.per_page).to be_a(Integer)
|
66
|
+
expect(response.total_entries).to be_a(Integer)
|
67
|
+
expect(response.total_pages).to be_a(Integer)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -135,4 +135,40 @@ describe Dnsimple::Client, ".zones" do
|
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
|
+
describe "#zone_file" do
|
139
|
+
let(:account_id) { 1010 }
|
140
|
+
|
141
|
+
before do
|
142
|
+
stub_request(:get, %r{/v2/#{account_id}/zones/.+$}).
|
143
|
+
to_return(read_http_fixture("getZoneFile/success.http"))
|
144
|
+
end
|
145
|
+
|
146
|
+
it "builds the correct request" do
|
147
|
+
subject.zone_file(account_id, zone = "example.com")
|
148
|
+
|
149
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone}/file").
|
150
|
+
with(headers: { 'Accept' => 'application/json' })
|
151
|
+
end
|
152
|
+
|
153
|
+
it "returns the zone id" do
|
154
|
+
response = subject.zone_file(account_id, "example.com")
|
155
|
+
expect(response).to be_a(Dnsimple::Response)
|
156
|
+
|
157
|
+
result = response.data
|
158
|
+
expect(result).to be_a(Dnsimple::Struct::ZoneFile)
|
159
|
+
expect(result.zone).to eq("$ORIGIN example.com.\n$TTL 1h\nexample.com. 3600 IN SOA ns1.dnsimple.com. admin.dnsimple.com. 1453132552 86400 7200 604800 300\nexample.com. 3600 IN NS ns1.dnsimple.com.\nexample.com. 3600 IN NS ns2.dnsimple.com.\nexample.com. 3600 IN NS ns3.dnsimple.com.\nexample.com. 3600 IN NS ns4.dnsimple.com.\n")
|
160
|
+
end
|
161
|
+
|
162
|
+
context "when the zone file does not exist" do
|
163
|
+
it "raises NotFoundError" do
|
164
|
+
stub_request(:get, %r{/v2}).
|
165
|
+
to_return(read_http_fixture("notfound-zone.http"))
|
166
|
+
|
167
|
+
expect {
|
168
|
+
subject.zone_file(account_id, "example.com")
|
169
|
+
}.to raise_error(Dnsimple::NotFoundError)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
138
174
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
HTTP/1.1 204 No Content
|
2
|
+
Server: nginx
|
3
|
+
Date: Thu, 11 Aug 2016 10:23:46 GMT
|
4
|
+
Connection: keep-alive
|
5
|
+
X-RateLimit-Limit: 2400
|
6
|
+
X-RateLimit-Remaining: 2392
|
7
|
+
X-RateLimit-Reset: 1470913058
|
8
|
+
Cache-Control: no-cache
|
9
|
+
X-Request-Id: 5867ab50-6237-4cf8-b220-51f5ef57debd
|
10
|
+
X-Runtime: 0.582482
|
11
|
+
X-Content-Type-Options: nosniff
|
12
|
+
X-Download-Options: noopen
|
13
|
+
X-Frame-Options: DENY
|
14
|
+
X-Permitted-Cross-Domain-Policies: none
|
15
|
+
X-XSS-Protection: 1; mode=block
|
16
|
+
Strict-Transport-Security: max-age=31536000
|
17
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
HTTP/1.1 201 Created
|
2
|
+
Server: nginx
|
3
|
+
Date: Fri, 07 Oct 2016 08:51:12 GMT
|
4
|
+
Content-Type: application/json; charset=utf-8
|
5
|
+
Transfer-Encoding: chunked
|
6
|
+
Connection: keep-alive
|
7
|
+
X-RateLimit-Limit: 2400
|
8
|
+
X-RateLimit-Remaining: 2398
|
9
|
+
X-RateLimit-Reset: 1475833772
|
10
|
+
ETag: W/"3e59e2eafbf1d4b626413a5703309b57"
|
11
|
+
Cache-Control: max-age=0, private, must-revalidate
|
12
|
+
X-Request-Id: 9f27e164-2448-4d23-ad67-4ecedaec063e
|
13
|
+
X-Runtime: 0.387144
|
14
|
+
X-Content-Type-Options: nosniff
|
15
|
+
X-Download-Options: noopen
|
16
|
+
X-Frame-Options: DENY
|
17
|
+
X-Permitted-Cross-Domain-Policies: none
|
18
|
+
X-XSS-Protection: 1; mode=block
|
19
|
+
Strict-Transport-Security: max-age=31536000
|
20
|
+
|
21
|
+
{"data":{"id":101,"domain_id":1,"domain_name":"example.com","user_id":null,"user_email":"invited-user@example.com","invitation":true,"created_at":"2016-10-07T08:51:12.630Z","updated_at":"2016-10-07T08:51:12.630Z","accepted_at":null}}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
HTTP/1.1 201 Created
|
2
|
+
Server: nginx
|
3
|
+
Date: Fri, 07 Oct 2016 08:53:41 GMT
|
4
|
+
Content-Type: application/json; charset=utf-8
|
5
|
+
Transfer-Encoding: chunked
|
6
|
+
Connection: keep-alive
|
7
|
+
X-RateLimit-Limit: 2400
|
8
|
+
X-RateLimit-Remaining: 2397
|
9
|
+
X-RateLimit-Reset: 1475833772
|
10
|
+
ETag: W/"d35fa3da40b4f6586503174563d71bfc"
|
11
|
+
Cache-Control: max-age=0, private, must-revalidate
|
12
|
+
X-Request-Id: 42de3144-37c7-4329-88c4-fdc103cb150f
|
13
|
+
X-Runtime: 0.156436
|
14
|
+
X-Content-Type-Options: nosniff
|
15
|
+
X-Download-Options: noopen
|
16
|
+
X-Frame-Options: DENY
|
17
|
+
X-Permitted-Cross-Domain-Policies: none
|
18
|
+
X-XSS-Protection: 1; mode=block
|
19
|
+
Strict-Transport-Security: max-age=31536000
|
20
|
+
|
21
|
+
{"data":{"id":100,"domain_id":1,"domain_name":"example.com","user_id":999,"user_email":"existing-user@example.com","invitation":false,"created_at":"2016-10-07T08:53:41.643Z","updated_at":"2016-10-07T08:53:41.643Z","accepted_at":"2016-10-07T08:53:41.643Z"}}
|