gandi_v5 0.2.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +13 -3
  4. data/.travis.yml +15 -1
  5. data/CHANGELOG.md +63 -0
  6. data/FUNDING.yml +10 -0
  7. data/LICENSE.md +2 -6
  8. data/README.md +16 -21
  9. data/gandi_v5.gemspec +3 -2
  10. data/lib/gandi_v5.rb +64 -24
  11. data/lib/gandi_v5/billing.rb +0 -2
  12. data/lib/gandi_v5/billing/info.rb +0 -2
  13. data/lib/gandi_v5/data.rb +1 -4
  14. data/lib/gandi_v5/data/converter.rb +0 -4
  15. data/lib/gandi_v5/data/converter/integer.rb +26 -0
  16. data/lib/gandi_v5/domain.rb +167 -28
  17. data/lib/gandi_v5/domain/availability.rb +0 -3
  18. data/lib/gandi_v5/domain/availability/product.rb +0 -3
  19. data/lib/gandi_v5/domain/live_dns.rb +42 -0
  20. data/lib/gandi_v5/domain/renewal_information.rb +0 -3
  21. data/lib/gandi_v5/domain/sharing_space.rb +10 -2
  22. data/lib/gandi_v5/email.rb +0 -4
  23. data/lib/gandi_v5/email/forward.rb +102 -0
  24. data/lib/gandi_v5/email/mailbox.rb +57 -13
  25. data/lib/gandi_v5/email/slot.rb +11 -3
  26. data/lib/gandi_v5/error.rb +0 -2
  27. data/lib/gandi_v5/live_dns.rb +0 -16
  28. data/lib/gandi_v5/live_dns/domain.rb +221 -80
  29. data/lib/gandi_v5/live_dns/domain/dnssec_key.rb +115 -0
  30. data/lib/gandi_v5/live_dns/domain/record.rb +81 -0
  31. data/lib/gandi_v5/live_dns/domain/snapshot.rb +107 -0
  32. data/lib/gandi_v5/live_dns/domain/tsig_key.rb +71 -0
  33. data/lib/gandi_v5/organization.rb +38 -5
  34. data/lib/gandi_v5/organization/customer.rb +90 -0
  35. data/lib/gandi_v5/version.rb +1 -1
  36. data/spec/.rubocop.yml +9 -2
  37. data/spec/fixtures/bodies/GandiV5_Billing/{info.yaml → info.yml} +0 -0
  38. data/spec/fixtures/bodies/GandiV5_Domain/{get.yaml → fetch.yml} +8 -0
  39. data/spec/fixtures/bodies/GandiV5_Domain/{fetch_contacts.yaml → fetch_contacts.yml} +0 -0
  40. data/spec/fixtures/bodies/GandiV5_Domain/fetch_glue_records.yml +7 -0
  41. data/spec/fixtures/bodies/GandiV5_Domain/fetch_livedns.yml +6 -0
  42. data/spec/fixtures/bodies/GandiV5_Domain/fetch_name_servers.yml +2 -0
  43. data/spec/fixtures/bodies/GandiV5_Domain/{renewal_info.yaml → fetch_renewal_info.yml} +0 -3
  44. data/spec/fixtures/bodies/GandiV5_Domain/{restore_info.yaml → fetch_restore_info.yml} +0 -0
  45. data/spec/fixtures/bodies/GandiV5_Domain/{list.yaml → list.yml} +1 -0
  46. data/spec/fixtures/bodies/GandiV5_Domain_Availability/{fetch.yaml → fetch.yml} +0 -0
  47. data/spec/fixtures/bodies/GandiV5_Domain_TLD/{fetch.yaml → fetch.yml} +0 -0
  48. data/spec/fixtures/bodies/GandiV5_Domain_TLD/{list.yaml → list.yml} +0 -0
  49. data/spec/fixtures/bodies/GandiV5_Email_Forward/list.yml +6 -0
  50. data/spec/fixtures/bodies/GandiV5_Email_Mailbox/{get.yaml → fetch.yml} +0 -0
  51. data/spec/fixtures/bodies/GandiV5_Email_Mailbox/{list.yaml → list.yml} +0 -0
  52. data/spec/fixtures/bodies/GandiV5_Email_Slot/{get.yaml → fetch.yml} +0 -0
  53. data/spec/fixtures/bodies/GandiV5_Email_Slot/{list.yaml → list.yml} +0 -0
  54. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/fetch.yml +3 -0
  55. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/{list.yaml → list.yml} +0 -0
  56. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/list_tsig.yml +3 -0
  57. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/nameservers.yml +3 -0
  58. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_DnssecKey/fetch.yml +12 -0
  59. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_DnssecKey/list.yml +9 -0
  60. data/spec/fixtures/bodies/{GandiV5_LiveDNS_Zone_Snapshot/fetch.yaml → GandiV5_LiveDNS_Domain_Snapshot/fetch.yml} +4 -3
  61. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_Snapshot/list.yml +5 -0
  62. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_TsigKey/fetch.yml +9 -0
  63. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_TsigKey/list.yml +4 -0
  64. data/spec/fixtures/bodies/GandiV5_Organization/{get.yaml → fetch.yml} +0 -0
  65. data/spec/fixtures/bodies/GandiV5_Organization/list.yml +7 -0
  66. data/spec/fixtures/bodies/GandiV5_Organization_Customer/list.yml +8 -0
  67. data/spec/spec_helper.rb +2 -2
  68. data/spec/units/gandi_v5/billing_spec.rb +2 -2
  69. data/spec/units/gandi_v5/data/converter/integer_spec.rb +16 -0
  70. data/spec/units/gandi_v5/domain/availability_spec.rb +1 -1
  71. data/spec/units/gandi_v5/domain/live_dns_spec.rb +45 -0
  72. data/spec/units/gandi_v5/domain/tld_spec.rb +2 -2
  73. data/spec/units/gandi_v5/domain_spec.rb +294 -65
  74. data/spec/units/gandi_v5/email/forward_spec.rb +92 -0
  75. data/spec/units/gandi_v5/email/mailbox_spec.rb +122 -40
  76. data/spec/units/gandi_v5/email/slot_spec.rb +13 -5
  77. data/spec/units/gandi_v5/live_dns/domain/dnssec_key_spec.rb +128 -0
  78. data/spec/units/gandi_v5/live_dns/{record_set_spec.rb → domain/record_spec.rb} +1 -1
  79. data/spec/units/gandi_v5/live_dns/domain/snapshot_spec.rb +101 -0
  80. data/spec/units/gandi_v5/live_dns/domain/tsig_key_spec.rb +78 -0
  81. data/spec/units/gandi_v5/live_dns/domain_spec.rb +299 -120
  82. data/spec/units/gandi_v5/live_dns_spec.rb +0 -12
  83. data/spec/units/gandi_v5/organization/customer_spec.rb +81 -0
  84. data/spec/units/gandi_v5/organization_spec.rb +52 -1
  85. data/spec/units/gandi_v5_spec.rb +139 -30
  86. metadata +68 -95
  87. data/doc/GandiV5.html +0 -1183
  88. data/doc/GandiV5/Billing.html +0 -293
  89. data/doc/GandiV5/Billing/Info.html +0 -641
  90. data/doc/GandiV5/Billing/Info/Prepaid.html +0 -817
  91. data/doc/GandiV5/Data.html +0 -785
  92. data/doc/GandiV5/Data/ClassMethods.html +0 -223
  93. data/doc/GandiV5/Data/Converter.html +0 -433
  94. data/doc/GandiV5/Data/Converter/ArrayOf.html +0 -413
  95. data/doc/GandiV5/Data/Converter/Symbol.html +0 -322
  96. data/doc/GandiV5/Data/Converter/Time.html +0 -330
  97. data/doc/GandiV5/Domain.html +0 -16847
  98. data/doc/GandiV5/Domain/AutoRenew.html +0 -1237
  99. data/doc/GandiV5/Domain/Availability.html +0 -1020
  100. data/doc/GandiV5/Domain/Availability/Product.html +0 -988
  101. data/doc/GandiV5/Domain/Availability/Product/Period.html +0 -220
  102. data/doc/GandiV5/Domain/Availability/Product/Price.html +0 -1031
  103. data/doc/GandiV5/Domain/Availability/Tax.html +0 -440
  104. data/doc/GandiV5/Domain/Contact.html +0 -4459
  105. data/doc/GandiV5/Domain/Contract.html +0 -520
  106. data/doc/GandiV5/Domain/Dates.html +0 -1313
  107. data/doc/GandiV5/Domain/RenewalInformation.html +0 -1147
  108. data/doc/GandiV5/Domain/RestoreInformation.html +0 -339
  109. data/doc/GandiV5/Domain/SharingSpace.html +0 -437
  110. data/doc/GandiV5/Domain/TLD.html +0 -1565
  111. data/doc/GandiV5/Email.html +0 -144
  112. data/doc/GandiV5/Email/Mailbox.html +0 -6307
  113. data/doc/GandiV5/Email/Mailbox/Responder.html +0 -1560
  114. data/doc/GandiV5/Email/Offer.html +0 -514
  115. data/doc/GandiV5/Email/Slot.html +0 -4244
  116. data/doc/GandiV5/Error.html +0 -151
  117. data/doc/GandiV5/Error/GandiError.html +0 -270
  118. data/doc/GandiV5/LiveDNS.html +0 -300
  119. data/doc/GandiV5/LiveDNS/Domain.html +0 -2984
  120. data/doc/GandiV5/LiveDNS/RecordSet.html +0 -1593
  121. data/doc/GandiV5/LiveDNS/Zone.html +0 -8891
  122. data/doc/GandiV5/LiveDNS/Zone/Snapshot.html +0 -1556
  123. data/doc/GandiV5/Organization.html +0 -2341
  124. data/doc/_index.html +0 -474
  125. data/doc/class_list.html +0 -51
  126. data/doc/css/common.css +0 -1
  127. data/doc/css/full_list.css +0 -58
  128. data/doc/css/style.css +0 -496
  129. data/doc/file.README.html +0 -175
  130. data/doc/file_list.html +0 -56
  131. data/doc/frames.html +0 -17
  132. data/doc/index.html +0 -175
  133. data/doc/js/app.js +0 -303
  134. data/doc/js/full_list.js +0 -216
  135. data/doc/js/jquery.js +0 -4
  136. data/doc/method_list.html +0 -2427
  137. data/doc/top-level-namespace.html +0 -110
  138. data/lib/gandi_v5/live_dns/record_set.rb +0 -79
  139. data/lib/gandi_v5/live_dns/zone.rb +0 -305
  140. data/lib/gandi_v5/live_dns/zone/snapshot.rb +0 -81
  141. data/spec/features/domain_spec.rb +0 -45
  142. data/spec/features/livedns_domain_spec.rb +0 -8
  143. data/spec/features/livedns_zone_spec.rb +0 -45
  144. data/spec/features/mailbox_spec.rb +0 -18
  145. data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/get.yaml +0 -4
  146. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/get.yaml +0 -11
  147. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/list.yaml +0 -11
  148. data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/list.yaml +0 -3
  149. data/spec/fixtures/vcr/Domain_features/List_domains.yml +0 -54
  150. data/spec/fixtures/vcr/Domain_features/Renew_domain.yml +0 -133
  151. data/spec/fixtures/vcr/LiveDNS_Domain_features/List_domains.yml +0 -32
  152. data/spec/fixtures/vcr/LiveDNS_Zone_features/List_zones.yml +0 -42
  153. data/spec/fixtures/vcr/LiveDNS_Zone_features/Make_and_save_snapshot.yml +0 -72
  154. data/spec/fixtures/vcr/LiveDNS_Zone_features/Save_zone_to_file.yml +0 -28
  155. data/spec/fixtures/vcr/Mailbox_features/List_mailboxes.yml +0 -39
  156. data/spec/units/gandi_v5/live_dns/zone/snapshot_spec.rb +0 -66
  157. data/spec/units/gandi_v5/live_dns/zone_spec.rb +0 -347
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class GandiV5
4
- VERSION = '0.2.0'
4
+ VERSION = '0.7.0'
5
5
  end
