dnsimple 4.3.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. checksums.yaml +5 -5
  2. data/.dependabot/config.yml +9 -0
  3. data/.rubocop.yml +7 -0
  4. data/.rubocop_dnsimple.yml +136 -45
  5. data/.travis.yml +13 -9
  6. data/CHANGELOG.md +57 -23
  7. data/CONTRIBUTING.md +55 -7
  8. data/Gemfile +4 -1
  9. data/LICENSE.txt +1 -1
  10. data/README.md +8 -6
  11. data/dnsimple.gemspec +3 -3
  12. data/lib/dnsimple.rb +2 -0
  13. data/lib/dnsimple/client.rb +12 -10
  14. data/lib/dnsimple/client/accounts.rb +2 -1
  15. data/lib/dnsimple/client/certificates.rb +188 -28
  16. data/lib/dnsimple/client/clients.rb +6 -2
  17. data/lib/dnsimple/client/contacts.rb +2 -5
  18. data/lib/dnsimple/client/domains.rb +3 -5
  19. data/lib/dnsimple/client/{collaborators.rb → domains_collaborators.rb} +3 -1
  20. data/lib/dnsimple/client/domains_delegation_signer_records.rb +2 -0
  21. data/lib/dnsimple/client/domains_dnssec.rb +2 -0
  22. data/lib/dnsimple/client/domains_email_forwards.rb +2 -0
  23. data/lib/dnsimple/client/domains_pushes.rb +2 -0
  24. data/lib/dnsimple/client/identity.rb +2 -0
  25. data/lib/dnsimple/client/oauth.rb +2 -0
  26. data/lib/dnsimple/client/registrar.rb +51 -5
  27. data/lib/dnsimple/client/registrar_auto_renewal.rb +2 -0
  28. data/lib/dnsimple/client/registrar_delegation.rb +6 -4
  29. data/lib/dnsimple/client/registrar_whois_privacy.rb +23 -1
  30. data/lib/dnsimple/client/services.rb +2 -2
  31. data/lib/dnsimple/client/services_domains.rb +2 -0
  32. data/lib/dnsimple/client/templates.rb +2 -0
  33. data/lib/dnsimple/client/templates_domains.rb +2 -0
  34. data/lib/dnsimple/client/templates_records.rb +2 -0
  35. data/lib/dnsimple/client/tlds.rb +16 -17
  36. data/lib/dnsimple/client/vanity_name_servers.rb +12 -10
  37. data/lib/dnsimple/client/webhooks.rb +2 -3
  38. data/lib/dnsimple/client/zones.rb +2 -1
  39. data/lib/dnsimple/client/zones_distributions.rb +49 -0
  40. data/lib/dnsimple/client/zones_records.rb +25 -28
  41. data/lib/dnsimple/default.rb +11 -9
  42. data/lib/dnsimple/error.rb +2 -0
  43. data/lib/dnsimple/extra.rb +2 -0
  44. data/lib/dnsimple/options.rb +2 -0
  45. data/lib/dnsimple/response.rb +6 -4
  46. data/lib/dnsimple/struct.rb +7 -0
  47. data/lib/dnsimple/struct/account.rb +2 -0
  48. data/lib/dnsimple/struct/certificate.rb +11 -0
  49. data/lib/dnsimple/struct/certificate_bundle.rb +5 -0
  50. data/lib/dnsimple/struct/certificate_purchase.rb +27 -0
  51. data/lib/dnsimple/struct/certificate_renewal.rb +30 -0
  52. data/lib/dnsimple/struct/collaborator.rb +2 -0
  53. data/lib/dnsimple/struct/contact.rb +2 -0
  54. data/lib/dnsimple/struct/delegation_signer_record.rb +2 -0
  55. data/lib/dnsimple/struct/dnssec.rb +2 -0
  56. data/lib/dnsimple/struct/domain.rb +24 -3
  57. data/lib/dnsimple/struct/domain_check.rb +2 -0
  58. data/lib/dnsimple/struct/domain_premium_price.rb +2 -0
  59. data/lib/dnsimple/struct/domain_push.rb +2 -0
  60. data/lib/dnsimple/struct/domain_registration.rb +2 -3
  61. data/lib/dnsimple/struct/domain_renewal.rb +2 -3
  62. data/lib/dnsimple/struct/domain_transfer.rb +4 -2
  63. data/lib/dnsimple/struct/email_forward.rb +2 -0
  64. data/lib/dnsimple/struct/extended_attribute.rb +3 -1
  65. data/lib/dnsimple/struct/oauth_token.rb +2 -0
  66. data/lib/dnsimple/struct/service.rb +3 -1
  67. data/lib/dnsimple/struct/template.rb +2 -0
  68. data/lib/dnsimple/struct/template_record.rb +2 -0
  69. data/lib/dnsimple/struct/tld.rb +2 -0
  70. data/lib/dnsimple/struct/user.rb +2 -0
  71. data/lib/dnsimple/struct/vanity_name_server.rb +27 -0
  72. data/lib/dnsimple/struct/webhook.rb +2 -0
  73. data/lib/dnsimple/struct/whoami.rb +4 -2
  74. data/lib/dnsimple/struct/whois_privacy.rb +2 -0
  75. data/lib/dnsimple/struct/whois_privacy_renewal.rb +30 -0
  76. data/lib/dnsimple/struct/zone.rb +2 -0
  77. data/lib/dnsimple/struct/zone_distribution.rb +13 -0
  78. data/lib/dnsimple/struct/zone_file.rb +2 -0
  79. data/lib/dnsimple/struct/zone_record.rb +2 -0
  80. data/lib/dnsimple/version.rb +3 -1
  81. data/spec/dnsimple/client/accounts_spec.rb +2 -0
  82. data/spec/dnsimple/client/certificates_spec.rb +227 -1
  83. data/spec/dnsimple/client/client_service_spec.rb +2 -0
  84. data/spec/dnsimple/client/contacts_spec.rb +3 -1
  85. data/spec/dnsimple/client/{collaborators_spec.rb → domains_collaborators_spec.rb} +3 -1
  86. data/spec/dnsimple/client/domains_delegation_signer_records_spec.rb +3 -1
  87. data/spec/dnsimple/client/domains_dnssec_spec.rb +4 -2
  88. data/spec/dnsimple/client/domains_email_forwards_spec.rb +3 -1
  89. data/spec/dnsimple/client/domains_pushes_spec.rb +3 -1
  90. data/spec/dnsimple/client/domains_spec.rb +19 -16
  91. data/spec/dnsimple/client/identity_spec.rb +2 -0
  92. data/spec/dnsimple/client/oauth_spec.rb +2 -0
  93. data/spec/dnsimple/client/registrar_auto_renewal_spec.rb +2 -0
  94. data/spec/dnsimple/client/registrar_delegation_spec.rb +5 -2
  95. data/spec/dnsimple/client/registrar_spec.rb +73 -4
  96. data/spec/dnsimple/client/registrar_whois_privacy_spec.rb +60 -3
  97. data/spec/dnsimple/client/services_domains_spec.rb +2 -0
  98. data/spec/dnsimple/client/services_spec.rb +3 -1
  99. data/spec/dnsimple/client/templates_domains_spec.rb +2 -0
  100. data/spec/dnsimple/client/templates_records_spec.rb +2 -0
  101. data/spec/dnsimple/client/templates_spec.rb +2 -0
  102. data/spec/dnsimple/client/tlds_spec.rb +22 -19
  103. data/spec/dnsimple/client/vanity_name_servers_spec.rb +2 -0
  104. data/spec/dnsimple/client/webhooks_spec.rb +2 -0
  105. data/spec/dnsimple/client/zones_distributions_spec.rb +137 -0
  106. data/spec/dnsimple/client/zones_records_spec.rb +37 -35
  107. data/spec/dnsimple/client/zones_spec.rb +4 -2
  108. data/spec/dnsimple/client_spec.rb +8 -6
  109. data/spec/dnsimple/extra_spec.rb +2 -0
  110. data/spec/dnsimple/options/base_spec.rb +2 -0
  111. data/spec/dnsimple/options/list_options_spec.rb +2 -0
  112. data/spec/fixtures.http/{transferDomainOut → authorizeDomainTransferOut}/success.http +0 -0
  113. data/spec/fixtures.http/cancelDomainTransfer/success.http +19 -0
  114. data/spec/fixtures.http/checkZoneDistribution/error.http +21 -0
  115. data/spec/fixtures.http/checkZoneDistribution/failure.http +21 -0
  116. data/spec/fixtures.http/checkZoneDistribution/success.http +21 -0
  117. data/spec/fixtures.http/checkZoneRecordDistribution/error.http +21 -0
  118. data/spec/fixtures.http/checkZoneRecordDistribution/failure.http +21 -0
  119. data/spec/fixtures.http/checkZoneRecordDistribution/success.http +21 -0
  120. data/spec/fixtures.http/createDomain/created.http +21 -16
  121. data/spec/fixtures.http/getCertificate/success.http +1 -1
  122. data/spec/fixtures.http/getDomain/success.http +14 -9
  123. data/spec/fixtures.http/getDomainTransfer/success.http +21 -0
  124. data/spec/fixtures.http/issueLetsencryptCertificate/success.http +21 -0
  125. data/spec/fixtures.http/issueRenewalLetsencryptCertificate/success.http +21 -0
  126. data/spec/fixtures.http/listCertificates/success.http +1 -1
  127. data/spec/fixtures.http/listDomains/success.http +21 -16
  128. data/spec/fixtures.http/purchaseLetsencryptCertificate/success.http +21 -0
  129. data/spec/fixtures.http/purchaseRenewalLetsencryptCertificate/success.http +21 -0
  130. data/spec/fixtures.http/registerDomain/success.http +2 -2
  131. data/spec/fixtures.http/renewDomain/success.http +2 -2
  132. data/spec/fixtures.http/renewWhoisPrivacy/success.http +21 -0
  133. data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-duplicated-order.http +19 -0
  134. data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-not-found.http +19 -0
  135. data/spec/fixtures.http/transferDomain/success.http +2 -2
  136. data/spec/fixtures.http/whoami/success-account.http +1 -1
  137. data/spec/fixtures.http/whoami/success-user.http +1 -1
  138. data/spec/fixtures.http/whoami/success.http +1 -1
  139. data/spec/spec_helper.rb +4 -2
  140. data/spec/support/helpers.rb +2 -0
  141. data/spec/support/webmock.rb +2 -0
  142. metadata +50 -19
  143. data/.ruby-gemset +0 -1
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -8,14 +10,17 @@ module Dnsimple
8
10
 
