dnsimple 2.2.0 → 3.0.0.pre.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (244) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +3 -1
  4. data/CHANGELOG.md +13 -2
  5. data/CONTRIBUTING.md +35 -0
  6. data/Gemfile +2 -0
  7. data/LICENSE.txt +1 -1
  8. data/README.md +30 -82
  9. data/dnsimple.gemspec +2 -1
  10. data/lib/dnsimple.rb +0 -2
  11. data/lib/dnsimple/client.rb +64 -64
  12. data/lib/dnsimple/client/clients.rb +82 -58
  13. data/lib/dnsimple/client/contacts.rb +74 -37
  14. data/lib/dnsimple/client/domains.rb +82 -28
  15. data/lib/dnsimple/client/domains_email_forwards.rb +107 -0
  16. data/lib/dnsimple/client/identity.rb +38 -0
  17. data/lib/dnsimple/client/oauth.rb +42 -0
  18. data/lib/dnsimple/client/registrar.rb +64 -72
  19. data/lib/dnsimple/client/registrar_auto_renewal.rb +41 -0
  20. data/lib/dnsimple/client/registrar_whois_privacy.rb +74 -0
  21. data/lib/dnsimple/client/tlds.rb +88 -0
  22. data/lib/dnsimple/client/webhooks.rb +82 -0
  23. data/lib/dnsimple/client/zones.rb +68 -0
  24. data/lib/dnsimple/client/zones_records.rb +127 -0
  25. data/lib/dnsimple/default.rb +10 -17
  26. data/lib/dnsimple/error.rb +5 -8
  27. data/lib/dnsimple/extra.rb +1 -1
  28. data/lib/dnsimple/response.rb +80 -0
  29. data/lib/dnsimple/struct.rb +13 -14
  30. data/lib/dnsimple/struct/account.rb +13 -0
  31. data/lib/dnsimple/struct/contact.rb +6 -3
  32. data/lib/dnsimple/struct/domain.rb +10 -10
  33. data/lib/dnsimple/struct/domain_check.rb +16 -0
  34. data/lib/dnsimple/struct/email_forward.rb +11 -1
  35. data/lib/dnsimple/struct/oauth_token.rb +19 -0
  36. data/lib/dnsimple/struct/record.rb +25 -7
  37. data/lib/dnsimple/struct/tld.rb +22 -0
  38. data/lib/dnsimple/struct/user.rb +3 -7
  39. data/lib/dnsimple/struct/webhook.rb +13 -0
  40. data/lib/dnsimple/struct/whois_privacy.rb +8 -5
  41. data/lib/dnsimple/struct/zone.rb +25 -0
  42. data/lib/dnsimple/version.rb +1 -1
  43. data/spec/dnsimple/client/client_service_spec.rb +37 -0
  44. data/spec/dnsimple/client/contacts_spec.rb +108 -78
  45. data/spec/dnsimple/client/domains_email_forwards_spec.rb +190 -0
  46. data/spec/dnsimple/client/domains_spec.rb +121 -58
  47. data/spec/dnsimple/client/identity_spec.rb +56 -0
  48. data/spec/dnsimple/client/oauth_spec.rb +48 -0
  49. data/spec/dnsimple/client/registrar_auto_renewal_spec.rb +80 -0
  50. data/spec/dnsimple/client/registrar_spec.rb +109 -122
  51. data/spec/dnsimple/client/registrar_whois_privacy_spec.rb +119 -0
  52. data/spec/dnsimple/client/tlds_spec.rb +139 -0
  53. data/spec/dnsimple/client/webhooks_spec.rb +142 -0
  54. data/spec/dnsimple/client/zones_records_spec.rb +277 -0
  55. data/spec/dnsimple/client/zones_spec.rb +109 -0
  56. data/spec/dnsimple/client_spec.rb +34 -46
  57. data/spec/dnsimple/extra_spec.rb +22 -0
  58. data/spec/{files → fixtures.http}/badgateway.http +14 -14
  59. data/spec/fixtures.http/checkDomain/success.http +17 -0
  60. data/spec/fixtures.http/createContact/created.http +17 -0
  61. data/spec/fixtures.http/createDomain/created.http +16 -0
  62. data/spec/fixtures.http/createEmailForward/created.http +17 -0
  63. data/spec/fixtures.http/createWebhook/created.http +17 -0
  64. data/spec/fixtures.http/createZoneRecord/created.http +17 -0
  65. data/spec/fixtures.http/deleteContact/success.http +13 -0
  66. data/spec/fixtures.http/deleteDomain/success.http +13 -0
  67. data/spec/fixtures.http/deleteEmailForward/success.http +12 -0
  68. data/spec/fixtures.http/deleteWebhook/success.http +13 -0
  69. data/spec/fixtures.http/deleteZoneRecord/success.http +13 -0
  70. data/spec/fixtures.http/disableAutoRenewal/success.http +12 -0
  71. data/spec/fixtures.http/disableWhoisPrivacy/success.http +17 -0
  72. data/spec/fixtures.http/enableAutoRenewal/success.http +12 -0
  73. data/spec/fixtures.http/enableWhoisPrivacy/created.http +17 -0
  74. data/spec/fixtures.http/enableWhoisPrivacy/success.http +17 -0
  75. data/spec/fixtures.http/getContact/success.http +17 -0
  76. data/spec/fixtures.http/getDomain/success.http +16 -0
  77. data/spec/fixtures.http/getEmailForward/success.http +17 -0
  78. data/spec/fixtures.http/getTld/success.http +17 -0
  79. data/spec/fixtures.http/getTldExtendedAttributes/success-noattributes.http +17 -0
  80. data/spec/fixtures.http/getTldExtendedAttributes/success.http +17 -0
  81. data/spec/fixtures.http/getWebhook/success.http +17 -0
  82. data/spec/fixtures.http/getWhoisPrivacy/success.http +17 -0
  83. data/spec/fixtures.http/getZone/success.http +17 -0
  84. data/spec/fixtures.http/getZoneRecord/success.http +17 -0
  85. data/spec/fixtures.http/listContacts/success.http +17 -0
  86. data/spec/fixtures.http/listDomains/success.http +16 -0
  87. data/spec/fixtures.http/listEmailForwards/success.http +17 -0
  88. data/spec/fixtures.http/listTlds/success.http +17 -0
  89. data/spec/fixtures.http/listWebhooks/success.http +17 -0
  90. data/spec/fixtures.http/listZoneRecords/success.http +17 -0
  91. data/spec/fixtures.http/listZones/success.http +17 -0
  92. data/spec/fixtures.http/notfound-contact.http +12 -0
  93. data/spec/fixtures.http/notfound-domain.http +12 -0
  94. data/spec/fixtures.http/notfound-emailforward.http +12 -0
  95. data/spec/fixtures.http/notfound-record.http +12 -0
  96. data/spec/fixtures.http/notfound-webhook.http +12 -0
  97. data/spec/fixtures.http/notfound-zone.http +12 -0
  98. data/spec/fixtures.http/oauthAccessToken/success.http +17 -0
  99. data/spec/fixtures.http/pages-1of3.http +16 -0
  100. data/spec/fixtures.http/pages-2of3.http +16 -0
  101. data/spec/fixtures.http/pages-3of3.http +16 -0
  102. data/spec/fixtures.http/registerDomain/success.http +17 -0
  103. data/spec/fixtures.http/renewDomain/error-tooearly.http +15 -0
  104. data/spec/fixtures.http/renewDomain/success.http +17 -0
  105. data/spec/fixtures.http/resetDomainToken/success.http +17 -0
  106. data/spec/fixtures.http/response.http +16 -0
  107. data/spec/fixtures.http/transferDomain/error-indnsimple.http +15 -0
  108. data/spec/fixtures.http/transferDomain/error-missing-authcode.http +15 -0
  109. data/spec/fixtures.http/transferDomain/success.http +17 -0
  110. data/spec/fixtures.http/transferDomainOut/success.http +13 -0
  111. data/spec/fixtures.http/updateContact/success.http +17 -0
  112. data/spec/fixtures.http/updateZoneRecord/success.http +17 -0
  113. data/spec/fixtures.http/whoami/success.http +16 -0
  114. data/spec/fixtures.http/whoami/success_account.http +16 -0
  115. data/spec/fixtures.http/whoami/success_user.http +16 -0
  116. data/spec/spec_helper.rb +0 -6
  117. data/spec/support/helpers.rb +4 -4
  118. metadata +161 -238
  119. data/lib/dnsimple/client/certificates.rb +0 -100
  120. data/lib/dnsimple/client/domains_autorenewal.rb +0 -35
  121. data/lib/dnsimple/client/domains_forwards.rb +0 -71
  122. data/lib/dnsimple/client/domains_privacy.rb +0 -35
  123. data/lib/dnsimple/client/domains_records.rb +0 -90
  124. data/lib/dnsimple/client/domains_sharing.rb +0 -54
  125. data/lib/dnsimple/client/domains_zones.rb +0 -22
  126. data/lib/dnsimple/client/name_servers.rb +0 -71
  127. data/lib/dnsimple/client/services.rb +0 -37
  128. data/lib/dnsimple/client/services_domains.rb +0 -68
  129. data/lib/dnsimple/client/templates.rb +0 -88
  130. data/lib/dnsimple/client/templates_domains.rb +0 -23
  131. data/lib/dnsimple/client/templates_records.rb +0 -88
  132. data/lib/dnsimple/client/users.rb +0 -39
  133. data/lib/dnsimple/client/vanity_name_servers.rb +0 -39
  134. data/lib/dnsimple/compatibility.rb +0 -46
  135. data/lib/dnsimple/struct/certificate.rb +0 -56
  136. data/lib/dnsimple/struct/membership.rb +0 -22
  137. data/lib/dnsimple/struct/price.rb +0 -16
  138. data/lib/dnsimple/struct/service.rb +0 -19
  139. data/lib/dnsimple/struct/template.rb +0 -19
  140. data/lib/dnsimple/struct/template_record.rb +0 -24
  141. data/lib/dnsimple/struct/transfer_order.rb +0 -10
  142. data/spec/dnsimple/client/certificates_spec.rb +0 -196
  143. data/spec/dnsimple/client/domains_autorenewals_spec.rb +0 -72
  144. data/spec/dnsimple/client/domains_forwards_spec.rb +0 -146
  145. data/spec/dnsimple/client/domains_privacy_spec.rb +0 -74
  146. data/spec/dnsimple/client/domains_records_spec.rb +0 -191
  147. data/spec/dnsimple/client/domains_sharing_spec.rb +0 -109
  148. data/spec/dnsimple/client/domains_zones_spec.rb +0 -40
  149. data/spec/dnsimple/client/name_servers_spec.rb +0 -131
  150. data/spec/dnsimple/client/services_domains_spec.rb +0 -101
  151. data/spec/dnsimple/client/services_spec.rb +0 -69
  152. data/spec/dnsimple/client/templates_domains_spec.rb +0 -38
  153. data/spec/dnsimple/client/templates_records_spec.rb +0 -180
  154. data/spec/dnsimple/client/templates_spec.rb +0 -166
  155. data/spec/dnsimple/client/users_spec.rb +0 -70
  156. data/spec/dnsimple/client/vanity_name_servers_spec.rb +0 -61
  157. data/spec/dnsimple/compatibility_spec.rb +0 -57
  158. data/spec/files/2fa/error-badtoken.http +0 -22
  159. data/spec/files/2fa/error-required.http +0 -23
  160. data/spec/files/2fa/exchange-token.http +0 -22
  161. data/spec/files/certificates/configure/success.http +0 -19
  162. data/spec/files/certificates/get/success.http +0 -19
  163. data/spec/files/certificates/list/success.http +0 -19
  164. data/spec/files/certificates/notfound.http +0 -19
  165. data/spec/files/certificates/purchase/success.http +0 -19
  166. data/spec/files/certificates/submit/success.http +0 -19
  167. data/spec/files/contacts/contact/success.http +0 -19
  168. data/spec/files/contacts/contacts/success.http +0 -23
  169. data/spec/files/contacts/create_contact/badrequest-missingcontact.http +0 -19
  170. data/spec/files/contacts/create_contact/badrequest-validationerror.http +0 -19
  171. data/spec/files/contacts/create_contact/created.http +0 -22
  172. data/spec/files/contacts/delete_contact/success-204.http +0 -18
  173. data/spec/files/contacts/delete_contact/success.http +0 -19
  174. data/spec/files/contacts/notfound-contact.http +0 -19
  175. data/spec/files/contacts/update_contact/success.http +0 -21
  176. data/spec/files/domains/create_domain/created.http +0 -21
  177. data/spec/files/domains/create_forward/created.http +0 -22
  178. data/spec/files/domains/create_membership/success.http +0 -21
  179. data/spec/files/domains/create_record/created.http +0 -21
  180. data/spec/files/domains/delete_domain/success-204.http +0 -18
  181. data/spec/files/domains/delete_domain/success.http +0 -19
  182. data/spec/files/domains/delete_forward/success.http +0 -17
  183. data/spec/files/domains/delete_membership/success.http +0 -17
  184. data/spec/files/domains/delete_record/success-204.http +0 -18
  185. data/spec/files/domains/delete_record/success.http +0 -19
  186. data/spec/files/domains/disable_auto_renewal/success.http +0 -21
  187. data/spec/files/domains/disable_whois_privacy/success.http +0 -21
  188. data/spec/files/domains/domain/success.http +0 -21
  189. data/spec/files/domains/domains/success.http +0 -21
  190. data/spec/files/domains/enable_auto_renewal/success.http +0 -21
  191. data/spec/files/domains/enable_whois_privacy/success.http +0 -22
  192. data/spec/files/domains/forward/success.http +0 -21
  193. data/spec/files/domains/forwards/success.http +0 -21
  194. data/spec/files/domains/memberships/success.http +0 -21
  195. data/spec/files/domains/notfound-domain.http +0 -19
  196. data/spec/files/domains/notfound-forward.http +0 -19
  197. data/spec/files/domains/notfound-membership.http +0 -19
  198. data/spec/files/domains/record/success.http +0 -19
  199. data/spec/files/domains/records/success.http +0 -19
  200. data/spec/files/domains/update_record/success.http +0 -21
  201. data/spec/files/domains/zone/success.http +0 -21
  202. data/spec/files/nameservers/change/success.http +0 -23
  203. data/spec/files/nameservers/deregister/success.http +0 -17
  204. data/spec/files/nameservers/name_servers/success.http +0 -23
  205. data/spec/files/nameservers/notfound-domain.http +0 -19
  206. data/spec/files/nameservers/register/badrequest-valueerror.http +0 -19
  207. data/spec/files/nameservers/register/success.http +0 -21
  208. data/spec/files/nameservers/vanity_name_servers/disabled.http +0 -23
  209. data/spec/files/nameservers/vanity_name_servers/enabled.http +0 -23
  210. data/spec/files/registrar/check/available.http +0 -19
  211. data/spec/files/registrar/check/registered.http +0 -21
  212. data/spec/files/registrar/extended_attributes/success.http +0 -21
  213. data/spec/files/registrar/prices/success.http +0 -21
  214. data/spec/files/registrar/register/badrequest-missingdomain.http +0 -19
  215. data/spec/files/registrar/register/badrequest-missingregistrant.http +0 -19
  216. data/spec/files/registrar/register/success.http +0 -21
  217. data/spec/files/registrar/renew/badrequest-missingrenewal.http +0 -19
  218. data/spec/files/registrar/renew/badrequest-unable.http +0 -19
  219. data/spec/files/registrar/renew/success.http +0 -21
  220. data/spec/files/registrar/transfer/success.http +0 -21
  221. data/spec/files/services/applied/success.http +0 -21
  222. data/spec/files/services/apply/success.http +0 -21
  223. data/spec/files/services/available/success.http +0 -21
  224. data/spec/files/services/notfound-service.http +0 -19
  225. data/spec/files/services/service/success.http +0 -21
  226. data/spec/files/services/services/success.http +0 -21
  227. data/spec/files/services/unapply/success.http +0 -21
  228. data/spec/files/subscriptions/subscription/success.http +0 -21
  229. data/spec/files/templates/apply_template/success.http +0 -21
  230. data/spec/files/templates/create_template/created.http +0 -22
  231. data/spec/files/templates/delete_template/success-204.http +0 -21
  232. data/spec/files/templates/delete_template/success.http +0 -21
  233. data/spec/files/templates/notfound-template.http +0 -19
  234. data/spec/files/templates/template/success.http +0 -21
  235. data/spec/files/templates/templates/success.http +0 -21
  236. data/spec/files/templates/update_template/success.http +0 -21
  237. data/spec/files/templates_records/create_record/created.http +0 -22
  238. data/spec/files/templates_records/delete_record/success-204.http +0 -19
  239. data/spec/files/templates_records/delete_record/success.http +0 -21
  240. data/spec/files/templates_records/notfound-template-record.http +0 -19
  241. data/spec/files/templates_records/record/success.http +0 -21
  242. data/spec/files/templates_records/records/success.http +0 -21
  243. data/spec/files/templates_records/update_record/success.http +0 -21
  244. data/spec/files/users/user/success.http +0 -21