@@ -1,4 +1,11 @@
1
1
  Metrics/BlockLength:
2
- Max: 500
3
- Metrics/LineLength:
2
+ Max: 750
3
+ Layout/LineLength:
4
4
  Max: 125
5
+ Style/HashEachMethods:
6
+ Enabled: true
7
+ Style/HashTransformKeys:
8
+ Enabled: true
9
+ Style/HashTransformValues:
10
+ Enabled: true
11
+
@@ -35,3 +35,11 @@ contacts:
35
35
  services:
36
36
  - gandilivedns
37
37
  - dnssec
38
+ sharing_space:
39
+ id: SHARING-UUID
40
+ name: User
41
+ type: user
42
+ reseller: true
43
+ sharing_space:
44
+ id: RESELLER-UUID
45
+ name: Reseller
@@ -0,0 +1,7 @@
1
+ ---
2
+ - name: ns1
3
+ fqdn: example.com
4
+ fqdn_unicode: example.com
5
+ href: http://api.test/v5/domain/domains/example.com/hosts/ns1
6
+ ips:
7
+ - '1.2.3.4'
@@ -0,0 +1,6 @@
1
+ ---
2
+ current: livedns
3
+ nameservers:
4
+ - '1.2.3.4'
5
+ dnssec_available: true
6
+ livednssec_available: true
@@ -7,6 +7,3 @@ renew:
7
7
  maximum: 2