9
11
  # @return [String] The server certificate
10
12
  attr_accessor :server
13
+
11
14
  alias server_certificate server
12
15
 
13
16
  # @return [String] The root certificate
14
17
  attr_accessor :root
18
+
15
19
  alias root_certificate root
16
20
 
17
21
  # @return [Array<String>] Intermediate certificates
18
22
  attr_accessor :chain
23
+
19
24
  alias intermediate_certificates chain
20
25
 
21
26
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dnsimple
4
+ module Struct
5
+
6
+ class CertificatePurchase < Base
7
+ # @return [Integer] The certificate purchase ID in DNSimple.
8
+ attr_accessor :id
9
+
10
+ # @return [Integer] The certificate ID.
11
+ attr_accessor :certificate_id
12
+
13
+ # @return [String] The certificate renewal state.
14
+ attr_accessor :state
15
+
16
+ # @return [Boolean] True if the certificate is requested to auto-renew
17
+ attr_accessor :auto_renew
18
+
19
+ # @return [String] When the certificate renewal was created in DNSimple.
20
+ attr_accessor :created_at
21
+
22
+ # @return [String] When the certificate renewal was last updated in DNSimple.
23
+ attr_accessor :updated_at
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dnsimple
4
+ module Struct
5
+
6
+ class CertificateRenewal < Base
7
+ # @return [Integer] The certificate renewal ID in DNSimple.
8
+ attr_accessor :id
9
+
10
+ # @return [Integer] The old certificate ID.
11
+ attr_accessor :old_certificate_id
12
+
13
+ # @return [Integer] The new certificate ID.
14
+ attr_accessor :new_certificate_id
15
+
16
+ # @return [String] The certificate renewal state.
17
+ attr_accessor :state
18
+
19
+ # @return [Boolean] True if the certificate is requested to auto-renew
20
+ attr_accessor :auto_renew
21
+
22
+ # @return [String] When the certificate renewal was created in DNSimple.
23
+ attr_accessor :created_at
24
+
25
+ # @return [String] When the certificate renewal was last updated in DNSimple.
26
+ attr_accessor :updated_at
27
+ end
28
+
29
+ end
30
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -1,7 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
4
6
  class Domain < Base
