gandi_v5 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/.rspec +3 -0
- data/.rubocop.yml +20 -0
- data/.travis.yml +23 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +6 -0
- data/Guardfile +40 -0
- data/LICENSE.md +32 -0
- data/README.md +94 -0
- data/Rakefile +3 -0
- data/TODO.md +29 -0
- data/bin/console +13 -0
- data/gandi_v5.gemspec +41 -0
- data/lib/gandi_v5/billing/info/prepaid.rb +33 -0
- data/lib/gandi_v5/billing/info.rb +26 -0
- data/lib/gandi_v5/billing.rb +28 -0
- data/lib/gandi_v5/data/converter/array_of.rb +35 -0
- data/lib/gandi_v5/data/converter/symbol.rb +26 -0
- data/lib/gandi_v5/data/converter/time.rb +28 -0
- data/lib/gandi_v5/data/converter.rb +41 -0
- data/lib/gandi_v5/data.rb +244 -0
- data/lib/gandi_v5/domain/auto_renew.rb +64 -0
- data/lib/gandi_v5/domain/contact.rb +102 -0
- data/lib/gandi_v5/domain/contract.rb +22 -0
- data/lib/gandi_v5/domain/dates.rb +44 -0
- data/lib/gandi_v5/domain/renewal_information.rb +41 -0
- data/lib/gandi_v5/domain/restore_information.rb +18 -0
- data/lib/gandi_v5/domain/sharing_space.rb +21 -0
- data/lib/gandi_v5/domain.rb +431 -0
- data/lib/gandi_v5/email/mailbox/responder.rb +36 -0
- data/lib/gandi_v5/email/mailbox.rb +236 -0
- data/lib/gandi_v5/email/offer.rb +27 -0
- data/lib/gandi_v5/email/slot.rb +134 -0
- data/lib/gandi_v5/email.rb +11 -0
- data/lib/gandi_v5/error/gandi_error.rb +21 -0
- data/lib/gandi_v5/error.rb +9 -0
- data/lib/gandi_v5/live_dns/domain.rb +211 -0
- data/lib/gandi_v5/live_dns/record_set.rb +79 -0
- data/lib/gandi_v5/live_dns/zone/snapshot.rb +62 -0
- data/lib/gandi_v5/live_dns/zone.rb +301 -0
- data/lib/gandi_v5/live_dns.rb +30 -0
- data/lib/gandi_v5/organization.rb +66 -0
- data/lib/gandi_v5/version.rb +5 -0
- data/lib/gandi_v5.rb +178 -0
- data/spec/.rubocop.yml +4 -0
- data/spec/features/domain_spec.rb +45 -0
- data/spec/features/livedns_domain_spec.rb +8 -0
- data/spec/features/livedns_zone_spec.rb +45 -0
- data/spec/features/mailbox_spec.rb +18 -0
- data/spec/fixtures/bodies/GandiV5_Billing/info.yaml +10 -0
- data/spec/fixtures/bodies/GandiV5_Domain/availability.yaml +15 -0
- data/spec/fixtures/bodies/GandiV5_Domain/fetch_contacts.yaml +8 -0
- data/spec/fixtures/bodies/GandiV5_Domain/get.yaml +37 -0
- data/spec/fixtures/bodies/GandiV5_Domain/list.yaml +20 -0
- data/spec/fixtures/bodies/GandiV5_Domain/renewal_info.yaml +12 -0
- data/spec/fixtures/bodies/GandiV5_Domain/restore_info.yaml +5 -0
- data/spec/fixtures/bodies/GandiV5_Domain/tld.yaml +10 -0
- data/spec/fixtures/bodies/GandiV5_Domain/tlds.yaml +7 -0
- data/spec/fixtures/bodies/GandiV5_Email_Mailbox/get.yaml +16 -0
- data/spec/fixtures/bodies/GandiV5_Email_Mailbox/list.yaml +8 -0
- data/spec/fixtures/bodies/GandiV5_Email_Slot/get.yaml +10 -0
- data/spec/fixtures/bodies/GandiV5_Email_Slot/list.yaml +8 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/get.yaml +4 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/list.yaml +2 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/get.yaml +11 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/list.yaml +11 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/get.yaml +9 -0
- data/spec/fixtures/bodies/GandiV5_Organization/get.yaml +17 -0
- data/spec/fixtures/vcr/Domain_features/List_domains.yml +54 -0
- data/spec/fixtures/vcr/Domain_features/Renew_domain.yml +133 -0
- data/spec/fixtures/vcr/LiveDNS_Domain_features/List_domains.yml +32 -0
- data/spec/fixtures/vcr/LiveDNS_Zone_features/List_zones.yml +42 -0
- data/spec/fixtures/vcr/LiveDNS_Zone_features/Make_and_save_snapshot.yml +72 -0
- data/spec/fixtures/vcr/LiveDNS_Zone_features/Save_zone_to_file.yml +28 -0
- data/spec/fixtures/vcr/Mailbox_features/List_mailboxes.yml +39 -0
- data/spec/spec_helper.rb +60 -0
- data/spec/test.env +1 -0
- data/spec/units/gandi_v5/billing/info/prepaid_spec.rb +20 -0
- data/spec/units/gandi_v5/billing/info_spec.rb +4 -0
- data/spec/units/gandi_v5/billing_spec.rb +41 -0
- data/spec/units/gandi_v5/data/converter/array_of_spec.rb +18 -0
- data/spec/units/gandi_v5/data/converter/symbol_spec.rb +16 -0
- data/spec/units/gandi_v5/data/converter/time_spec.rb +16 -0
- data/spec/units/gandi_v5/data/converter_spec.rb +31 -0
- data/spec/units/gandi_v5/data_spec.rb +340 -0
- data/spec/units/gandi_v5/domain/auto_renew_spec.rb +70 -0
- data/spec/units/gandi_v5/domain/contact_spec.rb +36 -0
- data/spec/units/gandi_v5/domain/contract_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/dates_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/renewal_information_spec.rb +81 -0
- data/spec/units/gandi_v5/domain/restore_information_spec.rb +4 -0
- data/spec/units/gandi_v5/domain/sharing_space_spec.rb +4 -0
- data/spec/units/gandi_v5/domain_spec.rb +451 -0
- data/spec/units/gandi_v5/email/mailbox/responder_spec.rb +131 -0
- data/spec/units/gandi_v5/email/mailbox_spec.rb +384 -0
- data/spec/units/gandi_v5/email/offer_spec.rb +17 -0
- data/spec/units/gandi_v5/email/slot_spec.rb +102 -0
- data/spec/units/gandi_v5/error/gandi_error_spec.rb +30 -0
- data/spec/units/gandi_v5/error_spec.rb +4 -0
- data/spec/units/gandi_v5/live_dns/domain_spec.rb +247 -0
- data/spec/units/gandi_v5/live_dns/record_set_spec.rb +74 -0
- data/spec/units/gandi_v5/live_dns/zone/snapshot_spec.rb +37 -0
- data/spec/units/gandi_v5/live_dns/zone_spec.rb +329 -0
- data/spec/units/gandi_v5/live_dns_spec.rb +17 -0
- data/spec/units/gandi_v5/organization_spec.rb +30 -0
- data/spec/units/gandi_v5_spec.rb +204 -0
- metadata +406 -0
@@ -0,0 +1,340 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe GandiV5::Data do
|
4
|
+
around(:each) do |example|
|
5
|
+
# Class used for testing GandiV5::Data by including it.
|
6
|
+
class DataTestClass
|
7
|
+
include GandiV5::Data
|
8
|
+
|
9
|
+
members :basic
|
10
|
+
member :str_to_sym, converter: GandiV5::Data::Converter::Symbol
|
11
|
+
member :arr_of_str_to_sym, converter: GandiV5::Data::Converter::Symbol, array: true
|
12
|
+
member :diff_name, gandi_key: 'DiffName'
|
13
|
+
end
|
14
|
+
|
15
|
+
example.run
|
16
|
+
|
17
|
+
Object.send(:remove_const, :DataTestClass)
|
18
|
+
end
|
19
|
+
|
20
|
+
subject { DataTestClass.new }
|
21
|
+
|
22
|
+
describe '#initialize' do
|
23
|
+
describe 'Given expected data' do
|
24
|
+
subject { DataTestClass.new basic: :a, str_to_sym: :b, arr_of_str_to_sym: [:c], diff_name: :d }
|
25
|
+
|
26
|
+
its('basic') { should be :a }
|
27
|
+
its('str_to_sym') { should be :b }
|
28
|
+
its('arr_of_str_to_sym') { should match_array [:c] }
|
29
|
+
its('diff_name') { should be :d }
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'Given unexpected data' do
|
33
|
+
expect { DataTestClass.new no_member_by_this_name: :a }.to raise_error(
|
34
|
+
ArgumentError,
|
35
|
+
'unknown keyword: no_member_by_this_name'
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#to_h' do
|
41
|
+
it 'Everything is blank' do
|
42
|
+
expect(subject.to_h).to eq basic: nil, str_to_sym: nil, arr_of_str_to_sym: nil, diff_name: nil
|
43
|
+
end
|
44
|
+
|
45
|
+
it ':basic contains an enumerable with #transform_keys' do
|
46
|
+
subject = DataTestClass.new basic: { a: 'a' }
|
47
|
+
expect(subject.to_h).to include(basic: { a: 'a' })
|
48
|
+
end
|
49
|
+
|
50
|
+
it ':basic contains an enumerable with #map' do
|
51
|
+
subject = DataTestClass.new basic: ['a']
|
52
|
+
expect(subject.to_h).to include(basic: ['a'])
|
53
|
+
end
|
54
|
+
|
55
|
+
it ':basic contains an enumerable with values with #to_h' do
|
56
|
+
value = double Object
|
57
|
+
expect(value).to receive(:to_h).and_return('a' => 'a')
|
58
|
+
subject = DataTestClass.new basic: [value]
|
59
|
+
expect(subject.to_h).to include(basic: [{ 'a' => 'a' }])
|
60
|
+
end
|
61
|
+
|
62
|
+
it ':basic contains an enumerable with values without #to_h' do
|
63
|
+
subject = DataTestClass.new basic: ['a']
|
64
|
+
expect(subject.to_h).to include(basic: ['a'])
|
65
|
+
end
|
66
|
+
|
67
|
+
it ':basic contains a value with #to_h' do
|
68
|
+
value = double Object
|
69
|
+
expect(value).to receive(:to_h).and_return('a' => 'a')
|
70
|
+
subject = DataTestClass.new basic: value
|
71
|
+
expect(subject.to_h).to include(basic: { 'a' => 'a' })
|
72
|
+
end
|
73
|
+
|
74
|
+
it ':str_to_sym is not converted' do
|
75
|
+
subject = DataTestClass.new str_to_sym: :a
|
76
|
+
expect(subject.to_h).to include(str_to_sym: :a)
|
77
|
+
end
|
78
|
+
|
79
|
+
it ':arr_of_str_to_sym is not converted' do
|
80
|
+
subject = DataTestClass.new arr_of_str_to_sym: [:a]
|
81
|
+
expect(subject.to_h).to include(arr_of_str_to_sym: [:a])
|
82
|
+
end
|
83
|
+
|
84
|
+
it ':diff_name has correct key' do
|
85
|
+
subject = DataTestClass.new diff_name: 'a'
|
86
|
+
expect(subject.to_h).to include(diff_name: 'a')
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#to_gandi' do
|
91
|
+
it 'Everything is blank' do
|
92
|
+
expect(subject.to_gandi).to eq 'basic' => nil, 'str_to_sym' => nil, 'arr_of_str_to_sym' => nil, 'DiffName' => nil
|
93
|
+
end
|
94
|
+
|
95
|
+
it ':basic contains an enumerable with #transform_keys' do
|
96
|
+
subject = DataTestClass.new basic: { a: 'a' }
|
97
|
+
expect(subject.to_gandi).to include('basic' => { a: 'a' })
|
98
|
+
end
|
99
|
+
|
100
|
+
it ':basic contains an enumerable with #map' do
|
101
|
+
subject = DataTestClass.new basic: ['a']
|
102
|
+
expect(subject.to_gandi).to include('basic' => ['a'])
|
103
|
+
end
|
104
|
+
|
105
|
+
it ':basic contains a value with #to_gandi' do
|
106
|
+
value = double Object
|
107
|
+
expect(value).to receive(:to_gandi).and_return('a' => 'a')
|
108
|
+
subject = DataTestClass.new basic: value
|
109
|
+
expect(subject.to_gandi).to include('basic' => { 'a' => 'a' })
|
110
|
+
end
|
111
|
+
|
112
|
+
it ':str_to_sym is converted' do
|
113
|
+
subject = DataTestClass.new str_to_sym: :a
|
114
|
+
expect(subject.to_gandi).to include('str_to_sym' => 'a')
|
115
|
+
end
|
116
|
+
|
117
|
+
it ':arr_of_str_to_sym is converted' do
|
118
|
+
subject = DataTestClass.new arr_of_str_to_sym: [:a]
|
119
|
+
expect(subject.to_gandi).to include('arr_of_str_to_sym' => ['a'])
|
120
|
+
end
|
121
|
+
|
122
|
+
it ':diff_name has correct key' do
|
123
|
+
subject = DataTestClass.new diff_name: 'a'
|
124
|
+
expect(subject.to_gandi).to include('DiffName' => 'a')
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe '#values_at' do
|
129
|
+
let(:basic) { DataTestClass.new basic: :basic }
|
130
|
+
subject { DataTestClass.new basic: basic, arr_of_str_to_sym: [:a] }
|
131
|
+
|
132
|
+
it 'basic' do
|
133
|
+
expect(subject.basic).to be basic
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'basic.basic' do
|
137
|
+
expect(subject.basic.basic).to be :basic
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'no_member_by_this_name' do
|
141
|
+
expect { subject.values_at(:no_member_by_this_name) }.to raise_error(
|
142
|
+
ArgumentError,
|
143
|
+
'no_member_by_this_name is not a member.'
|
144
|
+
)
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'basic.no_member_by_this_name' do
|
148
|
+
expect { subject.values_at('basic.no_member_by_this_name') }.to raise_error(
|
149
|
+
ArgumentError,
|
150
|
+
'no_member_by_this_name is not a member.'
|
151
|
+
)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe '#from_gandi' do
|
156
|
+
describe 'Everything is blank' do
|
157
|
+
subject { DataTestClass.new.from_gandi({}) }
|
158
|
+
|
159
|
+
its('basic') { should be nil }
|
160
|
+
its('str_to_sym') { should be nil }
|
161
|
+
its('arr_of_str_to_sym') { should be nil }
|
162
|
+
its('diff_name') { should be nil }
|
163
|
+
end
|
164
|
+
|
165
|
+
it ':basic is left alone' do
|
166
|
+
subject.from_gandi 'basic' => 'left_alone'
|
167
|
+
expect(subject.basic).to be 'left_alone'
|
168
|
+
end
|
169
|
+
|
170
|
+
it ':str_to_sym is converted' do
|
171
|
+
subject.from_gandi 'str_to_sym' => 'converted'
|
172
|
+
expect(subject.str_to_sym).to be :converted
|
173
|
+
end
|
174
|
+
|
175
|
+
it ':arr_of_str_to_sym is converted' do
|
176
|
+
subject.from_gandi 'arr_of_str_to_sym' => ['converted']
|
177
|
+
expect(subject.arr_of_str_to_sym).to match_array [:converted]
|
178
|
+
end
|
179
|
+
|
180
|
+
it ':diff_name has correct key' do
|
181
|
+
subject.from_gandi 'DiffName' => 'left_alone'
|
182
|
+
expect(subject.diff_name).to be 'left_alone'
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'returns self' do
|
186
|
+
expect(subject.from_gandi({})).to be subject
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe '.from_gandi' do
|
191
|
+
it 'Given nothing' do
|
192
|
+
expect(DataTestClass.from_gandi(nil)).to be nil
|
193
|
+
end
|
194
|
+
|
195
|
+
describe 'Everything is blank' do
|
196
|
+
subject { DataTestClass.from_gandi({}) }
|
197
|
+
|
198
|
+
its('basic') { should be nil }
|
199
|
+
its('str_to_sym') { should be nil }
|
200
|
+
its('arr_of_str_to_sym') { should be nil }
|
201
|
+
its('diff_name') { should be nil }
|
202
|
+
end
|
203
|
+
|
204
|
+
it ':basic is left alone' do
|
205
|
+
subject = DataTestClass.from_gandi 'basic' => 'left_alone'
|
206
|
+
expect(subject.basic).to be 'left_alone'
|
207
|
+
end
|
208
|
+
|
209
|
+
it ':str_to_sym is converted' do
|
210
|
+
subject = DataTestClass.from_gandi 'str_to_sym' => 'converted'
|
211
|
+
expect(subject.str_to_sym).to be :converted
|
212
|
+
end
|
213
|
+
|
214
|
+
it ':arr_of_str_to_sym is converted' do
|
215
|
+
subject = DataTestClass.from_gandi 'arr_of_str_to_sym' => ['converted']
|
216
|
+
expect(subject.arr_of_str_to_sym).to match_array [:converted]
|
217
|
+
end
|
218
|
+
|
219
|
+
it ':diff_name has correct key' do
|
220
|
+
subject = DataTestClass.from_gandi 'DiffName' => 'left_alone'
|
221
|
+
expect(subject.diff_name).to be 'left_alone'
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'returns a DataTestClass' do
|
225
|
+
expect(DataTestClass.from_gandi({})).to be_a DataTestClass
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
describe 'Attribute methods' do
|
230
|
+
it '#basic=' do
|
231
|
+
expect(subject.instance_variable_get(:@basic)).to be nil
|
232
|
+
subject.send :basic=, :a
|
233
|
+
expect(subject.instance_variable_get(:@basic)).to be :a
|
234
|
+
end
|
235
|
+
|
236
|
+
describe 'Is nil' do
|
237
|
+
before(:each) { subject.send :basic=, nil }
|
238
|
+
|
239
|
+
it('#basic?') { expect(subject.basic?).to be false }
|
240
|
+
it('#basic') { expect(subject.basic).to be nil }
|
241
|
+
end
|
242
|
+
|
243
|
+
describe 'Is something' do
|
244
|
+
let(:value) { double Object }
|
245
|
+
before(:each) { subject.send :basic=, value }
|
246
|
+
|
247
|
+
it('#basic?') { expect(subject.basic?).to be true }
|
248
|
+
it('#basic') { expect(subject.basic).to be value }
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
describe 'Internal API methods' do
|
253
|
+
it '#data_members' do
|
254
|
+
expect(subject.send(:data_members)).to match_array %i[basic str_to_sym arr_of_str_to_sym diff_name]
|
255
|
+
end
|
256
|
+
|
257
|
+
it '#data_member?' do
|
258
|
+
expect(subject.send(:data_member?, :basic)).to be true
|
259
|
+
expect(subject.send(:data_member?, :no_member_by_this_name)).to be false
|
260
|
+
end
|
261
|
+
|
262
|
+
it '#data_gandi_key_to_member' do
|
263
|
+
expect(subject.send(:data_gandi_key_to_member, 'basic')).to be :basic
|
264
|
+
expect(subject.send(:data_gandi_key_to_member, 'DiffName')).to be :diff_name
|
265
|
+
expect { subject.send(:data_gandi_key_to_member, 'no_member_by_this_name') }.to raise_error KeyError
|
266
|
+
end
|
267
|
+
|
268
|
+
it '#data_member_to_gandi_key' do
|
269
|
+
expect(subject.send(:data_member_to_gandi_key, :basic)).to eq 'basic'
|
270
|
+
expect(subject.send(:data_member_to_gandi_key, :diff_name)).to eq 'DiffName'
|
271
|
+
expect { subject.send(:data_member_to_gandi_key, :no_member_by_this_name) }.to raise_error KeyError
|
272
|
+
end
|
273
|
+
|
274
|
+
it '#data_converter_for' do
|
275
|
+
expect(subject.send(:data_converter_for, :basic)).to be nil
|
276
|
+
expect(subject.send(:data_converter_for, :str_to_sym)).to be GandiV5::Data::Converter::Symbol
|
277
|
+
expect(subject.send(:data_converter_for, :no_member_by_this_name)).to be nil
|
278
|
+
end
|
279
|
+
|
280
|
+
it '#data_converter_for?' do
|
281
|
+
expect(subject.send(:data_converter_for?, :basic)).to be false
|
282
|
+
expect(subject.send(:data_converter_for?, :str_to_sym)).to be true
|
283
|
+
expect(subject.send(:data_converter_for?, :no_member_by_this_name)).to be false
|
284
|
+
end
|
285
|
+
|
286
|
+
it '.data_members' do
|
287
|
+
expect(DataTestClass.send(:data_members)).to match_array %i[basic str_to_sym arr_of_str_to_sym diff_name]
|
288
|
+
end
|
289
|
+
|
290
|
+
it '.data_member?' do
|
291
|
+
expect(DataTestClass.send(:data_member?, :basic)).to be true
|
292
|
+
expect(DataTestClass.send(:data_member?, :no_member_by_this_name)).to be false
|
293
|
+
end
|
294
|
+
|
295
|
+
it '.data_gandi_key_to_member' do
|
296
|
+
expect(DataTestClass.send(:data_gandi_key_to_member, 'basic')).to be :basic
|
297
|
+
expect(DataTestClass.send(:data_gandi_key_to_member, 'DiffName')).to be :diff_name
|
298
|
+
expect { DataTestClass.send(:data_gandi_key_to_member, 'no_member_by_this_name') }.to raise_error KeyError
|
299
|
+
end
|
300
|
+
|
301
|
+
it '.data_member_to_gandi_key' do
|
302
|
+
expect(DataTestClass.send(:data_member_to_gandi_key, :basic)).to eq 'basic'
|
303
|
+
expect(DataTestClass.send(:data_member_to_gandi_key, :diff_name)).to eq 'DiffName'
|
304
|
+
expect { DataTestClass.send(:data_member_to_gandi_key, :no_member_by_this_name) }.to raise_error KeyError
|
305
|
+
end
|
306
|
+
|
307
|
+
it '.data_converter_for' do
|
308
|
+
expect(DataTestClass.send(:data_converter_for, :basic)).to be nil
|
309
|
+
expect(DataTestClass.send(:data_converter_for, :str_to_sym)).to be GandiV5::Data::Converter::Symbol
|
310
|
+
expect(DataTestClass.send(:data_converter_for, :no_member_by_this_name)).to be nil
|
311
|
+
end
|
312
|
+
|
313
|
+
it '.data_converter_for?' do
|
314
|
+
expect(DataTestClass.send(:data_converter_for?, :basic)).to be false
|
315
|
+
expect(DataTestClass.send(:data_converter_for?, :str_to_sym)).to be true
|
316
|
+
expect(DataTestClass.send(:data_converter_for?, :no_member_by_this_name)).to be false
|
317
|
+
end
|
318
|
+
|
319
|
+
describe '.translate_gandi' do
|
320
|
+
it 'Not given a Hash' do
|
321
|
+
expect(DataTestClass.send(:translate_gandi, [])).to be_nil
|
322
|
+
end
|
323
|
+
|
324
|
+
it 'Does name mapping' do
|
325
|
+
data = { 'basic' => 'a', 'DiffName' => 'b' }
|
326
|
+
expect(DataTestClass.send(:translate_gandi, data).keys).to match_array %i[basic diff_name]
|
327
|
+
end
|
328
|
+
|
329
|
+
it 'Does value conversion' do
|
330
|
+
data = { 'basic' => 'a', 'str_to_sym' => 'b', 'arr_of_str_to_sym' => ['c'] }
|
331
|
+
expect(DataTestClass.send(:translate_gandi, data).values).to match_array ['a', :b, [:c]]
|
332
|
+
end
|
333
|
+
|
334
|
+
it 'Has worked on a clone' do
|
335
|
+
data = {}
|
336
|
+
expect(DataTestClass.send(:translate_gandi, data)).to_not be hash
|
337
|
+
end
|
338
|
+
end
|
339
|
+
end
|
340
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe GandiV5::Domain::AutoRenew do
|
4
|
+
before(:each) { subject.domain = double GandiV5::Domain, fqdn: 'example.com' }
|
5
|
+
let(:url) { 'https://api.gandi.net/v5/domain/domains/example.com/autorenew' }
|
6
|
+
|
7
|
+
it '#disable' do
|
8
|
+
expect(GandiV5).to receive(:patch).with(url, '{"enabled":false}')
|
9
|
+
.and_return('message' => 'Confirmation message.')
|
10
|
+
expect(subject.disable).to eq 'Confirmation message.'
|
11
|
+
expect(subject.enabled).to be false
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#enable' do
|
15
|
+
it 'Success' do
|
16
|
+
expect(GandiV5).to receive(:patch).with(url, '{"enabled":true,"duration":1,"org_id":"org-uuid"}')
|
17
|
+
.and_return('message' => 'Confirmation message.')
|
18
|
+
expect(subject.enable(org_id: 'org-uuid', duration: 1)).to eq 'Confirmation message.'
|
19
|
+
expect(subject.enabled).to be true
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'Duration too low' do
|
23
|
+
expect(GandiV5).to_not receive(:patch)
|
24
|
+
expect { subject.enable(org_id: 'org-uuid', duration: 0) }.to raise_error ArgumentError,
|
25
|
+
'duration can not be less than 1'
|
26
|
+
expect(subject.enabled).to be nil
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'Duration too high' do
|
30
|
+
expect(GandiV5).to_not receive(:patch)
|
31
|
+
expect { subject.enable(org_id: 'org-uuid', duration: 10) }.to raise_error ArgumentError,
|
32
|
+
'duration can not be more than 9'
|
33
|
+
expect(subject.enabled).to be nil
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'Missing duration' do
|
37
|
+
it 'Uses #duration if present' do
|
38
|
+
expect(GandiV5).to receive(:patch).with(url, '{"enabled":true,"duration":5,"org_id":"org-uuid"}')
|
39
|
+
.and_return('message' => 'Confirmation message.')
|
40
|
+
expect(subject).to receive(:duration).and_return(5)
|
41
|
+
expect(subject.enable(org_id: 'org-uuid')).to eq 'Confirmation message.'
|
42
|
+
expect(subject.enabled).to be true
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'Uses 1 if #duration not present' do
|
46
|
+
expect(GandiV5).to receive(:patch).with(url, '{"enabled":true,"duration":1,"org_id":"org-uuid"}')
|
47
|
+
.and_return('message' => 'Confirmation message.')
|
48
|
+
expect(subject.enable(org_id: 'org-uuid')).to eq 'Confirmation message.'
|
49
|
+
expect(subject.enabled).to be true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'Missing org_id' do
|
54
|
+
it 'Uses #org_id if present' do
|
55
|
+
expect(GandiV5).to receive(:patch).with(url, '{"enabled":true,"duration":1,"org_id":"org-uuid"}')
|
56
|
+
.and_return('message' => 'Confirmation message.')
|
57
|
+
expect(subject).to receive(:org_id).and_return('org-uuid')
|
58
|
+
expect(subject.enable).to eq 'Confirmation message.'
|
59
|
+
expect(subject.enabled).to be true
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'Errors if #org_id not present' do
|
63
|
+
expect(GandiV5).to_not receive(:patch)
|
64
|
+
expect { subject.enable }.to raise_error ArgumentError,
|
65
|
+
'org_id is required'
|
66
|
+
expect(subject.enabled).to be nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe GandiV5::Domain::Contact do
|
4
|
+
subject { described_class.new type: :person, reachability: :yes, validation: :yes }
|
5
|
+
|
6
|
+
describe '#name' do
|
7
|
+
it 'Joins given and family for a person' do
|
8
|
+
subject = described_class.new type: :person, given: 'John', family: 'Smith'
|
9
|
+
expect(subject.name).to eq 'John Smith'
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'Gives organisation name for other types' do
|
13
|
+
described_class::TYPES.keys.reject { |type| type == :person }.each do |type|
|
14
|
+
it type.to_s.capitalize do
|
15
|
+
subject = described_class.new type: type, organisation_name: 'Organisation Name'
|
16
|
+
expect(subject.name).to eq 'Organisation Name'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#to_s' do
|
23
|
+
it 'Joins type and name' do
|
24
|
+
subject = described_class.new type: :person, given: 'Jane', family: 'Doe'
|
25
|
+
expect(subject.to_s).to eq "Person\tJane Doe"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#to_gandi' do
|
30
|
+
it('Is a person') { expect(described_class.new(type: :person).to_gandi['type']).to eq 0 }
|
31
|
+
it('Is a company') { expect(described_class.new(type: :company).to_gandi['type']).to eq 1 }
|
32
|
+
it('Is an association') { expect(described_class.new(type: :association).to_gandi['type']).to eq 2 }
|
33
|
+
it('Is a public body') { expect(described_class.new(type: :'public body').to_gandi['type']).to eq 3 }
|
34
|
+
it('Is a reseller') { expect(described_class.new(type: :reseller).to_gandi['type']).to eq 4 }
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe GandiV5::Domain::RenewalInformation do
|
4
|
+
describe '#renewable?' do
|
5
|
+
before(:each) { Timecop.travel Time.new(2000, 1, 2, 12, 0, 0) }
|
6
|
+
let(:future) { Time.new 2000, 1, 3, 0, 0, 0, 0 }
|
7
|
+
let(:past) { Time.new 2000, 1, 1, 0, 0, 0, 0 }
|
8
|
+
|
9
|
+
describe 'Is prohibited' do
|
10
|
+
describe 'Begins in the future' do
|
11
|
+
it 'Ends in the future' do
|
12
|
+
info = described_class.new prohibited: true, begins_at: future, ends_at: future
|
13
|
+
expect(info.renewable?).to be false
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'Ends in the past' do
|
17
|
+
info = described_class.new prohibited: true, begins_at: future, ends_at: past
|
18
|
+
expect(info.renewable?).to be false
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'No end set' do
|
22
|
+
info = described_class.new prohibited: true, begins_at: future
|
23
|
+
expect(info.renewable?).to be false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'Begins in the past' do
|
28
|
+
it 'Ends in the future' do
|
29
|
+
info = described_class.new prohibited: true, begins_at: past, ends_at: future
|
30
|
+
expect(info.renewable?).to be false
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'Ends in the past' do
|
34
|
+
info = described_class.new prohibited: true, begins_at: past, ends_at: past
|
35
|
+
expect(info.renewable?).to be false
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'No end set' do
|
39
|
+
info = described_class.new prohibited: true, begins_at: past
|
40
|
+
expect(info.renewable?).to be false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'Is not prohibited' do
|
46
|
+
describe 'Begins in the future' do
|
47
|
+
it 'Ends in the future' do
|
48
|
+
info = described_class.new prohibited: false, begins_at: future, ends_at: future
|
49
|
+
expect(info.renewable?).to be false
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'Ends in the past' do
|
53
|
+
info = described_class.new prohibited: false, begins_at: future, ends_at: past
|
54
|
+
expect(info.renewable?).to be false
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'No end set' do
|
58
|
+
info = described_class.new prohibited: false, begins_at: future
|
59
|
+
expect(info.renewable?).to be false
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe 'Begins in the past' do
|
64
|
+
it 'Ends in the future' do
|
65
|
+
info = described_class.new prohibited: false, begins_at: past, ends_at: future
|
66
|
+
expect(info.renewable?).to be true
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'Ends in the past' do
|
70
|
+
info = described_class.new prohibited: false, begins_at: past, ends_at: past
|
71
|
+
expect(info.renewable?).to be false
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'No end set' do
|
75
|
+
info = described_class.new prohibited: false, begins_at: past
|
76
|
+
expect(info.renewable?).to be true
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|