8
8
  minimum: 1
9
9
  prohibited: false
10
- contracts:
11
- - id: uuid
12
- name: Name
@@ -18,3 +18,4 @@
18
18
  current: livedns
19
19
  href: https://api.gandi.net/v5/domain/domains/example.com
20
20
  fqdn_unicode: example.com
21
+ nameservers: []
@@ -0,0 +1,6 @@
1
+ ---
2
+ - source: alice
3
+ href: https://api.test/api/v5/email/forwards/example.com/alice
4
+ destinations:
5
+ - bob@example.com
6
+ - charlie@example.com
@@ -0,0 +1,3 @@
1
+ ---
2
+ fqdn: example.com
3
+ automatic_snapshots: true
@@ -0,0 +1,3 @@
1
+ ---
2
+ - id: key-uuid
3
+ key_name: key-name
@@ -0,0 +1,3 @@
1
+ ---
2
+ - a.example.com
3
+ - b.example.com
@@ -0,0 +1,12 @@
1
+ ---
2
+ id: key-uuid
3
+ status: status
4
+ fqdn: example.com
5
+ algorithm: 2
6
+ algorithm_name: Diffie-Hellman
7
+ deleted: false
8
+ ds: ds-record
9
+ flags: 256
10
+ fingerprint: fp
11
+ public_key: pub-key
12
+ tag: tag
@@ -0,0 +1,9 @@
1
+ ---
2
+ - id: key-uuid
3
+ status: status
4
+ fqdn: example.com
5
+ algorithm: 2
6
+ algorithm_name: Diffie-Hellman
7
+ deleted: false
8
+ ds: ds-record
9
+ flags: 256
@@ -1,7 +1,8 @@
1
1
  ---
2
- date_created: '2016-12-16T16:51:26Z'
3
- uuid: snapshot-uuid
4
- zone_uuid: zone-uuid
2
+ created_at: '2016-12-16T16:51:26Z'
3
+ id: snapshot-uuid
4
+ name: snapshot-name
5
+ automatic: true
5
6
  zone_data:
6
7
  - rrset_type: A
7
8
  rrset_ttl: 10800
@@ -0,0 +1,5 @@
1
+ ---
2
+ - id: snapshot-uuid
3
+ name: snapshot-name
4
+ automatic: true
5
+ created_at: '2016-12-16T16:51:26Z'
@@ -0,0 +1,9 @@
1
+ ---
2
+ id: key-uuid
3
+ key_name: key-name
4
+ secret: key-secret
5
+ config_samples:
6
+ bind: bind-sample
7
+ knot: knot-sample
8
+ nsd: nsd-sample
9
+ powerdns: powerdns-sample
@@ -0,0 +1,4 @@
1
+ ---
2
+ - id: key-uuid
3
+ key_name: key-name
4
+ secret: key-secret
@@ -0,0 +1,7 @@
1
+ ---
2
+ - id: organization-uuid
3
+ name: FirstLast
4
+ corporate: false
5
+ firstname: First
6
+ lastname: Last
7
+ reseller: false
@@ -0,0 +1,8 @@
1
+ ---
2
+ - id: customer-uuid
3
+ name: FirstLast
4
+ firstname: First
5
+ lastname: Last
6
+ email: first.last@example.com
7
+ type: individual
8
+ orgname: Org
@@ -13,12 +13,12 @@ allow_http_connections_to = %w[localhost 127.0.0.1]
13
13
 
14
14
  Dotenv.load File.join(__dir__, 'test.env')
15
15
 
16
- SimpleCov.coverage_dir(File.join('tmp', 'coverage'))
16
+ SimpleCov.coverage_dir(File.join('tmp', 'coverage')) unless ENV.key?('TRAVIS')
17
17
  SimpleCov.start do
