dnsimple 4.6.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +12 -0
  3. data/.gitignore +3 -0
  4. data/.rubocop.yml +9 -13
  5. data/.rubocop_dnsimple.yml +42 -40
  6. data/.rubocop_todo.yml +44 -5
  7. data/.travis.yml +14 -8
  8. data/CHANGELOG.md +56 -26
  9. data/CONTRIBUTING.md +43 -0
  10. data/Gemfile +6 -1
  11. data/LICENSE.txt +1 -1
  12. data/README.md +10 -7
  13. data/dnsimple.gemspec +3 -3
  14. data/lib/dnsimple.rb +2 -0
  15. data/lib/dnsimple/client.rb +23 -13
  16. data/lib/dnsimple/client/accounts.rb +2 -0
  17. data/lib/dnsimple/client/certificates.rb +2 -0
  18. data/lib/dnsimple/client/clients.rb +5 -2
  19. data/lib/dnsimple/client/contacts.rb +2 -0
  20. data/lib/dnsimple/client/domains.rb +3 -19
  21. data/lib/dnsimple/client/domains_collaborators.rb +2 -0
  22. data/lib/dnsimple/client/domains_delegation_signer_records.rb +2 -0
  23. data/lib/dnsimple/client/domains_dnssec.rb +2 -0
  24. data/lib/dnsimple/client/domains_email_forwards.rb +2 -0
  25. data/lib/dnsimple/client/domains_pushes.rb +2 -0
  26. data/lib/dnsimple/client/identity.rb +2 -0
  27. data/lib/dnsimple/client/oauth.rb +2 -0
  28. data/lib/dnsimple/client/registrar.rb +69 -0
  29. data/lib/dnsimple/client/registrar_auto_renewal.rb +2 -0
  30. data/lib/dnsimple/client/registrar_delegation.rb +2 -0
  31. data/lib/dnsimple/client/registrar_whois_privacy.rb +3 -1
  32. data/lib/dnsimple/client/services.rb +2 -0
  33. data/lib/dnsimple/client/services_domains.rb +2 -0
  34. data/lib/dnsimple/client/templates.rb +2 -0
  35. data/lib/dnsimple/client/templates_domains.rb +2 -0
  36. data/lib/dnsimple/client/templates_records.rb +2 -0
  37. data/lib/dnsimple/client/tlds.rb +2 -0
  38. data/lib/dnsimple/client/vanity_name_servers.rb +12 -10
  39. data/lib/dnsimple/client/webhooks.rb +2 -0
  40. data/lib/dnsimple/client/zones.rb +2 -0
  41. data/lib/dnsimple/client/zones_distributions.rb +2 -0
  42. data/lib/dnsimple/client/zones_records.rb +2 -0
  43. data/lib/dnsimple/default.rb +12 -10
  44. data/lib/dnsimple/error.rb +3 -1
  45. data/lib/dnsimple/extra.rb +4 -2
  46. data/lib/dnsimple/options.rb +2 -0
  47. data/lib/dnsimple/response.rb +7 -7
  48. data/lib/dnsimple/struct.rb +3 -0
  49. data/lib/dnsimple/struct/account.rb +2 -0
  50. data/lib/dnsimple/struct/certificate.rb +4 -2
  51. data/lib/dnsimple/struct/certificate_bundle.rb +5 -0
  52. data/lib/dnsimple/struct/certificate_purchase.rb +2 -0
  53. data/lib/dnsimple/struct/certificate_renewal.rb +2 -0
  54. data/lib/dnsimple/struct/collaborator.rb +2 -0
  55. data/lib/dnsimple/struct/contact.rb +2 -0
  56. data/lib/dnsimple/struct/delegation_signer_record.rb +2 -0
  57. data/lib/dnsimple/struct/dnssec.rb +2 -0
  58. data/lib/dnsimple/struct/domain.rb +4 -3
  59. data/lib/dnsimple/struct/domain_check.rb +2 -0
  60. data/lib/dnsimple/struct/domain_premium_price.rb +2 -0
  61. data/lib/dnsimple/struct/domain_price.rb +24 -0
  62. data/lib/dnsimple/struct/domain_push.rb +2 -0
  63. data/lib/dnsimple/struct/domain_registration.rb +2 -0
  64. data/lib/dnsimple/struct/domain_renewal.rb +2 -0
  65. data/lib/dnsimple/struct/domain_transfer.rb +5 -0
  66. data/lib/dnsimple/struct/email_forward.rb +2 -0
  67. data/lib/dnsimple/struct/extended_attribute.rb +2 -0
  68. data/lib/dnsimple/struct/oauth_token.rb +2 -0
  69. data/lib/dnsimple/struct/service.rb +2 -0
  70. data/lib/dnsimple/struct/template.rb +2 -0
  71. data/lib/dnsimple/struct/template_record.rb +2 -0
  72. data/lib/dnsimple/struct/tld.rb +2 -0
  73. data/lib/dnsimple/struct/user.rb +2 -0
  74. data/lib/dnsimple/struct/vanity_name_server.rb +2 -0
  75. data/lib/dnsimple/struct/webhook.rb +2 -0
  76. data/lib/dnsimple/struct/whoami.rb +2 -0
  77. data/lib/dnsimple/struct/whois_privacy.rb +2 -0
  78. data/lib/dnsimple/struct/whois_privacy_renewal.rb +2 -0
  79. data/lib/dnsimple/struct/zone.rb +2 -0
  80. data/lib/dnsimple/struct/zone_distribution.rb +2 -0
  81. data/lib/dnsimple/struct/zone_file.rb +2 -0
  82. data/lib/dnsimple/struct/zone_record.rb +2 -0
  83. data/lib/dnsimple/version.rb +3 -1
  84. data/spec/dnsimple/client/accounts_spec.rb +2 -0
  85. data/spec/dnsimple/client/certificates_spec.rb +35 -33
  86. data/spec/dnsimple/client/client_service_spec.rb +3 -1
  87. data/spec/dnsimple/client/contacts_spec.rb +4 -2
  88. data/spec/dnsimple/client/domains_collaborators_spec.rb +4 -2
  89. data/spec/dnsimple/client/domains_delegation_signer_records_spec.rb +3 -1
  90. data/spec/dnsimple/client/domains_dnssec_spec.rb +2 -0
  91. data/spec/dnsimple/client/domains_email_forwards_spec.rb +10 -8
  92. data/spec/dnsimple/client/domains_pushes_spec.rb +4 -2
  93. data/spec/dnsimple/client/domains_spec.rb +16 -41
  94. data/spec/dnsimple/client/identity_spec.rb +2 -0
  95. data/spec/dnsimple/client/oauth_spec.rb +2 -0
  96. data/spec/dnsimple/client/registrar_auto_renewal_spec.rb +2 -0
  97. data/spec/dnsimple/client/registrar_delegation_spec.rb +4 -2
  98. data/spec/dnsimple/client/registrar_spec.rb +116 -4
  99. data/spec/dnsimple/client/registrar_whois_privacy_spec.rb +2 -0
  100. data/spec/dnsimple/client/services_domains_spec.rb +4 -4
  101. data/spec/dnsimple/client/services_spec.rb +3 -3
  102. data/spec/dnsimple/client/templates_domains_spec.rb +2 -0
  103. data/spec/dnsimple/client/templates_records_spec.rb +3 -1
  104. data/spec/dnsimple/client/templates_spec.rb +4 -2
  105. data/spec/dnsimple/client/tlds_spec.rb +2 -0
  106. data/spec/dnsimple/client/vanity_name_servers_spec.rb +2 -0
  107. data/spec/dnsimple/client/webhooks_spec.rb +3 -1
  108. data/spec/dnsimple/client/zones_distributions_spec.rb +2 -0
  109. data/spec/dnsimple/client/zones_records_spec.rb +4 -2
  110. data/spec/dnsimple/client/zones_spec.rb +3 -1
  111. data/spec/dnsimple/client_spec.rb +18 -16
  112. data/spec/dnsimple/extra_spec.rb +2 -0
  113. data/spec/dnsimple/options/base_spec.rb +2 -0
  114. data/spec/dnsimple/options/list_options_spec.rb +6 -4
  115. data/spec/fixtures.http/accounts/success-account.http +0 -1
  116. data/spec/fixtures.http/accounts/success-user.http +0 -1
  117. data/spec/fixtures.http/addCollaborator/invite-success.http +0 -1
  118. data/spec/fixtures.http/addCollaborator/success.http +0 -1
  119. data/spec/fixtures.http/appliedServices/success.http +0 -1
  120. data/spec/fixtures.http/cancelDomainTransfer/success.http +18 -0
  121. data/spec/fixtures.http/changeDomainDelegation/success.http +0 -1
  122. data/spec/fixtures.http/changeDomainDelegationToVanity/success.http +0 -1
  123. data/spec/fixtures.http/checkDomain/success.http +0 -1
  124. data/spec/fixtures.http/checkDomainPremiumPrice/error_400_not_a_premium_domain.http +18 -0
  125. data/spec/fixtures.http/checkDomainPremiumPrice/error_400_tld_not_supported.http +18 -0
  126. data/spec/fixtures.http/checkDomainPremiumPrice/success.http +20 -0
  127. data/spec/fixtures.http/checkZoneDistribution/error.http +0 -1
  128. data/spec/fixtures.http/checkZoneDistribution/failure.http +0 -1
  129. data/spec/fixtures.http/checkZoneDistribution/success.http +0 -1
  130. data/spec/fixtures.http/checkZoneRecordDistribution/error.http +0 -1
  131. data/spec/fixtures.http/checkZoneRecordDistribution/failure.http +0 -1
  132. data/spec/fixtures.http/checkZoneRecordDistribution/success.http +0 -1
  133. data/spec/fixtures.http/createContact/created.http +0 -1
  134. data/spec/fixtures.http/createDelegationSignerRecord/created.http +0 -1
  135. data/spec/fixtures.http/createDelegationSignerRecord/validation-error.http +0 -1
  136. data/spec/fixtures.http/createDomain/created.http +20 -16
  137. data/spec/fixtures.http/createEmailForward/created.http +21 -17
  138. data/spec/fixtures.http/createPrimaryServer/created.http +21 -0
  139. data/spec/fixtures.http/createSecondaryZone/created.http +21 -0
  140. data/spec/fixtures.http/createTemplate/created.http +0 -1
  141. data/spec/fixtures.http/createTemplateRecord/created.http +0 -1
  142. data/spec/fixtures.http/createWebhook/created.http +0 -1
  143. data/spec/fixtures.http/createZoneRecord/created-apex.http +0 -1
  144. data/spec/fixtures.http/createZoneRecord/created.http +0 -1
  145. data/spec/fixtures.http/deleteContact/error-contact-in-use.http +18 -0
  146. data/spec/fixtures.http/deleteEmailForward/success.http +12 -7
  147. data/spec/fixtures.http/disableDnssec/not-enabled.http +0 -1
  148. data/spec/fixtures.http/disableWhoisPrivacy/success.http +0 -1
  149. data/spec/fixtures.http/downloadCertificate/success.http +0 -1
  150. data/spec/fixtures.http/enableDnssec/success.http +0 -1
  151. data/spec/fixtures.http/enableVanityNameServers/success.http +0 -1
  152. data/spec/fixtures.http/enableWhoisPrivacy/created.http +0 -1
  153. data/spec/fixtures.http/enableWhoisPrivacy/success.http +0 -1
  154. data/spec/fixtures.http/getCertificate/success.http +10 -11
  155. data/spec/fixtures.http/getCertificatePrivateKey/success.http +0 -1
  156. data/spec/fixtures.http/getContact/success.http +0 -1
  157. data/spec/fixtures.http/getDelegationSignerRecord/success.http +0 -1
  158. data/spec/fixtures.http/getDnssec/success.http +0 -1
  159. data/spec/fixtures.http/getDomain/success.http +13 -9
  160. data/spec/fixtures.http/getDomainDelegation/success-empty.http +0 -1
  161. data/spec/fixtures.http/getDomainDelegation/success.http +0 -1
  162. data/spec/fixtures.http/getDomainPremiumPrice/failure.http +0 -1
  163. data/spec/fixtures.http/getDomainPremiumPrice/success.http +0 -1
  164. data/spec/fixtures.http/getDomainPrices/failure.http +19 -0
  165. data/spec/fixtures.http/getDomainPrices/success.http +21 -0
  166. data/spec/fixtures.http/getDomainTransfer/success.http +20 -0
  167. data/spec/fixtures.http/getEmailForward/success.http +14 -10
  168. data/spec/fixtures.http/getPrimaryServer/success.http +21 -0
  169. data/spec/fixtures.http/getService/success.http +0 -1
  170. data/spec/fixtures.http/getTemplate/success.http +0 -1
  171. data/spec/fixtures.http/getTemplateRecord/success.http +0 -1
  172. data/spec/fixtures.http/getTld/success.http +0 -1
  173. data/spec/fixtures.http/getTldExtendedAttributes/success-attributes.http +0 -1
  174. data/spec/fixtures.http/getTldExtendedAttributes/success-noattributes.http +0 -1
  175. data/spec/fixtures.http/getTldExtendedAttributes/success.http +0 -1
  176. data/spec/fixtures.http/getWebhook/success.http +0 -1
  177. data/spec/fixtures.http/getWhoisPrivacy/success.http +0 -1
  178. data/spec/fixtures.http/getZone/success.http +0 -1
  179. data/spec/fixtures.http/getZoneFile/success.http +0 -1
  180. data/spec/fixtures.http/getZoneRecord/success.http +0 -1
  181. data/spec/fixtures.http/initiatePush/success.http +0 -1
  182. data/spec/fixtures.http/issueLetsencryptCertificate/success.http +18 -21
  183. data/spec/fixtures.http/issueRenewalLetsencryptCertificate/success.http +18 -21
  184. data/spec/fixtures.http/linkPrimaryServer/success.http +21 -0
  185. data/spec/fixtures.http/listAccounts/success-account.http +0 -1
  186. data/spec/fixtures.http/listAccounts/success-user.http +0 -1
  187. data/spec/fixtures.http/listCertificates/success.http +10 -11
  188. data/spec/fixtures.http/listCollaborators/success.http +0 -1
  189. data/spec/fixtures.http/listContacts/success.http +0 -1
  190. data/spec/fixtures.http/listDelegationSignerRecords/success.http +0 -1
  191. data/spec/fixtures.http/listDomains/success.http +20 -16
  192. data/spec/fixtures.http/listEmailForwards/success.http +0 -1
  193. data/spec/fixtures.http/listPrimaryServers/success.http +21 -0
  194. data/spec/fixtures.http/listPushes/success.http +0 -1
  195. data/spec/fixtures.http/listServices/success.http +0 -1
  196. data/spec/fixtures.http/listTemplateRecords/success.http +0 -1
  197. data/spec/fixtures.http/listTemplates/success.http +0 -1
  198. data/spec/fixtures.http/listTlds/success.http +0 -1
  199. data/spec/fixtures.http/listWebhooks/success.http +0 -1
  200. data/spec/fixtures.http/listZoneRecords/success.http +0 -1
  201. data/spec/fixtures.http/listZones/success.http +0 -1
  202. data/spec/fixtures.http/method-not-allowed.http +0 -1
  203. data/spec/fixtures.http/notfound-certificate.http +0 -1
  204. data/spec/fixtures.http/notfound-collaborator.http +0 -1
  205. data/spec/fixtures.http/notfound-contact.http +0 -1
  206. data/spec/fixtures.http/notfound-delegationsignerrecord.http +0 -1
  207. data/spec/fixtures.http/notfound-domain.http +0 -1
  208. data/spec/fixtures.http/notfound-domainpush.http +0 -1
  209. data/spec/fixtures.http/notfound-emailforward.http +0 -1
  210. data/spec/fixtures.http/notfound-record.http +0 -1
  211. data/spec/fixtures.http/notfound-template.http +0 -1
  212. data/spec/fixtures.http/notfound-webhook.http +0 -1
  213. data/spec/fixtures.http/notfound-whoisprivacy.http +0 -1
  214. data/spec/fixtures.http/notfound-zone.http +0 -1
  215. data/spec/fixtures.http/oauthAccessToken/error-invalid-request.http +0 -1
  216. data/spec/fixtures.http/oauthAccessToken/success.http +0 -1
  217. data/spec/fixtures.http/pages-1of3.http +0 -1
  218. data/spec/fixtures.http/pages-2of3.http +0 -1
  219. data/spec/fixtures.http/pages-3of3.http +0 -1
  220. data/spec/fixtures.http/purchaseLetsencryptCertificate/success.http +20 -21
  221. data/spec/fixtures.http/purchaseRenewalLetsencryptCertificate/success.http +20 -21
  222. data/spec/fixtures.http/registerDomain/success.http +1 -2
  223. data/spec/fixtures.http/renewDomain/error-tooearly.http +0 -1
  224. data/spec/fixtures.http/renewDomain/success.http +1 -2
  225. data/spec/fixtures.http/renewWhoisPrivacy/success.http +0 -1
  226. data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-duplicated-order.http +1 -2
  227. data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-not-found.http +1 -2
  228. data/spec/fixtures.http/response.http +0 -1
  229. data/spec/fixtures.http/transferDomain/error-indnsimple.http +0 -1
  230. data/spec/fixtures.http/transferDomain/error-missing-authcode.http +0 -1
  231. data/spec/fixtures.http/transferDomain/success.http +1 -2
  232. data/spec/fixtures.http/unlinkPrimaryServer/success.http +21 -0
  233. data/spec/fixtures.http/updateContact/success.http +0 -1
  234. data/spec/fixtures.http/updateTemplate/success.http +0 -1
  235. data/spec/fixtures.http/updateZoneRecord/success.http +0 -1
  236. data/spec/fixtures.http/validation-error.http +0 -1
  237. data/spec/fixtures.http/whoami/success-account.http +0 -1
  238. data/spec/fixtures.http/whoami/success-user.http +0 -1
  239. data/spec/fixtures.http/whoami/success.http +0 -1
  240. data/spec/spec_helper.rb +3 -1
  241. data/spec/support/helpers.rb +2 -0
  242. data/spec/support/webmock.rb +2 -0
  243. metadata +36 -15
  244. data/.ruby-gemset +0 -1
  245. data/spec/fixtures.http/resetDomainToken/success.http +0 -17
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".domains" do
@@ -6,6 +8,7 @@ describe Dnsimple::Client, ".domains" do
6
8
 
