dnsimple 5.2.0 → 7.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -0
- data/.github/dependabot.yml +13 -0
- data/.github/workflows/ci.yml +63 -0
- data/.github/workflows/release.yml +19 -0
- data/.gitignore +3 -0
- data/.markdownlint.yaml +3 -0
- data/.rubocop.yml +7 -16
- data/.rubocop_dnsimple.yml +28 -55
- data/.rubocop_todo.yml +44 -5
- data/CHANGELOG.md +24 -10
- data/CONTRIBUTING.md +8 -23
- data/Gemfile +3 -1
- data/LICENSE.txt +1 -1
- data/README.md +7 -11
- data/UPGRADING.md +4 -5
- data/dnsimple.gemspec +1 -1
- data/lib/dnsimple/client/clients.rb +3 -2
- data/lib/dnsimple/client/domains.rb +0 -18
- data/lib/dnsimple/client/domains_delegation_signer_records.rb +5 -4
- data/lib/dnsimple/client/registrar.rb +23 -0
- data/lib/dnsimple/client/registrar_whois_privacy.rb +1 -1
- data/lib/dnsimple/client.rb +11 -3
- data/lib/dnsimple/default.rb +2 -2
- data/lib/dnsimple/error.rb +1 -1
- data/lib/dnsimple/extra.rb +3 -3
- data/lib/dnsimple/response.rb +1 -3
- data/lib/dnsimple/struct/certificate.rb +0 -19
- data/lib/dnsimple/struct/delegation_signer_record.rb +3 -0
- data/lib/dnsimple/struct/domain.rb +0 -20
- data/lib/dnsimple/struct/domain_price.rb +24 -0
- data/lib/dnsimple/struct/tld.rb +3 -0
- data/lib/dnsimple/struct.rb +1 -0
- data/lib/dnsimple/version.rb +1 -1
- data/spec/dnsimple/client/certificates_spec.rb +0 -1
- data/spec/dnsimple/client/client_service_spec.rb +1 -1
- data/spec/dnsimple/client/contacts_spec.rb +2 -2
- data/spec/dnsimple/client/domains_collaborators_spec.rb +2 -2
- data/spec/dnsimple/client/domains_delegation_signer_records_spec.rb +2 -1
- data/spec/dnsimple/client/domains_email_forwards_spec.rb +8 -8
- data/spec/dnsimple/client/domains_pushes_spec.rb +2 -2
- data/spec/dnsimple/client/domains_spec.rb +1 -29
- data/spec/dnsimple/client/registrar_delegation_spec.rb +2 -2
- data/spec/dnsimple/client/registrar_spec.rb +46 -3
- data/spec/dnsimple/client/services_domains_spec.rb +2 -4
- data/spec/dnsimple/client/services_spec.rb +1 -3
- data/spec/dnsimple/client/templates_records_spec.rb +1 -1
- data/spec/dnsimple/client/templates_spec.rb +2 -2
- data/spec/dnsimple/client/tlds_spec.rb +1 -0
- data/spec/dnsimple/client/webhooks_spec.rb +1 -1
- data/spec/dnsimple/client/zones_records_spec.rb +2 -2
- data/spec/dnsimple/client/zones_spec.rb +1 -1
- data/spec/dnsimple/client_spec.rb +15 -15
- data/spec/dnsimple/extra_spec.rb +1 -1
- data/spec/dnsimple/options/list_options_spec.rb +4 -4
- data/spec/fixtures.http/accounts/success-account.http +0 -1
- data/spec/fixtures.http/accounts/success-user.http +0 -1
- data/spec/fixtures.http/addCollaborator/invite-success.http +0 -1
- data/spec/fixtures.http/addCollaborator/success.http +0 -1
- data/spec/fixtures.http/appliedServices/success.http +0 -1
- data/spec/fixtures.http/cancelDomainTransfer/success.http +0 -1
- data/spec/fixtures.http/changeDomainDelegation/success.http +0 -1
- data/spec/fixtures.http/changeDomainDelegationToVanity/success.http +0 -1
- data/spec/fixtures.http/checkDomain/success.http +0 -1
- data/spec/fixtures.http/checkDomainPremiumPrice/error_400_not_a_premium_domain.http +18 -0
- data/spec/fixtures.http/checkDomainPremiumPrice/error_400_tld_not_supported.http +18 -0
- data/spec/fixtures.http/checkDomainPremiumPrice/success.http +20 -0
- data/spec/fixtures.http/checkZoneDistribution/error.http +0 -1
- data/spec/fixtures.http/checkZoneDistribution/failure.http +0 -1
- data/spec/fixtures.http/checkZoneDistribution/success.http +0 -1
- data/spec/fixtures.http/checkZoneRecordDistribution/error.http +0 -1
- data/spec/fixtures.http/checkZoneRecordDistribution/failure.http +0 -1
- data/spec/fixtures.http/checkZoneRecordDistribution/success.http +0 -1
- data/spec/fixtures.http/createContact/created.http +0 -1
- data/spec/fixtures.http/createDelegationSignerRecord/created.http +1 -2
- data/spec/fixtures.http/createDelegationSignerRecord/validation-error.http +0 -1
- data/spec/fixtures.http/createDomain/created.http +0 -1
- data/spec/fixtures.http/createEmailForward/created.http +21 -17
- data/spec/fixtures.http/createPrimaryServer/created.http +21 -0
- data/spec/fixtures.http/createSecondaryZone/created.http +21 -0
- data/spec/fixtures.http/createTemplate/created.http +0 -1
- data/spec/fixtures.http/createTemplateRecord/created.http +0 -1
- data/spec/fixtures.http/createWebhook/created.http +0 -1
- data/spec/fixtures.http/createZoneRecord/created-apex.http +0 -1
- data/spec/fixtures.http/createZoneRecord/created.http +0 -1
- data/spec/fixtures.http/deleteContact/error-contact-in-use.http +18 -0
- data/spec/fixtures.http/deleteEmailForward/success.http +12 -7
- data/spec/fixtures.http/disableDnssec/not-enabled.http +0 -1
- data/spec/fixtures.http/disableWhoisPrivacy/success.http +0 -1
- data/spec/fixtures.http/downloadCertificate/success.http +0 -1
- data/spec/fixtures.http/enableDnssec/success.http +0 -1
- data/spec/fixtures.http/enableVanityNameServers/success.http +0 -1
- data/spec/fixtures.http/enableWhoisPrivacy/created.http +0 -1
- data/spec/fixtures.http/enableWhoisPrivacy/success.http +0 -1
- data/spec/fixtures.http/getCertificate/success.http +0 -1
- data/spec/fixtures.http/getCertificatePrivateKey/success.http +0 -1
- data/spec/fixtures.http/getContact/success.http +0 -1
- data/spec/fixtures.http/getDelegationSignerRecord/success.http +1 -2
- data/spec/fixtures.http/getDnssec/success.http +0 -1
- data/spec/fixtures.http/getDomain/success.http +0 -1
- data/spec/fixtures.http/getDomainDelegation/success-empty.http +0 -1
- data/spec/fixtures.http/getDomainDelegation/success.http +0 -1
- data/spec/fixtures.http/getDomainPremiumPrice/failure.http +0 -1
- data/spec/fixtures.http/getDomainPremiumPrice/success.http +0 -1
- data/spec/fixtures.http/getDomainPrices/failure.http +19 -0
- data/spec/fixtures.http/getDomainPrices/success.http +21 -0
- data/spec/fixtures.http/getDomainTransfer/success.http +0 -1
- data/spec/fixtures.http/getEmailForward/success.http +14 -10
- data/spec/fixtures.http/getPrimaryServer/success.http +21 -0
- data/spec/fixtures.http/getService/success.http +0 -1
- data/spec/fixtures.http/getTemplate/success.http +0 -1
- data/spec/fixtures.http/getTemplateRecord/success.http +0 -1
- data/spec/fixtures.http/getTld/success.http +1 -2
- data/spec/fixtures.http/getTldExtendedAttributes/success-attributes.http +0 -1
- data/spec/fixtures.http/getTldExtendedAttributes/success-noattributes.http +0 -1
- data/spec/fixtures.http/getTldExtendedAttributes/success.http +0 -1
- data/spec/fixtures.http/getWebhook/success.http +0 -1
- data/spec/fixtures.http/getWhoisPrivacy/success.http +0 -1
- data/spec/fixtures.http/getZone/success.http +0 -1
- data/spec/fixtures.http/getZoneFile/success.http +0 -1
- data/spec/fixtures.http/getZoneRecord/success.http +0 -1
- data/spec/fixtures.http/initiatePush/success.http +0 -1
- data/spec/fixtures.http/issueLetsencryptCertificate/success.http +0 -1
- data/spec/fixtures.http/issueRenewalLetsencryptCertificate/success.http +0 -1
- data/spec/fixtures.http/linkPrimaryServer/success.http +21 -0
- data/spec/fixtures.http/listAccounts/success-account.http +0 -1
- data/spec/fixtures.http/listAccounts/success-user.http +0 -1
- data/spec/fixtures.http/listCertificates/success.http +0 -1
- data/spec/fixtures.http/listCollaborators/success.http +0 -1
- data/spec/fixtures.http/listContacts/success.http +0 -1
- data/spec/fixtures.http/listDelegationSignerRecords/success.http +1 -2
- data/spec/fixtures.http/listDomains/success.http +0 -1
- data/spec/fixtures.http/listEmailForwards/success.http +0 -1
- data/spec/fixtures.http/listPrimaryServers/success.http +21 -0
- data/spec/fixtures.http/listPushes/success.http +0 -1
- data/spec/fixtures.http/listServices/success.http +0 -1
- data/spec/fixtures.http/listTemplateRecords/success.http +0 -1
- data/spec/fixtures.http/listTemplates/success.http +0 -1
- data/spec/fixtures.http/listTlds/success.http +1 -2
- data/spec/fixtures.http/listWebhooks/success.http +0 -1
- data/spec/fixtures.http/listZoneRecords/success.http +0 -1
- data/spec/fixtures.http/listZones/success.http +0 -1
- data/spec/fixtures.http/method-not-allowed.http +0 -1
- data/spec/fixtures.http/notfound-certificate.http +0 -1
- data/spec/fixtures.http/notfound-collaborator.http +0 -1
- data/spec/fixtures.http/notfound-contact.http +0 -1
- data/spec/fixtures.http/notfound-delegationsignerrecord.http +0 -1
- data/spec/fixtures.http/notfound-domain.http +0 -1
- data/spec/fixtures.http/notfound-domainpush.http +0 -1
- data/spec/fixtures.http/notfound-emailforward.http +0 -1
- data/spec/fixtures.http/notfound-record.http +0 -1
- data/spec/fixtures.http/notfound-template.http +0 -1
- data/spec/fixtures.http/notfound-webhook.http +0 -1
- data/spec/fixtures.http/notfound-whoisprivacy.http +0 -1
- data/spec/fixtures.http/notfound-zone.http +0 -1
- data/spec/fixtures.http/oauthAccessToken/error-invalid-request.http +0 -1
- data/spec/fixtures.http/oauthAccessToken/success.http +0 -1
- data/spec/fixtures.http/pages-1of3.http +0 -1
- data/spec/fixtures.http/pages-2of3.http +0 -1
- data/spec/fixtures.http/pages-3of3.http +0 -1
- data/spec/fixtures.http/purchaseLetsencryptCertificate/success.http +0 -1
- data/spec/fixtures.http/purchaseRenewalLetsencryptCertificate/success.http +0 -1
- data/spec/fixtures.http/registerDomain/success.http +0 -1
- data/spec/fixtures.http/renewDomain/error-tooearly.http +0 -1
- data/spec/fixtures.http/renewDomain/success.http +0 -1
- data/spec/fixtures.http/renewWhoisPrivacy/success.http +0 -1
- data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-duplicated-order.http +0 -1
- data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-not-found.http +0 -1
- data/spec/fixtures.http/response.http +0 -1
- data/spec/fixtures.http/transferDomain/error-indnsimple.http +0 -1
- data/spec/fixtures.http/transferDomain/error-missing-authcode.http +0 -1
- data/spec/fixtures.http/transferDomain/success.http +0 -1
- data/spec/fixtures.http/unlinkPrimaryServer/success.http +21 -0
- data/spec/fixtures.http/updateContact/success.http +0 -1
- data/spec/fixtures.http/updateTemplate/success.http +0 -1
- data/spec/fixtures.http/updateZoneRecord/success.http +0 -1
- data/spec/fixtures.http/validation-error.http +0 -1
- data/spec/fixtures.http/whoami/success-account.http +0 -1
- data/spec/fixtures.http/whoami/success-user.http +0 -1
- data/spec/fixtures.http/whoami/success.http +0 -1
- data/spec/spec_helper.rb +2 -2
- metadata +23 -177
- data/.dependabot/config.yml +0 -9
- data/.travis.yml +0 -17
- data/spec/fixtures.http/resetDomainToken/success.http +0 -17
@@ -82,15 +82,58 @@ describe Dnsimple::Client, ".registrar" do
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
+
describe "#get_domain_prices" do
|
86
|
+
let(:account_id) { 1010 }
|
87
|
+
|
88
|
+
before do
|
89
|
+
stub_request(:get, %r{/v2/#{account_id}/registrar/domains/bingo.pizza/prices$})
|
90
|
+
.to_return(read_http_fixture("getDomainPrices/success.http"))
|
91
|
+
end
|
92
|
+
|
93
|
+
it "builds the correct request" do
|
94
|
+
subject.get_domain_prices(account_id, "bingo.pizza")
|
95
|
+
|
96
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/bingo.pizza/prices")
|
97
|
+
.with(headers: { "Accept" => "application/json" })
|
98
|
+
end
|
99
|
+
|
100
|
+
it "returns the prices" do
|
101
|
+
response = subject.get_domain_prices(account_id, "bingo.pizza")
|
102
|
+
expect(response).to be_a(Dnsimple::Response)
|
103
|
+
|
104
|
+
result = response.data
|
105
|
+
|
106
|
+
expect(result).to be_a(Dnsimple::Struct::DomainPrice)
|
107
|
+
expect(result.domain).to eq("bingo.pizza")
|
108
|
+
expect(result.premium).to be(true)
|
109
|
+
expect(result.registration_price).to eq(20.0)
|
110
|
+
expect(result.renewal_price).to eq(20.0)
|
111
|
+
expect(result.transfer_price).to eq(20.0)
|
112
|
+
end
|
113
|
+
|
114
|
+
context "when the TLD is not supported" do
|
115
|
+
before do
|
116
|
+
stub_request(:get, %r{/v2/#{account_id}/registrar/domains/bingo.pineapple/prices$})
|
117
|
+
.to_return(read_http_fixture("getDomainPrices/failure.http"))
|
118
|
+
end
|
119
|
+
|
120
|
+
it "raises error" do
|
121
|
+
expect {
|
122
|
+
subject.get_domain_prices(account_id, "bingo.pineapple")
|
123
|
+
}.to raise_error(Dnsimple::RequestError, "TLD .PINEAPPLE is not supported")
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
85
128
|
describe "#register_domain" do
|
86
129
|
let(:account_id) { 1010 }
|
130
|
+
let(:attributes) { { registrant_id: "10" } }
|
87
131
|
|
88
132
|
before do
|
89
133
|
stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/registrations$})
|
90
134
|
.to_return(read_http_fixture("registerDomain/success.http"))
|
91
135
|
end
|
92
136
|
|
93
|
-
let(:attributes) { { registrant_id: "10" } }
|
94
137
|
|
95
138
|
it "builds the correct request" do
|
96
139
|
subject.register_domain(account_id, domain_name = "example.com", attributes)
|
@@ -119,13 +162,13 @@ describe Dnsimple::Client, ".registrar" do
|
|
119
162
|
|
120
163
|
describe "#renew_domain" do
|
121
164
|
let(:account_id) { 1010 }
|
165
|
+
let(:attributes) { { period: "3" } }
|
122
166
|
|
123
167
|
before do
|
124
168
|
stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/renewals$})
|
125
169
|
.to_return(read_http_fixture("renewDomain/success.http"))
|
126
170
|
end
|
127
171
|
|
128
|
-
let(:attributes) { { period: "3" } }
|
129
172
|
|
130
173
|
it "builds the correct request" do
|
131
174
|
subject.renew_domain(account_id, domain_name = "example.com", attributes)
|
@@ -159,13 +202,13 @@ describe Dnsimple::Client, ".registrar" do
|
|
159
202
|
|
160
203
|
describe "#transfer_domain" do
|
161
204
|
let(:account_id) { 1010 }
|
205
|
+
let(:attributes) { { registrant_id: "10", auth_code: "x1y2z3" } }
|
162
206
|
|
163
207
|
before do
|
164
208
|
stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/transfers$})
|
165
209
|
.to_return(read_http_fixture("transferDomain/success.http"))
|
166
210
|
end
|
167
211
|
|
168
|
-
let(:attributes) { { registrant_id: "10", auth_code: "x1y2z3" } }
|
169
212
|
|
170
213
|
it "builds the correct request" do
|
171
214
|
subject.transfer_domain(account_id, domain_name = "example.com", attributes)
|
@@ -52,15 +52,14 @@ describe Dnsimple::Client, ".services" do
|
|
52
52
|
expect(service.sid).to be_a(String)
|
53
53
|
expect(service.description).to be_a(String)
|
54
54
|
|
55
|
-
service.settings.
|
56
|
-
expect(service_setting).to be_a(Dnsimple::Struct::Service::Setting)
|
57
|
-
end
|
55
|
+
expect(service.settings).to all(be_a(Dnsimple::Struct::Service::Setting))
|
58
56
|
end
|
59
57
|
end
|
60
58
|
end
|
61
59
|
|
62
60
|
describe "#apply_service" do
|
63
61
|
let(:account_id) { 1010 }
|
62
|
+
let(:settings) { { app: "foo" } }
|
64
63
|
let(:domain_id) { "example.com" }
|
65
64
|
let(:service_id) { "service1" }
|
66
65
|
|
@@ -69,7 +68,6 @@ describe Dnsimple::Client, ".services" do
|
|
69
68
|
.to_return(read_http_fixture("applyService/success.http"))
|
70
69
|
end
|
71
70
|
|
72
|
-
let(:settings) { { app: "foo" } }
|
73
71
|
|
74
72
|
it "builds the correct request" do
|
75
73
|
subject.apply_service(account_id, service_id, domain_id, settings)
|
@@ -49,9 +49,7 @@ describe Dnsimple::Client, ".services" do
|
|
49
49
|
expect(service.sid).to be_a(String)
|
50
50
|
expect(service.description).to be_a(String)
|
51
51
|
|
52
|
-
service.settings.
|
53
|
-
expect(service_setting).to be_a(Dnsimple::Struct::Service::Setting)
|
54
|
-
end
|
52
|
+
expect(service.settings).to all(be_a(Dnsimple::Struct::Service::Setting))
|
55
53
|
end
|
56
54
|
end
|
57
55
|
end
|
@@ -78,6 +78,7 @@ describe Dnsimple::Client, ".templates" do
|
|
78
78
|
|
79
79
|
describe "#create_record" do
|
80
80
|
let(:account_id) { 1010 }
|
81
|
+
let(:attributes) { { type: "MX", name: "", content: "mx.example.com", priority: 10, ttl: 600 } }
|
81
82
|
let(:template_id) { "alpha" }
|
82
83
|
|
83
84
|
before do
|
@@ -85,7 +86,6 @@ describe Dnsimple::Client, ".templates" do
|
|
85
86
|
.to_return(read_http_fixture("createTemplateRecord/created.http"))
|
86
87
|
end
|
87
88
|
|
88
|
-
let(:attributes) { { type: "MX", name: "", content: "mx.example.com", priority: 10, ttl: 600 } }
|
89
89
|
|
90
90
|
it "builds the correct request" do
|
91
91
|
subject.create_record(account_id, template_id, attributes)
|
@@ -77,13 +77,13 @@ describe Dnsimple::Client, ".templates" do
|
|
77
77
|
|
78
78
|
describe "#create_template" do
|
79
79
|
let(:account_id) { 1010 }
|
80
|
+
let(:attributes) { { name: "Beta", short_name: "beta", description: "A beta template." } }
|
80
81
|
|
81
82
|
before do
|
82
83
|
stub_request(:post, %r{/v2/#{account_id}/templates$})
|
83
84
|
.to_return(read_http_fixture("createTemplate/created.http"))
|
84
85
|
end
|
85
86
|
|
86
|
-
let(:attributes) { { name: "Beta", short_name: "beta", description: "A beta template." } }
|
87
87
|
|
88
88
|
it "builds the correct request" do
|
89
89
|
subject.create_template(account_id, attributes)
|
@@ -138,6 +138,7 @@ describe Dnsimple::Client, ".templates" do
|
|
138
138
|
|
139
139
|
describe "#update_template" do
|
140
140
|
let(:account_id) { 1010 }
|
141
|
+
let(:attributes) { { name: "Alpha", short_name: "alpha", description: "An alpha template." } }
|
141
142
|
let(:template_id) { 1 }
|
142
143
|
|
143
144
|
before do
|
@@ -145,7 +146,6 @@ describe Dnsimple::Client, ".templates" do
|
|
145
146
|
.to_return(read_http_fixture("updateTemplate/success.http"))
|
146
147
|
end
|
147
148
|
|
148
|
-
let(:attributes) { { name: "Alpha", short_name: "alpha", description: "An alpha template." } }
|
149
149
|
|
150
150
|
it "builds the correct request" do
|
151
151
|
subject.update_template(account_id, template_id, attributes)
|
@@ -107,6 +107,7 @@ describe Dnsimple::Client, ".tlds" do
|
|
107
107
|
expect(result.registration_enabled).to be(true)
|
108
108
|
expect(result.renewal_enabled).to be(true)
|
109
109
|
expect(result.transfer_enabled).to be(true)
|
110
|
+
expect(result.dnssec_interface_type).to eq("ds")
|
110
111
|
end
|
111
112
|
end
|
112
113
|
|
@@ -49,13 +49,13 @@ describe Dnsimple::Client, ".webhooks" do
|
|
49
49
|
|
50
50
|
describe "#create_webhook" do
|
51
51
|
let(:account_id) { 1010 }
|
52
|
+
let(:attributes) { { url: "https://webhook.test" } }
|
52
53
|
|
53
54
|
before do
|
54
55
|
stub_request(:post, %r{/v2/#{account_id}/webhooks$})
|
55
56
|
.to_return(read_http_fixture("createWebhook/created.http"))
|
56
57
|
end
|
57
58
|
|
58
|
-
let(:attributes) { { url: "https://webhook.test" } }
|
59
59
|
|
60
60
|
it "builds the correct request" do
|
61
61
|
subject.create_webhook(account_id, attributes)
|
@@ -112,6 +112,7 @@ describe Dnsimple::Client, ".zones" do
|
|
112
112
|
|
113
113
|
describe "#create_zone_record" do
|
114
114
|
let(:account_id) { 1010 }
|
115
|
+
let(:attributes) { { type: "A", name: "www", content: "127.0.0.1", regions: %w(global) } }
|
115
116
|
let(:zone_id) { "example.com" }
|
116
117
|
|
117
118
|
before do
|
@@ -119,7 +120,6 @@ describe Dnsimple::Client, ".zones" do
|
|
119
120
|
.to_return(read_http_fixture("createZoneRecord/created.http"))
|
120
121
|
end
|
121
122
|
|
122
|
-
let(:attributes) { { type: "A", name: "www", content: "127.0.0.1", regions: %w(global) } }
|
123
123
|
|
124
124
|
it "builds the correct request" do
|
125
125
|
subject.create_zone_record(account_id, zone_id, attributes)
|
@@ -216,6 +216,7 @@ describe Dnsimple::Client, ".zones" do
|
|
216
216
|
|
217
217
|
describe "#update_zone_record" do
|
218
218
|
let(:account_id) { 1010 }
|
219
|
+
let(:attributes) { { content: "mxb.example.com", priority: "20", regions: ['global'] } }
|
219
220
|
let(:zone_id) { "example.com" }
|
220
221
|
let(:record_id) { 5 }
|
221
222
|
|
@@ -224,7 +225,6 @@ describe Dnsimple::Client, ".zones" do
|
|
224
225
|
.to_return(read_http_fixture("updateZoneRecord/success.http"))
|
225
226
|
end
|
226
227
|
|
227
|
-
let(:attributes) { { content: "mxb.example.com", priority: "20", regions: ['global'] } }
|
228
228
|
|
229
229
|
it "builds the correct request" do
|
230
230
|
subject.update_zone_record(account_id, zone_id, record_id, attributes)
|
@@ -89,7 +89,7 @@ describe Dnsimple::Client, ".zones" do
|
|
89
89
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones?page=1&per_page=100&sort=name:desc")
|
90
90
|
end
|
91
91
|
|
92
|
-
it "supports
|
92
|
+
it "supports filtering" do
|
93
93
|
subject.all_zones(account_id, filter: { name_like: "zone.test" })
|
94
94
|
|
95
95
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones?page=1&per_page=100&name_like=zone.test")
|
@@ -49,35 +49,35 @@ describe Dnsimple::Client do
|
|
49
49
|
|
50
50
|
describe "#get" do
|
51
51
|
it "delegates to #request" do
|
52
|
-
|
52
|
+
allow(subject).to receive(:execute).with(:get, "path", nil, foo: "bar").and_return(:returned)
|
53
53
|
expect(subject.get("path", foo: "bar")).to eq(:returned)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
describe "#post" do
|
58
58
|
it "delegates to #request" do
|
59
|
-
|
59
|
+
allow(subject).to receive(:execute).with(:post, "path", { foo: "bar" }, {}).and_return(:returned)
|
60
60
|
expect(subject.post("path", foo: "bar")).to eq(:returned)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
describe "#put" do
|
65
65
|
it "delegates to #request" do
|
66
|
-
|
66
|
+
allow(subject).to receive(:execute).with(:put, "path", { foo: "bar" }, {}).and_return(:returned)
|
67
67
|
expect(subject.put("path", foo: "bar")).to eq(:returned)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
describe "#patch" do
|
72
72
|
it "delegates to #request" do
|
73
|
-
|
73
|
+
allow(subject).to receive(:execute).with(:patch, "path", { foo: "bar" }, {}).and_return(:returned)
|
74
74
|
expect(subject.patch("path", foo: "bar")).to eq(:returned)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
describe "#delete" do
|
79
79
|
it "delegates to #request" do
|
80
|
-
|
80
|
+
allow(subject).to receive(:execute).with(:delete, "path", { foo: "bar" }, {}).and_return(:returned)
|
81
81
|
expect(subject.delete("path", foo: "bar")).to eq(:returned)
|
82
82
|
end
|
83
83
|
end
|
@@ -126,20 +126,20 @@ describe Dnsimple::Client do
|
|
126
126
|
it "delegates to HTTParty" do
|
127
127
|
stub_request(:get, %r{/foo})
|
128
128
|
|
129
|
-
|
129
|
+
allow(HTTParty).to receive(:get)
|
130
130
|
.with(
|
131
131
|
"#{subject.base_url}foo",
|
132
132
|
format: :json,
|
133
133
|
basic_auth: { username: "user", password: "pass" },
|
134
134
|
headers: { 'Accept' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT }
|
135
135
|
)
|
136
|
-
.and_return(
|
136
|
+
.and_return(instance_double('response', code: 200))
|
137
137
|
|
138
138
|
subject.request(:get, 'foo')
|
139
139
|
end
|
140
140
|
|
141
141
|
it "properly extracts processes options and encodes data" do
|
142
|
-
|
142
|
+
allow(HTTParty).to receive(:put)
|
143
143
|
.with(
|
144
144
|
"#{subject.base_url}foo",
|
145
145
|
format: :json,
|
@@ -148,13 +148,13 @@ describe Dnsimple::Client do
|
|
148
148
|
basic_auth: { username: "user", password: "pass" },
|
149
149
|
headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT, "Custom" => "Header" }
|
150
150
|
)
|
151
|
-
.and_return(
|
151
|
+
.and_return(instance_double('response', code: 200))
|
152
152
|
|
153
153
|
subject.request(:put, 'foo', { something: "else" }, { query: { foo: "bar" }, headers: { "Custom" => "Header" } })
|
154
154
|
end
|
155
155
|
|
156
156
|
it "handles non application/json content types" do
|
157
|
-
|
157
|
+
allow(HTTParty).to receive(:post)
|
158
158
|
.with(
|
159
159
|
"#{subject.base_url}foo",
|
160
160
|
format: :json,
|
@@ -162,13 +162,13 @@ describe Dnsimple::Client do
|
|
162
162
|
basic_auth: { username: "user", password: "pass" },
|
163
163
|
headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded', 'User-Agent' => Dnsimple::Default::USER_AGENT }
|
164
164
|
)
|
165
|
-
.and_return(
|
165
|
+
.and_return(instance_double('response', code: 200))
|
166
166
|
|
167
167
|
subject.request(:post, 'foo', { something: "else" }, { headers: { "Content-Type" => "application/x-www-form-urlencoded" } })
|
168
168
|
end
|
169
169
|
|
170
170
|
it "includes options for proxy support" do
|
171
|
-
|
171
|
+
allow(HTTParty).to receive(:get)
|
172
172
|
.with(
|
173
173
|
"#{subject.base_url}test",
|
174
174
|
format: :json,
|
@@ -176,20 +176,20 @@ describe Dnsimple::Client do
|
|
176
176
|
http_proxyport: "4321",
|
177
177
|
headers: { 'Accept' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT }
|
178
178
|
)
|
179
|
-
.and_return(
|
179
|
+
.and_return(instance_double('response', code: 200))
|
180
180
|
|
181
181
|
subject = described_class.new(proxy: "example-proxy.com:4321")
|
182
182
|
subject.request(:get, "test", nil, {})
|
183
183
|
end
|
184
184
|
|
185
185
|
it "supports custom user agent" do
|
186
|
-
|
186
|
+
allow(HTTParty).to receive(:get)
|
187
187
|
.with(
|
188
188
|
"#{subject.base_url}test",
|
189
189
|
format: :json,
|
190
190
|
headers: hash_including("User-Agent" => "customAgent #{Dnsimple::Default::USER_AGENT}")
|
191
191
|
)
|
192
|
-
.and_return(
|
192
|
+
.and_return(instance_double("response", code: 200))
|
193
193
|
|
194
194
|
subject = described_class.new(user_agent: "customAgent")
|
195
195
|
subject.request(:get, "test", nil)
|
data/spec/dnsimple/extra_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe Dnsimple::Extra do
|
|
26
26
|
describe ".validate_mandatory_attributes" do
|
27
27
|
let(:mandatory_attributes) { %i(name email) }
|
28
28
|
|
29
|
-
it "raises an error if a mandatory attribute is not present
|
29
|
+
it "raises an error if a mandatory attribute is not present" do
|
30
30
|
expect {
|
31
31
|
described_class.validate_mandatory_attributes({ name: "foo" }, mandatory_attributes)
|
32
32
|
}.to raise_error(ArgumentError, ":email is required")
|
@@ -14,14 +14,14 @@ RSpec.describe Dnsimple::Options::ListOptions do
|
|
14
14
|
expect(options.to_h).to eq({})
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
describe 'query' do
|
18
18
|
it 'adds "query" key if given options are filled' do
|
19
19
|
options = described_class.new(a: 1)
|
20
20
|
expect(options.to_h).to have_key(:query)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
describe 'pagination' do
|
25
25
|
it 'adds "page" to "query"' do
|
26
26
|
raw = { page: '23' }
|
27
27
|
expected = { query: raw }
|
@@ -47,7 +47,7 @@ RSpec.describe Dnsimple::Options::ListOptions do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
|
50
|
+
describe 'sorting' do
|
51
51
|
it 'adds sorting policy to "query"' do
|
52
52
|
raw = { sort: 'name:desc' }
|
53
53
|
expected = { query: raw }
|
@@ -73,7 +73,7 @@ RSpec.describe Dnsimple::Options::ListOptions do
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
|
76
|
+
describe 'filtering' do
|
77
77
|
it 'adds filtering policy to "query"' do
|
78
78
|
raw = { filter: { name_like: 'example' } }
|
79
79
|
expected = { query: raw.fetch(:filter) }
|
@@ -0,0 +1,18 @@
|
|
1
|
+
HTTP/1.1 400 Bad Request
|
2
|
+
Server: nginx
|
3
|
+
Date: Mon, 27 Jul 2020 13:43:02 GMT
|
4
|
+
Content-Type: application/json; charset=utf-8
|
5
|
+
Connection: keep-alive
|
6
|
+
X-RateLimit-Limit: 4800
|
7
|
+
X-RateLimit-Remaining: 4786
|
8
|
+
X-RateLimit-Reset: 1595859922
|
9
|
+
Cache-Control: no-cache
|
10
|
+
X-Request-Id: 382b409c-0f90-4758-af3b-0bccd31a9d0d
|
11
|
+
X-Runtime: 1.346405
|
12
|
+
X-Frame-Options: DENY
|
13
|
+
X-Content-Type-Options: nosniff
|
14
|
+
X-XSS-Protection: 1; mode=block
|
15
|
+
X-Download-Options: noopen
|
16
|
+
X-Permitted-Cross-Domain-Policies: none
|
17
|
+
|
18
|
+
{"message":"`cocotero.love` is not a premium domain for registration"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
HTTP/1.1 400 Bad Request
|
2
|
+
Server: nginx
|
3
|
+
Date: Mon, 27 Jul 2020 13:41:23 GMT
|
4
|
+
Content-Type: application/json; charset=utf-8
|
5
|
+
Connection: keep-alive
|
6
|
+
X-RateLimit-Limit: 2400
|
7
|
+
X-RateLimit-Remaining: 2398
|
8
|
+
X-RateLimit-Reset: 1595860823
|
9
|
+
Cache-Control: no-cache
|
10
|
+
X-Request-Id: 6986cca3-4f57-4814-9e81-1c484d61c7ea
|
11
|
+
X-Runtime: 0.007339
|
12
|
+
X-Frame-Options: DENY
|
13
|
+
X-Content-Type-Options: nosniff
|
14
|
+
X-XSS-Protection: 1; mode=block
|
15
|
+
X-Download-Options: noopen
|
16
|
+
X-Permitted-Cross-Domain-Policies: none
|
17
|
+
|
18
|
+
{"message":"TLD .LOVE is not supported"}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx
|
3
|
+
Date: Mon, 27 Jul 2020 13:58:50 GMT
|
4
|
+
Content-Type: application/json; charset=utf-8
|
5
|
+
Connection: keep-alive
|
6
|
+
X-RateLimit-Limit: 4800
|
7
|
+
X-RateLimit-Remaining: 4769
|
8
|
+
X-RateLimit-Reset: 1595859923
|
9
|
+
ETag: W/"54b4776b898065f2f551fc33465d0936"
|
10
|
+
Cache-Control: max-age=0, private, must-revalidate
|
11
|
+
X-Request-Id: 75c5090e-8000-4e95-a516-ffd09383f641
|
12
|
+
X-Runtime: 2.380524
|
13
|
+
X-Frame-Options: DENY
|
14
|
+
X-Content-Type-Options: nosniff
|
15
|
+
X-XSS-Protection: 1; mode=block
|
16
|
+
X-Download-Options: noopen
|
17
|
+
X-Permitted-Cross-Domain-Policies: none
|
18
|
+
Strict-Transport-Security: max-age=31536000
|
19
|
+
|
20
|
+
{"data":{"premium_price":"2640.00","action":"registration"}}
|
@@ -2,7 +2,6 @@ HTTP/1.1 201 Created
|
|
2
2
|
Server: nginx
|
3
3
|
Date: Fri, 03 Mar 2017 15:24:00 GMT
|
4
4
|
Content-Type: application/json; charset=utf-8
|
5
|
-
Transfer-Encoding: chunked
|
6
5
|
Connection: keep-alive
|
7
6
|
X-RateLimit-Limit: 2400
|
8
7
|
X-RateLimit-Remaining: 2399
|
@@ -18,4 +17,4 @@ X-Permitted-Cross-Domain-Policies: none
|
|
18
17
|
X-XSS-Protection: 1; mode=block
|
19
18
|
Strict-Transport-Security: max-age=31536000
|
20
19
|
|
21
|
-
{"data":{"id":2,"domain_id":1010,"algorithm":"13","digest":"684a1f049d7d082b7f98691657da5a65764913df7f065f6f8c36edf62d66ca03","digest_type":"2","keytag":"2371","created_at":"2017-03-03T15:24:00Z","updated_at":"2017-03-03T15:24:00Z"}}
|
20
|
+
{"data":{"id":2,"domain_id":1010,"algorithm":"13","digest":"684a1f049d7d082b7f98691657da5a65764913df7f065f6f8c36edf62d66ca03","digest_type":"2","keytag":"2371","public_key":null,"created_at":"2017-03-03T15:24:00Z","updated_at":"2017-03-03T15:24:00Z"}}
|