@@ -1,74 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dnsimple::Client, ".domains / privacy" do
4
-
5
- subject { described_class.new(api_endpoint: "https://api.zone", username: "user", api_token: "token").domains }
6
-
7
-
8
- describe "#enable_whois_privacy" do
9
- before do
10
- stub_request(:post, %r[/v1/domains/.+/whois_privacy$]).
11
- to_return(read_fixture("domains/enable_whois_privacy/success.http"))
12
- end
13
-
14
- it "builds the correct request" do
15
- subject.enable_whois_privacy("example.com")
16
-
17
- expect(WebMock).to have_requested(:post, "https://api.zone/v1/domains/example.com/whois_privacy").
18
- with(headers: { 'Accept' => 'application/json' })
19
- end
20
-
21
- it "returns the domain" do
22
- result = subject.enable_whois_privacy("example.com")
23
-
24
- expect(result).to be_a(Dnsimple::Struct::WhoisPrivacy)
25
- expect(result.id).to be_a(Fixnum)
26
- end
27
-
28
- context "when the domain does not exist" do
29
- it "raises NotFoundError" do
30
- stub_request(:post, %r[/v1]).
31
- to_return(read_fixture("domains/notfound-domain.http"))
32
-
33
- expect {
34
- subject.enable_whois_privacy("example.com")
35
- }.to raise_error(Dnsimple::NotFoundError)
36
- end
37
- end
38
- end
39
-
40
- describe "#disable_whois_privacy" do
41
- before do
42
- stub_request(:delete, %r[/v1/domains/.+/whois_privacy]).
43
- to_return(read_fixture("domains/disable_whois_privacy/success.http"))
44
- end
45
-
46
- it "builds the correct request" do
47
- subject.disable_whois_privacy("example.com")
48
-
49
- expect(WebMock).to have_requested(:delete, "https://api.zone/v1/domains/example.com/whois_privacy").
50
- with(headers: { 'Accept' => 'application/json' })
51
- end
52
-
53
- it "returns the domain" do
54
- result = subject.disable_whois_privacy("example.com")
55
-
56
- expect(result).to be_a(Dnsimple::Struct::WhoisPrivacy)
57
- expect(result.id).to be_a(Fixnum)
58
- end
59
-
60
- context "when the domain does not exist" do
61
- it "raises NotFoundError" do
62
- stub_request(:delete, %r[/v1]).
63
- to_return(read_fixture("domains/notfound-domain.http"))
64
-
65
- expect {
66
- subject.disable_whois_privacy("example.com")
67
- }.to raise_error(Dnsimple::NotFoundError)
68
- end
69
- end
70
- end
71
-
72
-
73
-
74
- end
@@ -1,191 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dnsimple::Client, ".domains / records" do
4
-
5
- subject { described_class.new(api_endpoint: "https://api.zone", username: "user", api_token: "token").domains }
6
-
7
-
8
- describe "#records" do
9
- before do
10
- stub_request(:get, %r[/v1/domains/.+/records$]).
11
- to_return(read_fixture("domains/records/success.http"))
12
- end
13
-
14
- it "builds the correct request" do
15
- subject.records("example.com")
16
-
17
- expect(WebMock).to have_requested(:get, "https://api.zone/v1/domains/example.com/records").
18
- with(headers: { 'Accept' => 'application/json' })
19
- end
20
-
21
- it "returns the records" do
22
- results = subject.records("example.com")
23
-
24
- expect(results).to be_a(Array)
25
- expect(results.size).to eq(7)
26
-
27
- results.each do |result|
28
- expect(result).to be_a(Dnsimple::Struct::Record)
29
- expect(result.id).to be_a(Fixnum)
30
- end
31
- end
32
-
33
- context "when something does not exist" do
34
- it "raises NotFoundError" do
35
- stub_request(:get, %r[/v1]).
36
- to_return(read_fixture("domains/notfound-domain.http"))
37
-
38
- expect {
39
- subject.records("example.com")
40
- }.to raise_error(Dnsimple::NotFoundError)
41
- end
42
- end
43
- end
44
-
45
- describe "#create_record" do
46
- before do
47
- stub_request(:post, %r[/v1/domains/.+/records$]).
48
- to_return(read_fixture("domains/create_record/created.http"))
49
- end
50
-
51
- it "builds the correct request" do
52
- subject.create_record("example.com", { name: "", record_type: "A", content: "127.0.0.1", prio: "1" })
53
-
54
- expect(WebMock).to have_requested(:post, "https://api.zone/v1/domains/example.com/records").
55
- with(body: { record: { name: "", record_type: "A", content: "127.0.0.1", prio: "1" } }).
56
- with(headers: { 'Accept' => 'application/json' })
57
- end
58
-
59
- it "returns the record" do
60
- result = subject.create_record("example.com", { name: "", record_type: "", content: "" })
61
-
62
- expect(result).to be_a(Dnsimple::Struct::Record)
63
- expect(result.id).to be_a(Fixnum)
64
- end
65
-
66
- context "when something does not exist" do
67
- it "raises NotFoundError" do
68
- stub_request(:post, %r[/v1]).
69
- to_return(read_fixture("domains/notfound-domain.http"))
70
-
71
- expect {
72
- subject.create_record("example.com", { name: "", record_type: "", content: "" })
73
- }.to raise_error(Dnsimple::NotFoundError)
74
- end
75
- end
76
- end
77
-
78
- describe "#record" do
79
- before do
80
- stub_request(:get, %r[/v1/domains/.+/records/.+$]).
81
- to_return(read_fixture("domains/record/success.http"))
82
- end
83
-
84
- it "builds the correct request" do
85
- subject.record("example.com", 2)
86
-
87
- expect(WebMock).to have_requested(:get, "https://api.zone/v1/domains/example.com/records/2").
88
- with(headers: { 'Accept' => 'application/json' })
89
- end
90
-
91
- it "returns the record" do
92
- result = subject.record("example.com", 2)
93
-
94
- expect(result).to be_a(Dnsimple::Struct::Record)
95
- expect(result.id).to eq(1495)
96
- expect(result.domain_id).to eq(6)
97
- expect(result.name).to eq("www")
98
- expect(result.content).to eq("1.2.3.4")
99
- expect(result.ttl).to eq(3600)
100
- expect(result.prio).to be_nil
101
- expect(result.record_type).to eq("A")
102
- expect(result.created_at).to eq("2014-01-14T18:25:56Z")
103
- expect(result.updated_at).to eq("2014-01-14T18:26:04Z")
104
- end
105
-
106
- context "when something does not exist" do
107
- it "raises NotFoundError" do
108
- stub_request(:get, %r[/v1]).
109
- to_return(read_fixture("domains/notfound-domain.http"))
110
-
111
- expect {
112
- subject.record("example.com", 2)
113
- }.to raise_error(Dnsimple::NotFoundError)
114
- end
115
- end
116
- end
117
-
118
- describe "#update_record" do
119
- before do
120
- stub_request(:put, %r[/v1/domains/.+/records/.+$]).
121
- to_return(read_fixture("domains/update_record/success.http"))
122
- end
123
-
124
- it "builds the correct request" do
125
- subject.update_record("example.com", 2, { content: "127.0.0.1", prio: "1" })
126
-
127
- expect(WebMock).to have_requested(:put, "https://api.zone/v1/domains/example.com/records/2").
128
- with(body: { record: { content: "127.0.0.1", prio: "1" } }).
129
- with(headers: { 'Accept' => 'application/json' })
130
- end
131
-
132
- it "returns the record" do
133
- result = subject.update_record("example.com", 2, {})
134
-
135
- expect(result).to be_a(Dnsimple::Struct::Record)
136
- expect(result.id).to be_a(Fixnum)
137
- end
138
-
139
- context "when something does not exist" do
140
- it "raises NotFoundError" do
141
- stub_request(:put, %r[/v1]).
142
- to_return(read_fixture("domains/notfound-domain.http"))
143
-
144
- expect {
145
- subject.update_record("example.com", 2, {})
146
- }.to raise_error(Dnsimple::NotFoundError)
147
- end
148
- end
149
- end
150
-
151
- describe "#delete_record" do
152
- before do
153
- stub_request(:delete, %r[/v1/domains/.+/records/.+$]).
154
- to_return(read_fixture("domains/delete_record/success.http"))
155
- end
156
-
157
- it "builds the correct request" do
158
- subject.delete_record("example.com", 2)
159
-
160
- expect(WebMock).to have_requested(:delete, "https://api.zone/v1/domains/example.com/records/2").
161
- with(headers: { 'Accept' => 'application/json' })
162
- end
163
-
164
- it "returns nothing" do
165
- result = subject.delete_record("example.com", 2)
166
-
167
- expect(result).to be_truthy
168
- end
169
-
170
- it "supports HTTP 204" do
171
- stub_request(:delete, %r[/v1]).
172
- to_return(read_fixture("domains/delete_record/success-204.http"))
173
-
174
- result = subject.delete_record("example.com", 2)
175
-
176
- expect(result).to be_truthy
177
- end
178
-
179
- context "when something does not exist" do
180
- it "raises NotFoundError" do
181
- stub_request(:delete, %r[/v1]).
182
- to_return(read_fixture("domains/notfound-domain.http"))
183
-
184
- expect {
185
- subject.delete_record("example.com", 2)
186
- }.to raise_error(Dnsimple::NotFoundError)
187
- end
188
- end
189
- end
190
-
191
- end
@@ -1,109 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dnsimple::Client, ".domains / sharing" do
4
-
5
- subject { described_class.new(api_endpoint: "https://api.zone", username: "user", api_token: "token").domains }
6
-
7
-
8
- describe "#memberships" do
9
- before do
10
- stub_request(:get, %r[/v1/domains/.+/memberships$]).
11
- to_return(read_fixture("domains/memberships/success.http"))
12
- end
13
-
14
- it "builds the correct request" do
15
- subject.memberships("example.com")
16
-
17
- expect(WebMock).to have_requested(:get, "https://api.zone/v1/domains/example.com/memberships").
18
- with(headers: { 'Accept' => 'application/json' })
19
- end
20
-
21
- it "returns the records" do
22
- results = subject.memberships("example.com")
23
-
24
- expect(results).to be_a(Array)
25
- expect(results.size).to eq(2)
26
-
27
- results.each do |result|
28
- expect(result).to be_a(Dnsimple::Struct::Membership)
29
- expect(result.id).to be_a(Fixnum)
30
- end
31
- end
32
-
33
- context "when the domain does not exist" do
34
- it "raises NotFoundError" do
35
- stub_request(:get, %r[/v1]).
36
- to_return(read_fixture("domains/notfound-domain.http"))
37
-
38
- expect {
39
- subject.memberships("example.com")
40
- }.to raise_error(Dnsimple::NotFoundError)
41
- end
42
- end
43
- end
44
-
45
- describe "#create_membership" do
46
- before do
47
- stub_request(:post, %r[/v1/domains/.+/memberships$]).
48
- to_return(read_fixture("domains/create_membership/success.http"))
49
- end
50
-
51
- it "builds the correct request" do
52
- subject.create_membership("example.com", "someone@example.com")
53
-
54
- expect(WebMock).to have_requested(:post, "https://api.zone/v1/domains/example.com/memberships").
55
- with(body: { membership: { email: "someone@example.com" } }).
56
- with(headers: { 'Accept' => 'application/json' })
57
- end
58
-
59
- it "returns the record" do
60
- result = subject.create_membership("example.com", "someone@example.com")
61
-
62
- expect(result).to be_a(Dnsimple::Struct::Membership)
63
- expect(result.id).to be_a(Fixnum)
64
- end
65
-
66
- context "when the domain does not exist" do
67
- it "raises NotFoundError" do
68
- stub_request(:post, %r[/v1]).
69
- to_return(read_fixture("domains/notfound-domain.http"))
70
-
71
- expect {
72
- subject.create_membership("example.com", "someone@example.com")
73
- }.to raise_error(Dnsimple::NotFoundError)
74
- end
75
- end
76
- end
77
-
78
- describe "#delete_membership" do
79
- before do
80
- stub_request(:delete, %r[/v1/domains/.+/memberships/.+$]).
81
- to_return(read_fixture("domains/delete_membership/success.http"))
82
- end
83
-
84
- it "builds the correct request" do
85
- subject.delete_membership("example.com", 2)
86
-
87
- expect(WebMock).to have_requested(:delete, "https://api.zone/v1/domains/example.com/memberships/2").
88
- with(headers: { 'Accept' => 'application/json' })
89
- end
90
-
91
- it "returns nothing" do
92
- result = subject.delete_membership("example.com", 2)
93
-
94
- expect(result).to be_truthy
95
- end
96
-
97
- context "when the membership does not exist" do
98
- it "raises NotFoundError" do
99
- stub_request(:delete, %r[/v1]).
100
- to_return(read_fixture("domains/notfound-membership.http"))
101
-
102
- expect {
103
- subject.delete_membership("example.com", 2)
104
- }.to raise_error(Dnsimple::NotFoundError)
105
- end
106
- end
107
- end
108
-
109
- end
@@ -1,40 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dnsimple::Client, ".domains / zones" do
4
-
5
- subject { described_class.new(api_endpoint: "https://api.zone", username: "user", api_token: "token").domains }
6
-
7
-
8
- describe "#zone" do
9
- before do
10
- stub_request(:get, %r[/v1/domains/.+/zone$]).
11
- to_return(read_fixture("domains/zone/success.http"))
12
- end
13
-
14
- it "builds the correct request" do
15
- subject.zone("example.com")
16
-
17
- expect(WebMock).to have_requested(:get, "https://api.zone/v1/domains/example.com/zone").
18
- with(headers: { 'Accept' => 'application/json' })
19
- end
20
-
21
- it "returns the record" do
22
- result = subject.zone("example.com")
23
-
24
- expect(result).to be_a(String)
25
- expect(result).to match(/^#{Regexp.escape("$ORIGIN")}/)
26
- end
27
-
28
- context "when domain does not exist" do
29
- it "raises NotFoundError" do
30
- stub_request(:get, %r[/v1]).
31
- to_return(read_fixture("domains/notfound-domain.http"))
32
-
33
- expect {
34
- subject.zone("example.com")
35
- }.to raise_error(Dnsimple::NotFoundError)
36
- end
37
- end
38
- end
39
-
40
- end
@@ -1,131 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dnsimple::Client, ".name_servers" do
4
-
5
- subject { described_class.new(api_endpoint: "https://api.zone", username: "user", api_token: "token").name_servers }
6
-
7
-
8
- describe "#name_servers" do
9
- before do
10
- stub_request(:get, %r[/v1/domains/.+/name_servers$]).
11
- to_return(read_fixture("nameservers/name_servers/success.http"))
12
- end
13
-
14
- it "builds the correct request" do
15
- subject.list("example.com")
16
-
17
- expect(WebMock).to have_requested(:get, "https://api.zone/v1/domains/example.com/name_servers").
18
- with(headers: { 'Accept' => 'application/json' })
19
- end
20
-
21
- it "returns the name servers" do
22
- expect(subject.name_servers("example.com")).to eq(%w( ns1.dnsimple.com ns2.dnsimple.com ))
23
- end
24
-
25
- context "when something does not exist" do
26
- it "raises NotFoundError" do
27
- stub_request(:get, %r[/v1]).
28
- to_return(read_fixture("nameservers/notfound-domain.http"))
29
-
30
- expect {
31
- subject.name_servers("example.com")
32
- }.to raise_error(Dnsimple::NotFoundError)
33
- end
34
- end
35
- end
36
-
37
- describe "#change" do
38
- before do
39
- stub_request(:post, %r[/v1/domains/.+/name_servers$]).
40
- to_return(read_fixture("nameservers/change/success.http"))
41
- end
42
-
43
- it "builds the correct request" do
44
- subject.change("example.com", %w( ns1.example.com ns2.example.com ))
45
-
46
- expect(WebMock).to have_requested(:post, "https://api.zone/v1/domains/example.com/name_servers").
47
- with(body: { "name_servers" => { "ns1" => "ns1.example.com", "ns2" => "ns2.example.com" }}).
48
- with(headers: { 'Accept' => 'application/json' })
49
- end
50
-
51
- it "returns the name servers" do
52
- expect(subject.change("example.com", %w())).to eq(%w( ns1.dnsimple.com ns2.dnsimple.com ))
53
- end
54
-
55
- context "when something does not exist" do
56
- it "raises NotFoundError" do
57
- stub_request(:post, %r[/v1]).
58
- to_return(read_fixture("nameservers/notfound-domain.http"))
59
-
60
- expect {
61
- subject.change("example.com", %w())
62
- }.to raise_error(Dnsimple::NotFoundError)
63
- end
64
- end
65
- end
66
-
67
-
68
- describe "#register" do
69
- before do
70
- stub_request(:post, %r[/v1/domains/.+/registry_name_servers$]).
71
- to_return(read_fixture("nameservers/register/success.http"))
72
- end
73
-
74
- it "builds the correct request" do
75
- subject.register("example.com", "ns1.example.com", "127.0.0.1")
76
-
77
- expect(WebMock).to have_requested(:post, "https://api.zone/v1/domains/example.com/registry_name_servers").
78
- with(body: { "name_server" => { "name" => "ns1.example.com", "ip" => "127.0.0.1" }}).
79
- with(headers: { 'Accept' => 'application/json' })
80
- end
81
-
82
- it "returns nothing" do
83
- result = subject.register("example.com", "ns1.example.com", "127.0.0.1")
84
-
85
- expect(result).to be_truthy
86
- end
87
-
88
- context "when the domain does not exist" do
89
- it "raises NotFoundError" do
90
- stub_request(:post, %r[/v1]).
91
- to_return(read_fixture("nameservers/notfound-domain.http"))
92
-
93
- expect {
94
- subject.register("example.com", "ns1.example.com", "127.0.0.1")
95
- }.to raise_error(Dnsimple::NotFoundError)
96
- end
97
- end
98
- end
99
-
100
- describe "#deregister" do
101
- before do
102
- stub_request(:delete, %r[/v1/domains/.+/registry_name_servers/.+$]).
103
- to_return(read_fixture("nameservers/deregister/success.http"))
104
- end
105
-
106
- it "builds the correct request" do
107
- subject.deregister("example.com", "ns1.example.com")
108
-
109
- expect(WebMock).to have_requested(:delete, "https://api.zone/v1/domains/example.com/registry_name_servers/ns1.example.com").
110
- with(headers: { 'Accept' => 'application/json' })
111
- end
112
-
113
- it "returns nothing" do
114
- result = subject.deregister("example.com", "ns1.example.com")
115
-
116
- expect(result).to be_truthy
117
- end
118
-
119
- context "when the domain does not exist" do
120
- it "raises NotFoundError" do
121
- stub_request(:delete, %r[/v1]).
122
- to_return(read_fixture("nameservers/notfound-domain.http"))
123
-
124
- expect {
125
- subject.deregister("example.com", "ns1.example.com")
126
- }.to raise_error(Dnsimple::NotFoundError)
127
- end
128
- end
129
- end
130
-
131
- end