18
18
  add_filter 'spec/'
19
19
  end
20
20
 
21
- if ENV['TRAVIS']
21
+ if ENV.key?('TRAVIS')
22
22
  Coveralls.wear!
23
23
  allow_http_connections_to.push 'coveralls.io'
24
24
  end
@@ -4,7 +4,7 @@ describe GandiV5::Billing do
4
4
  describe '.info' do
5
5
  subject { described_class.info }
6
6
  before :each do
7
- body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Billing', 'info.yaml'))
7
+ body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Billing', 'info.yml'))
8
8
  expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/billing/info')
9
9
  .and_return([nil, YAML.load_file(body_fixture)])
10
10
  end
@@ -23,7 +23,7 @@ describe GandiV5::Billing do
23
23
  describe '.info (for a sharing_id)' do
24
24
  subject { described_class.info('sharing-id') }
25
25
  before :each do
26
- body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Billing', 'info.yaml'))
26
+ body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Billing', 'info.yml'))
27
27
  expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/billing/info/sharing-id')
28
28
  .and_return([nil, YAML.load_file(body_fixture)])
29
29
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe GandiV5::Data::Converter::Integer do
4
+ it '.from_gandi' do
5
+ expect(described_class.from_gandi('123')).to eq 123
6
+ end
7
+
8
+ it '.to_gandi' do
9
+ expect(described_class.to_gandi(123)).to eq '123'
10
+ end
11
+
12
+ it 'nil value' do
13
+ expect(described_class.from_gandi(nil)).to be nil
14
+ expect(described_class.to_gandi(nil)).to be nil
15
+ end
16
+ end
@@ -3,7 +3,7 @@
3
3
  describe GandiV5::Domain::Availability do
4
4
  describe '.fetch' do
5
5
  let(:body_fixture) do
6
- File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain_Availability', 'fetch.yaml'))
6
+ File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain_Availability', 'fetch.yml'))
7
7
  end
8
8
 
9
9
  describe 'With default values' do
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe GandiV5::Domain::LiveDNS do
4
+ describe '#classic?' do
5
+ it 'Is using classic DNS' do
6
+ expect(described_class.new(current: :classic).classic?).to be true
7
+ end
8
+
9
+ it 'Is using LiveDNS' do
10
+ expect(described_class.new(current: :livedns).classic?).to be false
11
+ end
12
+
13
+ it 'Is using custom DNS' do
14
+ expect(described_class.new(current: :custom).classic?).to be false
15
+ end
16
+ end
17
+
18
+ describe '#livedns?' do
19
+ it 'Is using classic DNS' do
20
+ expect(described_class.new(current: :classic).livedns?).to be false
21
+ end
22
+
23
+ it 'Is using LiveDNS' do
24
+ expect(described_class.new(current: :livedns).livedns?).to be true
25
+ end
26
+
27
+ it 'Is using custom DNS' do
28
+ expect(described_class.new(current: :custom).livedns?).to be false
29
+ end
30
+ end
31
+
32
+ describe '#custom?' do
33
+ it 'Is using classic DNS' do
34
+ expect(described_class.new(current: :classic).custom?).to be false
35
+ end
36
+
37
+ it 'Is using LiveDNS' do
38
+ expect(described_class.new(current: :livedns).custom?).to be false
39
+ end
40
+
41
+ it 'Is using custom DNS' do
42
+ expect(described_class.new(current: :custom).custom?).to be true
43
+ end
44
+ end
45
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  describe GandiV5::Domain::TLD do
4
4
  it '.list' do
5
- body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain_TLD', 'list.yaml'))
5
+ body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain_TLD', 'list.yml'))
6
6
  expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/tlds')
7
7
  .and_return([nil, YAML.load_file(body_fixture)])
8
8
  expect(described_class.list.map(&:name)).to match_array %w[a b c]
@@ -12,7 +12,7 @@ describe GandiV5::Domain::TLD do
12
12
  subject { described_class.fetch 'name' }
13
13
 
14
14
  before(:each) do
15
- body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain_TLD', 'fetch.yaml'))
15
+ body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain_TLD', 'fetch.yml'))
16
16
  expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/tlds/name')
17
17
  .and_return([nil, YAML.load_file(body_fixture)])
18
18
  end
@@ -4,22 +4,22 @@ describe GandiV5::Domain do
4
4
  subject { described_class.new fqdn: 'example.com' }
5
5
 
6
6
  describe '.list' do