7
9
  describe "#initiate_push" do
8
10
  let(:account_id) { 1010 }
11
+ let(:attributes) { { new_account_email: "admin@target-account.test" } }
9
12
  let(:domain_id) { "example.com" }
10
13
 
11
14
  before do
@@ -13,7 +16,6 @@ describe Dnsimple::Client, ".domains" do
13
16
  .to_return(read_http_fixture("initiatePush/success.http"))
14
17
  end
15
18
 
16
- let(:attributes) { { new_account_email: "admin@target-account.test" } }
17
19
 
18
20
  it "builds the correct request" do
19
21
  subject.initiate_push(account_id, domain_id, attributes)
@@ -86,6 +88,7 @@ describe Dnsimple::Client, ".domains" do
86
88
 
87
89
  describe "#accept_push" do
88
90
  let(:account_id) { 2020 }
91
+ let(:attributes) { { contact_id: 2 } }
89
92
  let(:push_id) { 1 }
90
93
 
91
94
  before do
@@ -93,7 +96,6 @@ describe Dnsimple::Client, ".domains" do
93
96
  .to_return(read_http_fixture("acceptPush/success.http"))
94
97
  end
95
98
 
96
- let(:attributes) { { contact_id: 2 } }
97
99
 
98
100
  it "builds the correct request" do
