dnsimple 7.0.0 → 8.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/CODEOWNERS +1 -0
- data/.github/dependabot.yml +11 -1
- data/.github/workflows/ci.yml +67 -0
- data/.github/workflows/release.yml +28 -0
- data/.markdownlint.yaml +3 -0
- data/.rubocop.yml +2 -5
- data/.rubocop_dnsimple.yml +28 -18
- data/.rubocop_todo.yml +1 -1
- data/.yamllint.yml +29 -0
- data/CHANGELOG.md +19 -13
- data/CONTRIBUTING.md +6 -21
- data/Gemfile +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +5 -9
- data/Rakefile +1 -1
- data/UPGRADING.md +4 -5
- data/dnsimple.gemspec +1 -1
- data/lib/dnsimple/client/certificates.rb +5 -7
- data/lib/dnsimple/client/clients.rb +0 -5
- data/lib/dnsimple/client/domains_delegation_signer_records.rb +5 -4
- data/lib/dnsimple/client/registrar.rb +0 -29
- data/lib/dnsimple/default.rb +9 -9
- data/lib/dnsimple/extra.rb +1 -1
- data/lib/dnsimple/struct/delegation_signer_record.rb +3 -0
- data/lib/dnsimple/struct/tld.rb +3 -0
- data/lib/dnsimple/version.rb +1 -1
- data/spec/dnsimple/client/certificates_spec.rb +8 -9
- 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 +3 -2
- data/spec/dnsimple/client/domains_email_forwards_spec.rb +2 -2
- data/spec/dnsimple/client/domains_spec.rb +2 -2
- data/spec/dnsimple/client/registrar_spec.rb +1 -49
- data/spec/dnsimple/client/services_spec.rb +1 -1
- 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 +2 -1
- data/spec/dnsimple/client/zones_records_spec.rb +3 -3
- data/spec/dnsimple/client/zones_spec.rb +2 -2
- data/spec/dnsimple/client_spec.rb +32 -33
- data/spec/dnsimple/extra_spec.rb +1 -1
- data/spec/fixtures.http/createDelegationSignerRecord/created.http +1 -1
- data/spec/fixtures.http/getDelegationSignerRecord/success.http +1 -1
- data/spec/fixtures.http/getTld/success.http +1 -1
- data/spec/fixtures.http/listDelegationSignerRecords/success.http +1 -1
- data/spec/fixtures.http/listTlds/success.http +1 -1
- metadata +10 -186
- data/.travis.yml +0 -25
@@ -23,11 +23,6 @@ module Dnsimple
|
|
23
23
|
@services[:domains] ||= Client::DomainsService.new(self)
|
24
24
|
end
|
25
25
|
|
26
|
-
# @return [Dnsimple::Client::DomainServicesService] The domain-services-related API proxy.
|
27
|
-
def domain_services
|
28
|
-
@services[:domains] ||= Client::DomainServicesService.new(self)
|
29
|
-
end
|
30
|
-
|
31
26
|
# @return [Dnsimple::Client::IdentityService] The identity-related API proxy.
|
32
27
|
def identity
|
33
28
|
@services[:auth] ||= Client::IdentityService.new(self)
|
@@ -67,15 +67,16 @@ module Dnsimple
|
|
67
67
|
# @param [#to_s] domain_id The domain ID or domain name
|
68
68
|
# @param [Hash] attributes
|
69
69
|
# @option attributes [Integer] :algorithm DNSSEC algorithm as number (required)
|
70
|
-
# @option attributes [String] :digest The hexidecimal representation of the digest of the corresponding DNSKEY record (required)
|
71
|
-
# @option attributes [Integer] :digest_type DNSSEC digest type (required)
|
72
|
-
# @option attributes [String] :keytag A keytag that references the corresponding DNSKEY record (required)
|
70
|
+
# @option attributes [String] :digest The hexidecimal representation of the digest of the corresponding DNSKEY record (required if TLD requires DS data)
|
71
|
+
# @option attributes [Integer] :digest_type DNSSEC digest type (required if TLD requires DS data)
|
72
|
+
# @option attributes [String] :keytag A keytag that references the corresponding DNSKEY record (required if TLD requires DS data)
|
73
|
+
# @option attributes [String] :public_key A public key that references the corresponding DNSKEY record (required if TLD requires KEY data)
|
73
74
|
# @param [Hash] options
|
74
75
|
# @return [Dnsimple::Response<Dnsimple::Struct::DelegationSignerRecord>]
|
75
76
|
#
|
76
77
|
# @raise [Dnsimple::RequestError]
|
77
78
|
def create_delegation_signer_record(account_id, domain_id, attributes, options = {})
|
78
|
-
Extra.validate_mandatory_attributes(attributes, [:algorithm
|
79
|
+
Extra.validate_mandatory_attributes(attributes, [:algorithm])
|
79
80
|
response = client.post(Client.versioned("/%s/domains/%s/ds_records" % [account_id, domain_id]), attributes, options)
|
80
81
|
|
81
82
|
Dnsimple::Response.new(response, Struct::DelegationSignerRecord.new(response["data"]))
|
@@ -24,35 +24,6 @@ module Dnsimple
|
|
24
24
|
Dnsimple::Response.new(response, Struct::DomainCheck.new(response["data"]))
|
25
25
|
end
|
26
26
|
|
27
|
-
# Checks the premium price for a domain
|
28
|
-
#
|
29
|
-
# @see https://developer.dnsimple.com/v2/registrar/#premium-price
|
30
|
-
#
|
31
|
-
# @example Check the ruby.codes premium price:
|
32
|
-
# client.registrar.domain_premium_price(1010, "ruby.codes")
|
33
|
-
#
|
34
|
-
# @example Check the ruby.codes premium price for transfer:
|
35
|
-
# client.registrar.domain_premium_price(1010, "ruby.codes", action: "transfer")
|
36
|
-
#
|
37
|
-
# @param [Integer] account_id the account ID
|
38
|
-
# @param [#to_s] domain_name the domain name to check
|
39
|
-
# @param [Hash] options
|
40
|
-
# @option options [String] :action Optional action between "registration",
|
41
|
-
# "renewal", and "transfer". If omitted, it defaults to "registration".
|
42
|
-
# @return [Struct::DomainPremiumPrice]
|
43
|
-
#
|
44
|
-
# @raise [RequestError] When the request fails.
|
45
|
-
#
|
46
|
-
# @deprecated Use {#get_domain_prices} instead of this one as it will soon be removed from the API.
|
47
|
-
def domain_premium_price(account_id, domain_name, options = {})
|
48
|
-
Dnsimple.deprecate("Use {#get_domain_prices} instead of this one as it will soon be removed from the API.")
|
49
|
-
endpoint = Client.versioned("/%s/registrar/domains/%s/premium_price" % [account_id, domain_name])
|
50
|
-
options[:query] = { action: options.delete(:action) } if options.key?(:action)
|
51
|
-
response = client.get(endpoint, options)
|
52
|
-
|
53
|
-
Dnsimple::Response.new(response, Struct::DomainPremiumPrice.new(response["data"]))
|
54
|
-
end
|
55
|
-
|
56
27
|
# Get prices for a domain.
|
57
28
|
# @see https://developer.dnsimple.com/v2/registrar/#getDomainPrices
|
58
29
|
#
|
data/lib/dnsimple/default.rb
CHANGED
@@ -9,7 +9,7 @@ module Dnsimple
|
|
9
9
|
BASE_URL = "https://api.dnsimple.com/"
|
10
10
|
|
11
11
|
# Default User Agent header
|
12
|
-
USER_AGENT = "dnsimple-ruby/#{VERSION}"
|
12
|
+
USER_AGENT = "dnsimple-ruby/#{VERSION}".freeze
|
13
13
|
|
14
14
|
class << self
|
15
15
|
|
@@ -30,49 +30,49 @@ module Dnsimple
|
|
30
30
|
# Configuration options
|
31
31
|
# @return [Hash]
|
32
32
|
def options
|
33
|
-
keys.
|
33
|
+
keys.to_h { |key| [key, send(key)] }
|
34
34
|
end
|
35
35
|
|
36
36
|
# Default API endpoint from ENV or {BASE_URL}
|
37
37
|
# @return [String]
|
38
38
|
def base_url
|
39
|
-
ENV
|
39
|
+
ENV.fetch('DNSIMPLE_BASE_URL', BASE_URL)
|
40
40
|
end
|
41
41
|
|
42
42
|
# Default DNSimple username for Basic Auth from ENV
|
43
43
|
# @return [String]
|
44
44
|
def username
|
45
|
-
ENV
|
45
|
+
ENV.fetch('DNSIMPLE_USERNAME', nil)
|
46
46
|
end
|
47
47
|
|
48
48
|
# Default DNSimple password for Basic Auth from ENV
|
49
49
|
# @return [String]
|
50
50
|
def password
|
51
|
-
ENV
|
51
|
+
ENV.fetch('DNSIMPLE_PASSWORD', nil)
|
52
52
|
end
|
53
53
|
|
54
54
|
# Default DNSimple access token for OAuth authentication from ENV
|
55
55
|
# @return [String]
|
56
56
|
def access_token
|
57
|
-
ENV
|
57
|
+
ENV.fetch('DNSIMPLE_ACCESS_TOKEN', nil)
|
58
58
|
end
|
59
59
|
|
60
60
|
# Default DNSimple Domain API Token for Token Auth from ENV
|
61
61
|
# @return [String]
|
62
62
|
def domain_api_token
|
63
|
-
ENV
|
63
|
+
ENV.fetch('DNSIMPLE_API_DOMAIN_TOKEN', nil)
|
64
64
|
end
|
65
65
|
|
66
66
|
# Default User-Agent header string from ENV
|
67
67
|
# @return [String]
|
68
68
|
def user_agent
|
69
|
-
ENV
|
69
|
+
ENV.fetch('DNSIMPLE_USER_AGENT', nil)
|
70
70
|
end
|
71
71
|
|
72
72
|
# Default Proxy address:port from ENV
|
73
73
|
# @return [String]
|
74
74
|
def proxy
|
75
|
-
ENV
|
75
|
+
ENV.fetch('DNSIMPLE_PROXY', nil)
|
76
76
|
end
|
77
77
|
|
78
78
|
end
|
data/lib/dnsimple/extra.rb
CHANGED
@@ -22,6 +22,9 @@ module Dnsimple
|
|
22
22
|
# @return [String] The keytag for the associated DNSKEY.
|
23
23
|
attr_accessor :keytag
|
24
24
|
|
25
|
+
# @return [String] The public key that references the corresponding DNSKEY record.
|
26
|
+
attr_accessor :public_key
|
27
|
+
|
25
28
|
# @return [String] When the delegation signing record was created in DNSimple.
|
26
29
|
attr_accessor :created_at
|
27
30
|
|
data/lib/dnsimple/struct/tld.rb
CHANGED
@@ -30,6 +30,9 @@ module Dnsimple
|
|
30
30
|
|
31
31
|
# @return [Boolean] True if DNSimple supports inbound transfers for this TLD.
|
32
32
|
attr_accessor :transfer_enabled
|
33
|
+
|
34
|
+
# @return [String, nil] Type of data interface required for DNSSEC for this TLD.
|
35
|
+
attr_accessor :dnssec_interface_type
|
33
36
|
end
|
34
37
|
|
35
38
|
end
|
data/lib/dnsimple/version.rb
CHANGED
@@ -68,8 +68,8 @@ describe Dnsimple::Client, ".certificates" do
|
|
68
68
|
let(:domain_id) { "dnsimple.us" }
|
69
69
|
|
70
70
|
it "delegates to client.paginate" do
|
71
|
-
expect(subject).to receive(:paginate).with(:certificates, account_id, domain_id, foo: "bar")
|
72
|
-
subject.all_certificates(account_id, domain_id, foo: "bar")
|
71
|
+
expect(subject).to receive(:paginate).with(:certificates, account_id, domain_id, { foo: "bar" })
|
72
|
+
subject.all_certificates(account_id, domain_id, { foo: "bar" })
|
73
73
|
end
|
74
74
|
|
75
75
|
it "supports sorting" do
|
@@ -232,7 +232,6 @@ describe Dnsimple::Client, ".certificates" do
|
|
232
232
|
describe "#purchase_letsencrypt_certificate" do
|
233
233
|
let(:account_id) { 1010 }
|
234
234
|
let(:domain_id) { "bingo.pizza" }
|
235
|
-
let(:contact_id) { 100 }
|
236
235
|
|
237
236
|
before do
|
238
237
|
stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/certificates/letsencrypt})
|
@@ -240,7 +239,7 @@ describe Dnsimple::Client, ".certificates" do
|
|
240
239
|
end
|
241
240
|
|
242
241
|
it "builds the correct request" do
|
243
|
-
attributes = {
|
242
|
+
attributes = {}
|
244
243
|
subject.purchase_letsencrypt_certificate(account_id, domain_id, attributes)
|
245
244
|
|
246
245
|
expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/certificates/letsencrypt")
|
@@ -249,7 +248,7 @@ describe Dnsimple::Client, ".certificates" do
|
|
249
248
|
end
|
250
249
|
|
251
250
|
it "passes extra attributes" do
|
252
|
-
attributes = {
|
251
|
+
attributes = { name: "www", auto_renew: true, alternate_names: ["api.example.com"] }
|
253
252
|
subject.purchase_letsencrypt_certificate(account_id, domain_id, attributes)
|
254
253
|
|
255
254
|
expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/certificates/letsencrypt")
|
@@ -258,7 +257,7 @@ describe Dnsimple::Client, ".certificates" do
|
|
258
257
|
end
|
259
258
|
|
260
259
|
it "returns the certificate purchase" do
|
261
|
-
response = subject.purchase_letsencrypt_certificate(account_id, domain_id
|
260
|
+
response = subject.purchase_letsencrypt_certificate(account_id, domain_id)
|
262
261
|
expect(response).to be_a(Dnsimple::Response)
|
263
262
|
|
264
263
|
result = response.data
|
@@ -276,7 +275,7 @@ describe Dnsimple::Client, ".certificates" do
|
|
276
275
|
.to_return(read_http_fixture("notfound-domain.http"))
|
277
276
|
|
278
277
|
expect {
|
279
|
-
subject.purchase_letsencrypt_certificate(account_id, domain_id
|
278
|
+
subject.purchase_letsencrypt_certificate(account_id, domain_id)
|
280
279
|
}.to raise_error(Dnsimple::NotFoundError)
|
281
280
|
end
|
282
281
|
end
|
@@ -311,7 +310,7 @@ describe Dnsimple::Client, ".certificates" do
|
|
311
310
|
expect(result.common_name).to eq("www.bingo.pizza")
|
312
311
|
expect(result.alternate_names).to eq([])
|
313
312
|
expect(result.years).to eq(1)
|
314
|
-
expect(result.csr).to
|
313
|
+
expect(result.csr).to be_nil
|
315
314
|
expect(result.state).to eq("requesting")
|
316
315
|
expect(result.authority_identifier).to eq("letsencrypt")
|
317
316
|
expect(result.auto_renew).to be(false)
|
@@ -421,7 +420,7 @@ describe Dnsimple::Client, ".certificates" do
|
|
421
420
|
expect(result.common_name).to eq("www.bingo.pizza")
|
422
421
|
expect(result.alternate_names).to eq([])
|
423
422
|
expect(result.years).to eq(1)
|
424
|
-
expect(result.csr).to
|
423
|
+
expect(result.csr).to be_nil
|
425
424
|
expect(result.state).to eq("requesting")
|
426
425
|
expect(result.authority_identifier).to eq("letsencrypt")
|
427
426
|
expect(result.auto_renew).to be(false)
|
@@ -73,8 +73,8 @@ describe Dnsimple::Client, ".contacts" do
|
|
73
73
|
let(:account_id) { 1010 }
|
74
74
|
|
75
75
|
it "delegates to client.paginate" do
|
76
|
-
expect(subject).to receive(:paginate).with(:contacts, account_id, foo: "bar")
|
77
|
-
subject.all_contacts(account_id, foo: "bar")
|
76
|
+
expect(subject).to receive(:paginate).with(:contacts, account_id, { foo: "bar" })
|
77
|
+
subject.all_contacts(account_id, { foo: "bar" })
|
78
78
|
end
|
79
79
|
|
80
80
|
it "supports sorting" do
|
@@ -116,8 +116,8 @@ describe Dnsimple::Client, ".domains" do
|
|
116
116
|
result = response.data
|
117
117
|
expect(result).to be_a(Dnsimple::Struct::Collaborator)
|
118
118
|
expect(result.id).to be_a(Integer)
|
119
|
-
expect(result.user_id).to
|
120
|
-
expect(result.accepted_at).to
|
119
|
+
expect(result.user_id).to be_nil
|
120
|
+
expect(result.accepted_at).to be_nil
|
121
121
|
expect(result.user_email).to eq(attributes.fetch(:email))
|
122
122
|
expect(result.invitation).to be(true)
|
123
123
|
end
|
@@ -86,8 +86,8 @@ describe Dnsimple::Client, ".domains" do
|
|
86
86
|
let(:domain_id) { "example.com" }
|
87
87
|
|
88
88
|
it "delegates to client.paginate" do
|
89
|
-
expect(subject).to receive(:paginate).with(:delegation_signer_records, account_id, domain_id, foo: "bar")
|
90
|
-
subject.all_delegation_signer_records(account_id, domain_id, foo: "bar")
|
89
|
+
expect(subject).to receive(:paginate).with(:delegation_signer_records, account_id, domain_id, { foo: "bar" })
|
90
|
+
subject.all_delegation_signer_records(account_id, domain_id, { foo: "bar" })
|
91
91
|
end
|
92
92
|
|
93
93
|
it "supports sorting" do
|
@@ -155,6 +155,7 @@ describe Dnsimple::Client, ".domains" do
|
|
155
155
|
expect(result.digest).to eq("C1F6E04A5A61FBF65BF9DC8294C363CF11C89E802D926BDAB79C55D27BEFA94F")
|
156
156
|
expect(result.digest_type).to eq("2")
|
157
157
|
expect(result.keytag).to eq("44620")
|
158
|
+
expect(result.public_key).to be_nil
|
158
159
|
expect(result.created_at).to eq("2017-03-03T13:49:58Z")
|
159
160
|
expect(result.updated_at).to eq("2017-03-03T13:49:58Z")
|
160
161
|
end
|
@@ -86,8 +86,8 @@ describe Dnsimple::Client, ".domains" do
|
|
86
86
|
let(:domain_id) { "example.com" }
|
87
87
|
|
88
88
|
it "delegates to client.paginate" do
|
89
|
-
expect(subject).to receive(:paginate).with(:email_forwards, account_id, domain_id, foo: "bar")
|
90
|
-
subject.all_email_forwards(account_id, domain_id, foo: "bar")
|
89
|
+
expect(subject).to receive(:paginate).with(:email_forwards, account_id, domain_id, { foo: "bar" })
|
90
|
+
subject.all_email_forwards(account_id, domain_id, { foo: "bar" })
|
91
91
|
end
|
92
92
|
|
93
93
|
it "supports sorting" do
|
@@ -79,8 +79,8 @@ describe Dnsimple::Client, ".domains" do
|
|
79
79
|
let(:account_id) { 1010 }
|
80
80
|
|
81
81
|
it "delegates to client.paginate" do
|
82
|
-
expect(subject).to receive(:paginate).with(:domains, account_id, foo: "bar")
|
83
|
-
subject.all_domains(account_id, foo: "bar")
|
82
|
+
expect(subject).to receive(:paginate).with(:domains, account_id, { foo: "bar" })
|
83
|
+
subject.all_domains(account_id, { foo: "bar" })
|
84
84
|
end
|
85
85
|
|
86
86
|
it "supports sorting" do
|
@@ -34,54 +34,6 @@ describe Dnsimple::Client, ".registrar" do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
describe "#domain_premium_price" do
|
38
|
-
let(:account_id) { 1010 }
|
39
|
-
|
40
|
-
context "when premium price" do
|
41
|
-
before do
|
42
|
-
stub_request(:get, %r{/v2/#{account_id}/registrar/domains/.+/premium_price[?action]*})
|
43
|
-
.to_return(read_http_fixture("getDomainPremiumPrice/success.http"))
|
44
|
-
end
|
45
|
-
|
46
|
-
it "builds the correct request" do
|
47
|
-
subject.domain_premium_price(account_id, domain_name = "ruby.codes")
|
48
|
-
|
49
|
-
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/premium_price")
|
50
|
-
.with(headers: { "Accept" => "application/json" })
|
51
|
-
end
|
52
|
-
|
53
|
-
it "returns the premium price" do
|
54
|
-
response = subject.domain_premium_price(account_id, "ruby.codes")
|
55
|
-
expect(response).to be_a(Dnsimple::Response)
|
56
|
-
|
57
|
-
result = response.data
|
58
|
-
expect(result).to be_a(Dnsimple::Struct::DomainPremiumPrice)
|
59
|
-
expect(result.premium_price).to eq("109.00")
|
60
|
-
expect(result.action).to eq("registration")
|
61
|
-
end
|
62
|
-
|
63
|
-
it "builds the correct request when action is passed" do
|
64
|
-
subject.domain_premium_price(account_id, domain_name = "ruby.codes", action: "registration")
|
65
|
-
|
66
|
-
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/premium_price?action=registration")
|
67
|
-
.with(headers: { "Accept" => "application/json" })
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context "when not premium price" do
|
72
|
-
before do
|
73
|
-
stub_request(:get, %r{/v2/#{account_id}/registrar/domains/.+/premium_price$})
|
74
|
-
.to_return(read_http_fixture("getDomainPremiumPrice/failure.http"))
|
75
|
-
end
|
76
|
-
|
77
|
-
it "raises error" do
|
78
|
-
expect {
|
79
|
-
subject.domain_premium_price(account_id, "example.com")
|
80
|
-
}.to raise_error(Dnsimple::RequestError, "`example.com` is not a premium domain for registration")
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
37
|
describe "#get_domain_prices" do
|
86
38
|
let(:account_id) { 1010 }
|
87
39
|
|
@@ -317,7 +269,7 @@ describe Dnsimple::Client, ".registrar" do
|
|
317
269
|
expect(result.state).to eq("transferring")
|
318
270
|
expect(result.auto_renew).to be(false)
|
319
271
|
expect(result.whois_privacy).to be(false)
|
320
|
-
expect(result.status_description).to
|
272
|
+
expect(result.status_description).to be_nil
|
321
273
|
expect(result.created_at).to eq("2020-06-05T18:08:00Z")
|
322
274
|
expect(result.updated_at).to eq("2020-06-05T18:08:04Z")
|
323
275
|
end
|
@@ -61,7 +61,7 @@ describe Dnsimple::Client, ".services" do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
it "delegates to client.paginate" do
|
64
|
-
expect(subject).to receive(:paginate).with(:services, foo: "bar")
|
64
|
+
expect(subject).to receive(:paginate).with(:services, { foo: "bar" })
|
65
65
|
subject.all_services(foo: "bar")
|
66
66
|
end
|
67
67
|
|
@@ -65,7 +65,7 @@ describe Dnsimple::Client, ".templates" do
|
|
65
65
|
let(:template_id) { "alpha" }
|
66
66
|
|
67
67
|
it "delegates to client.paginate" do
|
68
|
-
expect(subject).to receive(:paginate).with(:records, account_id, template_id, option: "value")
|
68
|
+
expect(subject).to receive(:paginate).with(:records, account_id, template_id, { option: "value" })
|
69
69
|
subject.all_records(account_id, template_id, option: "value")
|
70
70
|
end
|
71
71
|
|
@@ -64,8 +64,8 @@ describe Dnsimple::Client, ".templates" do
|
|
64
64
|
let(:account_id) { 1010 }
|
65
65
|
|
66
66
|
it "delegates to client.paginate" do
|
67
|
-
expect(subject).to receive(:paginate).with(:templates, account_id, foo: "bar")
|
68
|
-
subject.all_templates(account_id, foo: "bar")
|
67
|
+
expect(subject).to receive(:paginate).with(:templates, account_id, { foo: "bar" })
|
68
|
+
subject.all_templates(account_id, { foo: "bar" })
|
69
69
|
end
|
70
70
|
|
71
71
|
it "supports sorting" do
|
@@ -68,7 +68,7 @@ describe Dnsimple::Client, ".tlds" do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
it "delegates to client.paginate" do
|
71
|
-
expect(subject).to receive(:paginate).with(:list_tlds, foo: "bar")
|
71
|
+
expect(subject).to receive(:paginate).with(:list_tlds, { foo: "bar" })
|
72
72
|
subject.all_tlds(foo: "bar")
|
73
73
|
end
|
74
74
|
|
@@ -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
|
|
@@ -93,8 +93,8 @@ describe Dnsimple::Client, ".zones" do
|
|
93
93
|
let(:zone_id) { "example.com" }
|
94
94
|
|
95
95
|
it "delegates to client.paginate" do
|
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
|
+
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" })
|
98
98
|
end
|
99
99
|
|
100
100
|
it "supports sorting" do
|
@@ -179,7 +179,7 @@ describe Dnsimple::Client, ".zones" do
|
|
179
179
|
expect(result).to be_a(Dnsimple::Struct::ZoneRecord)
|
180
180
|
expect(result.id).to eq(record_id)
|
181
181
|
expect(result.zone_id).to eq("example.com")
|
182
|
-
expect(result.parent_id).to
|
182
|
+
expect(result.parent_id).to be_nil
|
183
183
|
expect(result.type).to eq("MX")
|
184
184
|
expect(result.name).to eq("")
|
185
185
|
expect(result.content).to eq("mxa.example.com")
|
@@ -79,8 +79,8 @@ describe Dnsimple::Client, ".zones" do
|
|
79
79
|
let(:account_id) { 1010 }
|
80
80
|
|
81
81
|
it "delegates to client.paginate" do
|
82
|
-
expect(subject).to receive(:paginate).with(:zones, account_id, foo: "bar")
|
83
|
-
subject.all_zones(account_id, foo: "bar")
|
82
|
+
expect(subject).to receive(:paginate).with(:zones, account_id, { foo: "bar" })
|
83
|
+
subject.all_zones(account_id, { foo: "bar" })
|
84
84
|
end
|
85
85
|
|
86
86
|
it "supports sorting" do
|
@@ -49,36 +49,36 @@ describe Dnsimple::Client do
|
|
49
49
|
|
50
50
|
describe "#get" do
|
51
51
|
it "delegates to #request" do
|
52
|
-
allow(subject).to receive(:execute).with(:get, "path", nil, foo: "bar").and_return(:returned)
|
53
|
-
expect(subject.get("path", foo: "bar")).to eq(:returned)
|
52
|
+
allow(subject).to receive(:execute).with(:get, "path", nil, { foo: "bar" }).and_return(:returned)
|
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
|
-
expect(subject.post("path", foo: "bar")).to eq(:returned)
|
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
|
-
expect(subject.put("path", foo: "bar")).to eq(:returned)
|
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
|
-
expect(subject.patch("path", foo: "bar")).to eq(:returned)
|
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
|
-
expect(subject.delete("path", foo: "bar")).to eq(:returned)
|
81
|
+
expect(subject.delete("path", { foo: "bar" })).to eq(:returned)
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -128,12 +128,12 @@ describe Dnsimple::Client do
|
|
128
128
|
|
129
129
|
allow(HTTParty).to receive(:get)
|
130
130
|
.with(
|
131
|
-
"#{subject.base_url}foo",
|
132
|
-
|
133
|
-
|
134
|
-
|
131
|
+
"#{subject.base_url}foo", {
|
132
|
+
format: :json,
|
133
|
+
basic_auth: { username: "user", password: "pass" },
|
134
|
+
headers: { 'Accept' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT },
|
135
|
+
}
|
135
136
|
)
|
136
|
-
.and_return(instance_double('response', code: 200))
|
137
137
|
|
138
138
|
subject.request(:get, 'foo')
|
139
139
|
end
|
@@ -141,14 +141,14 @@ describe Dnsimple::Client do
|
|
141
141
|
it "properly extracts processes options and encodes data" do
|
142
142
|
allow(HTTParty).to receive(:put)
|
143
143
|
.with(
|
144
|
-
"#{subject.base_url}foo",
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
144
|
+
"#{subject.base_url}foo", {
|
145
|
+
format: :json,
|
146
|
+
body: JSON.dump(something: "else"),
|
147
|
+
query: { foo: "bar" },
|
148
|
+
basic_auth: { username: "user", password: "pass" },
|
149
|
+
headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT, "Custom" => "Header" },
|
150
|
+
}
|
150
151
|
)
|
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
|
@@ -156,13 +156,13 @@ describe Dnsimple::Client do
|
|
156
156
|
it "handles non application/json content types" do
|
157
157
|
allow(HTTParty).to receive(:post)
|
158
158
|
.with(
|
159
|
-
"#{subject.base_url}foo",
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
159
|
+
"#{subject.base_url}foo", {
|
160
|
+
format: :json,
|
161
|
+
body: { something: "else" },
|
162
|
+
basic_auth: { username: "user", password: "pass" },
|
163
|
+
headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded', 'User-Agent' => Dnsimple::Default::USER_AGENT },
|
164
|
+
}
|
164
165
|
)
|
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
|
@@ -170,13 +170,13 @@ describe Dnsimple::Client do
|
|
170
170
|
it "includes options for proxy support" do
|
171
171
|
allow(HTTParty).to receive(:get)
|
172
172
|
.with(
|
173
|
-
"#{subject.base_url}test",
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
173
|
+
"#{subject.base_url}test", {
|
174
|
+
format: :json,
|
175
|
+
http_proxyaddr: "example-proxy.com",
|
176
|
+
http_proxyport: "4321",
|
177
|
+
headers: { 'Accept' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT },
|
178
|
+
}
|
178
179
|
)
|
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, {})
|
@@ -186,10 +186,9 @@ describe Dnsimple::Client do
|
|
186
186
|
allow(HTTParty).to receive(:get)
|
187
187
|
.with(
|
188
188
|
"#{subject.base_url}test",
|
189
|
-
format: :json,
|
190
|
-
|
189
|
+
{ format: :json,
|
190
|
+
headers: hash_including("User-Agent" => "customAgent #{Dnsimple::Default::USER_AGENT}"), }
|
191
191
|
)
|
192
|
-
.and_return(instance_double("response", code: 200))
|
193
192
|
|
194
193
|
subject = described_class.new(user_agent: "customAgent")
|
195
194
|
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")
|
@@ -17,4 +17,4 @@ X-Permitted-Cross-Domain-Policies: none
|
|
17
17
|
X-XSS-Protection: 1; mode=block
|
18
18
|
Strict-Transport-Security: max-age=31536000
|
19
19
|
|
20
|
-
{"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"}}
|
@@ -17,4 +17,4 @@ X-Permitted-Cross-Domain-Policies: none
|
|
17
17
|
X-XSS-Protection: 1; mode=block
|
18
18
|
Strict-Transport-Security: max-age=31536000
|
19
19
|
|
20
|
-
{"data":{"id":24,"domain_id":1010,"algorithm":"8","digest":"C1F6E04A5A61FBF65BF9DC8294C363CF11C89E802D926BDAB79C55D27BEFA94F","digest_type":"2","keytag":"44620","created_at":"2017-03-03T13:49:58Z","updated_at":"2017-03-03T13:49:58Z"}}
|
20
|
+
{"data":{"id":24,"domain_id":1010,"algorithm":"8","digest":"C1F6E04A5A61FBF65BF9DC8294C363CF11C89E802D926BDAB79C55D27BEFA94F","digest_type":"2","keytag":"44620","public_key":null,"created_at":"2017-03-03T13:49:58Z","updated_at":"2017-03-03T13:49:58Z"}}
|
@@ -17,4 +17,4 @@ X-Permitted-Cross-Domain-Policies: none
|
|
17
17
|
X-XSS-Protection: 1; mode=block
|
18
18
|
Strict-Transport-Security: max-age=31536000
|
19
19
|
|
20
|
-
{"data":{"tld":"com","tld_type":1,"whois_privacy":true,"auto_renew_only":false,"idn":true,"minimum_registration":1,"registration_enabled":true,"renewal_enabled":true,"transfer_enabled":true}}
|
20
|
+
{"data":{"tld":"com","tld_type":1,"whois_privacy":true,"auto_renew_only":false,"idn":true,"minimum_registration":1,"registration_enabled":true,"renewal_enabled":true,"transfer_enabled":true,"dnssec_interface_type":"ds"}}
|