dnsimple 2.0.0.alpha2 → 2.0.0.alpha3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +6 -2
- data/README.markdown +32 -30
- data/dnsimple.gemspec +1 -2
- data/lib/dnsimple.rb +2 -13
- data/lib/dnsimple/client.rb +164 -53
- data/lib/dnsimple/client/certificates_service.rb +98 -0
- data/lib/dnsimple/client/client_service.rb +8 -0
- data/lib/dnsimple/client/contacts_service.rb +82 -0
- data/lib/dnsimple/client/domains_service.rb +333 -0
- data/lib/dnsimple/client/name_servers_service.rb +69 -0
- data/lib/dnsimple/client/registrars_service.rb +105 -0
- data/lib/dnsimple/client/services_service.rb +95 -0
- data/lib/dnsimple/client/templates_service.rb +180 -0
- data/lib/dnsimple/client/users_service.rb +37 -0
- data/lib/dnsimple/compatibility.rb +46 -0
- data/lib/dnsimple/default.rb +86 -0
- data/lib/dnsimple/error.rb +7 -11
- data/lib/dnsimple/extra.rb +54 -0
- data/lib/dnsimple/struct.rb +29 -0
- data/lib/dnsimple/struct/certificate.rb +56 -0
- data/lib/dnsimple/struct/contact.rb +61 -0
- data/lib/dnsimple/struct/domain.rb +40 -0
- data/lib/dnsimple/struct/email_forward.rb +14 -0
- data/lib/dnsimple/struct/extended_attribute.rb +39 -0
- data/lib/dnsimple/struct/membership.rb +22 -0
- data/lib/dnsimple/struct/price.rb +16 -0
- data/lib/dnsimple/struct/record.rb +22 -0
- data/lib/dnsimple/struct/service.rb +19 -0
- data/lib/dnsimple/struct/template.rb +19 -0
- data/lib/dnsimple/struct/template_record.rb +24 -0
- data/lib/dnsimple/struct/transfer_order.rb +10 -0
- data/lib/dnsimple/struct/user.rb +17 -0
- data/lib/dnsimple/struct/whois_privacy.rb +19 -0
- data/lib/dnsimple/version.rb +1 -1
- data/spec/dnsimple/client/certificates_service_spec.rb +196 -0
- data/spec/dnsimple/client/contacts_service_spec.rb +179 -0
- data/spec/dnsimple/client/domains_service_spec.rb +662 -0
- data/spec/dnsimple/client/name_servers_service_spec.rb +131 -0
- data/spec/dnsimple/client/registrars_service_spec.rb +160 -0
- data/spec/dnsimple/client/services_service_spec.rb +162 -0
- data/spec/dnsimple/client/templates_service_spec.rb +371 -0
- data/spec/dnsimple/client/users_service_spec.rb +70 -0
- data/spec/dnsimple/client_spec.rb +108 -99
- data/spec/dnsimple/compatibility_spec.rb +57 -0
- data/spec/files/2fa/exchange-token.http +8 -11
- data/spec/files/badgateway.http +14 -0
- data/spec/files/certificates/configure/success.http +19 -0
- data/spec/files/certificates/index/success.http +1 -1
- data/spec/files/certificates/notfound.http +19 -0
- data/spec/files/certificates/purchase/success.http +19 -0
- data/spec/files/certificates/show/success.http +1 -1
- data/spec/files/certificates/submit/success.http +19 -0
- data/spec/files/contacts/create/badrequest-missingcontact.http +19 -0
- data/spec/files/contacts/create/badrequest-validationerror.http +19 -0
- data/spec/files/contacts/create/created.http +22 -0
- data/spec/files/contacts/delete/success-204.http +18 -0
- data/spec/files/{extended_attributes/com.http → contacts/delete/success.http} +5 -5
- data/spec/files/{domains/auto_renewal_enable → contacts/index}/success.http +6 -6
- data/spec/files/contacts/notfound.http +19 -0
- data/spec/files/contacts/update/success.http +21 -0
- data/spec/files/domains/create/created.http +21 -0
- data/spec/files/domains/index/success.http +11 -9
- data/spec/files/domains/notfound.http +11 -9
- data/spec/files/domains/show/success.http +12 -10
- data/spec/files/domains_autorenewal/disable/success.http +21 -0
- data/spec/files/domains_autorenewal/enable/success.http +21 -0
- data/spec/files/domains_autorenewal/notfound-domain.http +19 -0
- data/spec/files/domains_forwards/create/created.http +22 -0
- data/spec/files/domains_forwards/delete/success.http +17 -0
- data/spec/files/domains_forwards/get/success.http +21 -0
- data/spec/files/domains_forwards/list/success.http +21 -0
- data/spec/files/domains_forwards/notfound-domain.http +19 -0
- data/spec/files/domains_forwards/notfound.http +19 -0
- data/spec/files/domains_records/create/created.http +21 -0
- data/spec/files/domains_records/delete/success-204.http +18 -0
- data/spec/files/{contacts/show/notfound.http → domains_records/delete/success.http} +9 -7
- data/spec/files/{records → domains_records}/index/success.http +0 -0
- data/spec/files/{records/show → domains_records}/notfound.http +1 -1
- data/spec/files/{records → domains_records}/show/success.http +0 -0
- data/spec/files/domains_records/update/success.http +21 -0
- data/spec/files/domains_sharing/create/success.http +21 -0
- data/spec/files/domains_sharing/delete/success.http +17 -0
- data/spec/files/domains_sharing/list/success.http +21 -0
- data/spec/files/domains_sharing/notfound-domain.http +19 -0
- data/spec/files/domains_sharing/notfound.http +19 -0
- data/spec/files/domains_whois_privacy/disable/success.http +21 -0
- data/spec/files/domains_whois_privacy/enable/success.http +22 -0
- data/spec/files/domains_zones/get/success.http +21 -0
- data/spec/files/domains_zones/notfound-domain.http +19 -0
- data/spec/files/{domains/auto_renewal_disable/notfound.http → nameservers/change/success.http} +23 -21
- data/spec/files/nameservers/deregister/success.http +17 -0
- data/spec/files/{domains/auto_renewal_enable/notfound.http → nameservers/list/success.http} +23 -21
- data/spec/files/nameservers/notfound-domain.http +19 -0
- data/spec/files/nameservers/register/badrequest-valueerror.http +19 -0
- data/spec/files/nameservers/register/success.http +21 -0
- data/spec/files/registrars/check/available.http +19 -0
- data/spec/files/registrars/check/registered.http +21 -0
- data/spec/files/registrars/register/badrequest-missingdomain.http +19 -0
- data/spec/files/registrars/register/badrequest-missingregistrant.http +19 -0
- data/spec/files/registrars/register/success.http +21 -0
- data/spec/files/registrars/renew/badrequest-missingrenewal.http +19 -0
- data/spec/files/registrars/renew/badrequest-unable.http +19 -0
- data/spec/files/registrars/renew/success.http +21 -0
- data/spec/files/registrars/transfer/success.http +21 -0
- data/spec/files/registrars_extended_attributes/list/success.http +21 -0
- data/spec/files/registrars_prices/list/success.http +21 -0
- data/spec/files/services/applied/success.http +21 -0
- data/spec/files/services/apply/success.http +21 -0
- data/spec/files/services/available/success.http +21 -0
- data/spec/files/services/index/success.http +21 -0
- data/spec/files/services/notfound.http +19 -0
- data/spec/files/services/show/success.http +21 -0
- data/spec/files/services/unapply/success.http +21 -0
- data/spec/files/subscription/show/success.http +21 -0
- data/spec/files/templates/apply/success.http +21 -0
- data/spec/files/templates/create/created.http +22 -0
- data/spec/files/templates/delete/success-204.http +21 -0
- data/spec/files/templates/delete/success.http +21 -0
- data/spec/files/templates/index/success.http +21 -0
- data/spec/files/templates/notfound.http +19 -0
- data/spec/files/templates/show/success.http +12 -10
- data/spec/files/templates/update/success.http +21 -0
- data/spec/files/templates_records/create/created.http +22 -0
- data/spec/files/templates_records/delete/success-204.http +19 -0
- data/spec/files/templates_records/delete/success.http +21 -0
- data/spec/files/templates_records/index/success.http +21 -0
- data/spec/files/templates_records/notfound.http +19 -0
- data/spec/files/templates_records/show/success.http +21 -0
- data/spec/files/templates_records/update/success.http +21 -0
- data/spec/files/users/user/success.http +21 -0
- data/spec/spec_helper.rb +0 -2
- metadata +206 -73
- data/lib/dnsimple/base.rb +0 -10
- data/lib/dnsimple/certificate.rb +0 -143
- data/lib/dnsimple/contact.rb +0 -157
- data/lib/dnsimple/domain.rb +0 -252
- data/lib/dnsimple/extended_attribute.rb +0 -52
- data/lib/dnsimple/record.rb +0 -94
- data/lib/dnsimple/service.rb +0 -42
- data/lib/dnsimple/template.rb +0 -65
- data/lib/dnsimple/template_record.rb +0 -80
- data/lib/dnsimple/transfer_order.rb +0 -34
- data/lib/dnsimple/user.rb +0 -50
- data/spec/dnsimple/certificate_spec.rb +0 -59
- data/spec/dnsimple/contact_spec.rb +0 -45
- data/spec/dnsimple/domain_spec.rb +0 -241
- data/spec/dnsimple/extended_attributes_spec.rb +0 -54
- data/spec/dnsimple/record_spec.rb +0 -51
- data/spec/dnsimple/template_spec.rb +0 -31
- data/spec/dnsimple/user_spec.rb +0 -70
- data/spec/files/account/user/success.http +0 -19
- data/spec/files/certificates/show/notfound.http +0 -17
- data/spec/files/domains/auto_renewal_disable/success.http +0 -23
- data/spec/files/domains/create/success.http +0 -19
- data/spec/files/extended_attributes/ca.http +0 -19
- data/spec/files/extended_attributes/success.http +0 -19
- data/spec/files/templates/show/notfound.http +0 -17
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Dnsimple::Contact do
|
4
|
-
|
5
|
-
describe ".find" do
|
6
|
-
before do
|
7
|
-
stub_request(:get, %r[/v1/contacts/2]).
|
8
|
-
to_return(read_fixture("contacts/show/success.http"))
|
9
|
-
end
|
10
|
-
|
11
|
-
it "builds the correct request" do
|
12
|
-
described_class.find("2")
|
13
|
-
|
14
|
-
expect(WebMock).to have_requested(:get, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/contacts/2").
|
15
|
-
with(:headers => { 'Accept' => 'application/json' })
|
16
|
-
end
|
17
|
-
|
18
|
-
context "when the contact exists" do
|
19
|
-
it "returns the contact" do
|
20
|
-
result = described_class.find("2")
|
21
|
-
|
22
|
-
expect(result).to be_a(described_class)
|
23
|
-
expect(result.id).to eq(2)
|
24
|
-
expect(result.first_name).to eq("Simone")
|
25
|
-
expect(result.last_name).to eq("Carletti")
|
26
|
-
expect(result.job_title).to eq("Underwater Programmer")
|
27
|
-
expect(result.organization_name).to eq("Dnsimple")
|
28
|
-
expect(result.email_address).to eq("example@example.com")
|
29
|
-
expect(result.phone).to eq("+1 111 000000")
|
30
|
-
expect(result.fax).to eq("+1 222 000000")
|
31
|
-
expect(result.address1).to eq("Awesome Street")
|
32
|
-
expect(result.address2).to eq("c/o Someone")
|
33
|
-
expect(result.city).to eq("Rome")
|
34
|
-
expect(result.state_province).to eq("RM")
|
35
|
-
expect(result.postal_code).to eq("00171")
|
36
|
-
expect(result.country).to eq("IT")
|
37
|
-
expect(result.created_at).to eq("2013-11-08T17:23:15Z")
|
38
|
-
expect(result.updated_at).to eq("2013-11-08T17:23:15Z")
|
39
|
-
|
40
|
-
expect(result.phone_ext).to be_nil
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
@@ -1,241 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Dnsimple::Domain do
|
4
|
-
|
5
|
-
let(:contact_id) { 1001 }
|
6
|
-
|
7
|
-
|
8
|
-
describe ".list" do
|
9
|
-
before do
|
10
|
-
stub_request(:get, %r[/v1/domains$]).
|
11
|
-
to_return(read_fixture("domains/index/success.http"))
|
12
|
-
end
|
13
|
-
|
14
|
-
it "builds the correct request" do
|
15
|
-
described_class.list
|
16
|
-
|
17
|
-
expect(WebMock).to have_requested(:get, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/domains").
|
18
|
-
with(headers: { 'Accept' => 'application/json' })
|
19
|
-
end
|
20
|
-
|
21
|
-
it "returns the list of domains" do
|
22
|
-
results = described_class.list
|
23
|
-
|
24
|
-
expect(results).to be_a(Array)
|
25
|
-
expect(results.size).to eq(2)
|
26
|
-
|
27
|
-
result = results[0]
|
28
|
-
expect(result.id).to eq(228)
|
29
|
-
|
30
|
-
result = results[1]
|
31
|
-
expect(result.id).to eq(227)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe ".create" do
|
36
|
-
before do
|
37
|
-
stub_request(:post, %r[/v1/domains$]).
|
38
|
-
to_return(read_fixture("domains/create/success.http"))
|
39
|
-
end
|
40
|
-
|
41
|
-
it "builds the correct request" do
|
42
|
-
described_class.create("example.com")
|
43
|
-
|
44
|
-
expect(WebMock).to have_requested(:post, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/domains").
|
45
|
-
with(headers: { 'Accept' => 'application/json' }).
|
46
|
-
with(body: { "domain" => { "name" => "example.com" }})
|
47
|
-
end
|
48
|
-
|
49
|
-
it "returns the domain" do
|
50
|
-
result = described_class.create("example.com")
|
51
|
-
|
52
|
-
expect(result).to be_a(described_class)
|
53
|
-
expect(result.id).to eq(6)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe ".find" do
|
58
|
-
before do
|
59
|
-
stub_request(:get, %r[/v1/domains/example.com]).
|
60
|
-
to_return(read_fixture("domains/show/success.http"))
|
61
|
-
end
|
62
|
-
|
63
|
-
it "builds the correct request" do
|
64
|
-
described_class.find("example.com")
|
65
|
-
|
66
|
-
expect(WebMock).to have_requested(:get, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/domains/example.com").
|
67
|
-
with(headers: { 'Accept' => 'application/json' })
|
68
|
-
end
|
69
|
-
|
70
|
-
it "returns the domain" do
|
71
|
-
result = described_class.find("example.com")
|
72
|
-
|
73
|
-
expect(result).to be_a(described_class)
|
74
|
-
expect(result.id).to eq(6)
|
75
|
-
expect(result.user_id).to eq(2)
|
76
|
-
expect(result.registrant_id).to eq(2)
|
77
|
-
expect(result.user_id).to eq(2)
|
78
|
-
expect(result.name).to eq("test-1383931357.com")
|
79
|
-
expect(result.state).to eq("registered")
|
80
|
-
expect(result.auto_renew).to eq(true)
|
81
|
-
expect(result.whois_protected).to eq(false)
|
82
|
-
expect(result.expires_on).to eq("2015-11-08")
|
83
|
-
expect(result.created_at).to eq("2013-11-08T17:22:48Z")
|
84
|
-
expect(result.updated_at).to eq("2014-01-14T18:27:04Z")
|
85
|
-
end
|
86
|
-
|
87
|
-
context "when the domain does not exist" do
|
88
|
-
it "raises RecordNotFound" do
|
89
|
-
stub_request(:get, %r[/v1/domains/example.com]).
|
90
|
-
to_return(read_fixture("domains/notfound.http"))
|
91
|
-
|
92
|
-
expect {
|
93
|
-
described_class.find("example.com")
|
94
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
describe ".delete" do
|
100
|
-
before do
|
101
|
-
stub_request(:delete, %r[/v1/domains/example.com]).
|
102
|
-
to_return(read_fixture("domains/delete/success.http"))
|
103
|
-
end
|
104
|
-
|
105
|
-
it "builds the correct request" do
|
106
|
-
described_class.delete("example.com")
|
107
|
-
|
108
|
-
expect(WebMock).to have_requested(:delete, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/domains/example.com").
|
109
|
-
with(headers: { 'Accept' => 'application/json' })
|
110
|
-
end
|
111
|
-
|
112
|
-
it "returns nothing" do
|
113
|
-
result = described_class.delete("example.com")
|
114
|
-
|
115
|
-
expect(result).to be_truthy
|
116
|
-
end
|
117
|
-
|
118
|
-
it "supports HTTP 204" do
|
119
|
-
stub_request(:delete, %r[/v1/domains/example.com]).
|
120
|
-
to_return(read_fixture("domains/delete/success-204.http"))
|
121
|
-
|
122
|
-
result = described_class.delete("example.com")
|
123
|
-
|
124
|
-
expect(result).to be_truthy
|
125
|
-
end
|
126
|
-
|
127
|
-
context "when the domain does not exist" do
|
128
|
-
it "raises RecordNotFound" do
|
129
|
-
stub_request(:delete, %r[/v1/domains/example.com]).
|
130
|
-
to_return(read_fixture("domains/notfound.http"))
|
131
|
-
|
132
|
-
expect {
|
133
|
-
described_class.delete("example.com")
|
134
|
-
}.to raise_error(Dnsimple::RecordNotFound)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
|
140
|
-
describe "#delete" do
|
141
|
-
it "delegates to .delete" do
|
142
|
-
subject = described_class.new(name: "example.com")
|
143
|
-
described_class.expects(:delete).with(subject.name).returns(:returned)
|
144
|
-
|
145
|
-
expect(subject.delete).to eq(:returned)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
describe "#enable_auto_renew" do
|
150
|
-
let(:domain) { described_class.new(:name => 'example.com', :auto_renew => false) }
|
151
|
-
|
152
|
-
context "when response is not 200" do
|
153
|
-
before do
|
154
|
-
stub_request(:post, %r[/v1/domains/example.com/auto_renewal]).
|
155
|
-
to_return(read_fixture("domains/auto_renewal_enable/notfound.http"))
|
156
|
-
end
|
157
|
-
|
158
|
-
it "raises a RequestError" do
|
159
|
-
expect { domain.enable_auto_renew }.to raise_error(Dnsimple::RequestError)
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
context "when auto_renew is true" do
|
164
|
-
let(:domain) { described_class.new(:name => 'example.com', :auto_renew => true) }
|
165
|
-
|
166
|
-
it "does not send a web request" do
|
167
|
-
domain.enable_auto_renew
|
168
|
-
expect(WebMock).to have_not_been_made
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
context "when auto_renew is false" do
|
173
|
-
let(:domain) { described_class.new(:name => 'example.com', :auto_renew => false) }
|
174
|
-
|
175
|
-
before do
|
176
|
-
stub_request(:post, %r[/v1/domains/example.com/auto_renewal]).
|
177
|
-
to_return(read_fixture("domains/auto_renewal_enable/success.http"))
|
178
|
-
end
|
179
|
-
|
180
|
-
it "builds the correct request to enable auto_renew" do
|
181
|
-
domain.enable_auto_renew
|
182
|
-
|
183
|
-
expect(WebMock).to have_requested(:post, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/domains/example.com/auto_renewal").
|
184
|
-
with(headers: { 'Accept' => 'application/json' })
|
185
|
-
end
|
186
|
-
|
187
|
-
it "sets auto_renew to true on the domain" do
|
188
|
-
domain.enable_auto_renew
|
189
|
-
expect(domain.auto_renew).to be_truthy
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
end
|
194
|
-
|
195
|
-
describe "#disable_auto_renew" do
|
196
|
-
let(:domain) { described_class.new(:name => 'example.com', :auto_renew => true) }
|
197
|
-
|
198
|
-
context "when response is not 200" do
|
199
|
-
before do
|
200
|
-
stub_request(:delete, %r[/v1/domains/example.com/auto_renewal]).
|
201
|
-
to_return(read_fixture("domains/auto_renewal_disable/notfound.http"))
|
202
|
-
end
|
203
|
-
|
204
|
-
it "raises a RequestError" do
|
205
|
-
expect { domain.disable_auto_renew }.to raise_error(Dnsimple::RequestError)
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
context "when auto_renew is false" do
|
210
|
-
let(:domain) { described_class.new(:name => 'example.com', :auto_renew => false) }
|
211
|
-
|
212
|
-
it "does not send a web request" do
|
213
|
-
domain.disable_auto_renew
|
214
|
-
expect(WebMock).to have_not_been_made
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
context "when auto_renew is true" do
|
219
|
-
let(:domain) { described_class.new(:name => 'example.com', :auto_renew => true) }
|
220
|
-
|
221
|
-
before do
|
222
|
-
stub_request(:delete, %r[/v1/domains/example.com/auto_renewal]).
|
223
|
-
to_return(read_fixture("domains/auto_renewal_disable/success.http"))
|
224
|
-
end
|
225
|
-
|
226
|
-
it "builds the correct request to disable auto_renew" do
|
227
|
-
domain.disable_auto_renew
|
228
|
-
|
229
|
-
expect(WebMock).to have_requested(:delete, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/domains/example.com/auto_renewal").
|
230
|
-
with(headers: { 'Accept' => 'application/json' })
|
231
|
-
end
|
232
|
-
|
233
|
-
it "sets auto_renew to false on the domain" do
|
234
|
-
domain.disable_auto_renew
|
235
|
-
expect(domain.auto_renew).to be_falsey
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
end
|
240
|
-
|
241
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Dnsimple::ExtendedAttribute do
|
4
|
-
|
5
|
-
describe ".find" do
|
6
|
-
before do
|
7
|
-
stub_request(:get, %r[/v1/extended_attributes/com]).
|
8
|
-
to_return(read_fixture("extended_attributes/success.http"))
|
9
|
-
end
|
10
|
-
|
11
|
-
it "builds the correct request" do
|
12
|
-
described_class.find("com")
|
13
|
-
|
14
|
-
expect(WebMock).to have_requested(:get, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/extended_attributes/com").
|
15
|
-
with(:headers => { 'Accept' => 'application/json' })
|
16
|
-
end
|
17
|
-
|
18
|
-
context "when the TLD has no attributes" do
|
19
|
-
before do
|
20
|
-
stub_request(:get, %r[/v1/extended_attributes/com]).
|
21
|
-
to_return(read_fixture("extended_attributes/com.http"))
|
22
|
-
end
|
23
|
-
|
24
|
-
it "returns an empty list" do
|
25
|
-
result = described_class.find("com")
|
26
|
-
|
27
|
-
expect(result).to eq([])
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context "when the TLD has attributes" do
|
32
|
-
before do
|
33
|
-
stub_request(:get, %r[/v1/extended_attributes/ca]).
|
34
|
-
to_return(read_fixture("extended_attributes/ca.http"))
|
35
|
-
end
|
36
|
-
|
37
|
-
it "returns the attributes" do
|
38
|
-
result = described_class.find("ca")
|
39
|
-
|
40
|
-
expect(result).to be_a(Array)
|
41
|
-
expect(result.size).to eq(5)
|
42
|
-
|
43
|
-
attribute = result[0]
|
44
|
-
expect(attribute).to be_a(described_class)
|
45
|
-
expect(attribute.name).to eq("cira_legal_type")
|
46
|
-
expect(attribute.description).to eq("Legal type of registrant contact")
|
47
|
-
expect(attribute.required).to be_truthy
|
48
|
-
expect(attribute.options).to be_a(Array)
|
49
|
-
expect(attribute.options.size).to eq(18)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Dnsimple::Record do
|
4
|
-
|
5
|
-
let(:domain) { Dnsimple::Domain.new(:name => 'example.com') }
|
6
|
-
|
7
|
-
|
8
|
-
describe ".find" do
|
9
|
-
before do
|
10
|
-
stub_request(:get, %r[/v1/domains/example.com/records/2]).
|
11
|
-
to_return(read_fixture("records/show/success.http"))
|
12
|
-
end
|
13
|
-
|
14
|
-
it "builds the correct request" do
|
15
|
-
described_class.find(domain, "2")
|
16
|
-
|
17
|
-
expect(WebMock).to have_requested(:get, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/domains/example.com/records/2").
|
18
|
-
with(:headers => { 'Accept' => 'application/json' })
|
19
|
-
end
|
20
|
-
|
21
|
-
context "when the record exists" do
|
22
|
-
it "returns the record" do
|
23
|
-
result = described_class.find(domain, "2")
|
24
|
-
|
25
|
-
expect(result).to be_a(described_class)
|
26
|
-
expect(result.id).to eq(1495)
|
27
|
-
expect(result.domain).to be(domain)
|
28
|
-
expect(result.name).to eq("www")
|
29
|
-
expect(result.content).to eq("1.2.3.4")
|
30
|
-
expect(result.ttl).to eq(3600)
|
31
|
-
expect(result.prio).to be_nil
|
32
|
-
expect(result.record_type).to eq("A")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
describe "#fqdn" do
|
39
|
-
it "joins the name and domain name" do
|
40
|
-
record = described_class.new(:name => 'www', :domain => domain)
|
41
|
-
expect(record.fqdn).to eq("www.#{domain.name}")
|
42
|
-
end
|
43
|
-
|
44
|
-
it "strips a blank name" do
|
45
|
-
record = described_class.new(:name => '', :domain => domain)
|
46
|
-
expect(record.fqdn).to eq(domain.name)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Dnsimple::Template do
|
4
|
-
|
5
|
-
describe ".find" do
|
6
|
-
before do
|
7
|
-
stub_request(:get, %r[/v1/templates/google-apps]).
|
8
|
-
to_return(read_fixture("templates/show/success.http"))
|
9
|
-
end
|
10
|
-
|
11
|
-
it "builds the correct request" do
|
12
|
-
described_class.find("google-apps")
|
13
|
-
|
14
|
-
expect(WebMock).to have_requested(:get, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/templates/google-apps").
|
15
|
-
with(:headers => { 'Accept' => 'application/json' })
|
16
|
-
end
|
17
|
-
|
18
|
-
context "when the template exists" do
|
19
|
-
it "returns the template" do
|
20
|
-
result = described_class.find("google-apps")
|
21
|
-
|
22
|
-
expect(result).to be_a(described_class)
|
23
|
-
expect(result.id).to eq(63)
|
24
|
-
expect(result.name).to eq("Google Apps")
|
25
|
-
expect(result.short_name).to eq("google-apps")
|
26
|
-
expect(result.description).to eq("The Google Mail Servers and Google Apps CNAME records in a single template.")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
data/spec/dnsimple/user_spec.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Dnsimple::User do
|
4
|
-
describe ".me" do
|
5
|
-
before do
|
6
|
-
stub_request(:get, %r[/v1/user]).
|
7
|
-
to_return(read_fixture("account/user/success.http"))
|
8
|
-
end
|
9
|
-
|
10
|
-
it "builds the correct request" do
|
11
|
-
described_class.me
|
12
|
-
|
13
|
-
expect(WebMock).to have_requested(:get, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/user").
|
14
|
-
with(:headers => { 'Accept' => 'application/json' })
|
15
|
-
end
|
16
|
-
|
17
|
-
it "returns the user" do
|
18
|
-
result = described_class.me
|
19
|
-
|
20
|
-
expect(result).to be_a(described_class)
|
21
|
-
expect(result.id).to eq(19)
|
22
|
-
expect(result.email).to eq("example@example.com")
|
23
|
-
expect(result.domain_count).to be_a(Integer)
|
24
|
-
expect(result.domain_limit).to be_a(Integer)
|
25
|
-
expect(result.login_count).to be_a(Integer)
|
26
|
-
expect(result.failed_login_count).to be_a(Integer)
|
27
|
-
expect(result.created_at).to eq("2014-01-15T21:59:04Z")
|
28
|
-
expect(result.updated_at).to be_a(String)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe ".two_factor_exchange_token" do
|
33
|
-
before do
|
34
|
-
stub_request(:get, %r[/v1/user]).
|
35
|
-
to_return(read_fixture("2fa/exchange-token.http"))
|
36
|
-
end
|
37
|
-
|
38
|
-
let(:otp_token) { '1234567' }
|
39
|
-
|
40
|
-
it "builds the correct request" do
|
41
|
-
described_class.two_factor_exchange_token(otp_token)
|
42
|
-
|
43
|
-
expect(WebMock).to have_requested(:get, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/user").
|
44
|
-
# workaround for https://github.com/bblimke/webmock/issues/276
|
45
|
-
with { |req|
|
46
|
-
# req.headers[Dnsimple::Client::HEADER_OTP_TOKEN] == otp_token
|
47
|
-
req.headers["X-Dnsimple-Otp"] == otp_token
|
48
|
-
}
|
49
|
-
end
|
50
|
-
|
51
|
-
it "returns the exchange_token" do
|
52
|
-
result = described_class.two_factor_exchange_token(otp_token)
|
53
|
-
|
54
|
-
expect(result).to eq("0c622716aaa64124219963075bc1c870")
|
55
|
-
end
|
56
|
-
|
57
|
-
context "when the OTP token is invalid" do
|
58
|
-
before do
|
59
|
-
stub_request(:get, %r[/v1/user]).
|
60
|
-
to_return(read_fixture("2fa/error-badtoken.http"))
|
61
|
-
end
|
62
|
-
|
63
|
-
it "raises an AuthenticationFailed" do
|
64
|
-
expect {
|
65
|
-
described_class.two_factor_exchange_token("invalid-token")
|
66
|
-
}.to raise_error(Dnsimple::AuthenticationFailed, "Bad OTP token")
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|