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
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe GandiV5::Email::Forward do
|
4
|
+
subject { described_class.new source: 'alice', destinations: ['bob@example.com'], fqdn: 'example.com' }
|
5
|
+
|
6
|
+
describe '#update' do
|
7
|
+
it 'ʘ‿ʘ' do
|
8
|
+
expect(GandiV5).to receive(:put).with(
|
9
|
+
'https://api.gandi.net/v5/email/forwards/example.com/alice',
|
10
|
+
'{"destinations":["bob@example.com","charlie@example.com"]}'
|
11
|
+
)
|
12
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
13
|
+
expect(subject.update('bob@example.com', 'charlie@example.com')).to eq 'Confirmation message.'
|
14
|
+
expect(subject.destinations).to match_array ['bob@example.com', 'charlie@example.com']
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'Empty destinations' do
|
18
|
+
expect { subject.update }.to raise_error ArgumentError, 'destinations can\'t be empty'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it '#delete' do
|
23
|
+
expect(GandiV5).to receive(:delete).with(
|
24
|
+
'https://api.gandi.net/v5/email/forwards/example.com/alice'
|
25
|
+
)
|
26
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
27
|
+
expect(subject.delete).to eq 'Confirmation message.'
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#to_s' do
|
31
|
+
it 'With one destination' do
|
32
|
+
expect(subject.to_s).to eq 'alice@example.com -> bob@example.com'
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'With many destinations' do
|
36
|
+
subject.instance_exec { @destinations = ['bob@example.com', 'charlie@example.com'] }
|
37
|
+
expect(subject.to_s).to eq 'alice@example.com -> bob@example.com, charlie@example.com'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '.create' do
|
42
|
+
it 'ʘ‿ʘ' do
|
43
|
+
response = double(
|
44
|
+
RestClient::Response,
|
45
|
+
headers: { location: 'https://api.gandi.net/v5/email/forwards/example.com/alice' }
|
46
|
+
)
|
47
|
+
expect(GandiV5).to receive(:post).with(
|
48
|
+
'https://api.gandi.net/v5/email/forwards/example.com',
|
49
|
+
'{"source":"alice","destinations":["bob@example.com"]}'
|
50
|
+
)
|
51
|
+
.and_return([response, { 'message' => 'Confirmation message.' }])
|
52
|
+
|
53
|
+
forward = described_class.new fqdn: 'example.com', source: 'alice', destinations: ['bob@example.com']
|
54
|
+
expect(described_class.create('example.com', 'alice', 'bob@example.com').to_h).to eq forward.to_h
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'Empty destinations' do
|
58
|
+
expect { described_class.create('example.com', 'alice') }.to raise_error ArgumentError, 'destinations can\'t be empty'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '.list' do
|
63
|
+
let(:body_fixture) do
|
64
|
+
File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Email_Forward', 'list.yml'))
|
65
|
+
end
|
66
|
+
let(:url) { 'https://api.gandi.net/v5/email/forwards/example.com' }
|
67
|
+
|
68
|
+
describe 'With default values' do
|
69
|
+
subject { described_class.list 'example.com' }
|
70
|
+
|
71
|
+
before :each do
|
72
|
+
expect(GandiV5).to receive(:paginated_get).with(url, (1..), 100, params: {})
|
73
|
+
.and_yield(YAML.load_file(body_fixture))
|
74
|
+
end
|
75
|
+
|
76
|
+
its('count') { should eq 1 }
|
77
|
+
its('first.source') { should eq 'alice' }
|
78
|
+
its('first.destinations') { should match_array ['bob@example.com', 'charlie@example.com'] }
|
79
|
+
its('first.fqdn') { should eq 'example.com' }
|
80
|
+
end
|
81
|
+
|
82
|
+
describe 'Passes optional query params' do
|
83
|
+
%i[source sort_by].each do |param|
|
84
|
+
it param.to_s do
|
85
|
+
headers = { params: { param => 'value' } }
|
86
|
+
expect(GandiV5).to receive(:paginated_get).with(url, (1..), 100, **headers)
|
87
|
+
expect(described_class.list('example.com', param => 'value')).to eq []
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -9,7 +9,7 @@ describe GandiV5::Email::Mailbox do
|
|
9
9
|
|
10
10
|
describe '#refresh' do
|
11
11
|
before :each do
|
12
|
-
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Email_Mailbox', '
|
12
|
+
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Email_Mailbox', 'fetch.yml'))
|
13
13
|
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/mailboxes/example.com/mailbox-uuid')
|
14
14
|
.and_return([nil, YAML.load_file(body_fixture)])
|
15
15
|
subject.refresh
|
@@ -87,6 +87,108 @@ describe GandiV5::Email::Mailbox do
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
+
describe '#upgrade' do
|
91
|
+
let(:url) { 'https://api.gandi.net/v5/email/mailboxes/example.com/mailbox-uuid/type' }
|
92
|
+
|
93
|
+
context 'No sharing_id' do
|
94
|
+
it 'Is upgraded' do
|
95
|
+
expect(GandiV5).to receive(:patch).with(url, '{"mailbox_type":"premium"}', 'Dry-Run': 0)
|
96
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
97
|
+
expect(subject.upgrade).to be true
|
98
|
+
expect(subject.type).to be :premium
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'Is already premium' do
|
102
|
+
subject.instance_exec { @type = :premium }
|
103
|
+
expect(GandiV5).to_not receive(:patch)
|
104
|
+
expect(subject.upgrade).to be false
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'With sharing_id' do
|
109
|
+
let(:url) { 'https://api.gandi.net/v5/email/mailboxes/example.com/mailbox-uuid/type?sharing_id=abc' }
|
110
|
+
|
111
|
+
it 'Is upgraded' do
|
112
|
+
expect(GandiV5).to receive(:patch).with(url, '{"mailbox_type":"premium"}', 'Dry-Run': 0)
|
113
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
114
|
+
expect(subject.upgrade(sharing_id: 'abc')).to be true
|
115
|
+
expect(subject.type).to be :premium
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'Is already premium' do
|
119
|
+
subject.instance_exec { @type = :premium }
|
120
|
+
expect(GandiV5).to_not receive(:patch)
|
121
|
+
expect(subject.upgrade(sharing_id: 'abc')).to be false
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'Dry run' do
|
126
|
+
it 'Is upgraded' do
|
127
|
+
expect(GandiV5).to receive(:patch).with(url, '{"mailbox_type":"premium"}', 'Dry-Run': 1)
|
128
|
+
.and_return([nil, { 'status' => 'success' }])
|
129
|
+
expect(subject.upgrade(dry_run: true)).to eq('status' => 'success')
|
130
|
+
expect(subject.type).to be :standard
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'Is already premium' do
|
134
|
+
subject.instance_exec { @type = :premium }
|
135
|
+
expect(GandiV5).to_not receive(:patch)
|
136
|
+
expect(subject.upgrade(dry_run: true)).to be false
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe '#downgrade' do
|
142
|
+
let(:url) { 'https://api.gandi.net/v5/email/mailboxes/example.com/mailbox-uuid/type' }
|
143
|
+
|
144
|
+
context 'No sharing_id' do
|
145
|
+
it 'Is downgraded' do
|
146
|
+
subject.instance_exec { @type = :premium }
|
147
|
+
expect(GandiV5).to receive(:patch).with(url, '{"mailbox_type":"standard"}', 'Dry-Run': 0)
|
148
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
149
|
+
expect(subject.downgrade).to be true
|
150
|
+
expect(subject.type).to be :standard
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'Is already premium' do
|
154
|
+
expect(GandiV5).to_not receive(:patch)
|
155
|
+
expect(subject.downgrade).to be false
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context 'With sharing_id' do
|
160
|
+
let(:url) { 'https://api.gandi.net/v5/email/mailboxes/example.com/mailbox-uuid/type?sharing_id=abc' }
|
161
|
+
|
162
|
+
it 'Is downgraded' do
|
163
|
+
subject.instance_exec { @type = :premium }
|
164
|
+
expect(GandiV5).to receive(:patch).with(url, '{"mailbox_type":"standard"}', 'Dry-Run': 0)
|
165
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
166
|
+
expect(subject.downgrade(sharing_id: 'abc')).to be true
|
167
|
+
expect(subject.type).to be :standard
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'Is already premium' do
|
171
|
+
expect(GandiV5).to_not receive(:patch)
|
172
|
+
expect(subject.downgrade(sharing_id: 'abc')).to be false
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context 'Dry run' do
|
177
|
+
it 'Is downgraded' do
|
178
|
+
subject.instance_exec { @type = :premium }
|
179
|
+
expect(GandiV5).to receive(:patch).with(url, '{"mailbox_type":"standard"}', 'Dry-Run': 1)
|
180
|
+
.and_return([nil, { 'status' => 'success' }])
|
181
|
+
expect(subject.downgrade(dry_run: true)).to eq('status' => 'success')
|
182
|
+
expect(subject.type).to be :premium
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'Is already premium' do
|
186
|
+
expect(GandiV5).to_not receive(:patch)
|
187
|
+
expect(subject.downgrade(dry_run: true)).to be false
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
90
192
|
it '#delete' do
|
91
193
|
url = 'https://api.gandi.net/v5/email/mailboxes/example.com/mailbox-uuid'
|
92
194
|
expect(GandiV5).to receive(:delete).with(url)
|
@@ -204,7 +306,7 @@ describe GandiV5::Email::Mailbox do
|
|
204
306
|
|
205
307
|
it 'No aliases and :standard type' do
|
206
308
|
body = '{"mailbox_type":"standard","login":"login","password":"crypted_password","aliases":[]}'
|
207
|
-
expect(GandiV5).to receive(:post).with(url, body)
|
309
|
+
expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 0)
|
208
310
|
.and_return([created_response, { 'message' => 'Confirmation message.' }])
|
209
311
|
expect(described_class).to receive(:crypt_password).with(good_password).and_return('crypted_password')
|
210
312
|
expect(described_class).to receive(:fetch).with('example.com', 'created-mailbox-uuid').and_return(created_mailbox)
|
@@ -214,7 +316,7 @@ describe GandiV5::Email::Mailbox do
|
|
214
316
|
|
215
317
|
it 'With aliases' do
|
216
318
|
body = '{"mailbox_type":"standard","login":"login","password":"crypted_password","aliases":["alias-1"]}'
|
217
|
-
expect(GandiV5).to receive(:post).with(url, body)
|
319
|
+
expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 0)
|
218
320
|
.and_return([created_response, { 'message' => 'Confirmation message.' }])
|
219
321
|
expect(described_class).to receive(:crypt_password).with(good_password).and_return('crypted_password')
|
220
322
|
expect(described_class).to receive(:fetch).with('example.com', 'created-mailbox-uuid').and_return(created_mailbox)
|
@@ -224,7 +326,7 @@ describe GandiV5::Email::Mailbox do
|
|
224
326
|
|
225
327
|
it 'With different type' do
|
226
328
|
body = '{"mailbox_type":"premium","login":"login","password":"crypted_password","aliases":[]}'
|
227
|
-
expect(GandiV5).to receive(:post).with(url, body)
|
329
|
+
expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 0)
|
228
330
|
.and_return([created_response, { 'message' => 'Confirmation message.' }])
|
229
331
|
expect(described_class).to receive(:crypt_password).with(good_password).and_return('crypted_password')
|
230
332
|
expect(described_class).to receive(:fetch).with('example.com', 'created-mailbox-uuid').and_return(created_mailbox)
|
@@ -254,13 +356,23 @@ describe GandiV5::Email::Mailbox do
|
|
254
356
|
'no available standard slots'
|
255
357
|
)
|
256
358
|
end
|
359
|
+
|
360
|
+
it 'Doing a dry run' do
|
361
|
+
body = '{"mailbox_type":"standard","login":"login","password":"crypted_password","aliases":[]}'
|
362
|
+
expect(GandiV5).to receive(:post).with(url, body, 'Dry-Run': 1)
|
363
|
+
.and_return([nil, { 'status' => 'success' }])
|
364
|
+
expect(described_class).to receive(:crypt_password).with(good_password).and_return('crypted_password')
|
365
|
+
expect(described_class).to_not receive(:fetch)
|
366
|
+
|
367
|
+
expect(described_class.create('example.com', 'login', good_password, dry_run: true)).to eq('status' => 'success')
|
368
|
+
end
|
257
369
|
end
|
258
370
|
|
259
371
|
describe '.fetch' do
|
260
372
|
subject { described_class.fetch 'example.com', 'mailbox-uuid' }
|
261
373
|
|
262
374
|
before :each do
|
263
|
-
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Email_Mailbox', '
|
375
|
+
body_fixture = File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Email_Mailbox', 'fetch.yml'))
|
264
376
|
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/mailboxes/example.com/mailbox-uuid')
|
265
377
|
.and_return([nil, YAML.load_file(body_fixture)])
|
266
378
|
end
|
@@ -281,16 +393,16 @@ describe GandiV5::Email::Mailbox do
|
|
281
393
|
|
282
394
|
describe '.list' do
|
283
395
|
let(:body_fixture) do
|
284
|
-
File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Email_Mailbox', 'list.
|
396
|
+
File.expand_path(File.join('spec', 'fixtures', 'bodies', 'GandiV5_Email_Mailbox', 'list.yml'))
|
285
397
|
end
|
398
|
+
let(:url) { 'https://api.gandi.net/v5/email/mailboxes/example.com' }
|
286
399
|
|
287
400
|
describe 'With default values' do
|
288
401
|
subject { described_class.list 'example.com' }
|
289
402
|
|
290
403
|
before :each do
|
291
|
-
|
292
|
-
|
293
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
404
|
+
expect(GandiV5).to receive(:paginated_get).with(url, (1..), 100, params: {})
|
405
|
+
.and_yield(YAML.load_file(body_fixture))
|
294
406
|
end
|
295
407
|
|
296
408
|
its('count') { should eq 1 }
|
@@ -302,43 +414,13 @@ describe GandiV5::Email::Mailbox do
|
|
302
414
|
its('first.quota_used') { should eq 1_000_000 }
|
303
415
|
end
|
304
416
|
|
305
|
-
it 'Keeps fetching until no more to get' do
|
306
|
-
headers1 = { params: { page: 1, per_page: 1 } }
|
307
|
-
headers2 = { params: { page: 2, per_page: 1 } }
|
308
|
-
# https://github.com/rubocop-hq/rubocop/issues/7088
|
309
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/mailboxes/example.com', headers1)
|
310
|
-
.ordered
|
311
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
312
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/mailboxes/example.com', headers2)
|
313
|
-
.ordered
|
314
|
-
.and_return([nil, []])
|
315
|
-
|
316
|
-
expect(described_class.list('example.com', per_page: 1).count).to eq 1
|
317
|
-
end
|
318
|
-
|
319
|
-
it 'Given a range as page number' do
|
320
|
-
headers1 = { params: { page: 1, per_page: 1 } }
|
321
|
-
headers2 = { params: { page: 2, per_page: 1 } }
|
322
|
-
# https://github.com/rubocop-hq/rubocop/issues/7088
|
323
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/mailboxes/example.com', headers1)
|
324
|
-
.ordered
|
325
|
-
.and_return([nil, YAML.load_file(body_fixture)])
|
326
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/mailboxes/example.com', headers2)
|
327
|
-
.ordered
|
328
|
-
.and_return([nil, []])
|
329
|
-
|
330
|
-
expect(described_class.list('example.com', page: (1..2), per_page: 1).count).to eq 1
|
331
|
-
end
|
332
|
-
|
333
417
|
describe 'Passes optional query params' do
|
334
418
|
{
|
335
419
|
login: '~login',
|
336
420
|
sort_by: :sort_by
|
337
421
|
}.each do |param, query_param|
|
338
422
|
it param.to_s do
|
339
|
-
|
340
|
-
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/mailboxes/example.com', headers)
|
341
|
-
.and_return([nil, []])
|
423
|
+
expect(GandiV5).to receive(:paginated_get).with(url, (1..), 100, params: { query_param => 'value' })
|
342
424
|
expect(described_class.list('example.com', param => 'value')).to eq []
|
343
425
|
end
|
344
426
|
end
|
@@ -28,7 +28,7 @@ describe GandiV5::Email::Slot do
|
|
28
28
|
|
29
29
|
describe '#refresh' do
|
30
30
|
before :each do
|
31
|
-
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'))
|
32
32
|
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/slots/example.com/123')
|
33
33
|
.and_return([nil, YAML.load_file(body_fixture)])
|
34
34
|
subject.refresh
|
@@ -130,7 +130,7 @@ describe GandiV5::Email::Slot do
|
|
130
130
|
end
|
131
131
|
let(:created_slot) { double GandiV5::Email::Slot }
|
132
132
|
|
133
|
-
it 'With default type' do
|
133
|
+
it 'With default type and no sharingID' do
|
134
134
|
expect(GandiV5).to receive(:post).with(url, '{"mailbox_type":"standard"}')
|
135
135
|
.and_return([created_response, { 'message' => 'Confirmation message.' }])
|
136
136
|
expect(described_class).to receive(:fetch).with('example.com', 'created-slot-uuid').and_return(created_slot)
|
@@ -143,7 +143,15 @@ describe GandiV5::Email::Slot do
|
|
143
143
|
.and_return([created_response, { 'message' => 'Confirmation message.' }])
|
144
144
|
expect(described_class).to receive(:fetch).with('example.com', 'created-slot-uuid').and_return(created_slot)
|
145
145
|
|
146
|
-
expect(described_class.create('example.com', :premium)).to be created_slot
|
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
|
147
155
|
end
|
148
156
|
end
|
149
157
|
|
@@ -151,7 +159,7 @@ describe GandiV5::Email::Slot do
|
|
151
159
|
subject { described_class.fetch 'example.com', 123 }
|
152
160
|
|
153
161
|
before :each do
|
154
|
-
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'))
|
155
163
|
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/slots/example.com/123')
|
156
164
|
.and_return([nil, YAML.load_file(body_fixture)])
|
157
165
|
end
|
@@ -171,7 +179,7 @@ describe GandiV5::Email::Slot do
|
|
171
179
|
subject { described_class.list 'example.com' }
|
172
180
|
|
173
181
|
before :each do
|
174
|
-
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'))
|
175
183
|
expect(GandiV5).to receive(:get).with('https://api.gandi.net/v5/email/slots/example.com')
|
176
184
|
.and_return([nil, YAML.load_file(body_fixture)])
|
177
185
|
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe GandiV5::LiveDNS::Domain::DnssecKey do
|
4
|
+
subject do
|
5
|
+
described_class.new(
|
6
|
+
uuid: 'key-uuid',
|
7
|
+
status: 'status',
|
8
|
+
fqdn: 'example.com',
|
9
|
+
algorithm_id: 2,
|
10
|
+
algorithm_name: 'Diffie-Hellman',
|
11
|
+
deleted: false,
|
12
|
+
ds: 'ds-record',
|
13
|
+
flags: 256,
|
14
|
+
fingerprint: 'fp',
|
15
|
+
public_key: 'pub-key',
|
16
|
+
tag: 'tag'
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
it '#delete' do
|
21
|
+
expect(GandiV5).to receive(:delete).with('https://api.gandi.net/v5/livedns/domains/example.com/keys/key-uuid')
|
22
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
23
|
+
expect(subject.delete).to eq 'Confirmation message.'
|
24
|
+
expect(subject.deleted).to be true
|
25
|
+
end
|
26
|
+
|
27
|
+
it '#undelete' do
|
28
|
+
subject = described_class.new deleted: true, uuid: 'key-uuid', fqdn: 'example.com'
|
29
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/keys/key-uuid'
|
30
|
+
expect(GandiV5).to receive(:patch).with(url, '{"deleted":false}')
|
31
|
+
.and_return([nil, { 'message' => 'Confirmation message.' }])
|
32
|
+
expect(subject.undelete).to eq 'Confirmation message.'
|
33
|
+
expect(subject.deleted).to be false
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'flags helper methods' do
|
37
|
+
describe '256 (zone signing key)' do
|
38
|
+
before(:each) { subject.instance_exec { @flags = 256 } }
|
39
|
+
its('zone_signing_key?') { should be true }
|
40
|
+
its('key_signing_key?') { should be false }
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '257 (key signing key)' do
|
44
|
+
before(:each) { subject.instance_exec { @flags = 257 } }
|
45
|
+
its('zone_signing_key?') { should be false }
|
46
|
+
its('key_signing_key?') { should be true }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '.create' do
|
51
|
+
let(:url) { 'https://api.gandi.net/v5/livedns/domains/example.com/keys' }
|
52
|
+
let(:response) do
|
53
|
+
double RestClient::Response, headers: {
|
54
|
+
location: 'https://api.gandi.net/v5/livedns/domains/example.com/keys/created-key-uuid'
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'Accepts integer for flags' do
|
59
|
+
returns = double described_class
|
60
|
+
expect(GandiV5).to receive(:post).with(url, '{"flags":256}').and_return([response, nil])
|
61
|
+
expect(described_class).to receive(:fetch).with('example.com', 'created-key-uuid')
|
62
|
+
.and_return(returns)
|
63
|
+
expect(described_class.create('example.com', :zone_signing_key)).to be returns
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'Accepts :zone_signing_key for flags' do
|
67
|
+
expect(GandiV5).to receive(:post).with(url, '{"flags":256}').and_return([response, nil])
|
68
|
+
expect(described_class).to receive(:fetch)
|
69
|
+
described_class.create('example.com', :zone_signing_key)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'Accepts :key_signing_key for flags' do
|
73
|
+
expect(GandiV5).to receive(:post).with(url, '{"flags":257}').and_return([response, nil])
|
74
|
+
expect(described_class).to receive(:fetch)
|
75
|
+
described_class.create('example.com', :key_signing_key)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'Fails on invalid flags' do
|
79
|
+
expect { described_class.create('example.com', :invalid) }.to raise_error ArgumentError, 'flags is invalid'
|
80
|
+
expect { described_class.create('example.com', '0') }.to raise_error ArgumentError, 'flags is invalid'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
it '.list' do
|
85
|
+
body_fixture = File.expand_path(
|
86
|
+
File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Domain_DnssecKey', 'list.yml')
|
87
|
+
)
|
88
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/keys'
|
89
|
+
|
90
|
+
expect(GandiV5).to receive(:get).with(url).and_return([nil, YAML.load_file(body_fixture)])
|
91
|
+
results = described_class.list('example.com')
|
92
|
+
result = results.first
|
93
|
+
expect(results.count).to eq 1
|
94
|
+
expect(result.uuid).to eq 'key-uuid'
|
95
|
+
expect(result.status).to eq 'status'
|
96
|
+
expect(result.fqdn).to eq 'example.com'
|
97
|
+
expect(result.algorithm_id).to eq 2
|
98
|
+
expect(result.algorithm_name).to eq 'Diffie-Hellman'
|
99
|
+
expect(result.deleted).to be false
|
100
|
+
expect(result.ds).to eq 'ds-record'
|
101
|
+
expect(result.flags).to eq 256
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '.fetch' do
|
105
|
+
subject { described_class.fetch 'example.com', 'key-uuid' }
|
106
|
+
|
107
|
+
before :each do
|
108
|
+
body_fixture = File.expand_path(
|
109
|
+
File.join('spec', 'fixtures', 'bodies', 'GandiV5_LiveDNS_Domain_DnssecKey', 'fetch.yml')
|
110
|
+
)
|
111
|
+
url = 'https://api.gandi.net/v5/livedns/domains/example.com/keys/key-uuid'
|
112
|
+
expect(GandiV5).to receive(:get).with(url)
|
113
|
+
.and_return([nil, YAML.load_file(body_fixture)])
|
114
|
+
end
|
115
|
+
|
116
|
+
its('uuid') { should eq 'key-uuid' }
|
117
|
+
its('status') { should eq 'status' }
|
118
|
+
its('fqdn') { should eq 'example.com' }
|
119
|
+
its('algorithm_id') { should eq 2 }
|
120
|
+
its('algorithm_name') { should eq 'Diffie-Hellman' }
|
121
|
+
its('deleted') { should be false }
|
122
|
+
its('ds') { should eq 'ds-record' }
|
123
|
+
its('flags') { should eq 256 }
|
124
|
+
its('fingerprint') { should eq 'fp' }
|
125
|
+
its('public_key') { should eq 'pub-key' }
|
126
|
+
its('tag') { should eq 'tag' }
|
127
|
+
end
|
128
|
+
end
|