gandi_v5 0.1.0 → 0.6.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 +14 -4
- data/.travis.yml +16 -1
- data/CHANGELOG.md +80 -2
- data/FUNDING.yml +10 -0
- data/Guardfile +5 -6
- data/LICENSE.md +2 -6
- data/README.md +17 -23
- data/gandi_v5.gemspec +4 -3
- data/lib/gandi_v5.rb +54 -15
- data/lib/gandi_v5/billing.rb +2 -4
- data/lib/gandi_v5/billing/info.rb +0 -2
- data/lib/gandi_v5/data.rb +1 -2
- 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 +201 -101
- data/lib/gandi_v5/domain/auto_renew.rb +4 -4
- data/lib/gandi_v5/domain/availability.rb +46 -0
- data/lib/gandi_v5/domain/availability/product.rb +49 -0
- data/lib/gandi_v5/domain/availability/product/period.rb +24 -0
- data/lib/gandi_v5/domain/availability/product/price.rb +36 -0
- data/lib/gandi_v5/domain/availability/tax.rb +20 -0
- 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/domain/tld.rb +57 -0
- data/lib/gandi_v5/email.rb +0 -4
- data/lib/gandi_v5/email/forward.rb +108 -0
- data/lib/gandi_v5/email/mailbox.rb +85 -24
- data/lib/gandi_v5/email/mailbox/responder.rb +43 -2
- data/lib/gandi_v5/email/offer.rb +2 -2
- data/lib/gandi_v5/email/slot.rb +52 -18
- data/lib/gandi_v5/error.rb +0 -2
- data/lib/gandi_v5/error/gandi_error.rb +2 -2
- data/lib/gandi_v5/live_dns.rb +20 -4
- data/lib/gandi_v5/live_dns/domain.rb +21 -150
- data/lib/gandi_v5/live_dns/has_zone_records.rb +153 -0
- data/lib/gandi_v5/live_dns/record_set.rb +1 -1
- data/lib/gandi_v5/live_dns/zone.rb +24 -165
- data/lib/gandi_v5/live_dns/zone/snapshot.rb +27 -8
- data/lib/gandi_v5/organization.rb +39 -6
- 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/features/domain_spec.rb +2 -2
- data/spec/features/livedns_zone_spec.rb +12 -13
- 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.yaml → GandiV5_Domain_Availability/fetch.yml} +0 -0
- data/spec/fixtures/bodies/{GandiV5_Domain/tld.yaml → GandiV5_Domain_TLD/fetch.yml} +0 -0
- data/spec/fixtures/bodies/{GandiV5_Domain/tlds.yaml → GandiV5_Domain_TLD/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/{get.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/{list.yaml → list.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/{get.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/{list.yaml → list.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/{get.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/list.yml +3 -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/fixtures/vcr/Domain_features/List_domains.yml +2 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/units/gandi_v5/billing_spec.rb +4 -4
- data/spec/units/gandi_v5/data/converter/integer_spec.rb +16 -0
- data/spec/units/gandi_v5/domain/auto_renew_spec.rb +5 -5
- data/spec/units/gandi_v5/domain/availability/product/period_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/availability/product/price_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/availability/product_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/availability/tax_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/availability_spec.rb +43 -0
- data/spec/units/gandi_v5/domain/live_dns_spec.rb +45 -0
- data/spec/units/gandi_v5/domain/tld_spec.rb +29 -0
- data/spec/units/gandi_v5/domain_spec.rb +359 -91
- data/spec/units/gandi_v5/email/forward_spec.rb +121 -0
- data/spec/units/gandi_v5/email/mailbox/responder_spec.rb +52 -0
- data/spec/units/gandi_v5/email/mailbox_spec.rb +174 -33
- data/spec/units/gandi_v5/email/offer_spec.rb +1 -1
- data/spec/units/gandi_v5/email/slot_spec.rb +113 -17
- data/spec/units/gandi_v5/live_dns/domain_spec.rb +73 -43
- data/spec/units/gandi_v5/live_dns/zone/snapshot_spec.rb +32 -3
- data/spec/units/gandi_v5/live_dns/zone_spec.rb +70 -52
- data/spec/units/gandi_v5/live_dns_spec.rb +24 -0
- 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 +56 -19
- metadata +71 -29
- data/TODO.md +0 -29
@@ -8,7 +8,7 @@ describe GandiV5::Email::Offer do
|
|
8
8
|
|
9
9
|
before :each do
|
10
10
|
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/offers/example.com')
|
11
|
-
.and_return('status' => 'active', 'version' => 2)
|
11
|
+
.and_return([nil, { 'status' => 'active', 'version' => 2 }])
|
12
12
|
end
|
13
13
|
|
14
14
|
its('status') { should be :active }
|
@@ -5,19 +5,32 @@ describe GandiV5::Email::Slot do
|
|
5
5
|
described_class.new id: 123, capacity: 1, mailbox_type: :standard, status: :inactive, fqdn: 'example.com'
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
describe '#delete' do
|
9
|
+
it 'Is deletable' do
|
10
|
+
subject = described_class.new fqdn: 'example.com', id: 123, status: :inactive, refundable: true
|
11
|
+
expect(GandiV5).to receive(:delete).with('https://api.gandi.net/v5/email/slots/example.com/123')
|
12
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
13
|
+
expect(subject.delete).to eq 'Confirmation message.'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'Is in use' do
|
17
|
+
subject = described_class.new fqdn: 'example.com', id: 123, status: :active, refundable: true
|
18
|
+
expect(GandiV5).to_not receive(:delete)
|
19
|
+
expect { subject.delete }.to raise_error GandiV5::Error, 'slot can\'t be deleted whilst active'
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'Is not refundable' do
|
23
|
+
subject = described_class.new fqdn: 'example.com', id: 123, status: :inactive, refundable: false
|
24
|
+
expect(GandiV5).to_not receive(:delete)
|
25
|
+
expect { subject.delete }.to raise_error GandiV5::Error, 'slot can\'t be deleted if it\'s not refundable'
|
26
|
+
end
|
12
27
|
end
|
13
|
-
# TODO: check for inactiveness
|
14
|
-
# TODO: check for refundableness
|
15
28
|
|
16
29
|
describe '#refresh' do
|
17
30
|
before :each do
|
18
|
-
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Email_Slot', '
|
31
|
+
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Email_Slot', 'fetch.yml'))
|
19
32
|
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/slots/example.com/123')
|
20
|
-
.and_return(YAML.load_file(body_fixture))
|
33
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
21
34
|
subject.refresh
|
22
35
|
end
|
23
36
|
|
@@ -44,18 +57,101 @@ describe GandiV5::Email::Slot do
|
|
44
57
|
end
|
45
58
|
end
|
46
59
|
|
60
|
+
describe '#inactive?' do
|
61
|
+
it 'When active' do
|
62
|
+
slot = described_class.new status: :active
|
63
|
+
expect(slot.inactive?).to be false
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'When inactive' do
|
67
|
+
slot = described_class.new status: :inactive
|
68
|
+
expect(slot.inactive?).to be true
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#free?' do
|
73
|
+
it 'When free' do
|
74
|
+
slot = described_class.new mailbox_type: :free
|
75
|
+
expect(slot.free?).to be true
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'When standard' do
|
79
|
+
slot = described_class.new mailbox_type: :standard
|
80
|
+
expect(slot.free?).to be false
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'When premium' do
|
84
|
+
slot = described_class.new mailbox_type: :premium
|
85
|
+
expect(slot.free?).to be false
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#standard?' do
|
90
|
+
it 'When free' do
|
91
|
+
slot = described_class.new mailbox_type: :free
|
92
|
+
expect(slot.standard?).to be false
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'When standard' do
|
96
|
+
slot = described_class.new mailbox_type: :standard
|
97
|
+
expect(slot.standard?).to be true
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'When premium' do
|
101
|
+
slot = described_class.new mailbox_type: :premium
|
102
|
+
expect(slot.standard?).to be false
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe '#premium?' do
|
107
|
+
it 'When free' do
|
108
|
+
slot = described_class.new mailbox_type: :free
|
109
|
+
expect(slot.premium?).to be false
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'When standard' do
|
113
|
+
slot = described_class.new mailbox_type: :standard
|
114
|
+
expect(slot.premium?).to be false
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'When premium' do
|
118
|
+
slot = described_class.new mailbox_type: :premium
|
119
|
+
expect(slot.premium?).to be true
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
47
123
|
describe '.create' do
|
48
124
|
let(:url) { 'https://api.gandi.net/v5/email/slots/example.com' }
|
49
|
-
|
125
|
+
let(:created_response) do
|
126
|
+
double(
|
127
|
+
RestClient::Response,
|
128
|
+
headers: { location: 'https://api.gandi.net/v5/email/slots/example.com/created-slot-uuid' }
|
129
|
+
)
|
130
|
+
end
|
131
|
+
let(:created_slot) { double GandiV5::Email::Slot }
|
132
|
+
|
133
|
+
it 'With default type and no sharingID' do
|
50
134
|
expect(GandiV5).to receive(:post).with(url, '{"mailbox_type":"standard"}')
|
51
|
-
.and_return('message' => 'Confirmation message.')
|
52
|
-
expect(described_class.
|
135
|
+
.and_return([created_response, { 'message' => 'Confirmation message.' }])
|
136
|
+
expect(described_class).to receive(:fetch).with('example.com', 'created-slot-uuid').and_return(created_slot)
|
137
|
+
|
138
|
+
expect(described_class.create('example.com')).to be created_slot
|
53
139
|
end
|
54
140
|
|
55
141
|
it 'With passed type' do
|
56
142
|
expect(GandiV5).to receive(:post).with(url, '{"mailbox_type":"premium"}')
|
57
|
-
.and_return('message' => 'Confirmation message.')
|
58
|
-
expect(described_class.
|
143
|
+
.and_return([created_response, { 'message' => 'Confirmation message.' }])
|
144
|
+
expect(described_class).to receive(:fetch).with('example.com', 'created-slot-uuid').and_return(created_slot)
|
145
|
+
|
146
|
+
expect(described_class.create('example.com', type: :premium)).to be created_slot
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'With sharingID' do
|
150
|
+
expect(GandiV5).to receive(:post).with("#{url}?sharing_id=SHARING-ID", '{"mailbox_type":"standard"}')
|
151
|
+
.and_return([created_response, { 'message' => 'Confirmation message.' }])
|
152
|
+
expect(described_class).to receive(:fetch).with('example.com', 'created-slot-uuid').and_return(created_slot)
|
153
|
+
|
154
|
+
expect(described_class.create('example.com', sharing_id: 'SHARING-ID')).to be created_slot
|
59
155
|
end
|
60
156
|
end
|
61
157
|
|
@@ -63,9 +159,9 @@ describe GandiV5::Email::Slot do
|
|
63
159
|
subject { described_class.fetch 'example.com', 123 }
|
64
160
|
|
65
161
|
before :each do
|
66
|
-
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Email_Slot', '
|
162
|
+
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Email_Slot', 'fetch.yml'))
|
67
163
|
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/slots/example.com/123')
|
68
|
-
.and_return(YAML.load_file(body_fixture))
|
164
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
69
165
|
end
|
70
166
|
|
71
167
|
its('fqdn') { should eq 'example.com' }
|
@@ -83,9 +179,9 @@ describe GandiV5::Email::Slot do
|
|
83
179
|
subject { described_class.list 'example.com' }
|
84
180
|
|
85
181
|
before :each do
|
86
|
-
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Email_Slot', 'list.
|
182
|
+
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Email_Slot', 'list.yml'))
|
87
183
|
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/slots/example.com')
|
88
|
-
.and_return(YAML.load_file(body_fixture))
|
184
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
89
185
|
end
|
90
186
|
|
91
187
|
its('count') { should eq 1 }
|
@@ -7,9 +7,9 @@ describe GandiV5::LiveDNS::Domain do
|
|
7
7
|
|
8
8
|
describe '#refresh' do
|
9
9
|
before :each do
|
10
|
-
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Domain', '
|
10
|
+
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Domain', 'fetch.yml'))
|
11
11
|
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/domains/example.com')
|
12
|
-
.and_return(YAML.load_file(body_fixture))
|
12
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
13
13
|
subject.refresh
|
14
14
|
end
|
15
15
|
|
@@ -20,14 +20,14 @@ describe GandiV5::LiveDNS::Domain do
|
|
20
20
|
describe '#fetch_records' do
|
21
21
|
it 'All of them' do
|
22
22
|
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/domains/example.com/records')
|
23
|
-
.and_return([])
|
23
|
+
.and_return([nil, []])
|
24
24
|
|
25
25
|
expect(subject.fetch_records).to eq []
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'All for a name' do
|
29
29
|
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/domains/example.com/records/name')
|
30
|
-
.and_return([])
|
30
|
+
.and_return([nil, []])
|
31
31
|
|
32
32
|
expect(subject.fetch_records('name')).to eq []
|
33
33
|
end
|
@@ -36,12 +36,15 @@ describe GandiV5::LiveDNS::Domain do
|
|
36
36
|
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/domains/example.com/records/name/TXT')
|
37
37
|
.and_return(
|
38
38
|
[
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
nil,
|
40
|
+
[
|
41
|
+
{
|
42
|
+
'rrset_type' => 'TXT',
|
43
|
+
'rrset_name' => 'name',
|
44
|
+
'rrset_ttl' => 600,
|
45
|
+
'rrset_values' => %w[a b]
|
46
|
+
}
|
47
|
+
]
|
45
48
|
]
|
46
49
|
)
|
47
50
|
|
@@ -61,19 +64,19 @@ describe GandiV5::LiveDNS::Domain do
|
|
61
64
|
describe '#fetch_zone_lines' do
|
62
65
|
it 'All of them' do
|
63
66
|
url = 'https://dns.api.gandi.net/api/v5/domains/example.com/records'
|
64
|
-
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return('returned')
|
67
|
+
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
|
65
68
|
expect(subject.fetch_zone_lines).to eq 'returned'
|
66
69
|
end
|
67
70
|
|
68
71
|
it 'All for a name' do
|
69
72
|
url = 'https://dns.api.gandi.net/api/v5/domains/example.com/records/name'
|
70
|
-
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return('returned')
|
73
|
+
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
|
71
74
|
expect(subject.fetch_zone_lines('name')).to eq 'returned'
|
72
75
|
end
|
73
76
|
|
74
77
|
it 'A type for a name' do
|
75
78
|
url = 'https://dns.api.gandi.net/api/v5/domains/example.com/records/name/TXT'
|
76
|
-
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return('returned')
|
79
|
+
expect(GandiV5).to receive(:get).with(url, accept: 'text/plain').and_return([nil, 'returned'])
|
77
80
|
expect(subject.fetch_zone_lines('name', 'TXT')).to eq 'returned'
|
78
81
|
end
|
79
82
|
|
@@ -86,7 +89,7 @@ describe GandiV5::LiveDNS::Domain do
|
|
86
89
|
it 'Success' do
|
87
90
|
url = 'https://dns.api.gandi.net/api/v5/domains/example.com/records'
|
88
91
|
body = '{"rrset_name":"name","rrset_type":"TXT","rrset_ttl":900,"rrset_values":["a","b"]}'
|
89
|
-
expect(GandiV5).to receive(:post).with(url, body).and_return('message' => 'Confirmation message.')
|
92
|
+
expect(GandiV5).to receive(:post).with(url, body).and_return([nil, { 'message' => 'Confirmation message.' }])
|
90
93
|
expect(subject.add_record('name', 'TXT', 900, 'a', 'b')).to eq 'Confirmation message.'
|
91
94
|
end
|
92
95
|
|
@@ -112,19 +115,19 @@ describe GandiV5::LiveDNS::Domain do
|
|
112
115
|
describe '#delete_records' do
|
113
116
|
it 'All of them' do
|
114
117
|
url = 'https://dns.api.gandi.net/api/v5/domains/example.com/records'
|
115
|
-
expect(GandiV5).to receive(:delete).with(url)
|
118
|
+
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
116
119
|
subject.delete_records
|
117
120
|
end
|
118
121
|
|
119
122
|
it 'All for a name' do
|
120
123
|
url = 'https://dns.api.gandi.net/api/v5/domains/example.com/records/name'
|
121
|
-
expect(GandiV5).to receive(:delete).with(url)
|
124
|
+
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
122
125
|
subject.delete_records 'name'
|
123
126
|
end
|
124
127
|
|
125
128
|
it 'A type for a name' do
|
126
129
|
url = 'https://dns.api.gandi.net/api/v5/domains/example.com/records/name/TXT'
|
127
|
-
expect(GandiV5).to receive(:delete).with(url)
|
130
|
+
expect(GandiV5).to receive(:delete).with(url).and_return([nil, nil])
|
128
131
|
subject.delete_records 'name', 'TXT'
|
129
132
|
end
|
130
133
|
|
@@ -142,7 +145,7 @@ describe GandiV5::LiveDNS::Domain do
|
|
142
145
|
url = 'https://dns.api.gandi.net/api/v5/domains/example.com/records'
|
143
146
|
body = '{"items":[{"rrset_name":"name","rrset_ttl":600,"rrset_type":"TXT","rrset_values":["a"]}]}'
|
144
147
|
expect(GandiV5).to receive(:put).with(url, body)
|
145
|
-
.and_return('message' => 'Confirmation message.')
|
148
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
146
149
|
expect(subject.replace_records(records: records)).to eq 'Confirmation message.'
|
147
150
|
end
|
148
151
|
|
@@ -154,7 +157,7 @@ describe GandiV5::LiveDNS::Domain do
|
|
154
157
|
|
155
158
|
url = 'https://dns.api.gandi.net/api/v5/domains/example.com/records'
|
156
159
|
expect(GandiV5).to receive(:put).with(url, records, 'content-type': 'text/plain')
|
157
|
-
.and_return('message' => 'Confirmation message.')
|
160
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
158
161
|
expect(subject.replace_records(text: records)).to eq 'Confirmation message.'
|
159
162
|
end
|
160
163
|
|
@@ -170,30 +173,35 @@ describe GandiV5::LiveDNS::Domain do
|
|
170
173
|
end
|
171
174
|
end
|
172
175
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
176
|
+
describe '#replace_records_for' do
|
177
|
+
it 'Given no type or ttl' do
|
178
|
+
url = 'https://dns.api.gandi.net/api/v5/domains/example.com/records/name'
|
179
|
+
body = '{"items":[{"rrset_type":"TXT","rrset_values":["a"]}]}'
|
180
|
+
expect(GandiV5).to receive(:put).with(url, body)
|
181
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
182
|
+
records = [{ type: 'TXT', values: ['a'] }]
|
183
|
+
expect(subject.replace_records_for('name', records)).to eq 'Confirmation message.'
|
184
|
+
end
|
181
185
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
body = '{"rrset_ttl":600,"rrset_values":["192.168.0.1","192.168.0.2"]}'
|
186
|
+
it 'Given type and ttl' do
|
187
|
+
url = 'https://dns.api.gandi.net/api/v5/domains/example.com/records/name/TXT'
|
188
|
+
body = '{"rrset_values":["a"],"rrset_ttl":600}'
|
186
189
|
expect(GandiV5).to receive(:put).with(url, body)
|
187
|
-
.and_return('message' => 'Confirmation message.')
|
188
|
-
expect(subject.
|
190
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
191
|
+
expect(subject.replace_records_for('name', ['a'], type: 'TXT', ttl: 600)).to eq 'Confirmation message.'
|
189
192
|
end
|
190
193
|
|
191
|
-
it '
|
194
|
+
it 'Given type but no ttl' do
|
192
195
|
url = 'https://dns.api.gandi.net/api/v5/domains/example.com/records/name/TXT'
|
193
|
-
body = '{"
|
196
|
+
body = '{"rrset_values":["a"],"rrset_ttl":null}'
|
194
197
|
expect(GandiV5).to receive(:put).with(url, body)
|
195
|
-
.and_return('message' => 'Confirmation message.')
|
196
|
-
expect(subject.
|
198
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
199
|
+
expect(subject.replace_records_for('name', ['a'], type: 'TXT')).to eq 'Confirmation message.'
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'Given ttl but no type' do
|
203
|
+
expect(GandiV5).to_not receive(:put)
|
204
|
+
expect { subject.replace_records_for 'name', 'a', ttl: 600 }.to raise_error ArgumentError, 'missing keyword: type'
|
197
205
|
end
|
198
206
|
end
|
199
207
|
|
@@ -202,7 +210,7 @@ describe GandiV5::LiveDNS::Domain do
|
|
202
210
|
url = 'https://dns.api.gandi.net/api/v5/domains/example.com'
|
203
211
|
body = '{"zone_uuid":"zone-uuid"}'
|
204
212
|
expect(GandiV5).to receive(:patch).with(url, body)
|
205
|
-
.and_return('message' => 'Confirmation message.')
|
213
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
206
214
|
expect(subject.change_zone('zone-uuid')).to eq 'Confirmation message.'
|
207
215
|
expect(subject.zone_uuid).to eq 'zone-uuid'
|
208
216
|
end
|
@@ -211,20 +219,42 @@ describe GandiV5::LiveDNS::Domain do
|
|
211
219
|
url = 'https://dns.api.gandi.net/api/v5/domains/example.com'
|
212
220
|
body = '{"zone_uuid":"zone-uuid"}'
|
213
221
|
expect(GandiV5).to receive(:patch).with(url, body)
|
214
|
-
.and_return('message' => 'Confirmation message.')
|
222
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
215
223
|
zone = double GandiV5::LiveDNS::Zone, uuid: 'zone-uuid'
|
216
224
|
expect(subject.change_zone(zone)).to eq 'Confirmation message.'
|
217
225
|
expect(subject.zone_uuid).to eq 'zone-uuid'
|
218
226
|
end
|
219
227
|
end
|
220
228
|
|
229
|
+
it '#fetch_zone' do
|
230
|
+
returns = double GandiV5::LiveDNS::Zone
|
231
|
+
expect(GandiV5::LiveDNS::Zone).to receive(:fetch).with('zone-uuid')
|
232
|
+
.and_return(returns)
|
233
|
+
expect(subject.fetch_zone).to be returns
|
234
|
+
end
|
235
|
+
|
236
|
+
describe '#zone' do
|
237
|
+
it 'Not previously fetched' do
|
238
|
+
returns = double GandiV5::LiveDNS::Zone
|
239
|
+
expect(subject).to receive(:fetch_zone).and_return(returns)
|
240
|
+
expect(subject.zone).to be returns
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'Previously fetched' do
|
244
|
+
returns = double GandiV5::LiveDNS::Zone
|
245
|
+
subject.instance_exec { @zone = returns }
|
246
|
+
expect(subject).to_not receive(:fetch_zone)
|
247
|
+
expect(subject.zone).to be returns
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
221
251
|
describe '.list' do
|
222
252
|
subject { described_class.list }
|
223
253
|
|
224
254
|
before :each do
|
225
|
-
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Domain', 'list.
|
255
|
+
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Domain', 'list.yml'))
|
226
256
|
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/domains')
|
227
|
-
.and_return(YAML.load_file(body_fixture))
|
257
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
228
258
|
end
|
229
259
|
|
230
260
|
its('count') { should eq 1 }
|
@@ -236,9 +266,9 @@ describe GandiV5::LiveDNS::Domain do
|
|
236
266
|
subject { described_class.fetch 'example.com' }
|
237
267
|
|
238
268
|
before :each do
|
239
|
-
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Domain', '
|
269
|
+
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Domain', 'fetch.yml'))
|
240
270
|
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/domains/example.com')
|
241
|
-
.and_return(YAML.load_file(body_fixture))
|
271
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
242
272
|
end
|
243
273
|
|
244
274
|
its('fqdn') { should eq 'example.com' }
|
@@ -12,17 +12,46 @@ describe GandiV5::LiveDNS::Zone::Snapshot do
|
|
12
12
|
|
13
13
|
it '#delete' do
|
14
14
|
expect(GandiV5).to receive(:delete).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/snapshots/snapshot-uuid')
|
15
|
-
.and_return('message' => 'Confirmation message.')
|
15
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
16
16
|
expect(subject.delete).to eq 'Confirmation message.'
|
17
17
|
end
|
18
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.yml'))
|
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
|
+
|
19
48
|
describe '.fetch' do
|
20
49
|
subject { described_class.fetch 'zone-uuid', 'snapshot-uuid' }
|
21
50
|
|
22
51
|
before :each do
|
23
|
-
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Zone_Snapshot', '
|
52
|
+
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Zone_Snapshot', 'fetch.yml'))
|
24
53
|
expect(GandiV5).to receive(:get).with('https://dns.api.gandi.net/api/v5/zones/zone-uuid/snapshots/snapshot-uuid')
|
25
|
-
.and_return(YAML.load_file(body_fixture))
|
54
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
26
55
|
end
|
27
56
|
|
28
57
|
its('created_at') { should eq Time.new(2016, 12, 16, 16, 51, 26, 0) }
|