7
- let(:body_fixture) { File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain', 'list.yaml')) }
7
+ let(:body_fixture) { File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain', 'list.yml')) }
8
+ let(:url) { 'https://api.gandi.net/v5/domain/domains' }
8
9
 
9
10
  describe 'With default values' do
10
11
  subject { described_class.list }
11
12
 
12
13
  before :each do
13
- headers = { params: { page: 1, per_page: 100 } }
14
- expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains', headers)
15
- .and_return([nil, YAML.load_file(body_fixture)])
14
+ expect(GandiV5).to receive(:paginated_get).with(url, (1..), 100, params: {})
15
+ .and_yield(YAML.load_file(body_fixture))
16
16
  end
17
17
 
18
18
  its('count') { should eq 1 }
19
19
  its('first.uuid') { should eq 'domain-uuid' }
20
20
  its('first.fqdn') { should eq 'example.com' }
21
21
  its('first.fqdn_unicode') { should eq 'example.com' }
22
- its('first.name_servers') { should be_nil }
22
+ its('first.name_servers') { should eq [] }
23
23
  its('first.services') { should be_nil }
24
24
  its('first.status') { should eq [] }
25
25
  its('first.tld') { should eq 'com' }
@@ -44,42 +44,11 @@ describe GandiV5::Domain do
44
44
  its('first.contacts?') { should be false }
45
45
  end
46
46
 
47
- it 'Keeps fetching until no more to get' do
48
- headers1 = { params: { page: 1, per_page: 1 } }
49
- headers2 = { params: { page: 2, per_page: 1 } }
50
- # https://github.com/rubocop-hq/rubocop/issues/7088
51
- expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains', headers1)
52
- .ordered
53
- .and_return([nil, YAML.load_file(body_fixture)])
54
- expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains', headers2)
55
- .ordered
56
- .and_return([nil, []])
57
-
58
- expect(described_class.list(per_page: 1).count).to eq 1
59
- end
60
-
61
- it 'Given a range as page number' do
62
- headers1 = { params: { page: 1, per_page: 1 } }
63
- headers2 = { params: { page: 2, per_page: 1 } }
64
- # https://github.com/rubocop-hq/rubocop/issues/7088
65
- expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains', headers1)
66
- .ordered
67
- .and_return([nil, YAML.load_file(body_fixture)])
68
- expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains', headers2)
69
- .ordered
70
- .and_return([nil, []])
71
-
72
- expect(described_class.list(page: (1..2), per_page: 1).count).to eq 1
73
- end
74
-
75
47
  describe 'Passes optional query params' do
76
- %i[fqdn page per_page sort_by tld].each do |param|
48
+ %i[fqdn sort_by tld].each do |param|
77
49
  it param.to_s do
78
- param = { param => 5 }
79
- headers = { params: { page: 1, per_page: 100 }.merge(param) }
80
- expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains', headers)
81
- .and_return([nil, []])
82
- expect(described_class.list(**param)).to eq []
50
+ expect(GandiV5).to receive(:paginated_get).with(url, (1..), 100, params: { param => 5 })
51
+ expect(described_class.list(param => 5)).to eq []
83
52
  end
84
53
  end
85
54
  end
@@ -89,7 +58,7 @@ describe GandiV5::Domain do
89
58
  subject { described_class.fetch 'example.com' }
90
59
 
91
60
  before :each do
92
- body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain', 'get.yaml'))
61
+ body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain', 'fetch.yml'))
93
62
  expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains/example.com')
94
63
  .and_return([nil, YAML.load_file(body_fixture)])
95
64
  end
@@ -108,7 +77,12 @@ describe GandiV5::Domain do
108
77
  its('domain_owner') { should be_nil }
109
78
  its('name_servers') { should match_array %w[192.168.0.1 192.168.0.2] }
110
79
  its('services') { should match_array %i[gandilivedns dnssec] }
111
- its('sharing_space') { should be_nil }
80
+ its('sharing_space.uuid') { should eq 'SHARING-UUID' }
81
+ its('sharing_space.name') { should eq 'User' }
82
+ its('sharing_space.type') { should eq 'user' }
83
+ its('sharing_space.reseller') { should be true }
84
+ its('sharing_space.reseller_details.uuid') { should eq 'RESELLER-UUID' }
85
+ its('sharing_space.reseller_details.name') { should eq 'Reseller' }
112
86
  its('dates.created_at') { should eq Time.new(2011, 2, 21, 10, 39, 0) }
113
87
  its('dates.registry_created_at') { should eq Time.new(2003, 3, 12, 12, 2, 11) }
114
88
  its('dates.registry_ends_at') { should eq Time.new(2020, 3, 12, 12, 2, 11) }
@@ -128,13 +102,13 @@ describe GandiV5::Domain do
128
102
 
129
103
  describe '.create' do
130
104
  let(:url) { 'https://api.gandi.net/v5/domain/domains' }
105
+ let(:returns) { double described_class }
106
+ let(:response) { double RestClient::Response, headers: { location: 'https://api.gandi.net/v5/domains/example.com' } }
131
107
 
132
108
  describe 'Sets dry-run header' do
133
109
  let(:body) { '{"owner":{},"fqdn":"example.com"}' }
134
110
 
135
111
  it 'False by default' do
136
- returns = double described_class
137
- response = double RestClient::Response, headers: { location: 'https://api.gandi.net/v5/domains/example.com' }
138
112
  expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 0).and_return([response, nil])
139
113
  expect(described_class).to receive(:fetch).with('example.com').and_return(returns)
140
114
  described_class.create 'example.com', owner: {}
@@ -146,8 +120,6 @@ describe GandiV5::Domain do
146
120
  end
147
121
 
148
122
  it 'False' do
149
- returns = double described_class
150
- response = double RestClient::Response, headers: { location: 'https://api.gandi.net/v5/domains/example.com' }
151
123
  expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 0).and_return([response, nil])
152
124
  expect(described_class).to receive(:fetch).with('example.com').and_return(returns)
153
125
  described_class.create 'example.com', owner: {}, dry_run: false
@@ -171,12 +143,29 @@ describe GandiV5::Domain do
171
143
  end
172
144
  end
173
145
 
146
+ describe 'Sets sharing_id' do
147
+ it 'Absent by default' do
148
+ expect(GandiV5).to receive(:post).with(url, any_args).and_return([response, nil])
149
+ expect(described_class).to receive(:fetch).with('example.com').and_return(returns)
150
+ described_class.create('example.com', owner: {})
151
+ end
152
+
153
+ it 'Paying as another organization' do
154
+ expect(GandiV5).to receive(:post).with("#{url}?sharing_id=organization_id", any_args).and_return([response, nil])
155
+ expect(described_class).to receive(:fetch).with('example.com').and_return(returns)
156
+ described_class.create('example.com', sharing_id: 'organization_id', owner: {})
157
+ end
158
+
159
+ it 'Buy as a reseller' do
160
+ expect(GandiV5).to receive(:post).with("#{url}?sharing_id=reseller_id", any_args).and_return([response, nil])
161
+ expect(described_class).to receive(:fetch).with('example.com').and_return(returns)
162
+ described_class.create('example.com', sharing_id: 'reseller_id', owner: {})
163
+ end
164
+ end
165
+
174
166
  it 'Success' do