7
+
8
+ def initialize(attributes = {})
9
+ attributes.delete("expires_on")
10
+ super
11
+ @expires_on = Date.parse(expires_at).to_s if expires_at
12
+ end
13
+
5
14
  # @return [Integer] The domain ID in DNSimple.
6
15
  attr_accessor :id
7
16
 
@@ -26,15 +35,27 @@ module Dnsimple
26
35
  # @return [Bool] True if the domain WHOIS privacy is enabled, false otherwise.
27
36
  attr_accessor :private_whois
28
37
 
29
- # @return [String] The date the domain will expire.
30
- attr_accessor :expires_on
38
+ # @return [String] The timestamp when domain will expire.
39
+ attr_accessor :expires_at
31
40
 
32
41
  # @return [String] When the domain was created in DNSimple.
33
42
  attr_accessor :created_at
34
43
 
35
44
  # @return [String] When the domain was last updated in DNSimple.
36
45
  attr_accessor :updated_at
37
- end
38
46
 
47
+ # @deprecated Please use #expires_at instead.
48
+ # @return [String] The date the domain will expire.
49
+ def expires_on
50
+ warn "[DEPRECATION] Domain#expires_on is deprecated. Please use `expires_at` instead."
51
+ @expires_on
52
+ end
53
+
54
+ def expires_on=(expiration_date)
55
+ warn "[DEPRECATION] Domain#expires_on= is deprecated. Please use `expires_at=` instead."
56
+ @expires_on = expiration_date
57
+ end
58
+
59
+ end
39
60
  end
