dnsimple 4.3.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.dependabot/config.yml +9 -0
- data/.rubocop.yml +7 -0
- data/.rubocop_dnsimple.yml +136 -45
- data/.travis.yml +13 -9
- data/CHANGELOG.md +57 -23
- data/CONTRIBUTING.md +55 -7
- data/Gemfile +4 -1
- data/LICENSE.txt +1 -1
- data/README.md +8 -6
- data/dnsimple.gemspec +3 -3
- data/lib/dnsimple.rb +2 -0
- data/lib/dnsimple/client.rb +12 -10
- data/lib/dnsimple/client/accounts.rb +2 -1
- data/lib/dnsimple/client/certificates.rb +188 -28
- data/lib/dnsimple/client/clients.rb +6 -2
- data/lib/dnsimple/client/contacts.rb +2 -5
- data/lib/dnsimple/client/domains.rb +3 -5
- data/lib/dnsimple/client/{collaborators.rb → domains_collaborators.rb} +3 -1
- data/lib/dnsimple/client/domains_delegation_signer_records.rb +2 -0
- data/lib/dnsimple/client/domains_dnssec.rb +2 -0
- data/lib/dnsimple/client/domains_email_forwards.rb +2 -0
- data/lib/dnsimple/client/domains_pushes.rb +2 -0
- data/lib/dnsimple/client/identity.rb +2 -0
- data/lib/dnsimple/client/oauth.rb +2 -0
- data/lib/dnsimple/client/registrar.rb +51 -5
- data/lib/dnsimple/client/registrar_auto_renewal.rb +2 -0
- data/lib/dnsimple/client/registrar_delegation.rb +6 -4
- data/lib/dnsimple/client/registrar_whois_privacy.rb +23 -1
- data/lib/dnsimple/client/services.rb +2 -2
- data/lib/dnsimple/client/services_domains.rb +2 -0
- data/lib/dnsimple/client/templates.rb +2 -0
- data/lib/dnsimple/client/templates_domains.rb +2 -0
- data/lib/dnsimple/client/templates_records.rb +2 -0
- data/lib/dnsimple/client/tlds.rb +16 -17
- data/lib/dnsimple/client/vanity_name_servers.rb +12 -10
- data/lib/dnsimple/client/webhooks.rb +2 -3
- data/lib/dnsimple/client/zones.rb +2 -1
- data/lib/dnsimple/client/zones_distributions.rb +49 -0
- data/lib/dnsimple/client/zones_records.rb +25 -28
- data/lib/dnsimple/default.rb +11 -9
- data/lib/dnsimple/error.rb +2 -0
- data/lib/dnsimple/extra.rb +2 -0
- data/lib/dnsimple/options.rb +2 -0
- data/lib/dnsimple/response.rb +6 -4
- data/lib/dnsimple/struct.rb +7 -0
- data/lib/dnsimple/struct/account.rb +2 -0
- data/lib/dnsimple/struct/certificate.rb +11 -0
- data/lib/dnsimple/struct/certificate_bundle.rb +5 -0
- data/lib/dnsimple/struct/certificate_purchase.rb +27 -0
- data/lib/dnsimple/struct/certificate_renewal.rb +30 -0
- data/lib/dnsimple/struct/collaborator.rb +2 -0
- data/lib/dnsimple/struct/contact.rb +2 -0
- data/lib/dnsimple/struct/delegation_signer_record.rb +2 -0
- data/lib/dnsimple/struct/dnssec.rb +2 -0
- data/lib/dnsimple/struct/domain.rb +24 -3
- data/lib/dnsimple/struct/domain_check.rb +2 -0
- data/lib/dnsimple/struct/domain_premium_price.rb +2 -0
- data/lib/dnsimple/struct/domain_push.rb +2 -0
- data/lib/dnsimple/struct/domain_registration.rb +2 -3
- data/lib/dnsimple/struct/domain_renewal.rb +2 -3
- data/lib/dnsimple/struct/domain_transfer.rb +4 -2
- data/lib/dnsimple/struct/email_forward.rb +2 -0
- data/lib/dnsimple/struct/extended_attribute.rb +3 -1
- data/lib/dnsimple/struct/oauth_token.rb +2 -0
- data/lib/dnsimple/struct/service.rb +3 -1
- data/lib/dnsimple/struct/template.rb +2 -0
- data/lib/dnsimple/struct/template_record.rb +2 -0
- data/lib/dnsimple/struct/tld.rb +2 -0
- data/lib/dnsimple/struct/user.rb +2 -0
- data/lib/dnsimple/struct/vanity_name_server.rb +27 -0
- data/lib/dnsimple/struct/webhook.rb +2 -0
- data/lib/dnsimple/struct/whoami.rb +4 -2
- data/lib/dnsimple/struct/whois_privacy.rb +2 -0
- data/lib/dnsimple/struct/whois_privacy_renewal.rb +30 -0
- data/lib/dnsimple/struct/zone.rb +2 -0
- data/lib/dnsimple/struct/zone_distribution.rb +13 -0
- data/lib/dnsimple/struct/zone_file.rb +2 -0
- data/lib/dnsimple/struct/zone_record.rb +2 -0
- data/lib/dnsimple/version.rb +3 -1
- data/spec/dnsimple/client/accounts_spec.rb +2 -0
- data/spec/dnsimple/client/certificates_spec.rb +227 -1
- data/spec/dnsimple/client/client_service_spec.rb +2 -0
- data/spec/dnsimple/client/contacts_spec.rb +3 -1
- data/spec/dnsimple/client/{collaborators_spec.rb → domains_collaborators_spec.rb} +3 -1
- data/spec/dnsimple/client/domains_delegation_signer_records_spec.rb +3 -1
- data/spec/dnsimple/client/domains_dnssec_spec.rb +4 -2
- data/spec/dnsimple/client/domains_email_forwards_spec.rb +3 -1
- data/spec/dnsimple/client/domains_pushes_spec.rb +3 -1
- data/spec/dnsimple/client/domains_spec.rb +19 -16
- data/spec/dnsimple/client/identity_spec.rb +2 -0
- data/spec/dnsimple/client/oauth_spec.rb +2 -0
- data/spec/dnsimple/client/registrar_auto_renewal_spec.rb +2 -0
- data/spec/dnsimple/client/registrar_delegation_spec.rb +5 -2
- data/spec/dnsimple/client/registrar_spec.rb +73 -4
- data/spec/dnsimple/client/registrar_whois_privacy_spec.rb +60 -3
- data/spec/dnsimple/client/services_domains_spec.rb +2 -0
- data/spec/dnsimple/client/services_spec.rb +3 -1
- data/spec/dnsimple/client/templates_domains_spec.rb +2 -0
- data/spec/dnsimple/client/templates_records_spec.rb +2 -0
- data/spec/dnsimple/client/templates_spec.rb +2 -0
- data/spec/dnsimple/client/tlds_spec.rb +22 -19
- data/spec/dnsimple/client/vanity_name_servers_spec.rb +2 -0
- data/spec/dnsimple/client/webhooks_spec.rb +2 -0
- data/spec/dnsimple/client/zones_distributions_spec.rb +137 -0
- data/spec/dnsimple/client/zones_records_spec.rb +37 -35
- data/spec/dnsimple/client/zones_spec.rb +4 -2
- data/spec/dnsimple/client_spec.rb +8 -6
- data/spec/dnsimple/extra_spec.rb +2 -0
- data/spec/dnsimple/options/base_spec.rb +2 -0
- data/spec/dnsimple/options/list_options_spec.rb +2 -0
- data/spec/fixtures.http/{transferDomainOut → authorizeDomainTransferOut}/success.http +0 -0
- data/spec/fixtures.http/cancelDomainTransfer/success.http +19 -0
- data/spec/fixtures.http/checkZoneDistribution/error.http +21 -0
- data/spec/fixtures.http/checkZoneDistribution/failure.http +21 -0
- data/spec/fixtures.http/checkZoneDistribution/success.http +21 -0
- data/spec/fixtures.http/checkZoneRecordDistribution/error.http +21 -0
- data/spec/fixtures.http/checkZoneRecordDistribution/failure.http +21 -0
- data/spec/fixtures.http/checkZoneRecordDistribution/success.http +21 -0
- data/spec/fixtures.http/createDomain/created.http +21 -16
- data/spec/fixtures.http/getCertificate/success.http +1 -1
- data/spec/fixtures.http/getDomain/success.http +14 -9
- data/spec/fixtures.http/getDomainTransfer/success.http +21 -0
- data/spec/fixtures.http/issueLetsencryptCertificate/success.http +21 -0
- data/spec/fixtures.http/issueRenewalLetsencryptCertificate/success.http +21 -0
- data/spec/fixtures.http/listCertificates/success.http +1 -1
- data/spec/fixtures.http/listDomains/success.http +21 -16
- data/spec/fixtures.http/purchaseLetsencryptCertificate/success.http +21 -0
- data/spec/fixtures.http/purchaseRenewalLetsencryptCertificate/success.http +21 -0
- data/spec/fixtures.http/registerDomain/success.http +2 -2
- data/spec/fixtures.http/renewDomain/success.http +2 -2
- data/spec/fixtures.http/renewWhoisPrivacy/success.http +21 -0
- data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-duplicated-order.http +19 -0
- data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-not-found.http +19 -0
- data/spec/fixtures.http/transferDomain/success.http +2 -2
- data/spec/fixtures.http/whoami/success-account.http +1 -1
- data/spec/fixtures.http/whoami/success-user.http +1 -1
- data/spec/fixtures.http/whoami/success.http +1 -1
- data/spec/spec_helper.rb +4 -2
- data/spec/support/helpers.rb +2 -0
- data/spec/support/webmock.rb +2 -0
- metadata +50 -19
- data/.ruby-gemset +0 -1
@@ -1,41 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Dnsimple::Client, ".tlds" do
|
4
6
|
subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").tlds }
|
5
7
|
|
6
|
-
describe "#
|
8
|
+
describe "#list_tlds" do
|
7
9
|
before do
|
8
10
|
stub_request(:get, %r{/v2/tlds})
|
9
11
|
.to_return(read_http_fixture("listTlds/success.http"))
|
10
12
|
end
|
11
13
|
|
12
14
|
it "builds the correct request" do
|
13
|
-
subject.
|
15
|
+
subject.list_tlds
|
14
16
|
|
15
17
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds")
|
16
18
|
.with(headers: { 'Accept' => 'application/json' })
|
17
19
|
end
|
18
20
|
|
19
21
|
it "supports pagination" do
|
20
|
-
subject.
|
22
|
+
subject.list_tlds(page: 2)
|
21
23
|
|
22
24
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds?page=2")
|
23
25
|
end
|
24
26
|
|
25
27
|
it "supports additional options" do
|
26
|
-
subject.
|
28
|
+
subject.list_tlds(query: { foo: "bar" })
|
27
29
|
|
28
30
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds?foo=bar")
|
29
31
|
end
|
30
32
|
|
31
33
|
it "supports sorting" do
|
32
|
-
subject.
|
34
|
+
subject.list_tlds(sort: "tld:asc")
|
33
35
|
|
34
36
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds?sort=tld:asc")
|
35
37
|
end
|
36
38
|
|
37
39
|
it "returns the tlds" do
|
38
|
-
response = subject.
|
40
|
+
response = subject.list_tlds
|
39
41
|
|
40
42
|
expect(response).to be_a(Dnsimple::PaginatedResponse)
|
41
43
|
expect(response.data).to be_an(Array)
|
@@ -49,9 +51,9 @@ describe Dnsimple::Client, ".tlds" do
|
|
49
51
|
end
|
50
52
|
|
51
53
|
it "exposes the pagination information" do
|
52
|
-
response = subject.
|
54
|
+
response = subject.list_tlds
|
53
55
|
|
54
|
-
expect(response.respond_to?(:page)).to
|
56
|
+
expect(response.respond_to?(:page)).to be(true)
|
55
57
|
expect(response.page).to eq(1)
|
56
58
|
expect(response.per_page).to be_a(Integer)
|
57
59
|
expect(response.total_entries).to be_a(Integer)
|
@@ -66,7 +68,7 @@ describe Dnsimple::Client, ".tlds" do
|
|
66
68
|
end
|
67
69
|
|
68
70
|
it "delegates to client.paginate" do
|
69
|
-
expect(subject).to receive(:paginate).with(:
|
71
|
+
expect(subject).to receive(:paginate).with(:list_tlds, foo: "bar")
|
70
72
|
subject.all_tlds(foo: "bar")
|
71
73
|
end
|
72
74
|
|
@@ -98,31 +100,31 @@ describe Dnsimple::Client, ".tlds" do
|
|
98
100
|
expect(result).to be_a(Dnsimple::Struct::Tld)
|
99
101
|
expect(result.tld).to eq('com')
|
100
102
|
expect(result.tld_type).to eq(1)
|
101
|
-
expect(result.whois_privacy).to
|
102
|
-
expect(result.auto_renew_only).to
|
103
|
-
expect(result.idn).to
|
103
|
+
expect(result.whois_privacy).to be(true)
|
104
|
+
expect(result.auto_renew_only).to be(false)
|
105
|
+
expect(result.idn).to be(true)
|
104
106
|
expect(result.minimum_registration).to eq(1)
|
105
|
-
expect(result.registration_enabled).to
|
106
|
-
expect(result.renewal_enabled).to
|
107
|
-
expect(result.transfer_enabled).to
|
107
|
+
expect(result.registration_enabled).to be(true)
|
108
|
+
expect(result.renewal_enabled).to be(true)
|
109
|
+
expect(result.transfer_enabled).to be(true)
|
108
110
|
end
|
109
111
|
end
|
110
112
|
|
111
|
-
describe "#
|
113
|
+
describe "#tld_extended_attributes" do
|
112
114
|
before do
|
113
115
|
stub_request(:get, %r{/v2/tlds/uk/extended_attributes$})
|
114
116
|
.to_return(read_http_fixture("getTldExtendedAttributes/success.http"))
|
115
117
|
end
|
116
118
|
|
117
119
|
it "builds the correct request" do
|
118
|
-
subject.
|
120
|
+
subject.tld_extended_attributes(tld = "uk")
|
119
121
|
|
120
122
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds/#{tld}/extended_attributes")
|
121
123
|
.with(headers: { 'Accept' => 'application/json' })
|
122
124
|
end
|
123
125
|
|
124
126
|
it "returns the extended attributes" do
|
125
|
-
response = subject.
|
127
|
+
response = subject.tld_extended_attributes("uk")
|
126
128
|
expect(response).to be_a(Dnsimple::CollectionResponse)
|
127
129
|
|
128
130
|
response.data.each do |result|
|
@@ -132,6 +134,7 @@ describe Dnsimple::Client, ".tlds" do
|
|
132
134
|
expect(result).to respond_to(:required)
|
133
135
|
|
134
136
|
next if result.options.empty?
|
137
|
+
|
135
138
|
result.options.each do |option|
|
136
139
|
expect(option).to be_a(Dnsimple::Struct::ExtendedAttribute::Option)
|
137
140
|
expect(option.title).to be_a(String)
|
@@ -148,7 +151,7 @@ describe Dnsimple::Client, ".tlds" do
|
|
148
151
|
end
|
149
152
|
|
150
153
|
it "returns an empty CollectionResponse" do
|
151
|
-
response = subject.
|
154
|
+
response = subject.tld_extended_attributes("com")
|
152
155
|
expect(response).to be_a(Dnsimple::CollectionResponse)
|
153
156
|
|
154
157
|
result = response.data
|
@@ -0,0 +1,137 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Dnsimple::Client, ".zones" do
|
6
|
+
|
7
|
+
subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").zones }
|
8
|
+
|
9
|
+
describe "#zone_distribution" do
|
10
|
+
let(:account_id) { 1010 }
|
11
|
+
|
12
|
+
before do
|
13
|
+
stub_request(:get, %r{/v2/#{account_id}/zones/.+$})
|
14
|
+
.to_return(read_http_fixture("checkZoneDistribution/success.http"))
|
15
|
+
end
|
16
|
+
|
17
|
+
it "builds the correct request" do
|
18
|
+
subject.zone_distribution(account_id, zone = "example.com")
|
19
|
+
|
20
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone}/distribution")
|
21
|
+
.with(headers: { 'Accept' => 'application/json' })
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns the zone distribution check with true when the zone is fully distributed" do
|
25
|
+
response = subject.zone_distribution(account_id, "example.com")
|
26
|
+
expect(response).to be_a(Dnsimple::Response)
|
27
|
+
|
28
|
+
result = response.data
|
29
|
+
expect(result).to be_a(Dnsimple::Struct::ZoneDistribution)
|
30
|
+
expect(result.distributed).to be(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns the zone distribution check with false when the zone isn't fully distributed" do
|
34
|
+
stub_request(:get, %r{/v2/#{account_id}/zones/.+$})
|
35
|
+
.to_return(read_http_fixture("checkZoneDistribution/failure.http"))
|
36
|
+
|
37
|
+
response = subject.zone_distribution(account_id, "example.com")
|
38
|
+
expect(response).to be_a(Dnsimple::Response)
|
39
|
+
|
40
|
+
result = response.data
|
41
|
+
expect(result).to be_a(Dnsimple::Struct::ZoneDistribution)
|
42
|
+
expect(result.distributed).to be(false)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "raises an error when the server wasn't able to complete the check" do
|
46
|
+
stub_request(:get, %r{/v2/#{account_id}/zones/.+$})
|
47
|
+
.to_return(read_http_fixture("checkZoneDistribution/error.http"))
|
48
|
+
|
49
|
+
expect {
|
50
|
+
subject.zone_distribution(account_id, "example.com")
|
51
|
+
}.to raise_error(Dnsimple::RequestError, "Could not query zone, connection timed out")
|
52
|
+
end
|
53
|
+
|
54
|
+
context "when the zone does not exist" do
|
55
|
+
it "raises NotFoundError" do
|
56
|
+
stub_request(:get, %r{/v2})
|
57
|
+
.to_return(read_http_fixture("notfound-zone.http"))
|
58
|
+
|
59
|
+
expect {
|
60
|
+
subject.zone_distribution(account_id, "example.com")
|
61
|
+
}.to raise_error(Dnsimple::NotFoundError)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
describe "#zone_record_distribution" do
|
68
|
+
let(:account_id) { 1010 }
|
69
|
+
let(:zone_id) { "example.com" }
|
70
|
+
let(:record_id) { 5 }
|
71
|
+
|
72
|
+
before do
|
73
|
+
stub_request(:get, %r{/v2/#{account_id}/zones/#{zone_id}/records/#{record_id}/distribution$})
|
74
|
+
.to_return(read_http_fixture("checkZoneRecordDistribution/success.http"))
|
75
|
+
end
|
76
|
+
|
77
|
+
it "builds the correct request" do
|
78
|
+
subject.zone_record_distribution(account_id, zone_id, record_id)
|
79
|
+
|
80
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records/#{record_id}/distribution")
|
81
|
+
.with(headers: { 'Accept' => 'application/json' })
|
82
|
+
end
|
83
|
+
|
84
|
+
it "returns the zone record distribution check with true when the zone is fully distributed" do
|
85
|
+
response = subject.zone_record_distribution(account_id, zone_id, record_id)
|
86
|
+
expect(response).to be_a(Dnsimple::Response)
|
87
|
+
|
88
|
+
result = response.data
|
89
|
+
expect(result).to be_a(Dnsimple::Struct::ZoneDistribution)
|
90
|
+
expect(result.distributed).to be(true)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "returns the zone distribution check with false when the zone isn't fully distributed" do
|
94
|
+
stub_request(:get, %r{/v2/#{account_id}/zones/#{zone_id}/records/#{record_id}/distribution$})
|
95
|
+
.to_return(read_http_fixture("checkZoneRecordDistribution/failure.http"))
|
96
|
+
|
97
|
+
response = subject.zone_record_distribution(account_id, zone_id, record_id)
|
98
|
+
expect(response).to be_a(Dnsimple::Response)
|
99
|
+
|
100
|
+
result = response.data
|
101
|
+
expect(result).to be_a(Dnsimple::Struct::ZoneDistribution)
|
102
|
+
expect(result.distributed).to be(false)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "raises an error when the server wasn't able to complete the check" do
|
106
|
+
stub_request(:get, %r{/v2/#{account_id}/zones/#{zone_id}/records/#{record_id}/distribution$})
|
107
|
+
.to_return(read_http_fixture("checkZoneRecordDistribution/error.http"))
|
108
|
+
|
109
|
+
expect {
|
110
|
+
subject.zone_record_distribution(account_id, zone_id, record_id)
|
111
|
+
}.to raise_error(Dnsimple::RequestError, "Could not query zone, connection timed out")
|
112
|
+
end
|
113
|
+
|
114
|
+
context "when the zone does not exist" do
|
115
|
+
it "raises NotFoundError" do
|
116
|
+
stub_request(:get, %r{/v2})
|
117
|
+
.to_return(read_http_fixture("notfound-zone.http"))
|
118
|
+
|
119
|
+
expect {
|
120
|
+
subject.zone_record_distribution(account_id, zone_id, "0")
|
121
|
+
}.to raise_error(Dnsimple::NotFoundError)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context "when the record does not exist" do
|
126
|
+
it "raises NotFoundError" do
|
127
|
+
stub_request(:get, %r{/v2})
|
128
|
+
.to_return(read_http_fixture("notfound-record.http"))
|
129
|
+
|
130
|
+
expect {
|
131
|
+
subject.zone_record_distribution(account_id, zone_id, "0")
|
132
|
+
}.to raise_error(Dnsimple::NotFoundError)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Dnsimple::Client, ".zones" do
|
@@ -5,7 +7,7 @@ describe Dnsimple::Client, ".zones" do
|
|
5
7
|
subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").zones }
|
6
8
|
|
7
9
|
|
8
|
-
describe "#
|
10
|
+
describe "#list_zone_records" do
|
9
11
|
let(:account_id) { 1010 }
|
10
12
|
let(:zone_id) { "example.com" }
|
11
13
|
|
@@ -15,38 +17,38 @@ describe Dnsimple::Client, ".zones" do
|
|
15
17
|
end
|
16
18
|
|
17
19
|
it "builds the correct request" do
|
18
|
-
subject.
|
20
|
+
subject.list_zone_records(account_id, zone_id)
|
19
21
|
|
20
22
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records")
|
21
23
|
.with(headers: { 'Accept' => 'application/json' })
|
22
24
|
end
|
23
25
|
|
24
26
|
it "supports pagination" do
|
25
|
-
subject.
|
27
|
+
subject.list_zone_records(account_id, zone_id, page: 2)
|
26
28
|
|
27
29
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records?page=2")
|
28
30
|
end
|
29
31
|
|
30
32
|
it "supports extra request options" do
|
31
|
-
subject.
|
33
|
+
subject.list_zone_records(account_id, zone_id, query: { foo: "bar" })
|
32
34
|
|
33
35
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records?foo=bar")
|
34
36
|
end
|
35
37
|
|
36
38
|
it "supports sorting" do
|
37
|
-
subject.
|
39
|
+
subject.list_zone_records(account_id, zone_id, sort: "type:asc")
|
38
40
|
|
39
41
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records?sort=type:asc")
|
40
42
|
end
|
41
43
|
|
42
44
|
it "supports filtering" do
|
43
|
-
subject.
|
45
|
+
subject.list_zone_records(account_id, zone_id, filter: { type: "A" })
|
44
46
|
|
45
47
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records?type=A")
|
46
48
|
end
|
47
49
|
|
48
50
|
it "returns the records" do
|
49
|
-
response = subject.
|
51
|
+
response = subject.list_zone_records(account_id, zone_id)
|
50
52
|
|
51
53
|
expect(response).to be_a(Dnsimple::PaginatedResponse)
|
52
54
|
expect(response.data).to be_a(Array)
|
@@ -60,9 +62,9 @@ describe Dnsimple::Client, ".zones" do
|
|
60
62
|
end
|
61
63
|
|
62
64
|
it "exposes the pagination information" do
|
63
|
-
response = subject.
|
65
|
+
response = subject.list_zone_records(account_id, zone_id)
|
64
66
|
|
65
|
-
expect(response.respond_to?(:page)).to
|
67
|
+
expect(response.respond_to?(:page)).to be(true)
|
66
68
|
expect(response.page).to eq(1)
|
67
69
|
expect(response.per_page).to be_a(Integer)
|
68
70
|
expect(response.total_entries).to be_a(Integer)
|
@@ -75,13 +77,13 @@ describe Dnsimple::Client, ".zones" do
|
|
75
77
|
.to_return(read_http_fixture("notfound-zone.http"))
|
76
78
|
|
77
79
|
expect {
|
78
|
-
subject.
|
80
|
+
subject.list_zone_records(account_id, zone_id)
|
79
81
|
}.to raise_error(Dnsimple::NotFoundError)
|
80
82
|
end
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
84
|
-
describe "#
|
86
|
+
describe "#all_zone_records" do
|
85
87
|
before do
|
86
88
|
stub_request(:get, %r{/v2/#{account_id}/zones/#{zone_id}/records})
|
87
89
|
.to_return(read_http_fixture("listZoneRecords/success.http"))
|
@@ -91,24 +93,24 @@ describe Dnsimple::Client, ".zones" do
|
|
91
93
|
let(:zone_id) { "example.com" }
|
92
94
|
|
93
95
|
it "delegates to client.paginate" do
|
94
|
-
expect(subject).to receive(:paginate).with(:
|
95
|
-
subject.
|
96
|
+
expect(subject).to receive(:paginate).with(:list_zone_records, account_id, zone_id, foo: "bar")
|
97
|
+
subject.all_zone_records(account_id, zone_id, foo: "bar")
|
96
98
|
end
|
97
99
|
|
98
100
|
it "supports sorting" do
|
99
|
-
subject.
|
101
|
+
subject.all_zone_records(account_id, zone_id, sort: "type:asc")
|
100
102
|
|
101
103
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records?page=1&per_page=100&sort=type:asc")
|
102
104
|
end
|
103
105
|
|
104
106
|
it "supports filtering" do
|
105
|
-
subject.
|
107
|
+
subject.all_zone_records(account_id, zone_id, filter: { name: "foo", type: "AAAA" })
|
106
108
|
|
107
109
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records?page=1&per_page=100&name=foo&type=AAAA")
|
108
110
|
end
|
109
111
|
end
|
110
112
|
|
111
|
-
describe "#
|
113
|
+
describe "#create_zone_record" do
|
112
114
|
let(:account_id) { 1010 }
|
113
115
|
let(:zone_id) { "example.com" }
|
114
116
|
|
@@ -120,7 +122,7 @@ describe Dnsimple::Client, ".zones" do
|
|
120
122
|
let(:attributes) { { type: "A", name: "www", content: "127.0.0.1", regions: %w(global) } }
|
121
123
|
|
122
124
|
it "builds the correct request" do
|
123
|
-
subject.
|
125
|
+
subject.create_zone_record(account_id, zone_id, attributes)
|
124
126
|
|
125
127
|
expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records")
|
126
128
|
.with(body: attributes)
|
@@ -128,7 +130,7 @@ describe Dnsimple::Client, ".zones" do
|
|
128
130
|
end
|
129
131
|
|
130
132
|
it "returns the record" do
|
131
|
-
response = subject.
|
133
|
+
response = subject.create_zone_record(account_id, zone_id, attributes)
|
132
134
|
expect(response).to be_a(Dnsimple::Response)
|
133
135
|
|
134
136
|
result = response.data
|
@@ -146,13 +148,13 @@ describe Dnsimple::Client, ".zones" do
|
|
146
148
|
.to_return(read_http_fixture("notfound-zone.http"))
|
147
149
|
|
148
150
|
expect {
|
149
|
-
subject.
|
151
|
+
subject.create_zone_record(account_id, zone_id, attributes)
|
150
152
|
}.to raise_error(Dnsimple::NotFoundError)
|
151
153
|
end
|
152
154
|
end
|
153
155
|
end
|
154
156
|
|
155
|
-
describe "#
|
157
|
+
describe "#zone_record" do
|
156
158
|
let(:account_id) { 1010 }
|
157
159
|
let(:zone_id) { "example.com" }
|
158
160
|
let(:record_id) { 5 }
|
@@ -163,14 +165,14 @@ describe Dnsimple::Client, ".zones" do
|
|
163
165
|
end
|
164
166
|
|
165
167
|
it "builds the correct request" do
|
166
|
-
subject.
|
168
|
+
subject.zone_record(account_id, zone_id, record_id)
|
167
169
|
|
168
170
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records/#{record_id}")
|
169
171
|
.with(headers: { 'Accept' => 'application/json' })
|
170
172
|
end
|
171
173
|
|
172
174
|
it "returns the record" do
|
173
|
-
response = subject.
|
175
|
+
response = subject.zone_record(account_id, zone_id, record_id)
|
174
176
|
expect(response).to be_a(Dnsimple::Response)
|
175
177
|
|
176
178
|
result = response.data
|
@@ -183,7 +185,7 @@ describe Dnsimple::Client, ".zones" do
|
|
183
185
|
expect(result.content).to eq("mxa.example.com")
|
184
186
|
expect(result.ttl).to eq(600)
|
185
187
|
expect(result.priority).to eq(10)
|
186
|
-
expect(result.system_record).to
|
188
|
+
expect(result.system_record).to be(false)
|
187
189
|
expect(result.regions).to eq(%w(SV1 IAD))
|
188
190
|
expect(result.created_at).to eq("2016-10-05T09:51:35Z")
|
189
191
|
expect(result.updated_at).to eq("2016-10-05T09:51:35Z")
|
@@ -195,7 +197,7 @@ describe Dnsimple::Client, ".zones" do
|
|
195
197
|
.to_return(read_http_fixture("notfound-zone.http"))
|
196
198
|
|
197
199
|
expect {
|
198
|
-
subject.
|
200
|
+
subject.zone_record(account_id, zone_id, "0")
|
199
201
|
}.to raise_error(Dnsimple::NotFoundError)
|
200
202
|
end
|
201
203
|
end
|
@@ -206,13 +208,13 @@ describe Dnsimple::Client, ".zones" do
|
|
206
208
|
.to_return(read_http_fixture("notfound-record.http"))
|
207
209
|
|
208
210
|
expect {
|
209
|
-
subject.
|
211
|
+
subject.zone_record(account_id, zone_id, "0")
|
210
212
|
}.to raise_error(Dnsimple::NotFoundError)
|
211
213
|
end
|
212
214
|
end
|
213
215
|
end
|
214
216
|
|
215
|
-
describe "#
|
217
|
+
describe "#update_zone_record" do
|
216
218
|
let(:account_id) { 1010 }
|
217
219
|
let(:zone_id) { "example.com" }
|
218
220
|
let(:record_id) { 5 }
|
@@ -225,7 +227,7 @@ describe Dnsimple::Client, ".zones" do
|
|
225
227
|
let(:attributes) { { content: "mxb.example.com", priority: "20", regions: ['global'] } }
|
226
228
|
|
227
229
|
it "builds the correct request" do
|
228
|
-
subject.
|
230
|
+
subject.update_zone_record(account_id, zone_id, record_id, attributes)
|
229
231
|
|
230
232
|
expect(WebMock).to have_requested(:patch, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records/#{record_id}")
|
231
233
|
.with(body: attributes)
|
@@ -233,7 +235,7 @@ describe Dnsimple::Client, ".zones" do
|
|
233
235
|
end
|
234
236
|
|
235
237
|
it "returns the record" do
|
236
|
-
response = subject.
|
238
|
+
response = subject.update_zone_record(account_id, zone_id, record_id, attributes)
|
237
239
|
expect(response).to be_a(Dnsimple::Response)
|
238
240
|
|
239
241
|
result = response.data
|
@@ -250,7 +252,7 @@ describe Dnsimple::Client, ".zones" do
|
|
250
252
|
.to_return(read_http_fixture("notfound-zone.http"))
|
251
253
|
|
252
254
|
expect {
|
253
|
-
subject.
|
255
|
+
subject.update_zone_record(account_id, zone_id, "0", {})
|
254
256
|
}.to raise_error(Dnsimple::NotFoundError)
|
255
257
|
end
|
256
258
|
end
|
@@ -261,13 +263,13 @@ describe Dnsimple::Client, ".zones" do
|
|
261
263
|
.to_return(read_http_fixture("notfound-record.http"))
|
262
264
|
|
263
265
|
expect {
|
264
|
-
subject.
|
266
|
+
subject.update_zone_record(account_id, zone_id, "0", {})
|
265
267
|
}.to raise_error(Dnsimple::NotFoundError)
|
266
268
|
end
|
267
269
|
end
|
268
270
|
end
|
269
271
|
|
270
|
-
describe "#
|
272
|
+
describe "#delete_zone_record" do
|
271
273
|
let(:account_id) { 1010 }
|
272
274
|
let(:zone_id) { "example.com" }
|
273
275
|
|
@@ -277,14 +279,14 @@ describe Dnsimple::Client, ".zones" do
|
|
277
279
|
end
|
278
280
|
|
279
281
|
it "builds the correct request" do
|
280
|
-
subject.
|
282
|
+
subject.delete_zone_record(account_id, zone_id, record_id = 2)
|
281
283
|
|
282
284
|
expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records/#{record_id}")
|
283
285
|
.with(headers: { 'Accept' => 'application/json' })
|
284
286
|
end
|
285
287
|
|
286
288
|
it "returns nothing" do
|
287
|
-
response = subject.
|
289
|
+
response = subject.delete_zone_record(account_id, zone_id, 2)
|
288
290
|
expect(response).to be_a(Dnsimple::Response)
|
289
291
|
|
290
292
|
result = response.data
|
@@ -297,7 +299,7 @@ describe Dnsimple::Client, ".zones" do
|
|
297
299
|
.to_return(read_http_fixture("notfound-zone.http"))
|
298
300
|
|
299
301
|
expect {
|
300
|
-
subject.
|
302
|
+
subject.delete_zone_record(account_id, zone_id, "0")
|
301
303
|
}.to raise_error(Dnsimple::NotFoundError)
|
302
304
|
end
|
303
305
|
end
|
@@ -308,7 +310,7 @@ describe Dnsimple::Client, ".zones" do
|
|
308
310
|
.to_return(read_http_fixture("notfound-record.http"))
|
309
311
|
|
310
312
|
expect {
|
311
|
-
subject.
|
313
|
+
subject.delete_zone_record(account_id, zone_id, "0")
|
312
314
|
}.to raise_error(Dnsimple::NotFoundError)
|
313
315
|
end
|
314
316
|
end
|