175
- returns = double described_class
176
- response = double RestClient::Response, headers: { location: 'https://api.gandi.net/v5/domains/example.com' }
177
167
  body = '{"owner":{},"fqdn":"example.com"}'
178
- expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 0)
179
- .and_return([response, nil])
168
+ expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 0).and_return([response, nil])
180
169
  expect(described_class).to receive(:fetch).with('example.com').and_return(returns)
181
170
  expect(described_class.create('example.com', owner: {})).to be returns
182
171
  end
@@ -186,18 +175,14 @@ describe GandiV5::Domain do
186
175
  end
187
176
 
188
177
  it 'Given contact as hash' do
189
- returns = double described_class
190
178
  body = '{"owner":{"email":"owner@example.com"},"fqdn":"example.com"}'
191
- response = double RestClient::Response, headers: { location: 'https://api.gandi.net/v5/domains/example.com' }
192
179
  expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 0).and_return([response, nil])
193
180
  expect(described_class).to receive(:fetch).with('example.com').and_return(returns)
194
181
  described_class.create 'example.com', owner: { email: 'owner@example.com' }
195
182
  end
196
183
 
197
184
  it 'Given contact as GandiV5::Domain::Contact' do
198
- returns = double described_class
199
185
  body = '{"owner":{"email":"owner@example.com"},"fqdn":"example.com"}'
200
- response = double RestClient::Response, headers: { location: 'https://api.gandi.net/v5/domains/example.com' }
201
186
  expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 0).and_return([response, nil])
202
187
  expect(described_class).to receive(:fetch).with('example.com').and_return(returns)
203
188
  owner = double GandiV5::Domain::Contact, to_gandi: { 'email' => 'owner@example.com' }
@@ -205,6 +190,24 @@ describe GandiV5::Domain do
205
190
  end
206
191
  end
207
192
 
193
+ it '.mailboxes' do
194
+ returns = double Array
195
+ expect(GandiV5::Email::Mailbox).to receive(:list).with(param: :value, fqdn: 'example.com').and_return(returns)
196
+ expect(subject.mailboxes(param: :value)).to be returns
197
+ end
198
+
199
+ it '.mailbox_slots' do
200
+ returns = double Array
201
+ expect(GandiV5::Email::Slot).to receive(:list).with(param: :value, fqdn: 'example.com').and_return(returns)
202
+ expect(subject.mailbox_slots(param: :value)).to be returns
203
+ end
204
+
205
+ it '.email_forwards' do
206
+ returns = double Array
207
+ expect(GandiV5::Email::Forward).to receive(:list).with(param: :value, fqdn: 'example.com').and_return(returns)
208
+ expect(subject.email_forwards(param: :value)).to be returns
209
+ end
210
+
208
211
  describe '#to_s' do
209
212
  it 'Has identical fqdn and fqdn_unicode' do
210
213
  domain = described_class.new fqdn: 'example.com', fqdn_unicode: 'example.com'
@@ -219,7 +222,7 @@ describe GandiV5::Domain do
219
222
 
220
223
  describe '#refresh' do
221
224
  before :each do
222
- body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain', 'get.yaml'))
225
+ body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain', 'fetch.yml'))
223
226
  expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains/example.com')
224
227
  .and_return([nil, YAML.load_file(body_fixture)])
225
228
  subject.refresh
@@ -239,7 +242,7 @@ describe GandiV5::Domain do
239
242
  its('domain_owner') { should be_nil }
240
243
  its('name_servers') { should match_array %w[192.168.0.1 192.168.0.2] }
241
244
  its('services') { should match_array %i[gandilivedns dnssec] }
242
- its('sharing_space') { should be_nil }
245
+ its('sharing_space') { should_not be_nil }
243
246
  its('dates.created_at') { should eq Time.new(2011, 2, 21, 10, 39, 0) }
244
247
  its('dates.registry_created_at') { should eq Time.new(2003, 3, 12, 12, 2, 11) }
245
248
  its('dates.registry_ends_at') { should eq Time.new(2020, 3, 12, 12, 2, 11) }
@@ -275,7 +278,7 @@ describe GandiV5::Domain do
275
278
  subject { described_class.new(fqdn: 'example.com').fetch_contacts }
276
279
 
277
280
  before(:each) do
278
- body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain', 'fetch_contacts.yaml'))
281
+ body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain', 'fetch_contacts.yml'))
279
282
  expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains/example.com/contacts')
280
283
  .and_return([nil, YAML.load_file(body_fixture)])
281
284
  end
@@ -332,7 +335,7 @@ describe GandiV5::Domain do
332
335
  subject { described_class.new(fqdn: 'example.com').fetch_renewal_information }
333
336
 
334
337
  before(:each) do
335
- body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain', 'renewal_info.yaml'))
338
+ body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain', 'fetch_renewal_info.yml'))
336
339
  expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains/example.com/renew')
337
340
  .and_return([nil, YAML.load_file(body_fixture)])
338
341
  end
@@ -342,15 +345,48 @@ describe GandiV5::Domain do
342
345
  its('minimum') { should eq 1 }
343
346
  its('maximum') { should eq 2 }
344
347
  its('durations') { should match_array [1, 2] }
345
- its('contracts.count') { should eq 1 }
346
- its('contracts.first.id') { should eq 'uuid' }
347
- its('contracts.first.name') { should eq 'Name' }
348
348
  end
349
349
 