40
61
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -23,9 +25,6 @@ module Dnsimple
23
25
  # @return [Bool] True if the domain WHOIS privacy was requested.
24
26
  attr_accessor :whois_privacy
25
27
 
26
- # @return [String] The premium price requested for the registration.
27
- attr_accessor :premium_price
28
-
29
28
  # @return [String] When the domain renewal was created in DNSimple.
30
29
  attr_accessor :created_at
31
30
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -14,9 +16,6 @@ module Dnsimple
14
16
  # @return [String] The state of the renewal.
15
17
  attr_accessor :state
16
18
 
17
- # @return [String] The premium price requested for the renewal.
18
- attr_accessor :premium_price
19
-
20
19
  # @return [String] When the domain renewal was created in DNSimple.
21
20
  attr_accessor :created_at
22
21
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -20,8 +22,8 @@ module Dnsimple
20
22
  # @return [Bool] True if the domain WHOIS privacy was requested.
21
23
  attr_accessor :whois_privacy
22
24
 
23
- # @return [String] The premium price requested for the registration.
24
- attr_accessor :premium_price
25
+ # @return [String,nil] The reason if transfer failed.
26
+ attr_accessor :status_description
25
27
 
26
28
  # @return [String] When the domain renewal was created in DNSimple.
27
29
  attr_accessor :created_at
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -24,7 +26,7 @@ module Dnsimple
24
26
  attr_accessor :required
25
27
 
26
28
  # @return [Array<Options>] The array of options with possible values for the extended attribute
27
- attr_accessor :options
29
+ attr_reader :options
28
30
 
29
31
  def initialize(*)
30
32
  super
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -45,7 +47,7 @@ module Dnsimple
45
47
  attr_accessor :default_subdomain
46
48
 
47
49
  # @return [Array<Settings>] The array of settings to setup this service, if setup is required.