99
101
  subject.accept_push(account_id, push_id, attributes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".domains" do
@@ -33,9 +35,9 @@ describe Dnsimple::Client, ".domains" do
33
35
  end
34
36
 
35
37
  it "supports sorting" do
36
- subject.domains(account_id, sort: "expires_on:asc")
38
+ subject.domains(account_id, sort: "expiration:asc")
37
39
 
38
- expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains?sort=expires_on:asc")
40
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains?sort=expiration:asc")
39
41
  end
40
42
 
41
43
  it "supports filtering" do
@@ -82,9 +84,9 @@ describe Dnsimple::Client, ".domains" do
82
84
  end
83
85
 
84
86
  it "supports sorting" do
85
- subject.all_domains(account_id, sort: "expires_on:asc")
87
+ subject.all_domains(account_id, sort: "expiration:asc")
86
88
 
87
- expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains?page=1&per_page=100&sort=expires_on:asc")
89
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains?page=1&per_page=100&sort=expiration:asc")
88
90
  end
89
91
 
90
92
  it "supports filtering" do
@@ -96,13 +98,13 @@ describe Dnsimple::Client, ".domains" do
96
98
 
97
99
  describe "#create_domain" do
98
100
  let(:account_id) { 1010 }
101
+ let(:attributes) { { name: "example.com" } }
99
102
 
100
103
  before do
101
104
  stub_request(:post, %r{/v2/#{account_id}/domains$})
102
105
  .to_return(read_http_fixture("createDomain/created.http"))
103
106
  end
104
107
 
105
- let(:attributes) { { name: "example.com" } }
106
108
 
107
109
  it "builds the correct request" do
108
110
  subject.create_domain(account_id, attributes)
@@ -131,28 +133,28 @@ describe Dnsimple::Client, ".domains" do
131
133
  end
132
134
 
133
135
  it "builds the correct request" do
134
- subject.domain(account_id, domain = "example.com")
136
+ subject.domain(account_id, domain = "example-alpha.com")
135
137
 
136
138
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain}")
137
139
  .with(headers: { 'Accept' => 'application/json' })
138
140
  end
139
141
 
140
142
  it "returns the domain" do
141
- response = subject.domain(account_id, "example.com")
143
+ response = subject.domain(account_id, "example-alpha.com")
142
144
  expect(response).to be_a(Dnsimple::Response)
143
145
 
144
146
  result = response.data
145
147
  expect(result).to be_a(Dnsimple::Struct::Domain)
146
- expect(result.id).to eq(1)
147
- expect(result.account_id).to eq(1010)
148
- expect(result.registrant_id).to eq(nil)
148
+ expect(result.id).to eq(181984)
149
+ expect(result.account_id).to eq(1385)
150
+ expect(result.registrant_id).to eq(2715)
149
151
  expect(result.name).to eq("example-alpha.com")
150
- expect(result.state).to eq("hosted")
152
+ expect(result.state).to eq("registered")
151
153
  expect(result.auto_renew).to be(false)
152
154
  expect(result.private_whois).to be(false)
153
- expect(result.expires_on).to eq(nil)
154
- expect(result.created_at).to eq("2014-12-06T15:56:55Z")
155
- expect(result.updated_at).to eq("2015-12-09T00:20:56Z")
155
+ expect(result.expires_at).to eq("2021-06-05T02:15:00Z")
156
+ expect(result.created_at).to eq("2020-06-04T19:15:14Z")
157
+ expect(result.updated_at).to eq("2020-06-04T19:15:21Z")
156
158
  end
157
159
 
158
160
  context "when the domain does not exist" do
@@ -201,31 +203,4 @@ describe Dnsimple::Client, ".domains" do
201
203
  end
202
204
  end
203
205
  end
204
-
205
- describe "#reset_domain_token" do
206
- let(:account_id) { 1010 }
207
- let(:domain_id) { "example.com" }
208
-
209
- before do
210
- stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/token})
211
- .to_return(read_http_fixture("resetDomainToken/success.http"))
212
- end
213
-
214
- it "builds the correct request" do
215
- subject.reset_domain_token(account_id, domain_id)
216
-
217
- expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/token")
218
- .with(headers: { 'Accept' => 'application/json' })
219
- end
220
-
221
- it "returns the domain" do
222
- response = subject.reset_domain_token(account_id, domain_id)
223
- expect(response).to be_a(Dnsimple::Response)
224
-
225
- result = response.data
226
- expect(result).to be_a(Dnsimple::Struct::Domain)
227
- expect(result.id).to be_a(Integer)
228
- end
229
- end
230
-
231
206
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".identity" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".oauth" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".registrar" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".registrar" do
@@ -29,13 +31,13 @@ describe Dnsimple::Client, ".registrar" do
29
31
 