350
- it '#renew_for' do
351
- expect(GandiV5).to receive(:post).with('https://api.gandi.net/v5/domain/domains/example.com/renew', '{"duration":2}')
352
- .and_return([nil, { 'message' => 'Confirmation message.' }])
353
- expect(subject.renew_for(2)).to eq 'Confirmation message.'
350
+ describe '#renew_for' do
351
+ it 'Defaults to 1 year and current user' do
352
+ expect(GandiV5).to receive(:post).with(
353
+ 'https://api.gandi.net/v5/domain/domains/example.com/renew',
354
+ '{"duration":1}',
355
+ 'Dry-Run': 0
356
+ )
357
+ .and_return([nil, { 'message' => 'Confirmation message.' }])
358
+ expect(subject.renew_for).to eq 'Confirmation message.'
359
+ end
360
+
361
+ it 'With provided duration' do
362
+ expect(GandiV5).to receive(:post).with(
363
+ 'https://api.gandi.net/v5/domain/domains/example.com/renew',
364
+ '{"duration":2}',
365
+ 'Dry-Run': 0
366
+ )
367
+ .and_return([nil, { 'message' => 'Confirmation message.' }])
368
+ expect(subject.renew_for(2)).to eq 'Confirmation message.'
369
+ end
370
+
371
+ it 'With provided sharing_id' do
372
+ expect(GandiV5).to receive(:post).with(
373
+ 'https://api.gandi.net/v5/domain/domains/example.com/renew?sharing_id=def',
374
+ '{"duration":1}',
375
+ 'Dry-Run': 0
376
+ )
377
+ .and_return([nil, { 'message' => 'Confirmation message.' }])
378
+ expect(subject.renew_for(sharing_id: 'def')).to eq 'Confirmation message.'
379
+ end
380
+
381
+ it 'Does a dry run' do
382
+ expect(GandiV5).to receive(:post).with(
383
+ 'https://api.gandi.net/v5/domain/domains/example.com/renew',
384
+ '{"duration":1}',
385
+ 'Dry-Run': 1
386
+ )
387
+ .and_return([nil, { 'status' => 'success' }])
388
+ expect(subject.renew_for(dry_run: true)).to eq('status' => 'success')
389
+ end
354
390
  end
355
391
 
356
392
  describe '#renewal_price' do
@@ -428,7 +464,8 @@ describe GandiV5::Domain do
428
464
 
429
465
  describe 'Information is available' do
430
466
  before(:each) do
431
- body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain', 'restore_info.yaml'))
467
+ body_fixture = File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain', 'fetch_restore_info.yml')
468
+ body_fixture = File.expand_path(body_fixture)
432
469
  expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains/example.com/restore')
433
470
  .and_return([nil, YAML.load_file(body_fixture)])
434
471
  end
@@ -456,4 +493,196 @@ describe GandiV5::Domain do
456
493
  expect(subject.restore).to eq 'Confirmation message.'
457
494
  end
458
495
  end
