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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +13 -3
- data/.travis.yml +15 -1
- data/CHANGELOG.md +63 -0
- data/FUNDING.yml +10 -0
- data/LICENSE.md +2 -6
- data/README.md +16 -21
- data/gandi_v5.gemspec +3 -2
- data/lib/gandi_v5.rb +64 -24
- data/lib/gandi_v5/billing.rb +0 -2
- data/lib/gandi_v5/billing/info.rb +0 -2
- data/lib/gandi_v5/data.rb +1 -4
- data/lib/gandi_v5/data/converter.rb +0 -4
- data/lib/gandi_v5/data/converter/integer.rb +26 -0
- data/lib/gandi_v5/domain.rb +167 -28
- data/lib/gandi_v5/domain/availability.rb +0 -3
- data/lib/gandi_v5/domain/availability/product.rb +0 -3
- data/lib/gandi_v5/domain/live_dns.rb +42 -0
- data/lib/gandi_v5/domain/renewal_information.rb +0 -3
- data/lib/gandi_v5/domain/sharing_space.rb +10 -2
- data/lib/gandi_v5/email.rb +0 -4
- data/lib/gandi_v5/email/forward.rb +102 -0
- data/lib/gandi_v5/email/mailbox.rb +57 -13
- data/lib/gandi_v5/email/slot.rb +11 -3
- data/lib/gandi_v5/error.rb +0 -2
- data/lib/gandi_v5/live_dns.rb +0 -16
- data/lib/gandi_v5/live_dns/domain.rb +221 -80
- data/lib/gandi_v5/live_dns/domain/dnssec_key.rb +115 -0
- data/lib/gandi_v5/live_dns/domain/record.rb +81 -0
- data/lib/gandi_v5/live_dns/domain/snapshot.rb +107 -0
- data/lib/gandi_v5/live_dns/domain/tsig_key.rb +71 -0
- data/lib/gandi_v5/organization.rb +38 -5
- data/lib/gandi_v5/organization/customer.rb +90 -0
- data/lib/gandi_v5/version.rb +1 -1
- data/spec/.rubocop.yml +9 -2
- data/spec/fixtures/bodies/GandiV5_Billing/{info.yaml → info.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Domain/{get.yaml → fetch.yml} +8 -0
- data/spec/fixtures/bodies/GandiV5_Domain/{fetch_contacts.yaml → fetch_contacts.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Domain/fetch_glue_records.yml +7 -0
- data/spec/fixtures/bodies/GandiV5_Domain/fetch_livedns.yml +6 -0
- data/spec/fixtures/bodies/GandiV5_Domain/fetch_name_servers.yml +2 -0
- data/spec/fixtures/bodies/GandiV5_Domain/{renewal_info.yaml → fetch_renewal_info.yml} +0 -3
- data/spec/fixtures/bodies/GandiV5_Domain/{restore_info.yaml → fetch_restore_info.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Domain/{list.yaml → list.yml} +1 -0
- data/spec/fixtures/bodies/GandiV5_Domain_Availability/{fetch.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Domain_TLD/{fetch.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Domain_TLD/{list.yaml → list.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Email_Forward/list.yml +6 -0
- data/spec/fixtures/bodies/GandiV5_Email_Mailbox/{get.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Email_Mailbox/{list.yaml → list.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Email_Slot/{get.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Email_Slot/{list.yaml → list.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/fetch.yml +3 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/{list.yaml → list.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/list_tsig.yml +3 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/nameservers.yml +3 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_DnssecKey/fetch.yml +12 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_DnssecKey/list.yml +9 -0
- data/spec/fixtures/bodies/{GandiV5_LiveDNS_Zone_Snapshot/fetch.yaml → GandiV5_LiveDNS_Domain_Snapshot/fetch.yml} +4 -3
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_Snapshot/list.yml +5 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_TsigKey/fetch.yml +9 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_TsigKey/list.yml +4 -0
- data/spec/fixtures/bodies/GandiV5_Organization/{get.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Organization/list.yml +7 -0
- data/spec/fixtures/bodies/GandiV5_Organization_Customer/list.yml +8 -0
- data/spec/spec_helper.rb +2 -2
- data/spec/units/gandi_v5/billing_spec.rb +2 -2
- data/spec/units/gandi_v5/data/converter/integer_spec.rb +16 -0
- data/spec/units/gandi_v5/domain/availability_spec.rb +1 -1
- data/spec/units/gandi_v5/domain/live_dns_spec.rb +45 -0
- data/spec/units/gandi_v5/domain/tld_spec.rb +2 -2
- data/spec/units/gandi_v5/domain_spec.rb +294 -65
- data/spec/units/gandi_v5/email/forward_spec.rb +92 -0
- data/spec/units/gandi_v5/email/mailbox_spec.rb +122 -40
- data/spec/units/gandi_v5/email/slot_spec.rb +13 -5
- data/spec/units/gandi_v5/live_dns/domain/dnssec_key_spec.rb +128 -0
- data/spec/units/gandi_v5/live_dns/{record_set_spec.rb → domain/record_spec.rb} +1 -1
- data/spec/units/gandi_v5/live_dns/domain/snapshot_spec.rb +101 -0
- data/spec/units/gandi_v5/live_dns/domain/tsig_key_spec.rb +78 -0
- data/spec/units/gandi_v5/live_dns/domain_spec.rb +299 -120
- data/spec/units/gandi_v5/live_dns_spec.rb +0 -12
- data/spec/units/gandi_v5/organization/customer_spec.rb +81 -0
- data/spec/units/gandi_v5/organization_spec.rb +52 -1
- data/spec/units/gandi_v5_spec.rb +139 -30
- metadata +68 -95
- data/doc/GandiV5.html +0 -1183
- data/doc/GandiV5/Billing.html +0 -293
- data/doc/GandiV5/Billing/Info.html +0 -641
- data/doc/GandiV5/Billing/Info/Prepaid.html +0 -817
- data/doc/GandiV5/Data.html +0 -785
- data/doc/GandiV5/Data/ClassMethods.html +0 -223
- data/doc/GandiV5/Data/Converter.html +0 -433
- data/doc/GandiV5/Data/Converter/ArrayOf.html +0 -413
- data/doc/GandiV5/Data/Converter/Symbol.html +0 -322
- data/doc/GandiV5/Data/Converter/Time.html +0 -330
- data/doc/GandiV5/Domain.html +0 -16847
- data/doc/GandiV5/Domain/AutoRenew.html +0 -1237
- data/doc/GandiV5/Domain/Availability.html +0 -1020
- data/doc/GandiV5/Domain/Availability/Product.html +0 -988
- data/doc/GandiV5/Domain/Availability/Product/Period.html +0 -220
- data/doc/GandiV5/Domain/Availability/Product/Price.html +0 -1031
- data/doc/GandiV5/Domain/Availability/Tax.html +0 -440
- data/doc/GandiV5/Domain/Contact.html +0 -4459
- data/doc/GandiV5/Domain/Contract.html +0 -520
- data/doc/GandiV5/Domain/Dates.html +0 -1313
- data/doc/GandiV5/Domain/RenewalInformation.html +0 -1147
- data/doc/GandiV5/Domain/RestoreInformation.html +0 -339
- data/doc/GandiV5/Domain/SharingSpace.html +0 -437
- data/doc/GandiV5/Domain/TLD.html +0 -1565
- data/doc/GandiV5/Email.html +0 -144
- data/doc/GandiV5/Email/Mailbox.html +0 -6307
- data/doc/GandiV5/Email/Mailbox/Responder.html +0 -1560
- data/doc/GandiV5/Email/Offer.html +0 -514
- data/doc/GandiV5/Email/Slot.html +0 -4244
- data/doc/GandiV5/Error.html +0 -151
- data/doc/GandiV5/Error/GandiError.html +0 -270
- data/doc/GandiV5/LiveDNS.html +0 -300
- data/doc/GandiV5/LiveDNS/Domain.html +0 -2984
- data/doc/GandiV5/LiveDNS/RecordSet.html +0 -1593
- data/doc/GandiV5/LiveDNS/Zone.html +0 -8891
- data/doc/GandiV5/LiveDNS/Zone/Snapshot.html +0 -1556
- data/doc/GandiV5/Organization.html +0 -2341
- data/doc/_index.html +0 -474
- data/doc/class_list.html +0 -51
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -58
- data/doc/css/style.css +0 -496
- data/doc/file.README.html +0 -175
- data/doc/file_list.html +0 -56
- data/doc/frames.html +0 -17
- data/doc/index.html +0 -175
- data/doc/js/app.js +0 -303
- data/doc/js/full_list.js +0 -216
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -2427
- data/doc/top-level-namespace.html +0 -110
- data/lib/gandi_v5/live_dns/record_set.rb +0 -79
- data/lib/gandi_v5/live_dns/zone.rb +0 -305
- data/lib/gandi_v5/live_dns/zone/snapshot.rb +0 -81
- data/spec/features/domain_spec.rb +0 -45
- data/spec/features/livedns_domain_spec.rb +0 -8
- data/spec/features/livedns_zone_spec.rb +0 -45
- data/spec/features/mailbox_spec.rb +0 -18
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/get.yaml +0 -4
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/get.yaml +0 -11
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/list.yaml +0 -11
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/list.yaml +0 -3
- data/spec/fixtures/vcr/Domain_features/List_domains.yml +0 -54
- data/spec/fixtures/vcr/Domain_features/Renew_domain.yml +0 -133
- data/spec/fixtures/vcr/LiveDNS_Domain_features/List_domains.yml +0 -32
- data/spec/fixtures/vcr/LiveDNS_Zone_features/List_zones.yml +0 -42
- data/spec/fixtures/vcr/LiveDNS_Zone_features/Make_and_save_snapshot.yml +0 -72
- data/spec/fixtures/vcr/LiveDNS_Zone_features/Save_zone_to_file.yml +0 -28
- data/spec/fixtures/vcr/Mailbox_features/List_mailboxes.yml +0 -39
- data/spec/units/gandi_v5/live_dns/zone/snapshot_spec.rb +0 -66
- data/spec/units/gandi_v5/live_dns/zone_spec.rb +0 -347
@@ -1,42 +0,0 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
4
|
-
method: get
|
5
|
-
uri: https://dns.api.gandi.net/api/v5/zones
|
6
|
-
body:
|
7
|
-
encoding: US-ASCII
|
8
|
-
string: ''
|
9
|
-
headers:
|
10
|
-
Accept:
|
11
|
-
- application/json
|
12
|
-
X-Api-Key:
|
13
|
-
- abdce12345
|
14
|
-
Host:
|
15
|
-
- api.gandi.net
|
16
|
-
response:
|
17
|
-
status:
|
18
|
-
code: 200
|
19
|
-
message: OK
|
20
|
-
headers:
|
21
|
-
Content-Type:
|
22
|
-
- application/json; charset=utf-8
|
23
|
-
body:
|
24
|
-
encoding: UTF-8
|
25
|
-
string: |-
|
26
|
-
[
|
27
|
-
{
|
28
|
-
"retry": 3600,
|
29
|
-
"uuid": "uuid-of-zone",
|
30
|
-
"minimum": 10800,
|
31
|
-
"refresh": 10800,
|
32
|
-
"expire": 604800,
|
33
|
-
"serial": 1432798405,
|
34
|
-
"user_uuid": "uuid-of-user",
|
35
|
-
"email": "hostmaster.gandi.net.",
|
36
|
-
"primary_ns": "a.dns.gandi.net.",
|
37
|
-
"name": "Zone Name"
|
38
|
-
}
|
39
|
-
]
|
40
|
-
http_version:
|
41
|
-
recorded_at: Thu, 30 May 2019 06:22:02 GMT
|
42
|
-
recorded_with: VCR 4.0.0
|
@@ -1,72 +0,0 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
4
|
-
method: post
|
5
|
-
uri: https://dns.api.gandi.net/api/v5/zones/zone-uuid/snapshots
|
6
|
-
body:
|
7
|
-
encoding: US-ASCII
|
8
|
-
string: ''
|
9
|
-
headers:
|
10
|
-
Accept:
|
11
|
-
- application/json
|
12
|
-
X-Api-Key:
|
13
|
-
- abdce12345
|
14
|
-
Host:
|
15
|
-
- api.gandi.net
|
16
|
-
response:
|
17
|
-
status:
|
18
|
-
code: 200
|
19
|
-
message: OK
|
20
|
-
headers:
|
21
|
-
Content-Type:
|
22
|
-
- application/json; charset=utf-8
|
23
|
-
body:
|
24
|
-
encoding: UTF-8
|
25
|
-
string: |-
|
26
|
-
{
|
27
|
-
"message": "Zone Snapshot Created",
|
28
|
-
"uuid": "snapshot-uuid"
|
29
|
-
}
|
30
|
-
http_version:
|
31
|
-
recorded_at: Thu, 30 May 2019 06:22:02 GMT
|
32
|
-
|
33
|
-
- request:
|
34
|
-
method: get
|
35
|
-
uri: https://dns.api.gandi.net/api/v5/zones/zone-uuid/snapshots/snapshot-uuid
|
36
|
-
body:
|
37
|
-
encoding: US-ASCII
|
38
|
-
string: ''
|
39
|
-
headers:
|
40
|
-
Accept:
|
41
|
-
- text/plain
|
42
|
-
X-Api-Key:
|
43
|
-
- abdce12345
|
44
|
-
Host:
|
45
|
-
- api.gandi.net
|
46
|
-
response:
|
47
|
-
status:
|
48
|
-
code: 200
|
49
|
-
message: OK
|
50
|
-
headers:
|
51
|
-
Content-Type:
|
52
|
-
- application/json; charset=utf-8
|
53
|
-
body:
|
54
|
-
encoding: UTF-8
|
55
|
-
string: |-
|
56
|
-
{
|
57
|
-
"date_created": "2016-12-16T16:51:26Z",
|
58
|
-
"uuid": "snapshot-uuid",
|
59
|
-
"zone_uuid": "zone-uuid",
|
60
|
-
"zone_data": [
|
61
|
-
{
|
62
|
-
"rrset_type": "A",
|
63
|
-
"rrset_ttl": 10800,
|
64
|
-
"rrset_name": "www",
|
65
|
-
"rrset_values": ["10.0.1.42"]
|
66
|
-
}
|
67
|
-
]
|
68
|
-
}
|
69
|
-
http_version:
|
70
|
-
recorded_at: Thu, 30 May 2019 06:22:02 GMT
|
71
|
-
|
72
|
-
recorded_with: VCR 4.0.0
|
@@ -1,28 +0,0 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
4
|
-
method: get
|
5
|
-
uri: https://dns.api.gandi.net/api/v5/zones/zone-uuid/records
|
6
|
-
body:
|
7
|
-
encoding: US-ASCII
|
8
|
-
string: ''
|
9
|
-
headers:
|
10
|
-
Accept:
|
11
|
-
- text/plain
|
12
|
-
X-Api-Key:
|
13
|
-
- abdce12345
|
14
|
-
Host:
|
15
|
-
- api.gandi.net
|
16
|
-
response:
|
17
|
-
status:
|
18
|
-
code: 200
|
19
|
-
message: OK
|
20
|
-
headers:
|
21
|
-
Content-Type:
|
22
|
-
- text/plain; charset=utf-8
|
23
|
-
body:
|
24
|
-
encoding: UTF-8
|
25
|
-
string: "Contents of zone file.\n"
|
26
|
-
http_version:
|
27
|
-
recorded_at: Thu, 30 May 2019 06:22:02 GMT
|
28
|
-
recorded_with: VCR 4.0.0
|
@@ -1,39 +0,0 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
4
|
-
method: get
|
5
|
-
uri: https://api.gandi.net/v5/email/mailboxes/example.net?page=1
|
6
|
-
body:
|
7
|
-
encoding: US-ASCII
|
8
|
-
string: ''
|
9
|
-
headers:
|
10
|
-
Accept:
|
11
|
-
- application/json
|
12
|
-
Authorization:
|
13
|
-
- Apikey abdce12345
|
14
|
-
Host:
|
15
|
-
- api.gandi.net
|
16
|
-
response:
|
17
|
-
status:
|
18
|
-
code: 200
|
19
|
-
message: OK
|
20
|
-
headers:
|
21
|
-
Content-Type:
|
22
|
-
- application/json; charset=utf-8
|
23
|
-
body:
|
24
|
-
encoding: UTF-8
|
25
|
-
string: |-
|
26
|
-
[
|
27
|
-
{
|
28
|
-
"domain": "example.net",
|
29
|
-
"login": "alice",
|
30
|
-
"address": "alice@example.net",
|
31
|
-
"id": "066743e5-96e4-4a1d-9195-8b8a700a8a79",
|
32
|
-
"mailbox_type": "standard",
|
33
|
-
"quota_used": 1200,
|
34
|
-
"href": "https://api.test/api/v5/email/example.net/066743e5-96e4-4a1d-9195-8b8a700a8a79"
|
35
|
-
}
|
36
|
-
]
|
37
|
-
http_version:
|
38
|
-
recorded_at: Thu, 30 May 2019 06:22:02 GMT
|
39
|
-
recorded_with: VCR 4.0.0
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe GandiV5::LiveDNS::Zone::Snapshot do
|
4
|
-
subject do
|
5
|
-
described_class.new(
|
6
|
-
created_at: Time.new(2016, 12, 16, 16, 51, 26, 0),
|
7
|
-
uuid: 'snapshot-uuid',
|
8
|
-
zone_uuid: 'zone-uuid',
|
9
|
-
records: []
|
10
|
-
)
|
11
|
-
end
|
12
|
-
|
13
|
-
it '#delete' do
|
14
|
-
expect(GandiV5).to receive(:delete).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/snapshots/snapshot-uuid')
|
15
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
16
|
-
expect(subject.delete).to eq 'Confirmation message.'
|
17
|
-
end
|
18
|
-
|
19
|
-
it '#fetch_zone' do
|
20
|
-
returns = double GandiV5::LiveDNS::Zone
|
21
|
-
expect(GandiV5::LiveDNS::Zone).to receive(:fetch).with('zone-uuid')
|
22
|
-
.and_return(returns)
|
23
|
-
expect(subject.fetch_zone).to be returns
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '#zone' do
|
27
|
-
it 'Not previously fetched' do
|
28
|
-
returns = double GandiV5::LiveDNS::Zone
|
29
|
-
expect(subject).to receive(:fetch_zone).and_return(returns)
|
30
|
-
expect(subject.zone).to be returns
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'Previously fetched' do
|
34
|
-
returns = double GandiV5::LiveDNS::Zone
|
35
|
-
subject.instance_exec { @zone = returns }
|
36
|
-
expect(subject).to_not receive(:fetch_zone)
|
37
|
-
expect(subject.zone).to be returns
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
it '.list' do
|
42
|
-
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Zone_Snapshot', 'list.yaml'))
|
43
|
-
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/snapshots')
|
44
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
45
|
-
expect(described_class.list('zone-uuid')).to eq('snapshot-uuid' => Time.new(2016, 12, 16, 16, 51, 26, 0))
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '.fetch' do
|
49
|
-
subject { described_class.fetch 'zone-uuid', 'snapshot-uuid' }
|
50
|
-
|
51
|
-
before :each do
|
52
|
-
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Zone_Snapshot', 'fetch.yaml'))
|
53
|
-
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/snapshots/snapshot-uuid')
|
54
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
55
|
-
end
|
56
|
-
|
57
|
-
its('created_at') { should eq Time.new(2016, 12, 16, 16, 51, 26, 0) }
|
58
|
-
its('uuid') { should eq 'snapshot-uuid' }
|
59
|
-
its('zone_uuid') { should eq 'zone-uuid' }
|
60
|
-
its('records.count') { should eq 1 }
|
61
|
-
its('records.first.type') { should eq 'A' }
|
62
|
-
its('records.first.ttl') { should eq 10_800 }
|
63
|
-
its('records.first.name') { should eq 'www' }
|
64
|
-
its('records.first.values') { should match_array ['10.0.1.42'] }
|
65
|
-
end
|
66
|
-
end
|
@@ -1,347 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe GandiV5::LiveDNS::Zone do
|
4
|
-
subject do
|
5
|
-
described_class.new(
|
6
|
-
name: 'Zone Name',
|
7
|
-
uuid: 'zone-uuid',
|
8
|
-
soa_retry: 1,
|
9
|
-
soa_minimum: 2,
|
10
|
-
soa_refresh: 3,
|
11
|
-
soa_expire: 4,
|
12
|
-
soa_serial: 5,
|
13
|
-
soa_email: 'admin.example.com',
|
14
|
-
soa_primary_ns: '192.168.0.1'
|
15
|
-
)
|
16
|
-
end
|
17
|
-
|
18
|
-
it '#to_s' do
|
19
|
-
expect(subject.to_s).to eq [
|
20
|
-
'@ IN SOA 192.168.0.1 admin.example.com (',
|
21
|
-
"\t5\t;Serial",
|
22
|
-
"\t3\t\t;Refresh",
|
23
|
-
"\t1\t\t;Retry",
|
24
|
-
"\t4\t\t;Expire",
|
25
|
-
"\t2\t\t;Minimum & Negative TTL",
|
26
|
-
')'
|
27
|
-
].join("\n")
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#fetch_records' do
|
31
|
-
it 'All of them' do
|
32
|
-
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/records')
|
33
|
-
.and_return([nil, []])
|
34
|
-
|
35
|
-
expect(subject.fetch_records).to eq []
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'All for a name' do
|
39
|
-
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name')
|
40
|
-
.and_return([nil, []])
|
41
|
-
|
42
|
-
expect(subject.fetch_records('name')).to eq []
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'A type for a name' do
|
46
|
-
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT')
|
47
|
-
.and_return(
|
48
|
-
[
|
49
|
-
nil,
|
50
|
-
[
|
51
|
-
{
|
52
|
-
'rrset_type' => 'TXT',
|
53
|
-
'rrset_name' => 'name',
|
54
|
-
'rrset_ttl' => 600,
|
55
|
-
'rrset_values' => %w[a b]
|
56
|
-
}
|
57
|
-
]
|
58
|
-
]
|
59
|
-
)
|
60
|
-
|
61
|
-
records = subject.fetch_records('name', 'TXT')
|
62
|
-
expect(records.count).to eq 1
|
63
|
-
expect(records.first.type).to eq 'TXT'
|
64
|
-
expect(records.first.ttl).to eq 600
|
65
|
-
expect(records.first.name).to eq 'name'
|
66
|
-
expect(records.first.values).to match_array %w[a b]
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'Invalid type' do
|
70
|
-
expect { subject.fetch_records 'name', 'INVALID-TYPE' }.to raise_error ArgumentError
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '#fetch_zone_lines' do
|
75
|
-
it 'All of them' do
|
76
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
|
77
|
-
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
|
78
|
-
expect(subject.fetch_zone_lines).to eq 'returned'
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'All for a name' do
|
82
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name'
|
83
|
-
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
|
84
|
-
expect(subject.fetch_zone_lines('name')).to eq 'returned'
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'A type for a name' do
|
88
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT'
|
89
|
-
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
|
90
|
-
expect(subject.fetch_zone_lines('name', 'TXT')).to eq 'returned'
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'Invalid type' do
|
94
|
-
expect { subject.fetch_zone_lines 'name', 'INVALID-TYPE' }.to raise_error ArgumentError
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe '#add_record' do
|
99
|
-
it 'Success' do
|
100
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
|
101
|
-
body = '{"rrset_name":"name","rrset_type":"TXT","rrset_ttl":900,"rrset_values":["a","b"]}'
|
102
|
-
expect(GandiV5).to receive(:post).with(url, body).and_return([nil, { 'message' => 'Confirmation message.' }])
|
103
|
-
expect(subject.add_record('name', 'TXT', 900, 'a', 'b')).to eq 'Confirmation message.'
|
104
|
-
end
|
105
|
-
|
106
|
-
it 'Bad type' do
|
107
|
-
expect { subject.add_record 'name', 'INVALID-TYPE', 900, 'a' }.to raise_error ArgumentError
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'Bad TTL' do
|
111
|
-
expect { subject.add_record 'name', 'TXT', -900, 'a' }.to raise_error(
|
112
|
-
ArgumentError,
|
113
|
-
'ttl must be positive and non-zero'
|
114
|
-
)
|
115
|
-
end
|
116
|
-
|
117
|
-
it 'No values' do
|
118
|
-
expect { subject.add_record 'name', 'TXT', 900 }.to raise_error(
|
119
|
-
ArgumentError,
|
120
|
-
'there must be at least one value'
|
121
|
-
)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
describe '#delete_records' do
|
126
|
-
it 'All of them' do
|
127
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
|
128
|
-
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
129
|
-
subject.delete_records
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'All for a name' do
|
133
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name'
|
134
|
-
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
135
|
-
subject.delete_records 'name'
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'A type for a name' do
|
139
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT'
|
140
|
-
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
141
|
-
subject.delete_records 'name', 'TXT'
|
142
|
-
end
|
143
|
-
|
144
|
-
it 'Invalid type' do
|
145
|
-
expect { subject.delete_records 'name', 'INVALID-TYPE' }.to raise_error ArgumentError
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
describe '#replace_records' do
|
150
|
-
it 'Given array of GandiV5::LiveDNS::RecordSet' do
|
151
|
-
records = [
|
152
|
-
{ name: 'name', ttl: 600, type: 'TXT', values: ['a'] }
|
153
|
-
]
|
154
|
-
|
155
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
|
156
|
-
body = '{"items":[{"rrset_name":"name","rrset_ttl":600,"rrset_type":"TXT","rrset_values":["a"]}]}'
|
157
|
-
expect(GandiV5).to receive(:put).with(url, body)
|
158
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
159
|
-
expect(subject.replace_records(records: records)).to eq 'Confirmation message.'
|
160
|
-
end
|
161
|
-
|
162
|
-
it 'Given string' do
|
163
|
-
records = [
|
164
|
-
'@ 86400 IN A 192.168.0.1',
|
165
|
-
'* 86400 IN A 192.168.0.1'
|
166
|
-
].join("\n")
|
167
|
-
|
168
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records'
|
169
|
-
expect(GandiV5).to receive(:put).with(url, records, 'content-type': 'text/plain')
|
170
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
171
|
-
expect(subject.replace_records(text: records)).to eq 'Confirmation message.'
|
172
|
-
end
|
173
|
-
|
174
|
-
it 'Given both' do
|
175
|
-
expect { subject.replace_records text: '', records: [] }.to raise_error(
|
176
|
-
ArgumentError,
|
177
|
-
'you must pass ONE of records: or text:'
|
178
|
-
)
|
179
|
-
end
|
180
|
-
|
181
|
-
it 'Given nothing' do
|
182
|
-
expect { subject.replace_records }.to raise_error ArgumentError, 'you must pass ONE of records: or text:'
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
describe '#replace_records_for' do
|
187
|
-
it 'Given no type or ttl' do
|
188
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name'
|
189
|
-
body = '{"items":[{"rrset_type":"TXT","rrset_values":["a"]}]}'
|
190
|
-
expect(GandiV5).to receive(:put).with(url, body)
|
191
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
192
|
-
records = [{ type: 'TXT', values: ['a'] }]
|
193
|
-
expect(subject.replace_records_for('name', records)).to eq 'Confirmation message.'
|
194
|
-
end
|
195
|
-
|
196
|
-
it 'Given type and ttl' do
|
197
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT'
|
198
|
-
body = '{"rrset_values":["a"],"rrset_ttl":600}'
|
199
|
-
expect(GandiV5).to receive(:put).with(url, body)
|
200
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
201
|
-
expect(subject.replace_records_for('name', ['a'], type: 'TXT', ttl: 600)).to eq 'Confirmation message.'
|
202
|
-
end
|
203
|
-
|
204
|
-
it 'Given type but no ttl' do
|
205
|
-
url = 'https://dns.api.gandi.net/api/v5/zones/zone-uuid/records/name/TXT'
|
206
|
-
body = '{"rrset_values":["a"],"rrset_ttl":null}'
|
207
|
-
expect(GandiV5).to receive(:put).with(url, body)
|
208
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
209
|
-
expect(subject.replace_records_for('name', ['a'], type: 'TXT')).to eq 'Confirmation message.'
|
210
|
-
end
|
211
|
-
|
212
|
-
it 'Given ttl but no type' do
|
213
|
-
expect(GandiV5).to_not receive(:put)
|
214
|
-
expect { subject.replace_records_for 'name', 'a', ttl: 600 }.to raise_error ArgumentError, 'missing keyword: type'
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
it '#list_domains' do
|
219
|
-
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/domains')
|
220
|
-
.and_return([nil, [{ 'fqdn' => 'example.com' }]])
|
221
|
-
expect(subject.list_domains).to match_array ['example.com']
|
222
|
-
end
|
223
|
-
|
224
|
-
describe '#attach_domain' do
|
225
|
-
it 'Given a fqdn' do
|
226
|
-
url = 'https://dns.api.gandi.net/api/v5/domains/example.com'
|
227
|
-
body = '{"zone_uuid":"zone-uuid"}'
|
228
|
-
expect(GandiV5).to receive(:patch).with(url, body)
|
229
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
230
|
-
expect(subject.attach_domain('example.com')).to eq 'Confirmation message.'
|
231
|
-
end
|
232
|
-
|
233
|
-
it 'Given something with a fqdn method' do
|
234
|
-
url = 'https://dns.api.gandi.net/api/v5/domains/example.com'
|
235
|
-
body = '{"zone_uuid":"zone-uuid"}'
|
236
|
-
expect(GandiV5).to receive(:patch).with(url, body)
|
237
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
238
|
-
domain = double GandiV5::LiveDNS::Domain, fqdn: 'example.com'
|
239
|
-
expect(subject.attach_domain(domain)).to eq 'Confirmation message.'
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
it '#snapshots' do
|
244
|
-
returns = double Hash
|
245
|
-
expect(GandiV5::LiveDNS::Zone::Snapshot).to receive(:list).with('zone-uuid')
|
246
|
-
.and_return(returns)
|
247
|
-
expect(subject.snapshots).to be returns
|
248
|
-
end
|
249
|
-
|
250
|
-
it '#snapshot' do
|
251
|
-
returns = double GandiV5::LiveDNS::Zone::Snapshot
|
252
|
-
expect(GandiV5::LiveDNS::Zone::Snapshot).to receive(:fetch).with('zone-uuid', 'snapshot-uuid')
|
253
|
-
.and_return(returns)
|
254
|
-
expect(subject.snapshot('snapshot-uuid')).to be returns
|
255
|
-
end
|
256
|
-
|
257
|
-
it '#take_snapshot' do
|
258
|
-
returns = double GandiV5::LiveDNS::Zone::Snapshot
|
259
|
-
expect(GandiV5).to receive(:post).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/snapshots')
|
260
|
-
.and_return([nil, { 'message' => 'Confirmation message.', 'uuid' => 'snapshot-uuid' }])
|
261
|
-
expect(GandiV5::LiveDNS::Zone::Snapshot).to receive(:fetch).with('zone-uuid', 'snapshot-uuid')
|
262
|
-
.and_return(returns)
|
263
|
-
expect(subject.take_snapshot).to be returns
|
264
|
-
end
|
265
|
-
|
266
|
-
it '#update' do
|
267
|
-
body = '{"name":"new-name"}'
|
268
|
-
expect(GandiV5).to receive(:patch).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid', body)
|
269
|
-
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
270
|
-
expect(subject.update(name: 'new-name')).to eq 'Confirmation message.'
|
271
|
-
end
|
272
|
-
|
273
|
-
it '#delete' do
|
274
|
-
expect(GandiV5).to receive(:delete).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid')
|
275
|
-
subject.delete
|
276
|
-
end
|
277
|
-
|
278
|
-
describe '.create' do
|
279
|
-
let(:created_response) do
|
280
|
-
double(
|
281
|
-
RestClient::Response,
|
282
|
-
headers: { location: 'https://dns.api.gandi.net/v5/zones/created-zone-uuid' }
|
283
|
-
)
|
284
|
-
end
|
285
|
-
let(:created_zone) { double GandiV5::LiveDNS::Zone }
|
286
|
-
|
287
|
-
it 'With sharing-id' do
|
288
|
-
body = '{"name":"Name"}'
|
289
|
-
params = { sharing_id: 'sharing-id' }
|
290
|
-
expect(GandiV5).to receive(:post).with('https://dns.api.gandi.net/api/v5/zones', body, params: params)
|
291
|
-
.and_return([created_response, { 'message' => 'Confirmation message.' }])
|
292
|
-
expect(described_class).to receive(:fetch).with('created-zone-uuid').and_return(created_zone)
|
293
|
-
expect(described_class.create('Name', sharing_id: 'sharing-id')).to be created_zone
|
294
|
-
end
|
295
|
-
|
296
|
-
it 'Without sharing-id' do
|
297
|
-
body = '{"name":"Name"}'
|
298
|
-
expect(GandiV5).to receive(:post).with('https://dns.api.gandi.net/api/v5/zones', body, params: {})
|
299
|
-
.and_return([created_response, { 'message' => 'Confirmation message.' }])
|
300
|
-
expect(described_class).to receive(:fetch).with('created-zone-uuid').and_return(created_zone)
|
301
|
-
expect(described_class.create('Name')).to be created_zone
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
describe '.list' do
|
306
|
-
subject { described_class.list }
|
307
|
-
|
308
|
-
before :each do
|
309
|
-
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Zone', 'list.yaml'))
|
310
|
-
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones')
|
311
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
312
|
-
end
|
313
|
-
|
314
|
-
its('count') { should eq 1 }
|
315
|
-
its('first.uuid') { should eq 'zone-uuid' }
|
316
|
-
its('first.name') { should eq 'Name' }
|
317
|
-
its('first.sharing_uuid') { should be nil }
|
318
|
-
its('first.soa_retry') { should eq 3_600 }
|
319
|
-
its('first.soa_minimum') { should eq 900 }
|
320
|
-
its('first.soa_refresh') { should eq 10_800 }
|
321
|
-
its('first.soa_expire') { should eq 604_800 }
|
322
|
-
its('first.soa_serial') { should eq 1_432_798_405 }
|
323
|
-
its('first.soa_email') { should eq 'hostmaster.gandi.net.' }
|
324
|
-
its('first.soa_primary_ns') { should eq 'a.dns.gandi.net.' }
|
325
|
-
end
|
326
|
-
|
327
|
-
describe '.fetch' do
|
328
|
-
subject { described_class.fetch 'zone-uuid' }
|
329
|
-
|
330
|
-
before :each do
|
331
|
-
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Zone', 'get.yaml'))
|
332
|
-
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid')
|
333
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
334
|
-
end
|
335
|
-
|
336
|
-
its('uuid') { should eq 'zone-uuid' }
|
337
|
-
its('name') { should eq 'Name' }
|
338
|
-
its('sharing_uuid') { should be nil }
|
339
|
-
its('soa_retry') { should eq 3_600 }
|
340
|
-
its('soa_minimum') { should eq 900 }
|
341
|
-
its('soa_refresh') { should eq 10_800 }
|
342
|
-
its('soa_expire') { should eq 604_800 }
|
343
|
-
its('soa_serial') { should eq 1_432_798_405 }
|
344
|
-
its('soa_email') { should eq 'hostmaster.gandi.net.' }
|
345
|
-
its('soa_primary_ns') { should eq 'a.dns.gandi.net.' }
|
346
|
-
end
|
347
|
-
end
|