48
- attr_accessor :settings
50
+ attr_reader :settings
49
51
 
50
52
  def initialize(*)
51
53
  super
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dnsimple
4
+ module Struct
5
+
6
+ class VanityNameServer < Base
7
+ # @return [Integer] The vanity name server ID in DNSimple.
8
+ attr_accessor :id
9
+
10
+ # @return [String] The vanity name server name.
11
+ attr_accessor :name
12
+
13
+ # @return [String] The vanity name server IPv4.
14
+ attr_accessor :ipv4
15
+
16
+ # @return [String] The vanity name server IPv6.
17
+ attr_accessor :ipv6
18
+
19
+ # @return [String] When the vanity name server was created in DNSimple.
20
+ attr_accessor :created_at
21
+
22
+ # @return [String] When the vanity name server was last updated in DNSimple.
23
+ attr_accessor :updated_at
24
+ end
25
+
26
+ end
27
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
4
6
  class Whoami < Base
5
7
  # @return [Account] The account, if present.
6
- attr_accessor :account
8
+ attr_reader :account
7
9
 
8
10
  # @return [String] The user, if present.
9
- attr_accessor :user
11
+ attr_reader :user
10
12
 
11
13
 
12
14
  # Converts account to a Struct::Account and sets it.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dnsimple
4
+ module Struct
5
+
6
+ class WhoisPrivacyRenewal < Base
7
+ # @return [Integer] The associated domain ID.
8
+ attr_accessor :domain_id
9
+
10
+ # @return [Integer] The associated WHOIS Privacy ID.
11
+ attr_accessor :whois_privacy_id
12
+
13
+ # @return [String] The WHOIS Privacy order state.
14
+ attr_accessor :state
15
+
16
+ # @return [Boolean] Whether the WHOIS Privacy is enabled for the domain.
17
+ attr_accessor :enabled
18
+
19
+ # @return [String] The date the WHOIS Privacy will expire on.
20
+ attr_accessor :expires_on
21
+
22
+ # @return [String] When the WHOIS Privacy was created in DNSimple.
23
+ attr_accessor :created_at
24
+
25
+ # @return [String] When the WHOIS Privacy was last updated in DNSimple.
26
+ attr_accessor :updated_at
27
+ end
28
+
29
+ end
30
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dnsimple
4
+ module Struct
5
+
6
+ class ZoneDistribution < Base
7
+ # @return [Boolean] true if the zone is properly distributed across
8
+ # all DNSimple name servers.
9
+ attr_accessor :distributed
10
+ end
11
+
12
+ end
13
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
4
  module Struct
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dnsimple
2
- VERSION = "4.3.0".freeze
4
+ VERSION = "5.1.0"
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".accounts" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".certificates" do
@@ -48,7 +50,7 @@ describe Dnsimple::Client, ".certificates" do
48
50
  it "exposes the pagination information" do
49
51
  response = subject.certificates(account_id, domain_id)
50
52
 
51
- expect(response.respond_to?(:page)).to be_truthy
53
+ expect(response.respond_to?(:page)).to be(true)
52
54
  expect(response.page).to eq(1)
53
55
  expect(response.per_page).to be_a(Integer)
54
56
  expect(response.total_entries).to be_a(Integer)
@@ -108,11 +110,14 @@ describe Dnsimple::Client, ".certificates" do
108
110
  expect(result).to be_a(Dnsimple::Struct::Certificate)
109
111
  expect(result.id).to eq(1)
110
112
  expect(result.domain_id).to eq(2)
113
+ expect(result.contact_id).to eq(3)
111
114
  expect(result.common_name).to eq("www.weppos.net")
115
+ expect(result.alternate_names).to eq(%w( weppos.net www.weppos.net ))
112
116
  expect(result.years).to eq(1)