496
+
497
+ describe '#glue_records' do
498
+ let(:glue_records) { double Hash }
499
+
500
+ it 'Already fetched' do
501
+ subject.instance_exec(glue_records) { |glue_records| @glue_records = glue_records }
502
+ expect(subject).to_not receive(:fetch_glue_records)
503
+ expect(subject.glue_records).to be glue_records
504
+ end
505
+
506
+ it 'Not already fetched' do
507
+ expect(subject).to receive(:fetch_glue_records).and_return(glue_records)
508
+ expect(subject.glue_records).to be glue_records
509
+ end
510
+ end
511
+
512
+ it '#fetch_glue_records' do
513
+ body_fixture = File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain', 'fetch_glue_records.yml')
514
+ body_fixture = File.expand_path(body_fixture)
515
+ expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains/example.com/hosts')
516
+ .and_return([nil, YAML.load_file(body_fixture)])
517
+ expect(subject.fetch_glue_records).to eq(
518
+ 'ns1' => ['1.2.3.4']
519
+ )
520
+ end
521
+
522
+ describe '#add_glue_record' do
523
+ before(:each) { described_class.instance_exec { @glue_records = {} } }
524
+
525
+ it 'Make API request' do
526
+ expect(GandiV5).to receive(:post).with(
527
+ 'https://api.gandi.net/v5/domain/domains/example.com/hosts',
528
+ '{"name":"ns1","ips":["1.2.3.4"]}'
529
+ )
530
+ .and_return([nil, { 'message' => 'Confirmation message.' }])
531
+ expect(subject.add_glue_record('ns1', '1.2.3.4')).to eq 'Confirmation message.'
532
+ end
533
+
534
+ it 'Updates glue records' do
535
+ expect(GandiV5).to receive(:post).and_return([nil, { 'message' => 'Confirmation message.' }])
536
+ subject.add_glue_record 'ns1', '1.2.3.4'
537
+ expect(subject.glue_records).to eq('ns1' => ['1.2.3.4'])
538
+ end
539
+ end
540
+
541
+ describe '#glue_record' do
542
+ before(:each) { subject.instance_exec { @glue_records = { 'ns1' => ['1.2.3.4'] } } }
543
+
544
+ it 'Already fetched' do
545
+ expect(subject).to_not receive(:fetch_glue_records)
546
+ expect(subject.glue_record('ns1')).to eq('ns1' => ['1.2.3.4'])
547
+ end
548
+
549
+ it 'Not already fetched' do
550
+ expect(subject).to receive(:fetch_glue_records).and_return('ns2' => ['2.3.4.5'])
551
+ expect(subject.glue_record('ns2')).to eq('ns2' => ['2.3.4.5'])
552
+ end
553
+
554
+ it 'Not present' do
555
+ expect(subject).to receive(:fetch_glue_records).and_return({})
556
+ expect(subject.glue_record('ns3')).to be nil
557
+ end
558
+ end
559
+
560
+ describe '#update_glue_record' do
561
+ it 'Make API request' do
562
+ expect(GandiV5).to receive(:put).with(
563
+ 'https://api.gandi.net/v5/domain/domains/example.com/hosts/name',
564
+ '{"ips":["1.2.3.4"]}'
565
+ )
566
+ .and_return([nil, { 'message' => 'Confirmation message.' }])
567
+ expect(subject.update_glue_record('name', '1.2.3.4')).to eq 'Confirmation message.'
568
+ end
569
+
570
+ it 'Update name_servers' do
571
+ expect(GandiV5).to receive(:put).and_return([nil, { 'message' => 'Confirmation message.' }])
572
+ subject.update_glue_record 'name', '1.2.3.4'
573
+ expect(subject.glue_records).to eq('name' => ['1.2.3.4'])
574
+ end
575
+ end
576
+
577
+ describe '#delete_glue_record' do
578
+ before(:each) { subject.instance_exec { @glue_records = { 'ns1' => ['1.2.3.4'], 'ns2' => [] } } }
579
+
580
+ it 'Make API request' do
581
+ expect(GandiV5).to receive(:delete).with(
582
+ 'https://api.gandi.net/v5/domain/domains/example.com/hosts/ns2'
583
+ )
584
+ .and_return([nil, { 'message' => 'Confirmation message.' }])
585
+ expect(subject.delete_glue_record('ns2')).to eq 'Confirmation message.'
586
+ end
587
+
588
+ it 'Update name_servers' do
589
+ expect(GandiV5).to receive(:delete).and_return([nil, { 'message' => 'Confirmation message.' }])
590
+ subject.delete_glue_record 'ns2'
591
+ expect(subject.glue_records).to eq('ns1' => ['1.2.3.4'])
592
+ end
593
+ end
594
+
595
+ describe '#livedns' do
596
+ let(:live_dns) { double GandiV5::Domain::LiveDNS }
597
+
598
+ it 'Already fetched' do
599
+ subject.instance_exec(live_dns) { |live_dns| @livedns = live_dns }
600
+ expect(subject).to_not receive(:fetch_livedns)
601
+ expect(subject.livedns).to be live_dns
602
+ end
603
+
604
+ it 'Not already fetched' do
605
+ expect(subject).to receive(:fetch_livedns).and_return(live_dns)
606
+ expect(subject.livedns).to be live_dns
607
+ end
608
+ end
609
+
610
+ describe '#fetch_livedns' do
611
+ before(:each) do
612
+ body_fixture = File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain', 'fetch_livedns.yml')
613
+ body_fixture = File.expand_path(body_fixture)
614
+ expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains/example.com/livedns')
615
+ .and_return([nil, YAML.load_file(body_fixture)])
616
+ end
617
+
618
+ describe 'Returned live_dns' do
619
+ subject { described_class.new(fqdn: 'example.com').fetch_livedns }
620
+
621
+ its('current') { should be :livedns }
622
+ its('name_servers') { should match_array ['1.2.3.4'] }
623
+ its('dnssec_available') { should be true }
624
+ its('livednssec_available') { should be true }
625
+ end
626
+
627
+ it 'Updates name_server' do
628
+ expect(subject.name_server).to be nil
629
+ subject.fetch_livedns
630
+ expect(subject.name_server).to be :livedns
631
+ end
632
+
633
+ it 'Updates name_servers' do
634
+ subject.instance_exec { @name_servers = [] }
635
+ subject.fetch_livedns
636
+ expect(subject.name_servers).to match_array ['1.2.3.4']
637
+ end
638
+ end
639
+
640
+ it '#enable_livedns' do
641
+ expect(GandiV5).to receive(:post).with('https://api.gandi.net/v5/domain/domains/example.com/livedns')
642
+ .and_return([nil, { 'message' => 'Confirmation message.' }])
643
+ expect(subject.enable_livedns).to eq 'Confirmation message.'
644
+ end
645
+
646
+ describe '#name_servers' do
647
+ let(:nameservers) { double Array }
648
+
649
+ it 'Already fetched' do
650
+ subject.instance_exec(nameservers) { |nameservers| @name_servers = nameservers }
651
+ expect(subject).to_not receive(:fetch_name_servers)
652
+ expect(subject.name_servers).to be nameservers
653
+ end
654
+
655
+ it 'Not already fetched' do
656
+ expect(subject).to receive(:fetch_name_servers).and_return(nameservers)
657
+ expect(subject.name_servers).to be nameservers
658
+ end
659
+ end
660
+
661
+ it '#fetch_name_servers' do
662
+ body_fixture = File.join('spec', 'fixtures', 'bodies', 'GandiV5_Domain', 'fetch_name_servers.yml')
663
+ body_fixture = File.expand_path(body_fixture)
664
+ expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/domain/domains/example.com/nameservers')
665
+ .and_return([nil, YAML.load_file(body_fixture)])
666
+ expect(subject.fetch_name_servers).to match_array ['1.2.3.4']
667
+ end
668
+
669
+ describe '#update_name_servers' do
670
+ subject { described_class.new fqdn: 'example.com', name_servers: [] }
671
+ let(:new_name_servers) { ['a.examle.com', 'b.example.net'] }
672
+
673
+ it 'Make API request' do
674
+ expect(GandiV5).to receive(:put).with(
675
+ 'https://api.gandi.net/v5/domain/domains/example.com/nameservers',
676
+ '{"nameservers":["a.examle.com","b.example.net"]}'
677
+ )
678
+ .and_return([nil, { 'message' => 'Confirmation message.' }])
679
+ expect(subject.update_name_servers(new_name_servers)).to eq 'Confirmation message.'
680
+ end
681
+
682
+ it 'Update name_servers' do
683
+ expect(GandiV5).to receive(:put).and_return([nil, { 'message' => 'Confirmation message.' }])
684
+ subject.update_name_servers new_name_servers
685
+ expect(subject.name_servers).to be new_name_servers
686
+ end
687
+ end
459
688
  end