sendgrid4r 0.5.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env.example +6 -8
- data/.rubocop.yml +1 -1
- data/README.md +0 -2
- data/lib/sendgrid4r/rest/api.rb +6 -0
- data/lib/sendgrid4r/rest/api_keys/api_keys.rb +5 -5
- data/lib/sendgrid4r/rest/asm/global_suppressions.rb +3 -3
- data/lib/sendgrid4r/rest/asm/groups.rb +4 -4
- data/lib/sendgrid4r/rest/asm/suppressions.rb +4 -4
- data/lib/sendgrid4r/rest/categories/categories.rb +1 -1
- data/lib/sendgrid4r/rest/contacts/custom_fields.rb +3 -3
- data/lib/sendgrid4r/rest/contacts/lists.rb +10 -10
- data/lib/sendgrid4r/rest/contacts/recipients.rb +10 -10
- data/lib/sendgrid4r/rest/contacts/segments.rb +5 -5
- data/lib/sendgrid4r/rest/ips/addresses.rb +3 -3
- data/lib/sendgrid4r/rest/ips/pools.rb +4 -4
- data/lib/sendgrid4r/rest/ips/warmup.rb +6 -6
- data/lib/sendgrid4r/rest/request.rb +2 -2
- data/lib/sendgrid4r/rest/subusers/subusers.rb +63 -3
- data/lib/sendgrid4r/rest/templates/templates.rb +14 -9
- data/lib/sendgrid4r/rest/templates/versions.rb +12 -10
- data/lib/sendgrid4r/rest/whitelabel/domains.rb +257 -0
- data/lib/sendgrid4r/rest/whitelabel/ips.rb +140 -0
- data/lib/sendgrid4r/rest/whitelabel/links.rb +185 -0
- data/lib/sendgrid4r/version.rb +1 -1
- data/sendgrid4r.gemspec +1 -1
- data/spec/client_spec.rb +93 -1
- data/spec/rest/api_keys/api_keys_spec.rb +23 -55
- data/spec/rest/asm/global_suppressions_spec.rb +40 -68
- data/spec/rest/asm/groups_spec.rb +31 -82
- data/spec/rest/asm/suppressions_spec.rb +33 -76
- data/spec/rest/categories/categories_spec.rb +8 -27
- data/spec/rest/contacts/custom_fields_spec.rb +18 -71
- data/spec/rest/contacts/lists_spec.rb +64 -187
- data/spec/rest/contacts/recipients_spec.rb +41 -196
- data/spec/rest/contacts/reserved_fields_spec.rb +2 -20
- data/spec/rest/contacts/segments_spec.rb +47 -33
- data/spec/rest/email_activity/email_activity_spec.rb +8 -21
- data/spec/rest/ips/addresses_spec.rb +18 -77
- data/spec/rest/ips/pools_spec.rb +21 -80
- data/spec/rest/ips/warmup_spec.rb +11 -58
- data/spec/rest/settings/enforced_tls_spec.rb +3 -40
- data/spec/rest/settings/mail_spec.rb +21 -294
- data/spec/rest/settings/partner_spec.rb +6 -79
- data/spec/rest/settings/tracking_spec.rb +10 -147
- data/spec/rest/stats/advanced_spec.rb +13 -135
- data/spec/rest/stats/category_spec.rb +5 -48
- data/spec/rest/stats/global_spec.rb +3 -5
- data/spec/rest/stats/parse_spec.rb +1 -24
- data/spec/rest/stats/subuser_spec.rb +6 -49
- data/spec/rest/subusers/subusers_spec.rb +156 -81
- data/spec/rest/templates/templates_spec.rb +32 -81
- data/spec/rest/templates/versions_spec.rb +50 -28
- data/spec/rest/whitelabel/domains_spec.rb +637 -0
- data/spec/rest/whitelabel/ips_spec.rb +231 -0
- data/spec/rest/whitelabel/links_spec.rb +359 -0
- metadata +22 -8
@@ -0,0 +1,637 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
3
|
+
|
4
|
+
describe SendGrid4r::REST::Whitelabel::Domains do
|
5
|
+
describe 'integration test', :it do
|
6
|
+
before do
|
7
|
+
begin
|
8
|
+
Dotenv.load
|
9
|
+
@client = SendGrid4r::Client.new(api_key: ENV['SILVER_API_KEY'])
|
10
|
+
@subdomain_name = ENV['SUBDOMAIN_DOMAIN']
|
11
|
+
@domain_name = ENV['DOMAIN']
|
12
|
+
@username = ENV['USERNAME']
|
13
|
+
@ip = ENV['IP']
|
14
|
+
@subuser1 = ENV['SUBUSER1']
|
15
|
+
@subuser2 = ENV['SUBUSER2']
|
16
|
+
|
17
|
+
# celan up test env(lists)
|
18
|
+
domains = @client.get_wl_domains
|
19
|
+
domains.each do |domain|
|
20
|
+
if domain.subdomain == "#{@subdomain_name}1" &&
|
21
|
+
domain.domain == @domain_name
|
22
|
+
@client.delete_wl_domain(id: domain.id)
|
23
|
+
end
|
24
|
+
if domain.subdomain == "#{@subdomain_name}2" &&
|
25
|
+
domain.domain == @domain_name
|
26
|
+
@client.delete_wl_domain(id: domain.id)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# post domain
|
31
|
+
@domain1 = @client.post_wl_domain(
|
32
|
+
domain: @domain_name, subdomain: @subdomain_name + '1',
|
33
|
+
username: @username, ips: nil,
|
34
|
+
automatic_security: true, custom_spf: false, default: false
|
35
|
+
)
|
36
|
+
@domain2 = @client.post_wl_domain(
|
37
|
+
domain: @domain_name, subdomain: @subdomain_name + '2',
|
38
|
+
username: @username, ips: nil,
|
39
|
+
automatic_security: false, custom_spf: true, default: false
|
40
|
+
)
|
41
|
+
rescue RestClient::ExceptionWithResponse => e
|
42
|
+
puts e.inspect
|
43
|
+
raise e
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'without block call' do
|
48
|
+
it '#get_wl_domains' do
|
49
|
+
begin
|
50
|
+
domains = @client.get_wl_domains
|
51
|
+
expect(domains).to be_a(Array)
|
52
|
+
domains.each do |domain|
|
53
|
+
expect(domain).to be_a(
|
54
|
+
SendGrid4r::REST::Whitelabel::Domains::Domain
|
55
|
+
)
|
56
|
+
end
|
57
|
+
rescue RestClient::ExceptionWithResponse => e
|
58
|
+
puts e.inspect
|
59
|
+
raise e
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it '#post_wl_domain' do
|
64
|
+
begin
|
65
|
+
expect(@domain1).to be_a(
|
66
|
+
SendGrid4r::REST::Whitelabel::Domains::Domain
|
67
|
+
)
|
68
|
+
expect(@domain1.domain).to eq(@domain_name)
|
69
|
+
expect(@domain1.subdomain).to eq(@subdomain_name + '1')
|
70
|
+
expect(@domain1.username).to eq(@username)
|
71
|
+
expect(@domain1.user_id).to be_a(Numeric)
|
72
|
+
expect(@domain1.ips).to eq([])
|
73
|
+
expect(@domain1.automatic_security).to eq(true)
|
74
|
+
expect(@domain1.custom_spf).to eq(false)
|
75
|
+
expect(@domain1.default).to eq(false)
|
76
|
+
expect(@domain1.legacy).to eq(false)
|
77
|
+
expect(@domain1.valid).to eq(false)
|
78
|
+
expect(@domain1.dns.mail_cname).to be_a(
|
79
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
80
|
+
)
|
81
|
+
expect(@domain1.dns.spf).to be_a(
|
82
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
83
|
+
)
|
84
|
+
expect(@domain1.dns.dkim1).to be_a(
|
85
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
86
|
+
)
|
87
|
+
expect(@domain1.dns.dkim2).to be_a(
|
88
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
89
|
+
)
|
90
|
+
expect(@domain2).to be_a(
|
91
|
+
SendGrid4r::REST::Whitelabel::Domains::Domain
|
92
|
+
)
|
93
|
+
expect(@domain2.domain).to eq(@domain_name)
|
94
|
+
expect(@domain2.subdomain).to eq(@subdomain_name + '2')
|
95
|
+
expect(@domain2.username).to eq(@username)
|
96
|
+
expect(@domain2.user_id).to be_a(Numeric)
|
97
|
+
expect(@domain2.ips).to eq([])
|
98
|
+
expect(@domain2.automatic_security).to eq(false)
|
99
|
+
expect(@domain2.custom_spf).to eq(true)
|
100
|
+
expect(@domain2.default).to eq(false)
|
101
|
+
expect(@domain2.legacy).to eq(false)
|
102
|
+
expect(@domain2.valid).to eq(false)
|
103
|
+
expect(@domain2.dns.mail_server).to be_a(
|
104
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
105
|
+
)
|
106
|
+
expect(@domain2.dns.subdomain_spf).to be_a(
|
107
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
108
|
+
)
|
109
|
+
expect(@domain2.dns.domain_spf).to be_a(
|
110
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
111
|
+
)
|
112
|
+
expect(@domain2.dns.dkim).to be_a(
|
113
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
114
|
+
)
|
115
|
+
rescue RestClient::ExceptionWithResponse => e
|
116
|
+
puts e.inspect
|
117
|
+
raise e
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
it '#get_wl_domain' do
|
122
|
+
begin
|
123
|
+
domain1 = @client.get_wl_domain(id: @domain1.id)
|
124
|
+
expect(domain1).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
|
125
|
+
expect(domain1.domain).to eq(@domain_name)
|
126
|
+
expect(domain1.subdomain).to eq(@subdomain_name + '1')
|
127
|
+
expect(domain1.username).to eq(@username)
|
128
|
+
expect(domain1.user_id).to be_a(Numeric)
|
129
|
+
expect(domain1.ips).to eq([])
|
130
|
+
expect(domain1.automatic_security).to eq(true)
|
131
|
+
expect(domain1.custom_spf).to eq(false)
|
132
|
+
expect(domain1.default).to eq(false)
|
133
|
+
expect(domain1.legacy).to eq(false)
|
134
|
+
expect(domain1.valid).to eq(false)
|
135
|
+
expect(domain1.dns.mail_cname).to be_a(
|
136
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
137
|
+
)
|
138
|
+
expect(domain1.dns.spf).to be_a(
|
139
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
140
|
+
)
|
141
|
+
expect(domain1.dns.dkim1).to be_a(
|
142
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
143
|
+
)
|
144
|
+
expect(domain1.dns.dkim2).to be_a(
|
145
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
146
|
+
)
|
147
|
+
domain2 = @client.get_wl_domain(id: @domain2.id)
|
148
|
+
expect(domain2).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
|
149
|
+
expect(domain2.domain).to eq(@domain_name)
|
150
|
+
expect(domain2.subdomain).to eq(@subdomain_name + '2')
|
151
|
+
expect(domain2.username).to eq(@username)
|
152
|
+
expect(domain2.user_id).to be_a(Numeric)
|
153
|
+
expect(domain2.ips).to eq([])
|
154
|
+
expect(domain2.automatic_security).to eq(false)
|
155
|
+
expect(domain2.custom_spf).to eq(true)
|
156
|
+
expect(domain2.default).to eq(false)
|
157
|
+
expect(domain2.legacy).to eq(false)
|
158
|
+
expect(domain2.valid).to eq(false)
|
159
|
+
expect(domain2.dns.mail_server).to be_a(
|
160
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
161
|
+
)
|
162
|
+
expect(domain2.dns.subdomain_spf).to be_a(
|
163
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
164
|
+
)
|
165
|
+
expect(domain2.dns.domain_spf).to be_a(
|
166
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
167
|
+
)
|
168
|
+
expect(domain2.dns.dkim).to be_a(
|
169
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
170
|
+
)
|
171
|
+
rescue RestClient::ExceptionWithResponse => e
|
172
|
+
puts e.inspect
|
173
|
+
raise e
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
it '#patch_wl_domain' do
|
178
|
+
begin
|
179
|
+
domain1 = @client.patch_wl_domain(
|
180
|
+
id: @domain1.id, custom_spf: true, default: nil
|
181
|
+
)
|
182
|
+
expect(domain1).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
|
183
|
+
expect(domain1.domain).to eq(@domain_name)
|
184
|
+
expect(domain1.subdomain).to eq(@subdomain_name + '1')
|
185
|
+
expect(domain1.username).to eq(@username)
|
186
|
+
expect(domain1.user_id).to be_a(Numeric)
|
187
|
+
expect(domain1.ips).to eq([])
|
188
|
+
expect(domain1.automatic_security).to eq(true)
|
189
|
+
expect(domain1.custom_spf).to eq(true)
|
190
|
+
expect(domain1.default).to eq(false)
|
191
|
+
rescue RestClient::ExceptionWithResponse => e
|
192
|
+
puts e.inspect
|
193
|
+
raise e
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
it '#delete_wl_domain' do
|
198
|
+
begin
|
199
|
+
@client.delete_wl_domain(id: @domain1.id)
|
200
|
+
rescue RestClient::ExceptionWithResponse => e
|
201
|
+
puts e.inspect
|
202
|
+
raise e
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
it '#get_default_wl_domain' do
|
207
|
+
begin
|
208
|
+
domain2 = @client.get_default_wl_domain
|
209
|
+
expect(domain2).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
|
210
|
+
rescue RestClient::ExceptionWithResponse => e
|
211
|
+
puts e.inspect
|
212
|
+
raise e
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
it '#add_ip_to_wl_domain' do
|
217
|
+
begin
|
218
|
+
domain2 = @client.add_ip_to_wl_domain(id: @domain2.id, ip: @ip)
|
219
|
+
expect(domain2.ips).to eq([@ip])
|
220
|
+
rescue RestClient::ExceptionWithResponse => e
|
221
|
+
puts e.inspect
|
222
|
+
raise e
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
it '#remove_ip_from_wl_domain' do
|
227
|
+
begin
|
228
|
+
@client.add_ip_to_wl_domain(id: @domain2.id, ip: @ip)
|
229
|
+
domain2 = @client.remove_ip_from_wl_domain(
|
230
|
+
id: @domain2.id, ip: @ip
|
231
|
+
)
|
232
|
+
expect(domain2.ips).to eq(nil)
|
233
|
+
rescue RestClient::ExceptionWithResponse => e
|
234
|
+
puts e.inspect
|
235
|
+
raise e
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
it '#validate_wl_domain' do
|
240
|
+
begin
|
241
|
+
result1 = @client.validate_wl_domain(id: @domain1.id)
|
242
|
+
expect(result1).to be_a(
|
243
|
+
SendGrid4r::REST::Whitelabel::Domains::Result
|
244
|
+
)
|
245
|
+
expect(result1.valid).to be(false)
|
246
|
+
expect(result1.validation_results.mail_cname.valid).to be(
|
247
|
+
false
|
248
|
+
)
|
249
|
+
expect(result1.validation_results.dkim1.valid).to be(
|
250
|
+
false
|
251
|
+
)
|
252
|
+
expect(result1.validation_results.dkim2.valid).to be(
|
253
|
+
false
|
254
|
+
)
|
255
|
+
expect(result1.validation_results.spf.valid).to be(
|
256
|
+
false
|
257
|
+
)
|
258
|
+
result2 = @client.validate_wl_domain(id: @domain2.id)
|
259
|
+
expect(result2).to be_a(
|
260
|
+
SendGrid4r::REST::Whitelabel::Domains::Result
|
261
|
+
)
|
262
|
+
expect(result2.valid).to be(false)
|
263
|
+
expect(result2.validation_results.mail_server.valid).to be(
|
264
|
+
false
|
265
|
+
)
|
266
|
+
expect(result2.validation_results.subdomain_spf.valid).to be(
|
267
|
+
false
|
268
|
+
)
|
269
|
+
expect(result2.validation_results.domain_spf.valid).to be(
|
270
|
+
false
|
271
|
+
)
|
272
|
+
expect(result2.validation_results.dkim.valid).to be(
|
273
|
+
false
|
274
|
+
)
|
275
|
+
rescue RestClient::ExceptionWithResponse => e
|
276
|
+
puts e.inspect
|
277
|
+
raise e
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
it '#get_associated_wl_domain' do
|
282
|
+
begin
|
283
|
+
domain1 = @client.get_associated_wl_domain(username: @subuser1)
|
284
|
+
expect(domain1).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
|
285
|
+
rescue RestClient::ExceptionWithResponse => e
|
286
|
+
puts e.inspect
|
287
|
+
raise e
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
it '#associate_wl_domain' do
|
292
|
+
begin
|
293
|
+
@client.associate_wl_domain(id: @domain2.id, username: @subuser1)
|
294
|
+
rescue RestClient::ExceptionWithResponse => e
|
295
|
+
puts e.inspect
|
296
|
+
raise e
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
it '#disassociate_wl_domain' do
|
301
|
+
begin
|
302
|
+
@client.associate_wl_domain(id: @domain2.id, username: @subuser1)
|
303
|
+
@client.disassociate_wl_domain(username: @subuser1)
|
304
|
+
rescue RestClient::ExceptionWithResponse => e
|
305
|
+
puts e.inspect
|
306
|
+
raise e
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
describe 'unit test', :ut do
|
313
|
+
let(:client) do
|
314
|
+
SendGrid4r::Client.new(api_key: '')
|
315
|
+
end
|
316
|
+
|
317
|
+
let(:domains) do
|
318
|
+
JSON.parse('[]')
|
319
|
+
end
|
320
|
+
|
321
|
+
let(:domain) do
|
322
|
+
JSON.parse(
|
323
|
+
'{'\
|
324
|
+
'"id": 1,'\
|
325
|
+
'"domain": "example.com",'\
|
326
|
+
'"subdomain": "mail",'\
|
327
|
+
'"username": "john@example.com",'\
|
328
|
+
'"user_id": 7,'\
|
329
|
+
'"ips": ['\
|
330
|
+
'"192.168.1.1",'\
|
331
|
+
'"192.168.1.2"'\
|
332
|
+
'],'\
|
333
|
+
'"custom_spf": true,'\
|
334
|
+
'"default": true,'\
|
335
|
+
'"legacy": false,'\
|
336
|
+
'"automatic_security": true,'\
|
337
|
+
'"valid": true,'\
|
338
|
+
'"dns": {'\
|
339
|
+
'"mail_cname": {'\
|
340
|
+
'"host": "mail.example.com",'\
|
341
|
+
'"type": "cname",'\
|
342
|
+
'"data": "u7.wl.sendgrid.net",'\
|
343
|
+
'"valid": true'\
|
344
|
+
'},'\
|
345
|
+
'"spf": {'\
|
346
|
+
'"host": "example.com",'\
|
347
|
+
'"type": "txt",'\
|
348
|
+
'"data": "v=spf1 include:u7.wl.sendgrid.net -all",'\
|
349
|
+
'"valid": true'\
|
350
|
+
'},'\
|
351
|
+
'"dkim1": {'\
|
352
|
+
'"host": "s1._domainkey.example.com",'\
|
353
|
+
'"type": "cname",'\
|
354
|
+
'"data": "s1._domainkey.u7.wl.sendgrid.net",'\
|
355
|
+
'"valid": true'\
|
356
|
+
'},'\
|
357
|
+
'"dkim2": {'\
|
358
|
+
'"host": "s2._domainkey.example.com",'\
|
359
|
+
'"type": "cname",'\
|
360
|
+
'"data": "s2._domainkey.u7.wl.sendgrid.net",'\
|
361
|
+
'"valid": true'\
|
362
|
+
'}'\
|
363
|
+
'}'\
|
364
|
+
'}'
|
365
|
+
)
|
366
|
+
end
|
367
|
+
|
368
|
+
let(:domain2) do
|
369
|
+
JSON.parse(
|
370
|
+
'{'\
|
371
|
+
'"id": 2,'\
|
372
|
+
'"user_id": 2,'\
|
373
|
+
'"subdomain": "mail2",'\
|
374
|
+
'"domain": "example.com",'\
|
375
|
+
'"username": "john@example.com",'\
|
376
|
+
'"ips": [],'\
|
377
|
+
'"custom_spf": true,'\
|
378
|
+
'"default": false,'\
|
379
|
+
'"legacy": false,'\
|
380
|
+
'"automatic_security": false,'\
|
381
|
+
'"valid": false,'\
|
382
|
+
'"dns": {'\
|
383
|
+
'"mail_server": {'\
|
384
|
+
'"valid": false,'\
|
385
|
+
'"type": "mx",'\
|
386
|
+
'"host": "mail2.example.com",'\
|
387
|
+
'"data": "mx.sendgrid.net."'\
|
388
|
+
'},'\
|
389
|
+
'"subdomain_spf": {'\
|
390
|
+
'"valid": false,'\
|
391
|
+
'"type": "txt",'\
|
392
|
+
'"host": "mail2.example.com",'\
|
393
|
+
'"data": "v=spf1 include:sendgrid.net ~all"'\
|
394
|
+
'},'\
|
395
|
+
'"domain_spf": {'\
|
396
|
+
'"valid": false,'\
|
397
|
+
'"type": "txt",'\
|
398
|
+
'"host": "example.com",'\
|
399
|
+
'"data": "v=spf1 include:mail2.example.com -all"'\
|
400
|
+
'},'\
|
401
|
+
'"dkim": {'\
|
402
|
+
'"valid": false,'\
|
403
|
+
'"type": "txt",'\
|
404
|
+
'"host": "m1._domainkey.example.com",'\
|
405
|
+
'"data": "k=rsa; t=s; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ"'\
|
406
|
+
'}'\
|
407
|
+
'}'\
|
408
|
+
'}'
|
409
|
+
)
|
410
|
+
end
|
411
|
+
|
412
|
+
let(:result) do
|
413
|
+
JSON.parse(
|
414
|
+
'{'\
|
415
|
+
'"id": 1,'\
|
416
|
+
'"valid": true,'\
|
417
|
+
'"validation_results": {'\
|
418
|
+
'"mail_cname": {'\
|
419
|
+
'"valid": false,'\
|
420
|
+
'"reason": "Expected your MX record to be \"mx.sendgrid.net\" '\
|
421
|
+
'but found \"example.com\"."'\
|
422
|
+
'},'\
|
423
|
+
'"dkim1": {'\
|
424
|
+
'"valid": true,'\
|
425
|
+
'"reason": null'\
|
426
|
+
'},'\
|
427
|
+
'"dkim2": {'\
|
428
|
+
'"valid": true,'\
|
429
|
+
'"reason": null'\
|
430
|
+
'},'\
|
431
|
+
'"spf": {'\
|
432
|
+
'"valid": true,'\
|
433
|
+
'"reason": null'\
|
434
|
+
'}'\
|
435
|
+
'}'\
|
436
|
+
'}'
|
437
|
+
)
|
438
|
+
end
|
439
|
+
|
440
|
+
it '#get_domains' do
|
441
|
+
allow(client).to receive(:execute).and_return(domains)
|
442
|
+
actual = client.get_wl_domains
|
443
|
+
expect(actual).to be_a(Array)
|
444
|
+
end
|
445
|
+
|
446
|
+
it '#post_domain' do
|
447
|
+
allow(client).to receive(:execute).and_return(domain)
|
448
|
+
actual = client.post_wl_domain(domain: '', subdomain: '')
|
449
|
+
expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
|
450
|
+
end
|
451
|
+
|
452
|
+
it '#get_domain' do
|
453
|
+
allow(client).to receive(:execute).and_return(domain)
|
454
|
+
actual = client.get_wl_domain(id: '')
|
455
|
+
expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
|
456
|
+
end
|
457
|
+
|
458
|
+
it '#patch_domain' do
|
459
|
+
allow(client).to receive(:execute).and_return(domain)
|
460
|
+
actual = client.patch_wl_domain(id: '', custom_spf: true, default: false)
|
461
|
+
expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
|
462
|
+
end
|
463
|
+
|
464
|
+
it '#delete_domain' do
|
465
|
+
allow(client).to receive(:execute).and_return('')
|
466
|
+
actual = client.delete_wl_domain(id: '')
|
467
|
+
expect(actual).to eq('')
|
468
|
+
end
|
469
|
+
|
470
|
+
it '#get_default_domain' do
|
471
|
+
allow(client).to receive(:execute).and_return(domain)
|
472
|
+
actual = client.get_default_wl_domain(domain: '')
|
473
|
+
expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
|
474
|
+
end
|
475
|
+
|
476
|
+
it '#add_ip_to_domain' do
|
477
|
+
allow(client).to receive(:execute).and_return(domain)
|
478
|
+
actual = client.add_ip_to_wl_domain(id: '', ip: '')
|
479
|
+
expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
|
480
|
+
end
|
481
|
+
|
482
|
+
it '#remove_ip_from_domain' do
|
483
|
+
allow(client).to receive(:execute).and_return(domain)
|
484
|
+
actual = client.remove_ip_from_wl_domain(id: '', ip: '')
|
485
|
+
expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
|
486
|
+
end
|
487
|
+
|
488
|
+
it '#validate_domain' do
|
489
|
+
allow(client).to receive(:execute).and_return(result)
|
490
|
+
actual = client.validate_wl_domain(id: '')
|
491
|
+
expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Result)
|
492
|
+
end
|
493
|
+
|
494
|
+
it '#get_associated_wl_domain' do
|
495
|
+
allow(client).to receive(:execute).and_return(domain)
|
496
|
+
actual = client.get_associated_wl_domain(username: '')
|
497
|
+
expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
|
498
|
+
end
|
499
|
+
|
500
|
+
it '#disassociate_wl_domain' do
|
501
|
+
allow(client).to receive(:execute).and_return('')
|
502
|
+
actual = client.disassociate_wl_domain(username: '')
|
503
|
+
expect(actual).to eq('')
|
504
|
+
end
|
505
|
+
|
506
|
+
it '#associate_wl_domain' do
|
507
|
+
allow(client).to receive(:execute).and_return(domain)
|
508
|
+
actual = client.associate_wl_domain(id: '', username: '')
|
509
|
+
expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
|
510
|
+
end
|
511
|
+
|
512
|
+
it 'creates domain instance' do
|
513
|
+
actual = SendGrid4r::REST::Whitelabel::Domains.create_domain(domain)
|
514
|
+
expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
|
515
|
+
expect(actual.id).to eq(1)
|
516
|
+
expect(actual.domain).to eq('example.com')
|
517
|
+
expect(actual.subdomain).to eq('mail')
|
518
|
+
expect(actual.username).to eq('john@example.com')
|
519
|
+
expect(actual.user_id).to eq(7)
|
520
|
+
expect(actual.ips).to be_a(Array)
|
521
|
+
expect(actual.ips[0]).to eq('192.168.1.1')
|
522
|
+
expect(actual.ips[1]).to eq('192.168.1.2')
|
523
|
+
expect(actual.custom_spf).to eq(true)
|
524
|
+
expect(actual.default).to eq(true)
|
525
|
+
expect(actual.legacy).to eq(false)
|
526
|
+
expect(actual.automatic_security).to eq(true)
|
527
|
+
expect(actual.valid).to eq(true)
|
528
|
+
expect(actual.dns).to be_a(SendGrid4r::REST::Whitelabel::Domains::Dns)
|
529
|
+
expect(actual.dns.mail_cname).to be_a(
|
530
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
531
|
+
)
|
532
|
+
expect(actual.dns.mail_cname.host).to eq('mail.example.com')
|
533
|
+
expect(actual.dns.mail_cname.type).to eq('cname')
|
534
|
+
expect(actual.dns.mail_cname.data).to eq('u7.wl.sendgrid.net')
|
535
|
+
expect(actual.dns.mail_cname.valid).to eq(true)
|
536
|
+
expect(actual.dns.spf).to be_a(
|
537
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
538
|
+
)
|
539
|
+
expect(actual.dns.spf.host).to eq('example.com')
|
540
|
+
expect(actual.dns.spf.type).to eq('txt')
|
541
|
+
expect(actual.dns.spf.data).to eq(
|
542
|
+
'v=spf1 include:u7.wl.sendgrid.net -all'
|
543
|
+
)
|
544
|
+
expect(actual.dns.spf.valid).to eq(true)
|
545
|
+
expect(actual.dns.dkim1).to be_a(
|
546
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
547
|
+
)
|
548
|
+
expect(actual.dns.dkim1.host).to eq('s1._domainkey.example.com')
|
549
|
+
expect(actual.dns.dkim1.type).to eq('cname')
|
550
|
+
expect(actual.dns.dkim1.data).to eq('s1._domainkey.u7.wl.sendgrid.net')
|
551
|
+
expect(actual.dns.dkim1.valid).to eq(true)
|
552
|
+
expect(actual.dns.dkim2).to be_a(
|
553
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
554
|
+
)
|
555
|
+
expect(actual.dns.dkim2.host).to eq('s2._domainkey.example.com')
|
556
|
+
expect(actual.dns.dkim2.type).to eq('cname')
|
557
|
+
expect(actual.dns.dkim2.data).to eq('s2._domainkey.u7.wl.sendgrid.net')
|
558
|
+
expect(actual.dns.dkim2.valid).to eq(true)
|
559
|
+
end
|
560
|
+
|
561
|
+
it 'creates domain2 instance' do
|
562
|
+
actual = SendGrid4r::REST::Whitelabel::Domains.create_domain(domain2)
|
563
|
+
expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
|
564
|
+
expect(actual.id).to eq(2)
|
565
|
+
expect(actual.domain).to eq('example.com')
|
566
|
+
expect(actual.subdomain).to eq('mail2')
|
567
|
+
expect(actual.username).to eq('john@example.com')
|
568
|
+
expect(actual.user_id).to eq(2)
|
569
|
+
expect(actual.ips).to be_a(Array)
|
570
|
+
expect(actual.custom_spf).to eq(true)
|
571
|
+
expect(actual.default).to eq(false)
|
572
|
+
expect(actual.legacy).to eq(false)
|
573
|
+
expect(actual.automatic_security).to eq(false)
|
574
|
+
expect(actual.valid).to eq(false)
|
575
|
+
expect(actual.dns).to be_a(SendGrid4r::REST::Whitelabel::Domains::Dns)
|
576
|
+
expect(actual.dns.mail_server).to be_a(
|
577
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
578
|
+
)
|
579
|
+
expect(actual.dns.mail_server.host).to eq('mail2.example.com')
|
580
|
+
expect(actual.dns.mail_server.type).to eq('mx')
|
581
|
+
expect(actual.dns.mail_server.data).to eq('mx.sendgrid.net.')
|
582
|
+
expect(actual.dns.mail_server.valid).to eq(false)
|
583
|
+
expect(actual.dns.subdomain_spf).to be_a(
|
584
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
585
|
+
)
|
586
|
+
expect(actual.dns.subdomain_spf.host).to eq('mail2.example.com')
|
587
|
+
expect(actual.dns.subdomain_spf.type).to eq('txt')
|
588
|
+
expect(actual.dns.subdomain_spf.data).to eq(
|
589
|
+
'v=spf1 include:sendgrid.net ~all'
|
590
|
+
)
|
591
|
+
expect(actual.dns.subdomain_spf.valid).to eq(false)
|
592
|
+
expect(actual.dns.domain_spf).to be_a(
|
593
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
594
|
+
)
|
595
|
+
expect(actual.dns.domain_spf.host).to eq('example.com')
|
596
|
+
expect(actual.dns.domain_spf.type).to eq('txt')
|
597
|
+
expect(actual.dns.domain_spf.data).to eq(
|
598
|
+
'v=spf1 include:mail2.example.com -all'
|
599
|
+
)
|
600
|
+
expect(actual.dns.domain_spf.valid).to eq(false)
|
601
|
+
expect(actual.dns.dkim).to be_a(
|
602
|
+
SendGrid4r::REST::Whitelabel::Domains::Record
|
603
|
+
)
|
604
|
+
expect(actual.dns.dkim.host).to eq('m1._domainkey.example.com')
|
605
|
+
expect(actual.dns.dkim.type).to eq('txt')
|
606
|
+
expect(actual.dns.dkim.data).to eq(
|
607
|
+
'k=rsa; t=s; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ'
|
608
|
+
)
|
609
|
+
expect(actual.dns.dkim.valid).to eq(false)
|
610
|
+
end
|
611
|
+
|
612
|
+
it 'creates result instance' do
|
613
|
+
actual = SendGrid4r::REST::Whitelabel::Domains.create_result(result)
|
614
|
+
expect(actual).to be_a(SendGrid4r::REST::Whitelabel::Domains::Result)
|
615
|
+
expect(actual.id).to eq(1)
|
616
|
+
expect(actual.valid).to eq(true)
|
617
|
+
expect(actual.validation_results).to be_a(
|
618
|
+
SendGrid4r::REST::Whitelabel::Domains::ValidationResults
|
619
|
+
)
|
620
|
+
expect(actual.validation_results.dkim1).to be_a(
|
621
|
+
SendGrid4r::REST::Whitelabel::Domains::ValidationResult
|
622
|
+
)
|
623
|
+
expect(actual.validation_results.dkim1.valid).to be(true)
|
624
|
+
expect(actual.validation_results.dkim1.reason).to be(nil)
|
625
|
+
expect(actual.validation_results.dkim2).to be_a(
|
626
|
+
SendGrid4r::REST::Whitelabel::Domains::ValidationResult
|
627
|
+
)
|
628
|
+
expect(actual.validation_results.dkim2.valid).to be(true)
|
629
|
+
expect(actual.validation_results.dkim2.reason).to be(nil)
|
630
|
+
expect(actual.validation_results.spf).to be_a(
|
631
|
+
SendGrid4r::REST::Whitelabel::Domains::ValidationResult
|
632
|
+
)
|
633
|
+
expect(actual.validation_results.spf.valid).to be(true)
|
634
|
+
expect(actual.validation_results.spf.reason).to be(nil)
|
635
|
+
end
|
636
|
+
end
|
637
|
+
end
|