113
117
  expect(result.csr).to eq("-----BEGIN CERTIFICATE REQUEST-----\nMIICljCCAX4CAQAwGTEXMBUGA1UEAwwOd3d3LndlcHBvcy5uZXQwggEiMA0GCSqG\nSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3MJwx9ahBG3kAwRjQdRvYZqtovUaxY6jp\nhd09975gO+2eYPDbc1yhNftVJ4KBT0zdEqzX0CwIlxE1MsnZ2YOsC7IJO531hMBp\ndBxM4tSG07xPz70AVUi9rY6YCUoJHmxoFbclpHFbtXZocR393WyzUK8047uM2mlz\n03AZKcMdyfeuo2/9TcxpTSCkklGqwqS9wtTogckaDHJDoBunAkMioGfOSMe7Yi6E\nYRtG4yPJYsDaq2yPJWV8+i0PFR1Wi5RCnPt0YdQWstHuZrxABi45+XVkzKtz3TUc\nYxrvPBucVa6uzd953u8CixNFkiOefvb/dajsv1GIwH6/Cvc1ftz1AgMBAAGgODA2\nBgkqhkiG9w0BCQ4xKTAnMCUGA1UdEQQeMByCDnd3dy53ZXBwb3MubmV0ggp3ZXBw\nb3MubmV0MA0GCSqGSIb3DQEBCwUAA4IBAQCDnVBO9RdJX0eFeZzlv5c8yG8duhKP\nl0Vl+V88fJylb/cbNj9qFPkKTK0vTXmS2XUFBChKPtLucp8+Z754UswX+QCsdc7U\nTTSG0CkyilcSubdZUERGej1XfrVQhrokk7Fu0Jh3BdT6REP0SIDTpA8ku/aRQiAp\np+h19M37S7+w/DMGDAq2LSX8jOpJ1yIokRDyLZpmwyLxutC21DXMGoJ3xZeUFrUT\nqRNwzkn2dJzgTrPkzhaXalUBqv+nfXHqHaWljZa/O0NVCFrHCdTdd53/6EE2Yabv\nq5SFTkRCpaxrvM/7a8Tr4ixD1/VKD6rw3+WC00000000000000000000\n-----END CERTIFICATE REQUEST-----\n")
114
118
  expect(result.state).to eq("issued")
115
119
  expect(result.authority_identifier).to eq("letsencrypt")
120
+ expect(result.auto_renew).to be(false)
116
121
  expect(result.created_at).to eq("2016-06-11T18:47:08Z")
117
122
  expect(result.updated_at).to eq("2016-06-11T18:47:37Z")
118
123
  expect(result.expires_on).to eq("2016-09-09")
@@ -224,4 +229,225 @@ describe Dnsimple::Client, ".certificates" do
224
229
  end
225
230
  end
226
231
 
