dnsimple 3.1.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.rubocop_dnsimple.yml +24 -18
- data/CHANGELOG.md +17 -5
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +0 -1
- data/README.md +14 -3
- data/dnsimple.gemspec +1 -1
- data/lib/dnsimple/client.rb +5 -5
- data/lib/dnsimple/client/certificates.rb +89 -0
- data/lib/dnsimple/client/clients.rb +37 -0
- data/lib/dnsimple/client/collaborators.rb +76 -0
- data/lib/dnsimple/client/domains_pushes.rb +97 -0
- data/lib/dnsimple/client/registrar.rb +2 -2
- data/lib/dnsimple/client/registrar_delegation.rb +42 -0
- data/lib/dnsimple/client/services_domains.rb +82 -0
- data/lib/dnsimple/client/templates.rb +0 -5
- data/lib/dnsimple/client/templates_domains.rb +29 -0
- data/lib/dnsimple/client/vanity_name_servers.rb +47 -0
- data/lib/dnsimple/client/zones.rb +17 -0
- data/lib/dnsimple/client/zones_records.rb +9 -9
- data/lib/dnsimple/struct.rb +6 -1
- data/lib/dnsimple/struct/certificate.rb +37 -0
- data/lib/dnsimple/struct/certificate_bundle.rb +24 -0
- data/lib/dnsimple/struct/collaborator.rb +34 -0
- data/lib/dnsimple/struct/domain_push.rb +28 -0
- data/lib/dnsimple/struct/tld.rb +12 -0
- data/lib/dnsimple/struct/zone_file.rb +10 -0
- data/lib/dnsimple/struct/{record.rb → zone_record.rb} +4 -1
- data/lib/dnsimple/version.rb +1 -1
- data/spec/dnsimple/client/accounts_spec.rb +1 -1
- data/spec/dnsimple/client/certificates_spec.rb +206 -0
- data/spec/dnsimple/client/collaborators_spec.rb +162 -0
- data/spec/dnsimple/client/contacts_spec.rb +5 -5
- data/spec/dnsimple/client/domains_email_forwards_spec.rb +5 -5
- data/spec/dnsimple/client/domains_pushes_spec.rb +162 -0
- data/spec/dnsimple/client/domains_spec.rb +6 -6
- data/spec/dnsimple/client/registrar_delegation_spec.rb +51 -0
- data/spec/dnsimple/client/registrar_spec.rb +6 -6
- data/spec/dnsimple/client/registrar_whois_privacy_spec.rb +4 -4
- data/spec/dnsimple/client/services_domains_spec.rb +115 -0
- data/spec/dnsimple/client/services_spec.rb +1 -1
- data/spec/dnsimple/client/templates_domains_spec.rb +32 -0
- data/spec/dnsimple/client/templates_records_spec.rb +1 -1
- data/spec/dnsimple/client/templates_spec.rb +25 -1
- data/spec/dnsimple/client/tlds_spec.rb +8 -4
- data/spec/dnsimple/client/vanity_name_servers_spec.rb +54 -0
- data/spec/dnsimple/client/webhooks_spec.rb +2 -2
- data/spec/dnsimple/client/zones_records_spec.rb +34 -23
- data/spec/dnsimple/client/zones_spec.rb +40 -4
- data/spec/fixtures.http/acceptPush/success.http +17 -0
- data/spec/fixtures.http/addCollaborator/invite-success.http +21 -0
- data/spec/fixtures.http/addCollaborator/success.http +21 -0
- data/spec/fixtures.http/appliedServices/success.http +21 -0
- data/spec/fixtures.http/applyService/created.http +17 -0
- data/spec/fixtures.http/applyTemplate/success.http +13 -0
- data/spec/fixtures.http/changeDomainDelegationFromVanity/success.http +17 -0
- data/spec/fixtures.http/changeDomainDelegationToVanity/success.http +21 -0
- data/spec/fixtures.http/createZoneRecord/created.http +13 -9
- data/spec/fixtures.http/disableVanityNameServers/success.http +17 -0
- data/spec/fixtures.http/downloadCertificate/success.http +21 -0
- data/spec/fixtures.http/enableVanityNameServers/success.http +21 -0
- data/spec/fixtures.http/getCertificate/success.http +21 -0
- data/spec/fixtures.http/getCertificatePrivateKey/success.http +21 -0
- data/spec/fixtures.http/getTld/success.http +13 -9
- data/spec/fixtures.http/getZoneFile/success.http +21 -0
- data/spec/fixtures.http/getZoneRecord/success.http +13 -9
- data/spec/fixtures.http/initiatePush/success.http +21 -0
- data/spec/fixtures.http/{accounts → listAccounts}/success-account.http +0 -0
- data/spec/fixtures.http/{accounts → listAccounts}/success-user.http +0 -0
- data/spec/fixtures.http/listCertificates/success.http +21 -0
- data/spec/fixtures.http/listCollaborators/success.http +21 -0
- data/spec/fixtures.http/listPushes/success.http +21 -0
- data/spec/fixtures.http/listTlds/success.http +13 -9
- data/spec/fixtures.http/listZoneRecords/success.http +13 -9
- data/spec/fixtures.http/notfound-certificate.http +16 -0
- data/spec/fixtures.http/notfound-collaborator.http +16 -0
- data/spec/fixtures.http/notfound-contact.http +1 -1
- data/spec/fixtures.http/notfound-domainpush.http +12 -0
- data/spec/fixtures.http/rejectPush/success.http +17 -0
- data/spec/fixtures.http/removeCollaborator/success.http +17 -0
- data/spec/fixtures.http/unapplyService/success.http +17 -0
- data/spec/fixtures.http/updateZoneRecord/success.http +13 -9
- metadata +80 -10
@@ -47,7 +47,7 @@ describe Dnsimple::Client, ".contacts" do
|
|
47
47
|
|
48
48
|
response.data.each do |result|
|
49
49
|
expect(result).to be_a(Dnsimple::Struct::Contact)
|
50
|
-
expect(result.id).to be_a(
|
50
|
+
expect(result.id).to be_a(Integer)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -56,9 +56,9 @@ describe Dnsimple::Client, ".contacts" do
|
|
56
56
|
|
57
57
|
expect(response.respond_to?(:page)).to be_truthy
|
58
58
|
expect(response.page).to eq(1)
|
59
|
-
expect(response.per_page).to be_a(
|
60
|
-
expect(response.total_entries).to be_a(
|
61
|
-
expect(response.total_pages).to be_a(
|
59
|
+
expect(response.per_page).to be_a(Integer)
|
60
|
+
expect(response.total_entries).to be_a(Integer)
|
61
|
+
expect(response.total_pages).to be_a(Integer)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -106,7 +106,7 @@ describe Dnsimple::Client, ".contacts" do
|
|
106
106
|
|
107
107
|
result = response.data
|
108
108
|
expect(result).to be_a(Dnsimple::Struct::Contact)
|
109
|
-
expect(result.id).to be_a(
|
109
|
+
expect(result.id).to be_a(Integer)
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
@@ -48,7 +48,7 @@ describe Dnsimple::Client, ".domains" do
|
|
48
48
|
|
49
49
|
response.data.each do |result|
|
50
50
|
expect(result).to be_a(Dnsimple::Struct::EmailForward)
|
51
|
-
expect(result.id).to be_a(
|
51
|
+
expect(result.id).to be_a(Integer)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -57,9 +57,9 @@ describe Dnsimple::Client, ".domains" do
|
|
57
57
|
|
58
58
|
expect(response.respond_to?(:page)).to be_truthy
|
59
59
|
expect(response.page).to eq(1)
|
60
|
-
expect(response.per_page).to be_a(
|
61
|
-
expect(response.total_entries).to be_a(
|
62
|
-
expect(response.total_pages).to be_a(
|
60
|
+
expect(response.per_page).to be_a(Integer)
|
61
|
+
expect(response.total_entries).to be_a(Integer)
|
62
|
+
expect(response.total_pages).to be_a(Integer)
|
63
63
|
end
|
64
64
|
|
65
65
|
context "when the domain does not exist" do
|
@@ -120,7 +120,7 @@ describe Dnsimple::Client, ".domains" do
|
|
120
120
|
|
121
121
|
result = response.data
|
122
122
|
expect(result).to be_a(Dnsimple::Struct::EmailForward)
|
123
|
-
expect(result.id).to be_a(
|
123
|
+
expect(result.id).to be_a(Integer)
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
@@ -0,0 +1,162 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dnsimple::Client, ".domains" do
|
4
|
+
|
5
|
+
subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").domains }
|
6
|
+
|
7
|
+
describe "#initiate_push" do
|
8
|
+
let(:account_id) { 1010 }
|
9
|
+
let(:domain_id) { "example.com" }
|
10
|
+
|
11
|
+
before do
|
12
|
+
stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/pushes$}).
|
13
|
+
to_return(read_http_fixture("initiatePush/success.http"))
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:attributes) { { new_account_email: "admin@target-account.test" } }
|
17
|
+
|
18
|
+
it "builds the correct request" do
|
19
|
+
subject.initiate_push(account_id, domain_id, attributes)
|
20
|
+
|
21
|
+
expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/pushes").
|
22
|
+
with(body: attributes).
|
23
|
+
with(headers: { 'Accept' => 'application/json' })
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns the domain push" do
|
27
|
+
response = subject.initiate_push(account_id, domain_id, attributes)
|
28
|
+
expect(response).to be_a(Dnsimple::Response)
|
29
|
+
|
30
|
+
result = response.data
|
31
|
+
expect(result).to be_a(Dnsimple::Struct::DomainPush)
|
32
|
+
expect(result.id).to be_a(Integer)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#pushes" do
|
37
|
+
let(:account_id) { 2020 }
|
38
|
+
|
39
|
+
before do
|
40
|
+
stub_request(:get, %r{/v2/#{account_id}/pushes}).
|
41
|
+
to_return(read_http_fixture("listPushes/success.http"))
|
42
|
+
end
|
43
|
+
|
44
|
+
it "builds the correct request" do
|
45
|
+
subject.pushes(account_id)
|
46
|
+
|
47
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/pushes").
|
48
|
+
with(headers: { 'Accept' => 'application/json' })
|
49
|
+
end
|
50
|
+
|
51
|
+
it "supports pagination" do
|
52
|
+
subject.pushes(account_id, page: 2)
|
53
|
+
|
54
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/pushes?page=2")
|
55
|
+
end
|
56
|
+
|
57
|
+
it "supports extra request options" do
|
58
|
+
subject.pushes(account_id, query: { foo: "bar" })
|
59
|
+
|
60
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/pushes?foo=bar")
|
61
|
+
end
|
62
|
+
|
63
|
+
it "returns a list of domain pushes" do
|
64
|
+
response = subject.pushes(account_id)
|
65
|
+
|
66
|
+
expect(response).to be_a(Dnsimple::PaginatedResponse)
|
67
|
+
expect(response.data).to be_a(Array)
|
68
|
+
expect(response.data.size).to eq(2)
|
69
|
+
|
70
|
+
response.data.each do |result|
|
71
|
+
expect(result).to be_a(Dnsimple::Struct::DomainPush)
|
72
|
+
expect(result.id).to be_a(Integer)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
it "exposes the pagination information" do
|
77
|
+
response = subject.pushes(account_id)
|
78
|
+
|
79
|
+
expect(response.respond_to?(:page)).to be_truthy
|
80
|
+
expect(response.page).to eq(1)
|
81
|
+
expect(response.per_page).to be_a(Integer)
|
82
|
+
expect(response.total_entries).to be_a(Integer)
|
83
|
+
expect(response.total_pages).to be_a(Integer)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "#accept_push" do
|
88
|
+
let(:account_id) { 2020 }
|
89
|
+
let(:push_id) { 1 }
|
90
|
+
|
91
|
+
before do
|
92
|
+
stub_request(:post, %r{/v2/#{account_id}/pushes/#{push_id}$}).
|
93
|
+
to_return(read_http_fixture("acceptPush/success.http"))
|
94
|
+
end
|
95
|
+
|
96
|
+
let(:attributes) { { contact_id: 2 } }
|
97
|
+
|
98
|
+
it "builds the correct request" do
|
99
|
+
subject.accept_push(account_id, push_id, attributes)
|
100
|
+
|
101
|
+
expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/pushes/#{push_id}").
|
102
|
+
with(body: attributes).
|
103
|
+
with(headers: { 'Accept' => 'application/json' })
|
104
|
+
end
|
105
|
+
|
106
|
+
it "returns nothing" do
|
107
|
+
response = subject.accept_push(account_id, push_id, attributes)
|
108
|
+
expect(response).to be_a(Dnsimple::Response)
|
109
|
+
|
110
|
+
result = response.data
|
111
|
+
expect(result).to be_nil
|
112
|
+
end
|
113
|
+
|
114
|
+
context "when the domain push does not exist" do
|
115
|
+
it "raises NotFoundError" do
|
116
|
+
stub_request(:post, %r{/v2}).
|
117
|
+
to_return(read_http_fixture("notfound-domainpush.http"))
|
118
|
+
|
119
|
+
expect {
|
120
|
+
subject.accept_push(account_id, push_id, attributes)
|
121
|
+
}.to raise_error(Dnsimple::NotFoundError)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "#reject_push" do
|
127
|
+
let(:account_id) { 2020 }
|
128
|
+
let(:push_id) { 1 }
|
129
|
+
|
130
|
+
before do
|
131
|
+
stub_request(:delete, %r{/v2/#{account_id}/pushes/#{push_id}$}).
|
132
|
+
to_return(read_http_fixture("rejectPush/success.http"))
|
133
|
+
end
|
134
|
+
|
135
|
+
it "builds the correct request" do
|
136
|
+
subject.reject_push(account_id, push_id)
|
137
|
+
|
138
|
+
expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/pushes/#{push_id}").
|
139
|
+
with(headers: { 'Accept' => 'application/json' })
|
140
|
+
end
|
141
|
+
|
142
|
+
it "returns nothing" do
|
143
|
+
response = subject.reject_push(account_id, push_id)
|
144
|
+
expect(response).to be_a(Dnsimple::Response)
|
145
|
+
|
146
|
+
result = response.data
|
147
|
+
expect(result).to be_nil
|
148
|
+
end
|
149
|
+
|
150
|
+
context "when the domain push does not exist" do
|
151
|
+
it "raises NotFoundError" do
|
152
|
+
stub_request(:delete, %r{/v2}).
|
153
|
+
to_return(read_http_fixture("notfound-domainpush.http"))
|
154
|
+
|
155
|
+
expect {
|
156
|
+
subject.reject_push(account_id, push_id)
|
157
|
+
}.to raise_error(Dnsimple::NotFoundError)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
@@ -53,7 +53,7 @@ describe Dnsimple::Client, ".domains" do
|
|
53
53
|
|
54
54
|
response.data.each do |result|
|
55
55
|
expect(result).to be_a(Dnsimple::Struct::Domain)
|
56
|
-
expect(result.id).to be_a(
|
56
|
+
expect(result.id).to be_a(Integer)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -62,9 +62,9 @@ describe Dnsimple::Client, ".domains" do
|
|
62
62
|
|
63
63
|
expect(response.respond_to?(:page)).to be_truthy
|
64
64
|
expect(response.page).to eq(1)
|
65
|
-
expect(response.per_page).to be_a(
|
66
|
-
expect(response.total_entries).to be_a(
|
67
|
-
expect(response.total_pages).to be_a(
|
65
|
+
expect(response.per_page).to be_a(Integer)
|
66
|
+
expect(response.total_entries).to be_a(Integer)
|
67
|
+
expect(response.total_pages).to be_a(Integer)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -118,7 +118,7 @@ describe Dnsimple::Client, ".domains" do
|
|
118
118
|
|
119
119
|
result = response.data
|
120
120
|
expect(result).to be_a(Dnsimple::Struct::Domain)
|
121
|
-
expect(result.id).to be_a(
|
121
|
+
expect(result.id).to be_a(Integer)
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
@@ -224,7 +224,7 @@ describe Dnsimple::Client, ".domains" do
|
|
224
224
|
|
225
225
|
result = response.data
|
226
226
|
expect(result).to be_a(Dnsimple::Struct::Domain)
|
227
|
-
expect(result.id).to be_a(
|
227
|
+
expect(result.id).to be_a(Integer)
|
228
228
|
end
|
229
229
|
end
|
230
230
|
|
@@ -52,4 +52,55 @@ describe Dnsimple::Client, ".registrar" do
|
|
52
52
|
expect(response.data).to match_array(%w(ns1.dnsimple.com ns2.dnsimple.com ns3.dnsimple.com ns4.dnsimple.com))
|
53
53
|
end
|
54
54
|
end
|
55
|
+
|
56
|
+
describe "#change_domain_delegation_to_vanity" do
|
57
|
+
let(:account_id) { 1010 }
|
58
|
+
|
59
|
+
before do
|
60
|
+
stub_request(:put, %r{/v2/#{account_id}/registrar/domains/.+/delegation/vanity$}).
|
61
|
+
to_return(read_http_fixture("changeDomainDelegationToVanity/success.http"))
|
62
|
+
end
|
63
|
+
|
64
|
+
let(:attributes) { %w(ns1.example.com ns2.example.com) }
|
65
|
+
|
66
|
+
it "builds the correct request" do
|
67
|
+
subject.change_domain_delegation_to_vanity(account_id, domain_name = "example.com", attributes)
|
68
|
+
|
69
|
+
expect(WebMock).to have_requested(:put, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/delegation/vanity").
|
70
|
+
with(body: JSON.dump(attributes)).
|
71
|
+
with(headers: { "Accept" => "application/json" })
|
72
|
+
end
|
73
|
+
|
74
|
+
it "returns vanity name servers of the domain" do
|
75
|
+
response = subject.change_domain_delegation_to_vanity(account_id, "example.com", attributes)
|
76
|
+
expect(response).to be_a(Dnsimple::Response)
|
77
|
+
|
78
|
+
vanity_name_servers = response.data.map { |ns| ns["name"] }
|
79
|
+
expect(vanity_name_servers).to match_array(%w(ns1.example.com ns2.example.com))
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "#change_domain_delegation_from_vanity" do
|
84
|
+
let(:account_id) { 1010 }
|
85
|
+
|
86
|
+
before do
|
87
|
+
stub_request(:delete, %r{/v2/#{account_id}/registrar/domains/.+/delegation/vanity$}).
|
88
|
+
to_return(read_http_fixture("changeDomainDelegationFromVanity/success.http"))
|
89
|
+
end
|
90
|
+
|
91
|
+
it "builds the correct request" do
|
92
|
+
subject.change_domain_delegation_from_vanity(account_id, domain_name = "example.com")
|
93
|
+
|
94
|
+
expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/delegation/vanity").
|
95
|
+
with(headers: { "Accept" => "application/json" })
|
96
|
+
end
|
97
|
+
|
98
|
+
it "returns empty response" do
|
99
|
+
response = subject.change_domain_delegation_from_vanity(account_id, "example.com")
|
100
|
+
expect(response).to be_a(Dnsimple::Response)
|
101
|
+
|
102
|
+
result = response.data
|
103
|
+
expect(result).to be_nil
|
104
|
+
end
|
105
|
+
end
|
55
106
|
end
|
@@ -56,7 +56,7 @@ describe Dnsimple::Client, ".registrar" do
|
|
56
56
|
|
57
57
|
result = response.data
|
58
58
|
expect(result).to be_a(Dnsimple::Struct::Domain)
|
59
|
-
expect(result.id).to be_a(
|
59
|
+
expect(result.id).to be_a(Integer)
|
60
60
|
end
|
61
61
|
|
62
62
|
context "when the attributes are incomplete" do
|
@@ -90,10 +90,10 @@ describe Dnsimple::Client, ".registrar" do
|
|
90
90
|
|
91
91
|
result = response.data
|
92
92
|
expect(result).to be_a(Dnsimple::Struct::Domain)
|
93
|
-
expect(result.id).to be_a(
|
93
|
+
expect(result.id).to be_a(Integer)
|
94
94
|
end
|
95
95
|
|
96
|
-
context "when it is too
|
96
|
+
context "when it is too soon for the domain to be renewed" do
|
97
97
|
it "raises a BadRequestError" do
|
98
98
|
stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/renewal$}).
|
99
99
|
to_return(read_http_fixture("renewDomain/error-tooearly.http"))
|
@@ -113,7 +113,7 @@ describe Dnsimple::Client, ".registrar" do
|
|
113
113
|
to_return(read_http_fixture("transferDomain/success.http"))
|
114
114
|
end
|
115
115
|
|
116
|
-
let(:attributes) { { registrant_id: "10",
|
116
|
+
let(:attributes) { { registrant_id: "10", auth_code: "x1y2z3" } }
|
117
117
|
|
118
118
|
it "builds the correct request" do
|
119
119
|
subject.transfer_domain(account_id, domain_name = "example.com", attributes)
|
@@ -135,7 +135,7 @@ describe Dnsimple::Client, ".registrar" do
|
|
135
135
|
|
136
136
|
context "when the attributes are incomplete" do
|
137
137
|
it "raises ArgumentError" do
|
138
|
-
expect { subject.transfer_domain(account_id, "example.com",
|
138
|
+
expect { subject.transfer_domain(account_id, "example.com", auth_code: "x1y2z3") }.to raise_error(ArgumentError)
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
@@ -150,7 +150,7 @@ describe Dnsimple::Client, ".registrar" do
|
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
-
context "when :
|
153
|
+
context "when :auth_code wasn't provided and is required by the TLD" do
|
154
154
|
it "raises a BadRequestError" do
|
155
155
|
stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/transfer$}).
|
156
156
|
to_return(read_http_fixture("transferDomain/error-missing-authcode.http"))
|
@@ -26,7 +26,7 @@ describe Dnsimple::Client, ".registrar" do
|
|
26
26
|
|
27
27
|
result = response.data
|
28
28
|
expect(result).to be_a(Dnsimple::Struct::WhoisPrivacy)
|
29
|
-
expect(result.domain_id).to be_kind_of(
|
29
|
+
expect(result.domain_id).to be_kind_of(Integer)
|
30
30
|
expect(result.enabled).to be_truthy
|
31
31
|
expect(result.expires_on).to be_kind_of(String)
|
32
32
|
end
|
@@ -55,7 +55,7 @@ describe Dnsimple::Client, ".registrar" do
|
|
55
55
|
|
56
56
|
result = response.data
|
57
57
|
expect(result).to be_a(Dnsimple::Struct::WhoisPrivacy)
|
58
|
-
expect(result.domain_id).to be_kind_of(
|
58
|
+
expect(result.domain_id).to be_kind_of(Integer)
|
59
59
|
expect(result.enabled).to be_truthy
|
60
60
|
expect(result.expires_on).to be_kind_of(String)
|
61
61
|
end
|
@@ -81,7 +81,7 @@ describe Dnsimple::Client, ".registrar" do
|
|
81
81
|
|
82
82
|
result = response.data
|
83
83
|
expect(result).to be_a(Dnsimple::Struct::WhoisPrivacy)
|
84
|
-
expect(result.domain_id).to be_kind_of(
|
84
|
+
expect(result.domain_id).to be_kind_of(Integer)
|
85
85
|
expect(result.enabled).to be_nil
|
86
86
|
expect(result.expires_on).to be_nil
|
87
87
|
end
|
@@ -110,7 +110,7 @@ describe Dnsimple::Client, ".registrar" do
|
|
110
110
|
|
111
111
|
result = response.data
|
112
112
|
expect(result).to be_a(Dnsimple::Struct::WhoisPrivacy)
|
113
|
-
expect(result.domain_id).to be_kind_of(
|
113
|
+
expect(result.domain_id).to be_kind_of(Integer)
|
114
114
|
expect(result.enabled).to be_falsey
|
115
115
|
expect(result.expires_on).to be_kind_of(String)
|
116
116
|
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dnsimple::Client, ".services" do
|
4
|
+
|
5
|
+
subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").services }
|
6
|
+
|
7
|
+
|
8
|
+
describe "#applied_services" do
|
9
|
+
let(:account_id) { 1010 }
|
10
|
+
let(:domain_id) { 'example.com' }
|
11
|
+
|
12
|
+
before do
|
13
|
+
stub_request(:get, %r{/v2/#{account_id}/domains/#{domain_id}/services}).
|
14
|
+
to_return(read_http_fixture("appliedServices/success.http"))
|
15
|
+
end
|
16
|
+
|
17
|
+
it "builds the correct request" do
|
18
|
+
subject.applied_services(account_id, domain_id)
|
19
|
+
|
20
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/services").
|
21
|
+
with(headers: { "Accept" => "application/json" })
|
22
|
+
end
|
23
|
+
|
24
|
+
it "supports pagination" do
|
25
|
+
subject.applied_services(account_id, domain_id, page: 2)
|
26
|
+
|
27
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/services?page=2")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "supports extra request options" do
|
31
|
+
subject.applied_services(account_id, domain_id, query: { foo: "bar" })
|
32
|
+
|
33
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/services?foo=bar")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "supports sorting" do
|
37
|
+
subject.applied_services(account_id, domain_id, sort: "short_name:asc")
|
38
|
+
|
39
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/services?sort=short_name:asc")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns the list of available services" do
|
43
|
+
response = subject.applied_services(account_id, domain_id)
|
44
|
+
expect(response).to be_a(Dnsimple::CollectionResponse)
|
45
|
+
|
46
|
+
response.data.each do |service|
|
47
|
+
expect(service).to be_a(Dnsimple::Struct::Service)
|
48
|
+
expect(service.id).to be_a(Integer)
|
49
|
+
expect(service.name).to be_a(String)
|
50
|
+
expect(service.short_name).to be_a(String)
|
51
|
+
expect(service.description).to be_a(String)
|
52
|
+
|
53
|
+
service.settings.each do |service_setting|
|
54
|
+
expect(service_setting).to be_a(Dnsimple::Struct::Service::Setting)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#apply_service" do
|
61
|
+
let(:account_id) { 1010 }
|
62
|
+
let(:domain_id) { "example.com" }
|
63
|
+
let(:service_id) { "service1" }
|
64
|
+
|
65
|
+
before do
|
66
|
+
stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/services/#{service_id}$}).
|
67
|
+
to_return(read_http_fixture("applyService/created.http"))
|
68
|
+
end
|
69
|
+
|
70
|
+
let(:settings) { { app: "foo" } }
|
71
|
+
|
72
|
+
it "builds the correct request" do
|
73
|
+
subject.apply_service(account_id, service_id, domain_id, settings)
|
74
|
+
|
75
|
+
expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/services/#{service_id}").
|
76
|
+
with(body: settings).
|
77
|
+
with(headers: { 'Accept' => 'application/json' })
|
78
|
+
end
|
79
|
+
|
80
|
+
it "returns empty response" do
|
81
|
+
response = subject.apply_service(account_id, service_id, domain_id, settings)
|
82
|
+
expect(response).to be_a(Dnsimple::Response)
|
83
|
+
|
84
|
+
result = response.data
|
85
|
+
expect(result).to be_nil
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "#unapply_service" do
|
90
|
+
let(:account_id) { 1010 }
|
91
|
+
let(:domain_id) { "example.com" }
|
92
|
+
let(:service_id) { "service1" }
|
93
|
+
|
94
|
+
before do
|
95
|
+
stub_request(:delete, %r{/v2/#{account_id}/domains/#{domain_id}/services/#{service_id}$}).
|
96
|
+
to_return(read_http_fixture("unapplyService/success.http"))
|
97
|
+
end
|
98
|
+
|
99
|
+
it "builds the correct request" do
|
100
|
+
subject.unapply_service(account_id, service_id, domain_id)
|
101
|
+
|
102
|
+
expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/services/#{service_id}").
|
103
|
+
with(headers: { 'Accept' => 'application/json' })
|
104
|
+
end
|
105
|
+
|
106
|
+
it "returns empty response" do
|
107
|
+
response = subject.unapply_service(account_id, service_id, domain_id)
|
108
|
+
expect(response).to be_a(Dnsimple::Response)
|
109
|
+
|
110
|
+
result = response.data
|
111
|
+
expect(result).to be_nil
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|