dnsimple 4.6.0 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +12 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +9 -13
- data/.rubocop_dnsimple.yml +42 -40
- data/.rubocop_todo.yml +44 -5
- data/.travis.yml +14 -8
- data/CHANGELOG.md +56 -26
- data/CONTRIBUTING.md +43 -0
- data/Gemfile +6 -1
- data/LICENSE.txt +1 -1
- data/README.md +10 -7
- data/dnsimple.gemspec +3 -3
- data/lib/dnsimple.rb +2 -0
- data/lib/dnsimple/client.rb +23 -13
- data/lib/dnsimple/client/accounts.rb +2 -0
- data/lib/dnsimple/client/certificates.rb +2 -0
- data/lib/dnsimple/client/clients.rb +5 -2
- data/lib/dnsimple/client/contacts.rb +2 -0
- data/lib/dnsimple/client/domains.rb +3 -19
- data/lib/dnsimple/client/domains_collaborators.rb +2 -0
- 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 +69 -0
- data/lib/dnsimple/client/registrar_auto_renewal.rb +2 -0
- data/lib/dnsimple/client/registrar_delegation.rb +2 -0
- data/lib/dnsimple/client/registrar_whois_privacy.rb +3 -1
- data/lib/dnsimple/client/services.rb +2 -0
- 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 +2 -0
- data/lib/dnsimple/client/vanity_name_servers.rb +12 -10
- data/lib/dnsimple/client/webhooks.rb +2 -0
- data/lib/dnsimple/client/zones.rb +2 -0
- data/lib/dnsimple/client/zones_distributions.rb +2 -0
- data/lib/dnsimple/client/zones_records.rb +2 -0
- data/lib/dnsimple/default.rb +12 -10
- data/lib/dnsimple/error.rb +3 -1
- data/lib/dnsimple/extra.rb +4 -2
- data/lib/dnsimple/options.rb +2 -0
- data/lib/dnsimple/response.rb +7 -7
- data/lib/dnsimple/struct.rb +3 -0
- data/lib/dnsimple/struct/account.rb +2 -0
- data/lib/dnsimple/struct/certificate.rb +4 -2
- data/lib/dnsimple/struct/certificate_bundle.rb +5 -0
- data/lib/dnsimple/struct/certificate_purchase.rb +2 -0
- data/lib/dnsimple/struct/certificate_renewal.rb +2 -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 +4 -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_price.rb +24 -0
- data/lib/dnsimple/struct/domain_push.rb +2 -0
- data/lib/dnsimple/struct/domain_registration.rb +2 -0
- data/lib/dnsimple/struct/domain_renewal.rb +2 -0
- data/lib/dnsimple/struct/domain_transfer.rb +5 -0
- data/lib/dnsimple/struct/email_forward.rb +2 -0
- data/lib/dnsimple/struct/extended_attribute.rb +2 -0
- data/lib/dnsimple/struct/oauth_token.rb +2 -0
- data/lib/dnsimple/struct/service.rb +2 -0
- 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 +2 -0
- data/lib/dnsimple/struct/webhook.rb +2 -0
- data/lib/dnsimple/struct/whoami.rb +2 -0
- data/lib/dnsimple/struct/whois_privacy.rb +2 -0
- data/lib/dnsimple/struct/whois_privacy_renewal.rb +2 -0
- data/lib/dnsimple/struct/zone.rb +2 -0
- data/lib/dnsimple/struct/zone_distribution.rb +2 -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 +35 -33
- data/spec/dnsimple/client/client_service_spec.rb +3 -1
- data/spec/dnsimple/client/contacts_spec.rb +4 -2
- data/spec/dnsimple/client/domains_collaborators_spec.rb +4 -2
- data/spec/dnsimple/client/domains_delegation_signer_records_spec.rb +3 -1
- data/spec/dnsimple/client/domains_dnssec_spec.rb +2 -0
- data/spec/dnsimple/client/domains_email_forwards_spec.rb +10 -8
- data/spec/dnsimple/client/domains_pushes_spec.rb +4 -2
- data/spec/dnsimple/client/domains_spec.rb +16 -41
- 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 +4 -2
- data/spec/dnsimple/client/registrar_spec.rb +116 -4
- data/spec/dnsimple/client/registrar_whois_privacy_spec.rb +2 -0
- data/spec/dnsimple/client/services_domains_spec.rb +4 -4
- data/spec/dnsimple/client/services_spec.rb +3 -3
- data/spec/dnsimple/client/templates_domains_spec.rb +2 -0
- data/spec/dnsimple/client/templates_records_spec.rb +3 -1
- data/spec/dnsimple/client/templates_spec.rb +4 -2
- data/spec/dnsimple/client/tlds_spec.rb +2 -0
- data/spec/dnsimple/client/vanity_name_servers_spec.rb +2 -0
- data/spec/dnsimple/client/webhooks_spec.rb +3 -1
- data/spec/dnsimple/client/zones_distributions_spec.rb +2 -0
- data/spec/dnsimple/client/zones_records_spec.rb +4 -2
- data/spec/dnsimple/client/zones_spec.rb +3 -1
- data/spec/dnsimple/client_spec.rb +18 -16
- 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 +6 -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 +18 -0
- 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 +0 -1
- data/spec/fixtures.http/createDelegationSignerRecord/validation-error.http +0 -1
- data/spec/fixtures.http/createDomain/created.http +20 -16
- 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 +10 -11
- 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 +0 -1
- data/spec/fixtures.http/getDnssec/success.http +0 -1
- data/spec/fixtures.http/getDomain/success.http +13 -9
- 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 +20 -0
- 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 +0 -1
- 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 +18 -21
- data/spec/fixtures.http/issueRenewalLetsencryptCertificate/success.http +18 -21
- 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 +10 -11
- 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 +0 -1
- data/spec/fixtures.http/listDomains/success.http +20 -16
- 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 +0 -1
- 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 +20 -21
- data/spec/fixtures.http/purchaseRenewalLetsencryptCertificate/success.http +20 -21
- data/spec/fixtures.http/registerDomain/success.http +1 -2
- data/spec/fixtures.http/renewDomain/error-tooearly.http +0 -1
- data/spec/fixtures.http/renewDomain/success.http +1 -2
- data/spec/fixtures.http/renewWhoisPrivacy/success.http +0 -1
- data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-duplicated-order.http +1 -2
- data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-not-found.http +1 -2
- 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 +1 -2
- 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 +3 -1
- data/spec/support/helpers.rb +2 -0
- data/spec/support/webmock.rb +2 -0
- metadata +36 -15
- data/.ruby-gemset +0 -1
- data/spec/fixtures.http/resetDomainToken/success.http +0 -17
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Dnsimple::Client, ".templates" do
|
@@ -75,13 +77,13 @@ describe Dnsimple::Client, ".templates" do
|
|
75
77
|
|
76
78
|
describe "#create_template" do
|
77
79
|
let(:account_id) { 1010 }
|
80
|
+
let(:attributes) { { name: "Beta", short_name: "beta", description: "A beta template." } }
|
78
81
|
|
79
82
|
before do
|
80
83
|
stub_request(:post, %r{/v2/#{account_id}/templates$})
|
81
84
|
.to_return(read_http_fixture("createTemplate/created.http"))
|
82
85
|
end
|
83
86
|
|
84
|
-
let(:attributes) { { name: "Beta", short_name: "beta", description: "A beta template." } }
|
85
87
|
|
86
88
|
it "builds the correct request" do
|
87
89
|
subject.create_template(account_id, attributes)
|
@@ -136,6 +138,7 @@ describe Dnsimple::Client, ".templates" do
|
|
136
138
|
|
137
139
|
describe "#update_template" do
|
138
140
|
let(:account_id) { 1010 }
|
141
|
+
let(:attributes) { { name: "Alpha", short_name: "alpha", description: "An alpha template." } }
|
139
142
|
let(:template_id) { 1 }
|
140
143
|
|
141
144
|
before do
|
@@ -143,7 +146,6 @@ describe Dnsimple::Client, ".templates" do
|
|
143
146
|
.to_return(read_http_fixture("updateTemplate/success.http"))
|
144
147
|
end
|
145
148
|
|
146
|
-
let(:attributes) { { name: "Alpha", short_name: "alpha", description: "An alpha template." } }
|
147
149
|
|
148
150
|
it "builds the correct request" do
|
149
151
|
subject.update_template(account_id, template_id, attributes)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Dnsimple::Client, ".webhooks" do
|
@@ -47,13 +49,13 @@ describe Dnsimple::Client, ".webhooks" do
|
|
47
49
|
|
48
50
|
describe "#create_webhook" do
|
49
51
|
let(:account_id) { 1010 }
|
52
|
+
let(:attributes) { { url: "https://webhook.test" } }
|
50
53
|
|
51
54
|
before do
|
52
55
|
stub_request(:post, %r{/v2/#{account_id}/webhooks$})
|
53
56
|
.to_return(read_http_fixture("createWebhook/created.http"))
|
54
57
|
end
|
55
58
|
|
56
|
-
let(:attributes) { { url: "https://webhook.test" } }
|
57
59
|
|
58
60
|
it "builds the correct request" do
|
59
61
|
subject.create_webhook(account_id, attributes)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Dnsimple::Client, ".zones" do
|
@@ -110,6 +112,7 @@ describe Dnsimple::Client, ".zones" do
|
|
110
112
|
|
111
113
|
describe "#create_zone_record" do
|
112
114
|
let(:account_id) { 1010 }
|
115
|
+
let(:attributes) { { type: "A", name: "www", content: "127.0.0.1", regions: %w(global) } }
|
113
116
|
let(:zone_id) { "example.com" }
|
114
117
|
|
115
118
|
before do
|
@@ -117,7 +120,6 @@ describe Dnsimple::Client, ".zones" do
|
|
117
120
|
.to_return(read_http_fixture("createZoneRecord/created.http"))
|
118
121
|
end
|
119
122
|
|
120
|
-
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
125
|
subject.create_zone_record(account_id, zone_id, attributes)
|
@@ -214,6 +216,7 @@ describe Dnsimple::Client, ".zones" do
|
|
214
216
|
|
215
217
|
describe "#update_zone_record" do
|
216
218
|
let(:account_id) { 1010 }
|
219
|
+
let(:attributes) { { content: "mxb.example.com", priority: "20", regions: ['global'] } }
|
217
220
|
let(:zone_id) { "example.com" }
|
218
221
|
let(:record_id) { 5 }
|
219
222
|
|
@@ -222,7 +225,6 @@ describe Dnsimple::Client, ".zones" do
|
|
222
225
|
.to_return(read_http_fixture("updateZoneRecord/success.http"))
|
223
226
|
end
|
224
227
|
|
225
|
-
let(:attributes) { { content: "mxb.example.com", priority: "20", regions: ['global'] } }
|
226
228
|
|
227
229
|
it "builds the correct request" do
|
228
230
|
subject.update_zone_record(account_id, zone_id, record_id, attributes)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Dnsimple::Client, ".zones" do
|
@@ -87,7 +89,7 @@ describe Dnsimple::Client, ".zones" do
|
|
87
89
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones?page=1&per_page=100&sort=name:desc")
|
88
90
|
end
|
89
91
|
|
90
|
-
it "supports
|
92
|
+
it "supports filtering" do
|
91
93
|
subject.all_zones(account_id, filter: { name_like: "zone.test" })
|
92
94
|
|
93
95
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones?page=1&per_page=100&name_like=zone.test")
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Dnsimple::Client do
|
@@ -47,35 +49,35 @@ describe Dnsimple::Client do
|
|
47
49
|
|
48
50
|
describe "#get" do
|
49
51
|
it "delegates to #request" do
|
50
|
-
|
52
|
+
allow(subject).to receive(:execute).with(:get, "path", nil, foo: "bar").and_return(:returned)
|
51
53
|
expect(subject.get("path", foo: "bar")).to eq(:returned)
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
55
57
|
describe "#post" do
|
56
58
|
it "delegates to #request" do
|
57
|
-
|
59
|
+
allow(subject).to receive(:execute).with(:post, "path", { foo: "bar" }, {}).and_return(:returned)
|
58
60
|
expect(subject.post("path", foo: "bar")).to eq(:returned)
|
59
61
|
end
|
60
62
|
end
|
61
63
|
|
62
64
|
describe "#put" do
|
63
65
|
it "delegates to #request" do
|
64
|
-
|
66
|
+
allow(subject).to receive(:execute).with(:put, "path", { foo: "bar" }, {}).and_return(:returned)
|
65
67
|
expect(subject.put("path", foo: "bar")).to eq(:returned)
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
69
71
|
describe "#patch" do
|
70
72
|
it "delegates to #request" do
|
71
|
-
|
73
|
+
allow(subject).to receive(:execute).with(:patch, "path", { foo: "bar" }, {}).and_return(:returned)
|
72
74
|
expect(subject.patch("path", foo: "bar")).to eq(:returned)
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|
76
78
|
describe "#delete" do
|
77
79
|
it "delegates to #request" do
|
78
|
-
|
80
|
+
allow(subject).to receive(:execute).with(:delete, "path", { foo: "bar" }, {}).and_return(:returned)
|
79
81
|
expect(subject.delete("path", foo: "bar")).to eq(:returned)
|
80
82
|
end
|
81
83
|
end
|
@@ -124,20 +126,20 @@ describe Dnsimple::Client do
|
|
124
126
|
it "delegates to HTTParty" do
|
125
127
|
stub_request(:get, %r{/foo})
|
126
128
|
|
127
|
-
|
129
|
+
allow(HTTParty).to receive(:get)
|
128
130
|
.with(
|
129
131
|
"#{subject.base_url}foo",
|
130
132
|
format: :json,
|
131
133
|
basic_auth: { username: "user", password: "pass" },
|
132
134
|
headers: { 'Accept' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT }
|
133
135
|
)
|
134
|
-
.and_return(
|
136
|
+
.and_return(instance_double('response', code: 200))
|
135
137
|
|
136
138
|
subject.request(:get, 'foo')
|
137
139
|
end
|
138
140
|
|
139
141
|
it "properly extracts processes options and encodes data" do
|
140
|
-
|
142
|
+
allow(HTTParty).to receive(:put)
|
141
143
|
.with(
|
142
144
|
"#{subject.base_url}foo",
|
143
145
|
format: :json,
|
@@ -146,13 +148,13 @@ describe Dnsimple::Client do
|
|
146
148
|
basic_auth: { username: "user", password: "pass" },
|
147
149
|
headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT, "Custom" => "Header" }
|
148
150
|
)
|
149
|
-
.and_return(
|
151
|
+
.and_return(instance_double('response', code: 200))
|
150
152
|
|
151
153
|
subject.request(:put, 'foo', { something: "else" }, { query: { foo: "bar" }, headers: { "Custom" => "Header" } })
|
152
154
|
end
|
153
155
|
|
154
156
|
it "handles non application/json content types" do
|
155
|
-
|
157
|
+
allow(HTTParty).to receive(:post)
|
156
158
|
.with(
|
157
159
|
"#{subject.base_url}foo",
|
158
160
|
format: :json,
|
@@ -160,13 +162,13 @@ describe Dnsimple::Client do
|
|
160
162
|
basic_auth: { username: "user", password: "pass" },
|
161
163
|
headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded', 'User-Agent' => Dnsimple::Default::USER_AGENT }
|
162
164
|
)
|
163
|
-
.and_return(
|
165
|
+
.and_return(instance_double('response', code: 200))
|
164
166
|
|
165
167
|
subject.request(:post, 'foo', { something: "else" }, { headers: { "Content-Type" => "application/x-www-form-urlencoded" } })
|
166
168
|
end
|
167
169
|
|
168
170
|
it "includes options for proxy support" do
|
169
|
-
|
171
|
+
allow(HTTParty).to receive(:get)
|
170
172
|
.with(
|
171
173
|
"#{subject.base_url}test",
|
172
174
|
format: :json,
|
@@ -174,20 +176,20 @@ describe Dnsimple::Client do
|
|
174
176
|
http_proxyport: "4321",
|
175
177
|
headers: { 'Accept' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT }
|
176
178
|
)
|
177
|
-
.and_return(
|
179
|
+
.and_return(instance_double('response', code: 200))
|
178
180
|
|
179
181
|
subject = described_class.new(proxy: "example-proxy.com:4321")
|
180
182
|
subject.request(:get, "test", nil, {})
|
181
183
|
end
|
182
184
|
|
183
185
|
it "supports custom user agent" do
|
184
|
-
|
186
|
+
allow(HTTParty).to receive(:get)
|
185
187
|
.with(
|
186
188
|
"#{subject.base_url}test",
|
187
189
|
format: :json,
|
188
|
-
headers: hash_including("User-Agent" => "#{Dnsimple::Default::USER_AGENT}
|
190
|
+
headers: hash_including("User-Agent" => "customAgent #{Dnsimple::Default::USER_AGENT}")
|
189
191
|
)
|
190
|
-
.and_return(
|
192
|
+
.and_return(instance_double("response", code: 200))
|
191
193
|
|
192
194
|
subject = described_class.new(user_agent: "customAgent")
|
193
195
|
subject.request(:get, "test", nil)
|
data/spec/dnsimple/extra_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
RSpec.describe Dnsimple::Options::ListOptions do
|
@@ -12,14 +14,14 @@ RSpec.describe Dnsimple::Options::ListOptions do
|
|
12
14
|
expect(options.to_h).to eq({})
|
13
15
|
end
|
14
16
|
|
15
|
-
|
17
|
+
describe 'query' do
|
16
18
|
it 'adds "query" key if given options are filled' do
|
17
19
|
options = described_class.new(a: 1)
|
18
20
|
expect(options.to_h).to have_key(:query)
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
|
-
|
24
|
+
describe 'pagination' do
|
23
25
|
it 'adds "page" to "query"' do
|
24
26
|
raw = { page: '23' }
|
25
27
|
expected = { query: raw }
|
@@ -45,7 +47,7 @@ RSpec.describe Dnsimple::Options::ListOptions do
|
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
48
|
-
|
50
|
+
describe 'sorting' do
|
49
51
|
it 'adds sorting policy to "query"' do
|
50
52
|
raw = { sort: 'name:desc' }
|
51
53
|
expected = { query: raw }
|
@@ -71,7 +73,7 @@ RSpec.describe Dnsimple::Options::ListOptions do
|
|
71
73
|
end
|
72
74
|
end
|
73
75
|
|
74
|
-
|
76
|
+
describe 'filtering' do
|
75
77
|
it 'adds filtering policy to "query"' do
|
76
78
|
raw = { filter: { name_like: 'example' } }
|
77
79
|
expected = { query: raw.fetch(:filter) }
|
@@ -0,0 +1,18 @@
|
|
1
|
+
HTTP/1.1 202 Accepted
|
2
|
+
Server: nginx
|
3
|
+
Date: Fri, 05 Jun 2020 18:09:42 GMT
|
4
|
+
Content-Type: application/json; charset=utf-8
|
5
|
+
Connection: keep-alive
|
6
|
+
X-RateLimit-Limit: 2400
|
7
|
+
X-RateLimit-Remaining: 2394
|
8
|
+
X-RateLimit-Reset: 1591384034
|
9
|
+
Cache-Control: no-cache
|
10
|
+
X-Request-Id: 3cf6dcfa-0bb5-439e-863a-af2ef08bc830
|
11
|
+
X-Runtime: 0.912731
|
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
|
+
{"data":{"id":361,"domain_id":182245,"registrant_id":2715,"state":"transferring","auto_renew":false,"whois_privacy":false,"status_description":null,"created_at":"2020-06-05T18:08:00Z","updated_at":"2020-06-05T18:08:04Z"}}
|
@@ -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"}
|