232
+ describe "#purchase_letsencrypt_certificate" do
233
+ let(:account_id) { 1010 }
234
+ let(:domain_id) { "example.com" }
235
+ let(:contact_id) { 100 }
236
+
237
+ before do
238
+ stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/certificates/letsencrypt})
239
+ .to_return(read_http_fixture("purchaseLetsencryptCertificate/success.http"))
240
+ end
241
+
242
+ it "builds the correct request" do
243
+ attributes = { contact_id: contact_id }
244
+ subject.purchase_letsencrypt_certificate(account_id, domain_id, attributes)
245
+
246
+ expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/certificates/letsencrypt")
247
+ .with(body: attributes)
248
+ .with(headers: { 'Accept' => 'application/json' })
249
+ end
250
+
251
+ it "passes extra attributes" do
252
+ attributes = { contact_id: contact_id, name: "www", auto_renew: true, alternate_names: ["api.example.com"] }
253
+ subject.purchase_letsencrypt_certificate(account_id, domain_id, attributes)
254
+
255
+ expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/certificates/letsencrypt")
256
+ .with(body: attributes)
257
+ .with(headers: { 'Accept' => 'application/json' })
258
+ end
259
+
260
+ it "returns the certificate purchase" do
261
+ response = subject.purchase_letsencrypt_certificate(account_id, domain_id, contact_id: contact_id)
262
+ expect(response).to be_a(Dnsimple::Response)
263
+
264
+ result = response.data
265
+ expect(result).to be_a(Dnsimple::Struct::CertificatePurchase)
266
+
267
+ expect(result.id).to eq(300)
268
+ expect(result.certificate_id).to eq(300)
269
+ expect(result.state).to eq("requesting")
270
+ expect(result.auto_renew).to be(false)
271
+ end
272
+
273
+ context "when the domain does not exist" do
274
+ it "raises NotFoundError" do
275
+ stub_request(:post, %r{/v2})
276
+ .to_return(read_http_fixture("notfound-domain.http"))
277
+
278
+ expect {
279
+ subject.purchase_letsencrypt_certificate(account_id, domain_id, contact_id: contact_id)
280
+ }.to raise_error(Dnsimple::NotFoundError)
281
+ end
282
+ end
283
+ end
284
+
285
+ describe "#issue_letsencrypt_certificate" do
286
+ let(:account_id) { 1010 }
287
+ let(:domain_id) { "example.com" }
288
+ let(:certificate_id) { 200 }
289
+
290
+ before do
291
+ stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/certificates/letsencrypt/#{certificate_id}/issue})
292
+ .to_return(read_http_fixture("issueLetsencryptCertificate/success.http"))
293
+ end
294
+
295
+ it "builds the correct request" do
296
+ subject.issue_letsencrypt_certificate(account_id, domain_id, certificate_id)
297
+
298
+ expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/certificates/letsencrypt/#{certificate_id}/issue")
299
+ .with(headers: { 'Accept' => 'application/json' })
300
+ end
301
+
302
+ it "returns the certificate" do
303
+ response = subject.issue_letsencrypt_certificate(account_id, domain_id, certificate_id)
304
+ expect(response).to be_a(Dnsimple::Response)
305
+
306
+ result = response.data
307
+ expect(result).to be_a(Dnsimple::Struct::Certificate)
308
+
309
+ expect(result.id).to eq(200)
310
+ expect(result.domain_id).to eq(300)
311
+ expect(result.common_name).to eq("www.example.com")
312
+ expect(result.alternate_names).to eq([])
313
+ expect(result.years).to eq(1)
314
+ expect(result.csr).to be(nil)
315
+ expect(result.state).to eq("requesting")
316
+ expect(result.authority_identifier).to eq("letsencrypt")
317
+ expect(result.auto_renew).to be(false)
318
+ end
319
+
320
+ context "when the domain does not exist" do
321
+ it "raises NotFoundError" do
322
+ stub_request(:post, %r{/v2})
323
+ .to_return(read_http_fixture("notfound-domain.http"))
324
+
325
+ expect {
326
+ subject.issue_letsencrypt_certificate(account_id, domain_id, certificate_id)
327
+ }.to raise_error(Dnsimple::NotFoundError)
328
+ end
329
+ end
330
+
331
+ context "when the certificate does not exist" do
332
+ it "raises NotFoundError" do
333
+ stub_request(:post, %r{/v2})
334
+ .to_return(read_http_fixture("notfound-certificate.http"))
335
+
336
+ expect {
337
+ subject.issue_letsencrypt_certificate(account_id, domain_id, certificate_id)
338
+ }.to raise_error(Dnsimple::NotFoundError)
339
+ end
340
+ end
341
+ end
342
+
343
+ describe "#purchase_letsencrypt_certificate_renewal" do
344
+ let(:account_id) { 1010 }
345
+ let(:domain_id) { "example.com" }
346
+ let(:certificate_id) { 200 }
347
+
348
+ before do
349
+ stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/certificates/letsencrypt/#{certificate_id}/renewals})
350
+ .to_return(read_http_fixture("purchaseRenewalLetsencryptCertificate/success.http"))
351
+ end
352
+
353
+ it "builds the correct request" do
354
+ subject.purchase_letsencrypt_certificate_renewal(account_id, domain_id, certificate_id)
355
+
356
+ expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/certificates/letsencrypt/#{certificate_id}/renewals")
357
+ .with(headers: { 'Accept' => 'application/json' })
358
+ end
359
+
360
+ it "passes extra attributes" do
361
+ attributes = { auto_renew: true }
362
+ subject.purchase_letsencrypt_certificate_renewal(account_id, domain_id, certificate_id, attributes)
363
+
364
+ expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/certificates/letsencrypt/#{certificate_id}/renewals")
365
+ .with(body: attributes)
366
+ .with(headers: { 'Accept' => 'application/json' })
367
+ end
368
+
369
+ it "returns the certificate renew" do
370
+ response = subject.purchase_letsencrypt_certificate_renewal(account_id, domain_id, certificate_id)
371
+ expect(response).to be_a(Dnsimple::Response)
372
+
373
+ result = response.data
374
+ expect(result).to be_a(Dnsimple::Struct::CertificateRenewal)
375
+
376
+ expect(result.id).to eq(999)
377
+ expect(result.old_certificate_id).to eq(certificate_id)
378
+ expect(result.new_certificate_id).to eq(300)
379
+ expect(result.state).to eq("new")
380
+ end
381
+
382
+ context "when the domain does not exist" do
383
+ it "raises NotFoundError" do
384
+ stub_request(:post, %r{/v2})
385
+ .to_return(read_http_fixture("notfound-domain.http"))
386
+
387
+ expect {
388
+ subject.purchase_letsencrypt_certificate_renewal(account_id, domain_id, certificate_id)
389
+ }.to raise_error(Dnsimple::NotFoundError)
390
+ end
391
+ end
392
+ end
393
+
394
+ describe "#issue_letsencrypt_certificate_renewal" do
395
+ let(:account_id) { 1010 }
396
+ let(:domain_id) { "example.com" }
397
+ let(:certificate_id) { 300 }
398
+ let(:certificate_renewal_id) { 999 }
399
+
400
+ before do
401
+ stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/certificates/letsencrypt/#{certificate_id}/renewals/#{certificate_renewal_id}/issue})
402
+ .to_return(read_http_fixture("issueRenewalLetsencryptCertificate/success.http"))
403
+ end
404
+
405
+ it "builds the correct request" do
406
+ subject.issue_letsencrypt_certificate_renewal(account_id, domain_id, certificate_id, certificate_renewal_id)
407
+
408
+ expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/certificates/letsencrypt/#{certificate_id}/renewals/#{certificate_renewal_id}/issue")
409
+ .with(headers: { 'Accept' => 'application/json' })
410
+ end
411
+
412
+ it "returns the certificate" do
413
+ response = subject.issue_letsencrypt_certificate_renewal(account_id, domain_id, certificate_id, certificate_renewal_id)
414
+ expect(response).to be_a(Dnsimple::Response)
415
+
416
+ result = response.data
417
+ expect(result).to be_a(Dnsimple::Struct::Certificate)
418
+
419
+ expect(result.id).to eq(300)
420
+ expect(result.domain_id).to eq(300)
421
+ expect(result.common_name).to eq("www.example.com")
422
+ expect(result.alternate_names).to eq([])
423
+ expect(result.years).to eq(1)
424
+ expect(result.csr).to be(nil)
425
+ expect(result.state).to eq("requesting")
426
+ expect(result.authority_identifier).to eq("letsencrypt")
427
+ expect(result.auto_renew).to be(false)
428
+ end
429
+
430
+ context "when the domain does not exist" do
431
+ it "raises NotFoundError" do
432
+ stub_request(:post, %r{/v2})
433
+ .to_return(read_http_fixture("notfound-domain.http"))
434
+
435
+ expect {
436
+ subject.issue_letsencrypt_certificate_renewal(account_id, domain_id, certificate_id, certificate_renewal_id)
437
+ }.to raise_error(Dnsimple::NotFoundError)
438
+ end
439
+ end
440
+
441
+ context "when the certificate does not exist" do
442
+ it "raises NotFoundError" do
443
+ stub_request(:post, %r{/v2})
444
+ .to_return(read_http_fixture("notfound-certificate.http"))
445
+
446
+ expect {
447
+ subject.issue_letsencrypt_certificate_renewal(account_id, domain_id, certificate_id, certificate_renewal_id)
448
+ }.to raise_error(Dnsimple::NotFoundError)
449
+ end
450
+ end
451
+ end
452
+
227
453
  end