30
32
  describe "#change_domain_delegation" do
31
33
  let(:account_id) { 1010 }
34
+ let(:attributes) { %w(ns1.dnsimple.com ns2.dnsimple.com ns3.dnsimple.com ns4.dnsimple.com) }
32
35
 
33
36
  before do
34
37
  stub_request(:put, %r{/v2/#{account_id}/registrar/domains/.+/delegation$})
35
38
  .to_return(read_http_fixture("changeDomainDelegation/success.http"))
36
39
  end
37
40
 
38
- let(:attributes) { %w(ns1.dnsimple.com ns2.dnsimple.com ns3.dnsimple.com ns4.dnsimple.com) }
39
41
 
40
42
  it "builds the correct request" do
41
43
  subject.change_domain_delegation(account_id, domain_name = "example.com", attributes)
@@ -55,13 +57,13 @@ describe Dnsimple::Client, ".registrar" do
55
57
 
56
58
  describe "#change_domain_delegation_to_vanity" do
57
59
  let(:account_id) { 1010 }
60
+ let(:attributes) { %w(ns1.example.com ns2.example.com) }
58
61
 
59
62
  before do
60
63
  stub_request(:put, %r{/v2/#{account_id}/registrar/domains/.+/delegation/vanity$})
61
64
  .to_return(read_http_fixture("changeDomainDelegationToVanity/success.http"))
62
65
  end
63
66
 
64
- let(:attributes) { %w(ns1.example.com ns2.example.com) }
65
67
 
66
68
  it "builds the correct request" do
67
69
  subject.change_domain_delegation_to_vanity(account_id, domain_name = "example.com", attributes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".registrar" do
@@ -37,7 +39,7 @@ describe Dnsimple::Client, ".registrar" do
37
39
 
38
40
  context "when premium price" do
39
41
  before do
40
- stub_request(:get, %r{/v2/#{account_id}/registrar/domains/.+/premium_price[\?action]*})
42
+ stub_request(:get, %r{/v2/#{account_id}/registrar/domains/.+/premium_price[?action]*})
41
43
  .to_return(read_http_fixture("getDomainPremiumPrice/success.http"))
42
44
  end
43
45
 
@@ -80,15 +82,58 @@ describe Dnsimple::Client, ".registrar" do
80
82
  end
81
83
  end
82
84
 
85
+ describe "#get_domain_prices" do
86
+ let(:account_id) { 1010 }
87
+
88
+ before do
89
+ stub_request(:get, %r{/v2/#{account_id}/registrar/domains/bingo.pizza/prices$})
90
+ .to_return(read_http_fixture("getDomainPrices/success.http"))
91
+ end
92
+
93
+ it "builds the correct request" do
94
+ subject.get_domain_prices(account_id, "bingo.pizza")
95
+
96
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/bingo.pizza/prices")
97
+ .with(headers: { "Accept" => "application/json" })
98
+ end
99
+
100
+ it "returns the prices" do
101
+ response = subject.get_domain_prices(account_id, "bingo.pizza")
102
+ expect(response).to be_a(Dnsimple::Response)
103
+
104
+ result = response.data
105
+
106
+ expect(result).to be_a(Dnsimple::Struct::DomainPrice)
107
+ expect(result.domain).to eq("bingo.pizza")
108
+ expect(result.premium).to be(true)
109
+ expect(result.registration_price).to eq(20.0)
110
+ expect(result.renewal_price).to eq(20.0)
111
+ expect(result.transfer_price).to eq(20.0)
112
+ end
113
+
114
+ context "when the TLD is not supported" do
115
+ before do
116
+ stub_request(:get, %r{/v2/#{account_id}/registrar/domains/bingo.pineapple/prices$})
117
+ .to_return(read_http_fixture("getDomainPrices/failure.http"))
118
+ end
119
+
120
+ it "raises error" do
121
+ expect {
122
+ subject.get_domain_prices(account_id, "bingo.pineapple")
123
+ }.to raise_error(Dnsimple::RequestError, "TLD .PINEAPPLE is not supported")
124
+ end
125
+ end
126
+ end
127
+
83
128
  describe "#register_domain" do
84
129
  let(:account_id) { 1010 }
130
+ let(:attributes) { { registrant_id: "10" } }
85
131
 
86
132
  before do
87
133
  stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/registrations$})
88
134
  .to_return(read_http_fixture("registerDomain/success.http"))
89
135
  end
90
136
 
91
- let(:attributes) { { registrant_id: "10" } }
92
137
 
93
138
  it "builds the correct request" do
94
139
  subject.register_domain(account_id, domain_name = "example.com", attributes)
@@ -117,13 +162,13 @@ describe Dnsimple::Client, ".registrar" do
117
162
 
118
163
  describe "#renew_domain" do
119
164
  let(:account_id) { 1010 }
165
+ let(:attributes) { { period: "3" } }
120
166
 
121
167
  before do
122
168
  stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/renewals$})
123
169
  .to_return(read_http_fixture("renewDomain/success.http"))
124
170
  end
125
171
 
126
- let(:attributes) { { period: "3" } }
127
172
 
128
173
  it "builds the correct request" do
129
174
  subject.renew_domain(account_id, domain_name = "example.com", attributes)
@@ -157,13 +202,13 @@ describe Dnsimple::Client, ".registrar" do
157
202
 
158
203
  describe "#transfer_domain" do
159
204
  let(:account_id) { 1010 }
205
+ let(:attributes) { { registrant_id: "10", auth_code: "x1y2z3" } }
160
206
 
161
207
  before do
162
208
  stub_request(:post, %r{/v2/#{account_id}/registrar/domains/.+/transfers$})
163
209
  .to_return(read_http_fixture("transferDomain/success.http"))
164
210
  end
165
211
 
166
- let(:attributes) { { registrant_id: "10", auth_code: "x1y2z3" } }
167
212
 
168
213
  it "builds the correct request" do
169
214
  subject.transfer_domain(account_id, domain_name = "example.com", attributes)
@@ -212,6 +257,73 @@ describe Dnsimple::Client, ".registrar" do
212
257
  end
213
258
  end
214
259
 
260
+ describe "#get_transfer_domain" do
261
+ let(:account_id) { 1010 }
262
+
263
+ before do
264
+ stub_request(:get, %r{/v2/#{account_id}/registrar/domains/.+/transfers/.+$})
265
+ .to_return(read_http_fixture("getDomainTransfer/success.http"))
266
+ end
267
+
268
+ it "builds the correct request" do
269
+ subject.get_domain_transfer(account_id, domain_name = "example.com", transfer_id = 361)
270
+
271
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/transfers/#{transfer_id}")
272
+ .with(headers: { "Accept" => "application/json" })
273
+ end
274
+
275
+ it "returns the domain transfer" do
276
+ response = subject.get_domain_transfer(account_id, "example.com", 361)
277
+ expect(response).to be_a(Dnsimple::Response)
278
+
279
+ result = response.data
280
+ expect(result).to be_a(Dnsimple::Struct::DomainTransfer)
281
+ expect(result.id).to eq(361)
282
+ expect(result.domain_id).to eq(182245)
283
+ expect(result.registrant_id).to eq(2715)
284
+ expect(result.state).to eq("cancelled")
285
+ expect(result.auto_renew).to be(false)
286
+ expect(result.whois_privacy).to be(false)
287
+ expect(result.status_description).to eq("Canceled by customer")
288
+ expect(result.created_at).to eq("2020-06-05T18:08:00Z")
289
+ expect(result.updated_at).to eq("2020-06-05T18:10:01Z")
290
+ end
291
+ end
292
+
293
+ describe "#cancel_domain_transfer" do
294
+ let(:account_id) { 1010 }
295
+
296
+ before do
297
+ stub_request(:delete, %r{/v2/#{account_id}/registrar/domains/.+/transfers/.+$})
298
+ .to_return(read_http_fixture("cancelDomainTransfer/success.http"))
299
+ end
300
+
301
+ it "builds the correct request" do
302
+ subject.cancel_domain_transfer(account_id, domain_name = "example.com", transfer_id = 361)
303
+
304
+ expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/transfers/#{transfer_id}")
305
+ .with(headers: { "Accept" => "application/json" })
306
+ end
307
+
308
+ it "returns the domain transfer" do
309
+ response = subject.cancel_domain_transfer(account_id, "example.com", 361)
310
+ expect(response).to be_a(Dnsimple::Response)
311
+
312
+ result = response.data
313
+ expect(result).to be_a(Dnsimple::Struct::DomainTransfer)
314
+ expect(result.id).to eq(361)
315
+ expect(result.domain_id).to eq(182245)
316
+ expect(result.registrant_id).to eq(2715)
317
+ expect(result.state).to eq("transferring")
318
+ expect(result.auto_renew).to be(false)
319
+ expect(result.whois_privacy).to be(false)
320
+ expect(result.status_description).to eq(nil)
321
+ expect(result.created_at).to eq("2020-06-05T18:08:00Z")
322
+ expect(result.updated_at).to eq("2020-06-05T18:08:04Z")
323
+ end
324
+ end
325
+
326
+
215
327
  describe "#transfer_domain_out" do
216
328
  let(:account_id) { 1010 }
217
329
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".registrar" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".services" do
@@ -50,15 +52,14 @@ describe Dnsimple::Client, ".services" do
50
52
  expect(service.sid).to be_a(String)
51
53
  expect(service.description).to be_a(String)
52
54
 
53
- service.settings.each do |service_setting|
54
- expect(service_setting).to be_a(Dnsimple::Struct::Service::Setting)
55
- end
55
+ expect(service.settings).to all(be_a(Dnsimple::Struct::Service::Setting))
56
56
  end
57
57
  end
58
58
  end
59
59
 
60
60
  describe "#apply_service" do
61
61
  let(:account_id) { 1010 }
62
+ let(:settings) { { app: "foo" } }
62
63
  let(:domain_id) { "example.com" }
63
64
  let(:service_id) { "service1" }
64
65
 
@@ -67,7 +68,6 @@ describe Dnsimple::Client, ".services" do
67
68
  .to_return(read_http_fixture("applyService/success.http"))
68
69
  end
69
70
 
70
- let(:settings) { { app: "foo" } }
71
71
 
72
72
  it "builds the correct request" do
73
73
  subject.apply_service(account_id, service_id, domain_id, settings)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".services" do
@@ -47,9 +49,7 @@ describe Dnsimple::Client, ".services" do
47
49
  expect(service.sid).to be_a(String)
48
50
  expect(service.description).to be_a(String)
49
51
 
50
- service.settings.each do |service_setting|
51
- expect(service_setting).to be_a(Dnsimple::Struct::Service::Setting)
52
- end
52
+ expect(service.settings).to all(be_a(Dnsimple::Struct::Service::Setting))
53
53
  end
54
54
  end
55
55
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".templates" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".templates" do
@@ -76,6 +78,7 @@ describe Dnsimple::Client, ".templates" do
76
78
 
77
79
  describe "#create_record" do
78
80
  let(:account_id) { 1010 }
81
+ let(:attributes) { { type: "MX", name: "", content: "mx.example.com", priority: 10, ttl: 600 } }
79
82
  let(:template_id) { "alpha" }
80
83
 
81
84
  before do
@@ -83,7 +86,6 @@ describe Dnsimple::Client, ".templates" do
83
86
  .to_return(read_http_fixture("createTemplateRecord/created.http"))
84
87
  end
85
88
 
86
- let(:attributes) { { type: "MX", name: "", content: "mx.example.com", priority: 10, ttl: 600 } }
87
89
 
88
90
  it "builds the correct request" do
89
91
  subject.create_record(account_id, template_id, attributes)