sendgrid4r 1.8.1 → 1.10.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/.rubocop.yml +6 -2
- data/README.md +1 -0
- data/lib/sendgrid4r/factory/campaign_factory.rb +18 -5
- data/lib/sendgrid4r/factory/condition_factory.rb +1 -1
- data/lib/sendgrid4r/factory/mail_factory.rb +57 -0
- data/lib/sendgrid4r/factory/segment_factory.rb +2 -5
- data/lib/sendgrid4r/factory/version_factory.rb +1 -1
- data/lib/sendgrid4r/rest/api.rb +48 -49
- data/lib/sendgrid4r/rest/api_keys_management/api_keys.rb +75 -0
- data/lib/sendgrid4r/rest/api_keys_management/permissions.rb +31 -0
- data/lib/sendgrid4r/rest/blocks.rb +49 -68
- data/lib/sendgrid4r/rest/bounces.rb +45 -64
- data/lib/sendgrid4r/rest/cancel_scheduled_sends.rb +53 -72
- data/lib/sendgrid4r/rest/categories.rb +31 -0
- data/lib/sendgrid4r/rest/email_activity.rb +72 -0
- data/lib/sendgrid4r/rest/invalid_emails.rb +50 -68
- data/lib/sendgrid4r/rest/ip_access_management.rb +86 -111
- data/lib/sendgrid4r/rest/ips/addresses.rb +50 -59
- data/lib/sendgrid4r/rest/ips/pools.rb +42 -53
- data/lib/sendgrid4r/rest/ips/warmup.rb +46 -55
- data/lib/sendgrid4r/rest/mail/address.rb +14 -0
- data/lib/sendgrid4r/rest/mail/attachment.rb +22 -0
- data/lib/sendgrid4r/rest/mail/content.rb +10 -0
- data/lib/sendgrid4r/rest/mail/mail.rb +28 -0
- data/lib/sendgrid4r/rest/mail/mail_settings.rb +62 -0
- data/lib/sendgrid4r/rest/mail/params.rb +64 -0
- data/lib/sendgrid4r/rest/mail/personalization.rb +33 -0
- data/lib/sendgrid4r/rest/mail/tracking_settings.rb +74 -0
- data/lib/sendgrid4r/rest/{contacts → marketing_campaigns/contacts}/custom_fields.rb +12 -27
- data/lib/sendgrid4r/rest/{contacts → marketing_campaigns/contacts}/lists.rb +20 -34
- data/lib/sendgrid4r/rest/marketing_campaigns/contacts/recipients.rb +134 -0
- data/lib/sendgrid4r/rest/{contacts → marketing_campaigns/contacts}/reserved_fields.rb +6 -9
- data/lib/sendgrid4r/rest/marketing_campaigns/contacts/segments.rb +86 -0
- data/lib/sendgrid4r/rest/marketing_campaigns/marketing_campaigns.rb +119 -0
- data/lib/sendgrid4r/rest/marketing_campaigns/senders.rb +101 -0
- data/lib/sendgrid4r/rest/request.rb +61 -63
- data/lib/sendgrid4r/rest/settings/enforced_tls.rb +23 -26
- data/lib/sendgrid4r/rest/settings/mail.rb +167 -183
- data/lib/sendgrid4r/rest/settings/partner.rb +33 -36
- data/lib/sendgrid4r/rest/settings/settings.rb +17 -22
- data/lib/sendgrid4r/rest/settings/tracking.rb +97 -107
- data/lib/sendgrid4r/rest/sm/global_unsubscribes.rb +52 -60
- data/lib/sendgrid4r/rest/sm/groups.rb +52 -58
- data/lib/sendgrid4r/rest/sm/sm.rb +15 -17
- data/lib/sendgrid4r/rest/sm/suppressions.rb +50 -67
- data/lib/sendgrid4r/rest/spam_reports.rb +49 -69
- data/lib/sendgrid4r/rest/stats/advanced.rb +100 -102
- data/lib/sendgrid4r/rest/stats/category.rb +31 -33
- data/lib/sendgrid4r/rest/stats/global.rb +17 -19
- data/lib/sendgrid4r/rest/stats/parse.rb +18 -20
- data/lib/sendgrid4r/rest/stats/stats.rb +59 -69
- data/lib/sendgrid4r/rest/stats/subuser.rb +70 -32
- data/lib/sendgrid4r/rest/subusers.rb +106 -134
- data/lib/sendgrid4r/rest/transactional_templates/templates.rb +63 -0
- data/lib/sendgrid4r/rest/transactional_templates/versions.rb +90 -0
- data/lib/sendgrid4r/rest/users.rb +125 -57
- data/lib/sendgrid4r/rest/webhooks/event.rb +36 -42
- data/lib/sendgrid4r/rest/webhooks/parse.rb +28 -37
- data/lib/sendgrid4r/rest/whitelabel/domains.rb +176 -222
- data/lib/sendgrid4r/rest/whitelabel/ips.rb +107 -128
- data/lib/sendgrid4r/rest/whitelabel/links.rb +131 -167
- data/lib/sendgrid4r/version.rb +1 -1
- data/lib/sendgrid4r.rb +23 -13
- data/sendgrid4r.gemspec +1 -1
- data/spec/client_spec.rb +12 -1
- data/spec/factory/campaign_factory_spec.rb +75 -35
- data/spec/factory/condition_factory_spec.rb +19 -18
- data/spec/factory/segment_factory_spec.rb +28 -21
- data/spec/factory/version_factory_spec.rb +28 -27
- data/spec/photo.jpg +0 -0
- data/spec/rest/api_keys_management/api_keys_spec.rb +174 -0
- data/spec/rest/api_keys_management/permissions_spec.rb +54 -0
- data/spec/rest/blocks_spec.rb +78 -106
- data/spec/rest/bounces_spec.rb +91 -118
- data/spec/rest/cancel_scheduled_sends_spec.rb +94 -149
- data/spec/rest/categories_spec.rb +77 -0
- data/spec/rest/email_activity_spec.rb +151 -0
- data/spec/rest/invalid_emails_spec.rb +85 -119
- data/spec/rest/ip_access_management_spec.rb +157 -195
- data/spec/rest/ips/addresses_spec.rb +94 -122
- data/spec/rest/ips/pools_spec.rb +84 -112
- data/spec/rest/ips/warmup_spec.rb +63 -71
- data/spec/rest/mail/address_spec.rb +28 -0
- data/spec/rest/mail/attachment_spec.rb +48 -0
- data/spec/rest/mail/content_spec.rb +32 -0
- data/spec/rest/mail/mail_settings_spec.rb +51 -0
- data/spec/rest/mail/mail_spec.rb +136 -0
- data/spec/rest/mail/params_spec.rb +152 -0
- data/spec/rest/mail/personalization_spec.rb +66 -0
- data/spec/rest/mail/tracking_settings_spec.rb +63 -0
- data/spec/rest/marketing_campaigns/contacts/custom_fields_spec.rb +146 -0
- data/spec/rest/marketing_campaigns/contacts/lists_spec.rb +307 -0
- data/spec/rest/marketing_campaigns/contacts/recipients_spec.rb +331 -0
- data/spec/rest/marketing_campaigns/contacts/reserved_fields_spec.rb +119 -0
- data/spec/rest/marketing_campaigns/contacts/segments_spec.rb +268 -0
- data/spec/rest/marketing_campaigns/marketing_campaigns_spec.rb +427 -0
- data/spec/rest/marketing_campaigns/senders_spec.rb +230 -0
- data/spec/rest/settings/enforced_tls_spec.rb +38 -54
- data/spec/rest/settings/mail_spec.rb +227 -330
- data/spec/rest/settings/partner_spec.rb +40 -59
- data/spec/rest/settings/settings_spec.rb +44 -42
- data/spec/rest/settings/tracking_spec.rb +130 -189
- data/spec/rest/sm/global_unsubscribes_spec.rb +47 -72
- data/spec/rest/sm/groups_spec.rb +88 -123
- data/spec/rest/sm/sm_spec.rb +32 -30
- data/spec/rest/sm/suppressions_spec.rb +105 -140
- data/spec/rest/spam_reports_spec.rb +81 -109
- data/spec/rest/stats/advanced_spec.rb +67 -125
- data/spec/rest/stats/category_spec.rb +27 -45
- data/spec/rest/stats/global_spec.rb +34 -42
- data/spec/rest/stats/parse_spec.rb +32 -30
- data/spec/rest/stats/stats_spec.rb +174 -172
- data/spec/rest/stats/subuser_spec.rb +97 -57
- data/spec/rest/subusers_spec.rb +156 -209
- data/spec/rest/transactional_templates/templates_spec.rb +199 -0
- data/spec/rest/transactional_templates/versions_spec.rb +228 -0
- data/spec/rest/users_spec.rb +176 -91
- data/spec/rest/webhooks/event_spec.rb +59 -85
- data/spec/rest/webhooks/parse_spec.rb +51 -71
- data/spec/rest/whitelabel/domains_spec.rb +333 -513
- data/spec/rest/whitelabel/ips_spec.rb +109 -147
- data/spec/rest/whitelabel/links_spec.rb +181 -265
- metadata +70 -40
- data/lib/sendgrid4r/rest/api_keys/api_keys.rb +0 -80
- data/lib/sendgrid4r/rest/api_keys/permissions.rb +0 -33
- data/lib/sendgrid4r/rest/campaigns/campaigns.rb +0 -126
- data/lib/sendgrid4r/rest/categories/categories.rb +0 -43
- data/lib/sendgrid4r/rest/contacts/recipients.rb +0 -150
- data/lib/sendgrid4r/rest/contacts/segments.rb +0 -97
- data/lib/sendgrid4r/rest/email_activity/email_activity.rb +0 -81
- data/lib/sendgrid4r/rest/templates/templates.rb +0 -69
- data/lib/sendgrid4r/rest/templates/versions.rb +0 -95
- data/spec/rest/api_keys/api_keys_spec.rb +0 -210
- data/spec/rest/api_keys/permissions_spec.rb +0 -65
- data/spec/rest/campaigns/campaigns_spec.rb +0 -492
- data/spec/rest/categories/categories_spec.rb +0 -96
- data/spec/rest/contacts/custom_fields_spec.rb +0 -174
- data/spec/rest/contacts/lists_spec.rb +0 -372
- data/spec/rest/contacts/recipients_spec.rb +0 -343
- data/spec/rest/contacts/reserved_fields_spec.rb +0 -146
- data/spec/rest/contacts/segments_spec.rb +0 -307
- data/spec/rest/email_activity/email_activity_spec.rb +0 -179
- data/spec/rest/templates/templates_spec.rb +0 -222
- data/spec/rest/templates/versions_spec.rb +0 -252
@@ -1,22 +1,20 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
3
3
|
|
4
|
-
|
5
|
-
describe
|
6
|
-
|
7
|
-
|
4
|
+
module SendGrid4r::REST::Whitelabel
|
5
|
+
describe Domains do
|
6
|
+
describe 'integration test', :it do
|
7
|
+
before do
|
8
8
|
Dotenv.load
|
9
9
|
@client = SendGrid4r::Client.new(api_key: ENV['SILVER_API_KEY'])
|
10
10
|
@subdomain_name = ENV['SUBDOMAIN_DOMAIN']
|
11
11
|
@domain_name = ENV['DOMAIN']
|
12
12
|
@username = ENV['USERNAME']
|
13
|
-
@
|
14
|
-
@subuser1 = ENV['SUBUSER1']
|
15
|
-
@subuser2 = ENV['SUBUSER2']
|
13
|
+
@subuser = ENV['SUBUSER']
|
16
14
|
@email1 = ENV['MAIL']
|
17
15
|
@password1 = ENV['PASS']
|
18
16
|
@ip = ENV['IP']
|
19
|
-
# celan up test env
|
17
|
+
# celan up test env
|
20
18
|
@id1 = nil
|
21
19
|
@id2 = nil
|
22
20
|
@id3 = nil
|
@@ -41,83 +39,41 @@ describe SendGrid4r::REST::Whitelabel::Domains do
|
|
41
39
|
end
|
42
40
|
end
|
43
41
|
# post domain
|
42
|
+
@client.delete_wl_domain(id: @id1) unless @id1.nil?
|
43
|
+
@client.delete_wl_domain(id: @id2) unless @id2.nil?
|
44
|
+
@client.delete_wl_domain(id: @id3) unless @id3.nil?
|
45
|
+
@client.delete_wl_domain(id: @id4) unless @id4.nil?
|
44
46
|
@domain1 = @client.post_wl_domain(
|
45
47
|
domain: @domain_name, subdomain: @subdomain_name + '1'
|
46
|
-
)
|
48
|
+
)
|
47
49
|
@domain2 = @client.post_wl_domain(
|
48
50
|
domain: @domain_name, subdomain: @subdomain_name + '2',
|
49
|
-
username: @
|
50
|
-
automatic_security: false, custom_spf:
|
51
|
-
)
|
51
|
+
username: @subuser, ips: nil,
|
52
|
+
automatic_security: false, custom_spf: false, default: false
|
53
|
+
)
|
52
54
|
@domain3 = @client.post_wl_domain(
|
53
55
|
domain: @domain_name, subdomain: @subdomain_name + '3',
|
54
|
-
username: @
|
56
|
+
username: @subuser, ips: nil,
|
55
57
|
automatic_security: true, custom_spf: false, default: false
|
56
|
-
) if @id3.nil?
|
57
|
-
@domain4 = @client.post_wl_domain(
|
58
|
-
domain: @domain_name, subdomain: @subdomain_name + '4',
|
59
|
-
username: @username, ips: [@ip],
|
60
|
-
automatic_security: true, custom_spf: true, default: false
|
61
|
-
) if @id4.nil?
|
62
|
-
# make a default
|
63
|
-
@id1 = @domain1.id if @id1.nil?
|
64
|
-
@id2 = @domain2.id if @id2.nil?
|
65
|
-
@id3 = @domain3.id if @id3.nil?
|
66
|
-
@id4 = @domain4.id if @id4.nil?
|
67
|
-
@client.patch_wl_domain(id: @id3, default: true)
|
68
|
-
@client.delete_wl_domain(id: @id1)
|
69
|
-
@client.delete_wl_domain(id: @id2)
|
70
|
-
@client.delete_wl_domain(id: @id4)
|
71
|
-
@domain1 = @client.post_wl_domain(
|
72
|
-
domain: @domain_name, subdomain: @subdomain_name + '1'
|
73
|
-
)
|
74
|
-
@domain2 = @client.post_wl_domain(
|
75
|
-
domain: @domain_name, subdomain: @subdomain_name + '2',
|
76
|
-
username: @username, ips: nil,
|
77
|
-
automatic_security: false, custom_spf: false, default: false
|
78
58
|
)
|
79
59
|
@domain4 = @client.post_wl_domain(
|
80
60
|
domain: @domain_name, subdomain: @subdomain_name + '4',
|
81
|
-
username: @
|
61
|
+
username: @subuser, ips: [@ip],
|
82
62
|
automatic_security: false, custom_spf: true, default: false
|
83
63
|
)
|
84
|
-
# clean subusers
|
85
|
-
subusers = @client.get_subusers
|
86
|
-
count = subusers.count { |subuser| subuser.username == @subuser1 }
|
87
|
-
@client.delete_subuser(username: @subuser1) if count == 1
|
88
|
-
@client.post_subuser(
|
89
|
-
username: @subuser1,
|
90
|
-
email: @email1,
|
91
|
-
password: @password1,
|
92
|
-
ips: [@ip]
|
93
|
-
)
|
94
|
-
rescue RestClient::ExceptionWithResponse => e
|
95
|
-
puts e.inspect
|
96
|
-
raise e
|
97
64
|
end
|
98
|
-
end
|
99
65
|
|
100
|
-
|
101
|
-
|
102
|
-
begin
|
66
|
+
context 'without block call' do
|
67
|
+
it '#get_wl_domains' do
|
103
68
|
domains = @client.get_wl_domains
|
104
69
|
expect(domains).to be_a(Array)
|
105
70
|
domains.each do |domain|
|
106
|
-
expect(domain).to be_a(
|
107
|
-
SendGrid4r::REST::Whitelabel::Domains::Domain
|
108
|
-
)
|
71
|
+
expect(domain).to be_a(Domains::Domain)
|
109
72
|
end
|
110
|
-
rescue RestClient::ExceptionWithResponse => e
|
111
|
-
puts e.inspect
|
112
|
-
raise e
|
113
73
|
end
|
114
|
-
end
|
115
74
|
|
116
|
-
|
117
|
-
|
118
|
-
expect(@domain1).to be_a(
|
119
|
-
SendGrid4r::REST::Whitelabel::Domains::Domain
|
120
|
-
)
|
75
|
+
it '#post_wl_domain' do
|
76
|
+
expect(@domain1).to be_a(Domains::Domain)
|
121
77
|
expect(@domain1.domain).to eq(@domain_name)
|
122
78
|
expect(@domain1.subdomain).to eq(@subdomain_name + '1')
|
123
79
|
expect(@domain1.username).to eq(@username)
|
@@ -128,21 +84,13 @@ describe SendGrid4r::REST::Whitelabel::Domains do
|
|
128
84
|
expect(@domain1.default).to eq(false)
|
129
85
|
expect(@domain1.legacy).to eq(false)
|
130
86
|
expect(@domain1.valid).to eq(false)
|
131
|
-
expect(@domain1.dns.mail_cname).to be_a(
|
132
|
-
|
133
|
-
)
|
134
|
-
expect(@
|
135
|
-
SendGrid4r::REST::Whitelabel::Domains::Record
|
136
|
-
)
|
137
|
-
expect(@domain1.dns.dkim2).to be_a(
|
138
|
-
SendGrid4r::REST::Whitelabel::Domains::Record
|
139
|
-
)
|
140
|
-
expect(@domain2).to be_a(
|
141
|
-
SendGrid4r::REST::Whitelabel::Domains::Domain
|
142
|
-
)
|
87
|
+
expect(@domain1.dns.mail_cname).to be_a(Domains::Record)
|
88
|
+
expect(@domain1.dns.dkim1).to be_a(Domains::Record)
|
89
|
+
expect(@domain1.dns.dkim2).to be_a(Domains::Record)
|
90
|
+
expect(@domain2).to be_a(Domains::Domain)
|
143
91
|
expect(@domain2.domain).to eq(@domain_name)
|
144
92
|
expect(@domain2.subdomain).to eq(@subdomain_name + '2')
|
145
|
-
expect(@domain2.username).to eq(@
|
93
|
+
expect(@domain2.username).to eq(@subuser)
|
146
94
|
expect(@domain2.user_id).to be_a(Numeric)
|
147
95
|
expect(@domain2.ips).to eq([])
|
148
96
|
expect(@domain2.automatic_security).to eq(false)
|
@@ -150,25 +98,14 @@ describe SendGrid4r::REST::Whitelabel::Domains do
|
|
150
98
|
expect(@domain2.default).to eq(false)
|
151
99
|
expect(@domain2.legacy).to eq(false)
|
152
100
|
expect(@domain2.valid).to eq(false)
|
153
|
-
expect(@domain2.dns.mail_server).to be_a(
|
154
|
-
|
155
|
-
)
|
156
|
-
expect(@domain2.dns.subdomain_spf).to be_a(
|
157
|
-
SendGrid4r::REST::Whitelabel::Domains::Record
|
158
|
-
)
|
159
|
-
expect(@domain2.dns.dkim).to be_a(
|
160
|
-
SendGrid4r::REST::Whitelabel::Domains::Record
|
161
|
-
)
|
162
|
-
rescue RestClient::ExceptionWithResponse => e
|
163
|
-
puts e.inspect
|
164
|
-
raise e
|
101
|
+
expect(@domain2.dns.mail_server).to be_a(Domains::Record)
|
102
|
+
expect(@domain2.dns.subdomain_spf).to be_a(Domains::Record)
|
103
|
+
expect(@domain2.dns.dkim).to be_a(Domains::Record)
|
165
104
|
end
|
166
|
-
end
|
167
105
|
|
168
|
-
|
169
|
-
begin
|
106
|
+
it '#get_wl_domain' do
|
170
107
|
domain1 = @client.get_wl_domain(id: @domain1.id)
|
171
|
-
expect(domain1).to be_a(
|
108
|
+
expect(domain1).to be_a(Domains::Domain)
|
172
109
|
expect(domain1.domain).to eq(@domain_name)
|
173
110
|
expect(domain1.subdomain).to eq(@subdomain_name + '1')
|
174
111
|
expect(domain1.username).to eq(@username)
|
@@ -180,9 +117,7 @@ describe SendGrid4r::REST::Whitelabel::Domains do
|
|
180
117
|
expect(domain1.legacy).to eq(false)
|
181
118
|
expect(domain1.valid).to eq(false)
|
182
119
|
# mail_cname
|
183
|
-
expect(domain1.dns.mail_cname).to be_a(
|
184
|
-
SendGrid4r::REST::Whitelabel::Domains::Record
|
185
|
-
)
|
120
|
+
expect(domain1.dns.mail_cname).to be_a(Domains::Record)
|
186
121
|
expect(domain1.dns.mail_cname.valid).to eq(false)
|
187
122
|
expect(domain1.dns.mail_cname.type).to eq('cname')
|
188
123
|
expect(domain1.dns.mail_cname.host).to eq(
|
@@ -191,29 +126,23 @@ describe SendGrid4r::REST::Whitelabel::Domains do
|
|
191
126
|
expect(domain1.dns.mail_cname.data).to be_a(String)
|
192
127
|
# dkim1
|
193
128
|
expect(domain1.dns.dkim1).to be_a(
|
194
|
-
|
129
|
+
Domains::Record
|
195
130
|
)
|
196
131
|
expect(domain1.dns.dkim1.valid).to eq(false)
|
197
132
|
expect(domain1.dns.dkim1.type).to eq('cname')
|
198
|
-
expect(domain1.dns.dkim1.host).to eq(
|
199
|
-
"s1._domainkey.#{@domain_name}"
|
200
|
-
)
|
133
|
+
expect(domain1.dns.dkim1.host).to eq("s1._domainkey.#{@domain_name}")
|
201
134
|
expect(domain1.dns.dkim1.data).to be_a(String)
|
202
135
|
# dkim2
|
203
|
-
expect(domain1.dns.dkim2).to be_a(
|
204
|
-
SendGrid4r::REST::Whitelabel::Domains::Record
|
205
|
-
)
|
136
|
+
expect(domain1.dns.dkim2).to be_a(Domains::Record)
|
206
137
|
expect(domain1.dns.dkim2.valid).to eq(false)
|
207
138
|
expect(domain1.dns.dkim2.type).to eq('cname')
|
208
|
-
expect(domain1.dns.dkim2.host).to eq(
|
209
|
-
"s2._domainkey.#{@domain_name}"
|
210
|
-
)
|
139
|
+
expect(domain1.dns.dkim2.host).to eq("s2._domainkey.#{@domain_name}")
|
211
140
|
expect(domain1.dns.dkim2.data).to be_a(String)
|
212
141
|
domain2 = @client.get_wl_domain(id: @domain2.id)
|
213
|
-
expect(domain2).to be_a(
|
142
|
+
expect(domain2).to be_a(Domains::Domain)
|
214
143
|
expect(domain2.domain).to eq(@domain_name)
|
215
144
|
expect(domain2.subdomain).to eq(@subdomain_name + '2')
|
216
|
-
expect(domain2.username).to eq(@
|
145
|
+
expect(domain2.username).to eq(@subuser)
|
217
146
|
expect(domain2.user_id).to be_a(Numeric)
|
218
147
|
expect(domain2.ips).to eq([])
|
219
148
|
expect(domain2.automatic_security).to eq(false)
|
@@ -222,9 +151,7 @@ describe SendGrid4r::REST::Whitelabel::Domains do
|
|
222
151
|
expect(domain2.legacy).to eq(false)
|
223
152
|
expect(domain2.valid).to eq(false)
|
224
153
|
# mail_server
|
225
|
-
expect(domain2.dns.mail_server).to be_a(
|
226
|
-
SendGrid4r::REST::Whitelabel::Domains::Record
|
227
|
-
)
|
154
|
+
expect(domain2.dns.mail_server).to be_a(Domains::Record)
|
228
155
|
expect(domain2.dns.mail_server.valid).to eq(false)
|
229
156
|
expect(domain2.dns.mail_server.type).to eq('mx')
|
230
157
|
expect(domain2.dns.mail_server.host).to eq(
|
@@ -232,9 +159,7 @@ describe SendGrid4r::REST::Whitelabel::Domains do
|
|
232
159
|
)
|
233
160
|
expect(domain2.dns.mail_server.data).to eq('mx.sendgrid.net.')
|
234
161
|
# subdomain_spf
|
235
|
-
expect(domain2.dns.subdomain_spf).to be_a(
|
236
|
-
SendGrid4r::REST::Whitelabel::Domains::Record
|
237
|
-
)
|
162
|
+
expect(domain2.dns.subdomain_spf).to be_a(Domains::Record)
|
238
163
|
expect(domain2.dns.subdomain_spf.valid).to eq(false)
|
239
164
|
expect(domain2.dns.subdomain_spf.type).to eq('txt')
|
240
165
|
expect(domain2.dns.subdomain_spf.host).to eq(
|
@@ -244,22 +169,16 @@ describe SendGrid4r::REST::Whitelabel::Domains do
|
|
244
169
|
'v=spf1 include:sendgrid.net ~all'
|
245
170
|
)
|
246
171
|
# dkim
|
247
|
-
expect(domain2.dns.dkim).to be_a(
|
248
|
-
SendGrid4r::REST::Whitelabel::Domains::Record
|
249
|
-
)
|
172
|
+
expect(domain2.dns.dkim).to be_a(Domains::Record)
|
250
173
|
expect(domain2.dns.dkim.valid).to eq(false)
|
251
174
|
expect(domain2.dns.dkim.type).to eq('txt')
|
252
|
-
expect(domain2.dns.dkim.host).to eq(
|
253
|
-
|
254
|
-
)
|
255
|
-
expect(domain2.dns.dkim.data).to start_with(
|
256
|
-
'k=rsa; t=s; p='
|
257
|
-
)
|
175
|
+
expect(domain2.dns.dkim.host).to eq("m1._domainkey.#{@domain_name}")
|
176
|
+
expect(domain2.dns.dkim.data).to start_with('k=rsa; t=s; p=')
|
258
177
|
domain4 = @client.get_wl_domain(id: @domain4.id)
|
259
|
-
expect(domain4).to be_a(
|
178
|
+
expect(domain4).to be_a(Domains::Domain)
|
260
179
|
expect(domain4.domain).to eq(@domain_name)
|
261
180
|
expect(domain4.subdomain).to eq(@subdomain_name + '4')
|
262
|
-
expect(domain4.username).to eq(@
|
181
|
+
expect(domain4.username).to eq(@subuser)
|
263
182
|
expect(domain4.user_id).to be_a(Numeric)
|
264
183
|
expect(domain4.ips).to eq([@ip])
|
265
184
|
expect(domain4.automatic_security).to eq(false)
|
@@ -268,9 +187,7 @@ describe SendGrid4r::REST::Whitelabel::Domains do
|
|
268
187
|
expect(domain4.legacy).to eq(false)
|
269
188
|
expect(domain4.valid).to eq(false)
|
270
189
|
# mail_server
|
271
|
-
expect(domain4.dns.mail_server).to be_a(
|
272
|
-
SendGrid4r::REST::Whitelabel::Domains::Record
|
273
|
-
)
|
190
|
+
expect(domain4.dns.mail_server).to be_a(Domains::Record)
|
274
191
|
expect(domain4.dns.mail_server.valid).to eq(false)
|
275
192
|
expect(domain4.dns.mail_server.type).to eq('mx')
|
276
193
|
expect(domain4.dns.mail_server.host).to eq(
|
@@ -278,41 +195,26 @@ describe SendGrid4r::REST::Whitelabel::Domains do
|
|
278
195
|
)
|
279
196
|
expect(domain4.dns.mail_server.data).to eq('mx.sendgrid.net.')
|
280
197
|
# subdomain_spf
|
281
|
-
expect(domain4.dns.subdomain_spf).to be_a(
|
282
|
-
SendGrid4r::REST::Whitelabel::Domains::Record
|
283
|
-
)
|
198
|
+
expect(domain4.dns.subdomain_spf).to be_a(Domains::Record)
|
284
199
|
expect(domain4.dns.subdomain_spf.valid).to eq(false)
|
285
200
|
expect(domain4.dns.subdomain_spf.type).to eq('txt')
|
286
201
|
expect(domain4.dns.subdomain_spf.host).to eq(
|
287
202
|
"#{@subdomain_name}4.#{@domain_name}"
|
288
203
|
)
|
289
|
-
expect(domain4.dns.subdomain_spf.data).to eq(
|
290
|
-
"v=spf1 ip4:#{@ip} -all"
|
291
|
-
)
|
204
|
+
expect(domain4.dns.subdomain_spf.data).to eq("v=spf1 ip4:#{@ip} -all")
|
292
205
|
# dkim
|
293
|
-
expect(domain4.dns.dkim).to be_a(
|
294
|
-
SendGrid4r::REST::Whitelabel::Domains::Record
|
295
|
-
)
|
206
|
+
expect(domain4.dns.dkim).to be_a(Domains::Record)
|
296
207
|
expect(domain4.dns.dkim.valid).to eq(false)
|
297
208
|
expect(domain4.dns.dkim.type).to eq('txt')
|
298
|
-
expect(domain4.dns.dkim.host).to eq(
|
299
|
-
|
300
|
-
)
|
301
|
-
expect(domain4.dns.dkim.data).to start_with(
|
302
|
-
'k=rsa; t=s; p='
|
303
|
-
)
|
304
|
-
rescue RestClient::ExceptionWithResponse => e
|
305
|
-
puts e.inspect
|
306
|
-
raise e
|
209
|
+
expect(domain4.dns.dkim.host).to eq("m1._domainkey.#{@domain_name}")
|
210
|
+
expect(domain4.dns.dkim.data).to start_with('k=rsa; t=s; p=')
|
307
211
|
end
|
308
|
-
end
|
309
212
|
|
310
|
-
|
311
|
-
begin
|
213
|
+
it '#patch_wl_domain' do
|
312
214
|
domain1 = @client.patch_wl_domain(
|
313
215
|
id: @domain1.id, custom_spf: true, default: nil
|
314
216
|
)
|
315
|
-
expect(domain1).to be_a(
|
217
|
+
expect(domain1).to be_a(Domains::Domain)
|
316
218
|
expect(domain1.domain).to eq(@domain_name)
|
317
219
|
expect(domain1.subdomain).to eq(@subdomain_name + '1')
|
318
220
|
expect(domain1.username).to eq(@username)
|
@@ -321,423 +223,341 @@ describe SendGrid4r::REST::Whitelabel::Domains do
|
|
321
223
|
expect(domain1.automatic_security).to eq(true)
|
322
224
|
expect(domain1.custom_spf).to eq(true)
|
323
225
|
expect(domain1.default).to eq(false)
|
324
|
-
rescue RestClient::ExceptionWithResponse => e
|
325
|
-
puts e.inspect
|
326
|
-
raise e
|
327
226
|
end
|
328
|
-
end
|
329
227
|
|
330
|
-
|
331
|
-
begin
|
228
|
+
it '#delete_wl_domain' do
|
332
229
|
@client.delete_wl_domain(id: @domain1.id)
|
333
|
-
rescue RestClient::ExceptionWithResponse => e
|
334
|
-
puts e.inspect
|
335
|
-
raise e
|
336
230
|
end
|
337
|
-
end
|
338
231
|
|
339
|
-
|
340
|
-
begin
|
232
|
+
it '#get_default_wl_domain' do
|
341
233
|
domain2 = @client.get_default_wl_domain
|
342
|
-
expect(domain2).to be_a(
|
343
|
-
rescue RestClient::ExceptionWithResponse => e
|
344
|
-
puts e.inspect
|
345
|
-
raise e
|
234
|
+
expect(domain2).to be_a(Domains::Domain)
|
346
235
|
end
|
347
|
-
end
|
348
236
|
|
349
|
-
|
350
|
-
begin
|
237
|
+
it '#add_ip_to_wl_domain' do
|
351
238
|
domain2 = @client.add_ip_to_wl_domain(id: @domain2.id, ip: @ip)
|
352
239
|
expect(domain2.ips).to eq([@ip])
|
353
|
-
rescue RestClient::ExceptionWithResponse => e
|
354
|
-
puts e.inspect
|
355
|
-
raise e
|
356
240
|
end
|
357
|
-
end
|
358
241
|
|
359
|
-
|
360
|
-
begin
|
242
|
+
it '#remove_ip_from_wl_domain' do
|
361
243
|
@client.add_ip_to_wl_domain(id: @domain2.id, ip: @ip)
|
362
|
-
domain2 = @client.remove_ip_from_wl_domain(
|
363
|
-
id: @domain2.id, ip: @ip
|
364
|
-
)
|
244
|
+
domain2 = @client.remove_ip_from_wl_domain(id: @domain2.id, ip: @ip)
|
365
245
|
expect(domain2.ips).to eq(nil)
|
366
|
-
rescue RestClient::ExceptionWithResponse => e
|
367
|
-
puts e.inspect
|
368
|
-
raise e
|
369
246
|
end
|
370
|
-
end
|
371
247
|
|
372
|
-
|
373
|
-
begin
|
248
|
+
it '#validate_wl_domain' do
|
374
249
|
result1 = @client.validate_wl_domain(id: @domain1.id)
|
375
|
-
expect(result1).to be_a(
|
376
|
-
SendGrid4r::REST::Whitelabel::Domains::Result
|
377
|
-
)
|
250
|
+
expect(result1).to be_a(Domains::Result)
|
378
251
|
expect(result1.valid).to be(false)
|
379
|
-
expect(result1.validation_results.mail_cname.valid).to be(
|
380
|
-
|
381
|
-
)
|
382
|
-
expect(result1.validation_results.
|
383
|
-
|
384
|
-
)
|
385
|
-
expect(result1.validation_results.dkim1.valid).to be(
|
386
|
-
false
|
387
|
-
)
|
388
|
-
expect(result1.validation_results.dkim1.reason).to be_a(
|
389
|
-
String
|
390
|
-
)
|
391
|
-
expect(result1.validation_results.dkim2.valid).to be(
|
392
|
-
false
|
393
|
-
)
|
394
|
-
expect(result1.validation_results.dkim2.reason).to be_a(
|
395
|
-
String
|
396
|
-
)
|
252
|
+
expect(result1.validation_results.mail_cname.valid).to be(false)
|
253
|
+
expect(result1.validation_results.mail_cname.reason).to be_a(String)
|
254
|
+
expect(result1.validation_results.dkim1.valid).to be(false)
|
255
|
+
expect(result1.validation_results.dkim1.reason).to be_a(String)
|
256
|
+
expect(result1.validation_results.dkim2.valid).to be(false)
|
257
|
+
expect(result1.validation_results.dkim2.reason).to be_a(String)
|
397
258
|
result2 = @client.validate_wl_domain(id: @domain2.id)
|
398
|
-
expect(result2).to be_a(
|
399
|
-
SendGrid4r::REST::Whitelabel::Domains::Result
|
400
|
-
)
|
259
|
+
expect(result2).to be_a(Domains::Result)
|
401
260
|
expect(result2.valid).to be(false)
|
402
|
-
expect(result2.validation_results.mail_server.valid).to be(
|
403
|
-
|
404
|
-
)
|
405
|
-
expect(result2.validation_results.mail_server.reason).to be_a(
|
406
|
-
String
|
407
|
-
)
|
408
|
-
expect(result2.validation_results.subdomain_spf.valid).to be(
|
409
|
-
false
|
410
|
-
)
|
261
|
+
expect(result2.validation_results.mail_server.valid).to be(false)
|
262
|
+
expect(result2.validation_results.mail_server.reason).to be_a(String)
|
263
|
+
expect(result2.validation_results.subdomain_spf.valid).to be(false)
|
411
264
|
expect(result2.validation_results.subdomain_spf.reason).to be_a(
|
412
265
|
String
|
413
266
|
)
|
414
|
-
expect(result2.validation_results.dkim.valid).to be(
|
415
|
-
|
416
|
-
)
|
417
|
-
expect(result2.validation_results.dkim.reason).to be_a(
|
418
|
-
String
|
419
|
-
)
|
420
|
-
rescue RestClient::ExceptionWithResponse => e
|
421
|
-
puts e.inspect
|
422
|
-
raise e
|
267
|
+
expect(result2.validation_results.dkim.valid).to be(false)
|
268
|
+
expect(result2.validation_results.dkim.reason).to be_a(String)
|
423
269
|
end
|
424
|
-
end
|
425
270
|
|
426
|
-
|
427
|
-
|
428
|
-
domain1
|
429
|
-
expect(domain1).to be_a(SendGrid4r::REST::Whitelabel::Domains::Domain)
|
430
|
-
rescue RestClient::ExceptionWithResponse => e
|
431
|
-
puts e.inspect
|
432
|
-
raise e
|
271
|
+
it '#get_associated_wl_domain' do
|
272
|
+
domain1 = @client.get_associated_wl_domain(username: @subuser)
|
273
|
+
expect(domain1).to be_a(Domains::Domain)
|
433
274
|
end
|
434
|
-
end
|
435
275
|
|
436
|
-
|
437
|
-
|
438
|
-
@client.associate_wl_domain(id: @domain2.id, username: @subuser1)
|
439
|
-
rescue RestClient::ExceptionWithResponse => e
|
440
|
-
puts e.inspect
|
441
|
-
raise e
|
276
|
+
it '#associate_wl_domain' do
|
277
|
+
@client.associate_wl_domain(id: @domain2.id, username: @subuser)
|
442
278
|
end
|
443
|
-
end
|
444
279
|
|
445
|
-
|
446
|
-
|
447
|
-
@client.
|
448
|
-
@client.disassociate_wl_domain(username: @subuser1)
|
449
|
-
rescue RestClient::ExceptionWithResponse => e
|
450
|
-
puts e.inspect
|
451
|
-
raise e
|
280
|
+
it '#disassociate_wl_domain' do
|
281
|
+
@client.associate_wl_domain(id: @domain2.id, username: @subuser)
|
282
|
+
@client.disassociate_wl_domain(username: @subuser)
|
452
283
|
end
|
453
284
|
end
|
454
285
|
end
|
455
|
-
end
|
456
286
|
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
287
|
+
describe 'unit test', :ut do
|
288
|
+
let(:client) do
|
289
|
+
SendGrid4r::Client.new(api_key: '')
|
290
|
+
end
|
461
291
|
|
462
|
-
|
463
|
-
|
464
|
-
|
292
|
+
let(:domains) do
|
293
|
+
JSON.parse('[]')
|
294
|
+
end
|
465
295
|
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
296
|
+
let(:domain) do
|
297
|
+
JSON.parse(
|
298
|
+
'{'\
|
299
|
+
'"id": 1,'\
|
300
|
+
'"domain": "example.com",'\
|
301
|
+
'"subdomain": "mail",'\
|
302
|
+
'"username": "john@example.com",'\
|
303
|
+
'"user_id": 7,'\
|
304
|
+
'"ips": ['\
|
305
|
+
'"192.168.1.1",'\
|
306
|
+
'"192.168.1.2"'\
|
307
|
+
'],'\
|
308
|
+
'"custom_spf": true,'\
|
309
|
+
'"default": true,'\
|
310
|
+
'"legacy": false,'\
|
311
|
+
'"automatic_security": true,'\
|
312
|
+
'"valid": true,'\
|
313
|
+
'"dns": {'\
|
314
|
+
'"mail_cname": {'\
|
315
|
+
'"host": "mail.example.com",'\
|
316
|
+
'"type": "cname",'\
|
317
|
+
'"data": "u7.wl.sendgrid.net",'\
|
318
|
+
'"valid": true'\
|
319
|
+
'},'\
|
320
|
+
'"dkim1": {'\
|
321
|
+
'"host": "s1._domainkey.example.com",'\
|
322
|
+
'"type": "cname",'\
|
323
|
+
'"data": "s1._domainkey.u7.wl.sendgrid.net",'\
|
324
|
+
'"valid": true'\
|
325
|
+
'},'\
|
326
|
+
'"dkim2": {'\
|
327
|
+
'"host": "s2._domainkey.example.com",'\
|
328
|
+
'"type": "cname",'\
|
329
|
+
'"data": "s2._domainkey.u7.wl.sendgrid.net",'\
|
330
|
+
'"valid": true'\
|
331
|
+
'}'\
|
501
332
|
'}'\
|
502
|
-
'}'
|
503
|
-
|
504
|
-
|
505
|
-
end
|
333
|
+
'}'
|
334
|
+
)
|
335
|
+
end
|
506
336
|
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
337
|
+
let(:domain2) do
|
338
|
+
JSON.parse(
|
339
|
+
'{'\
|
340
|
+
'"id": 2,'\
|
341
|
+
'"user_id": 2,'\
|
342
|
+
'"subdomain": "mail2",'\
|
343
|
+
'"domain": "example.com",'\
|
344
|
+
'"username": "john@example.com",'\
|
345
|
+
'"ips": [],'\
|
346
|
+
'"custom_spf": true,'\
|
347
|
+
'"default": false,'\
|
348
|
+
'"legacy": false,'\
|
349
|
+
'"automatic_security": false,'\
|
350
|
+
'"valid": false,'\
|
351
|
+
'"dns": {'\
|
352
|
+
'"mail_server": {'\
|
353
|
+
'"valid": false,'\
|
354
|
+
'"type": "mx",'\
|
355
|
+
'"host": "mail2.example.com",'\
|
356
|
+
'"data": "mx.sendgrid.net."'\
|
357
|
+
'},'\
|
358
|
+
'"subdomain_spf": {'\
|
359
|
+
'"valid": false,'\
|
360
|
+
'"type": "txt",'\
|
361
|
+
'"host": "mail2.example.com",'\
|
362
|
+
'"data": "v=spf1 include:sendgrid.net ~all"'\
|
363
|
+
'},'\
|
364
|
+
'"dkim": {'\
|
365
|
+
'"valid": false,'\
|
366
|
+
'"type": "txt",'\
|
367
|
+
'"host": "m1._domainkey.example.com",'\
|
368
|
+
'"data": "k=rsa; t=s; '\
|
369
|
+
'p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ"'\
|
370
|
+
'}'\
|
539
371
|
'}'\
|
540
|
-
'}'
|
541
|
-
|
542
|
-
|
543
|
-
end
|
372
|
+
'}'
|
373
|
+
)
|
374
|
+
end
|
544
375
|
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
376
|
+
let(:result) do
|
377
|
+
JSON.parse(
|
378
|
+
'{'\
|
379
|
+
'"id": 1,'\
|
380
|
+
'"valid": true,'\
|
381
|
+
'"validation_results": {'\
|
382
|
+
'"mail_cname": {'\
|
383
|
+
'"valid": false,'\
|
384
|
+
'"reason": "Expected your MX record to be \"mx.sendgrid.net\" '\
|
385
|
+
'but found \"example.com\"."'\
|
386
|
+
'},'\
|
387
|
+
'"dkim1": {'\
|
388
|
+
'"valid": true,'\
|
389
|
+
'"reason": null'\
|
390
|
+
'},'\
|
391
|
+
'"dkim2": {'\
|
392
|
+
'"valid": true,'\
|
393
|
+
'"reason": null'\
|
394
|
+
'}'\
|
563
395
|
'}'\
|
564
|
-
'}'
|
565
|
-
|
566
|
-
|
567
|
-
end
|
396
|
+
'}'
|
397
|
+
)
|
398
|
+
end
|
568
399
|
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
400
|
+
it '#get_domains' do
|
401
|
+
allow(client).to receive(:execute).and_return(domains)
|
402
|
+
actual = client.get_wl_domains
|
403
|
+
expect(actual).to be_a(Array)
|
404
|
+
end
|
574
405
|
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
406
|
+
it '#post_domain' do
|
407
|
+
allow(client).to receive(:execute).and_return(domain)
|
408
|
+
actual = client.post_wl_domain(domain: '', subdomain: '')
|
409
|
+
expect(actual).to be_a(Domains::Domain)
|
410
|
+
end
|
580
411
|
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
412
|
+
it '#get_domain' do
|
413
|
+
allow(client).to receive(:execute).and_return(domain)
|
414
|
+
actual = client.get_wl_domain(id: '')
|
415
|
+
expect(actual).to be_a(Domains::Domain)
|
416
|
+
end
|
586
417
|
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
418
|
+
it '#patch_domain' do
|
419
|
+
allow(client).to receive(:execute).and_return(domain)
|
420
|
+
actual = client.patch_wl_domain(
|
421
|
+
id: '', custom_spf: true, default: false
|
422
|
+
)
|
423
|
+
expect(actual).to be_a(Domains::Domain)
|
424
|
+
end
|
592
425
|
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
426
|
+
it '#delete_domain' do
|
427
|
+
allow(client).to receive(:execute).and_return('')
|
428
|
+
actual = client.delete_wl_domain(id: '')
|
429
|
+
expect(actual).to eq('')
|
430
|
+
end
|
598
431
|
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
432
|
+
it '#get_default_domain' do
|
433
|
+
allow(client).to receive(:execute).and_return(domain)
|
434
|
+
actual = client.get_default_wl_domain(domain: '')
|
435
|
+
expect(actual).to be_a(Domains::Domain)
|
436
|
+
end
|
604
437
|
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
438
|
+
it '#add_ip_to_domain' do
|
439
|
+
allow(client).to receive(:execute).and_return(domain)
|
440
|
+
actual = client.add_ip_to_wl_domain(id: '', ip: '')
|
441
|
+
expect(actual).to be_a(Domains::Domain)
|
442
|
+
end
|
610
443
|
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
444
|
+
it '#remove_ip_from_domain' do
|
445
|
+
allow(client).to receive(:execute).and_return(domain)
|
446
|
+
actual = client.remove_ip_from_wl_domain(id: '', ip: '')
|
447
|
+
expect(actual).to be_a(Domains::Domain)
|
448
|
+
end
|
616
449
|
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
450
|
+
it '#validate_domain' do
|
451
|
+
allow(client).to receive(:execute).and_return(result)
|
452
|
+
actual = client.validate_wl_domain(id: '')
|
453
|
+
expect(actual).to be_a(Domains::Result)
|
454
|
+
end
|
622
455
|
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
456
|
+
it '#get_associated_wl_domain' do
|
457
|
+
allow(client).to receive(:execute).and_return(domain)
|
458
|
+
actual = client.get_associated_wl_domain(username: '')
|
459
|
+
expect(actual).to be_a(Domains::Domain)
|
460
|
+
end
|
628
461
|
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
462
|
+
it '#disassociate_wl_domain' do
|
463
|
+
allow(client).to receive(:execute).and_return('')
|
464
|
+
actual = client.disassociate_wl_domain(username: '')
|
465
|
+
expect(actual).to eq('')
|
466
|
+
end
|
634
467
|
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
468
|
+
it '#associate_wl_domain' do
|
469
|
+
allow(client).to receive(:execute).and_return(domain)
|
470
|
+
actual = client.associate_wl_domain(id: '', username: '')
|
471
|
+
expect(actual).to be_a(Domains::Domain)
|
472
|
+
end
|
640
473
|
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
)
|
675
|
-
expect(actual.dns.dkim2.host).to eq('s2._domainkey.example.com')
|
676
|
-
expect(actual.dns.dkim2.type).to eq('cname')
|
677
|
-
expect(actual.dns.dkim2.data).to eq('s2._domainkey.u7.wl.sendgrid.net')
|
678
|
-
expect(actual.dns.dkim2.valid).to eq(true)
|
679
|
-
end
|
474
|
+
it 'creates domain instance' do
|
475
|
+
actual = Domains.create_domain(domain)
|
476
|
+
expect(actual).to be_a(Domains::Domain)
|
477
|
+
expect(actual.id).to eq(1)
|
478
|
+
expect(actual.domain).to eq('example.com')
|
479
|
+
expect(actual.subdomain).to eq('mail')
|
480
|
+
expect(actual.username).to eq('john@example.com')
|
481
|
+
expect(actual.user_id).to eq(7)
|
482
|
+
expect(actual.ips).to be_a(Array)
|
483
|
+
expect(actual.ips[0]).to eq('192.168.1.1')
|
484
|
+
expect(actual.ips[1]).to eq('192.168.1.2')
|
485
|
+
expect(actual.custom_spf).to eq(true)
|
486
|
+
expect(actual.default).to eq(true)
|
487
|
+
expect(actual.legacy).to eq(false)
|
488
|
+
expect(actual.automatic_security).to eq(true)
|
489
|
+
expect(actual.valid).to eq(true)
|
490
|
+
expect(actual.dns).to be_a(Domains::Dns)
|
491
|
+
expect(actual.dns.mail_cname).to be_a(Domains::Record)
|
492
|
+
expect(actual.dns.mail_cname.host).to eq('mail.example.com')
|
493
|
+
expect(actual.dns.mail_cname.type).to eq('cname')
|
494
|
+
expect(actual.dns.mail_cname.data).to eq('u7.wl.sendgrid.net')
|
495
|
+
expect(actual.dns.mail_cname.valid).to eq(true)
|
496
|
+
expect(actual.dns.dkim1).to be_a(Domains::Record)
|
497
|
+
expect(actual.dns.dkim1.host).to eq('s1._domainkey.example.com')
|
498
|
+
expect(actual.dns.dkim1.type).to eq('cname')
|
499
|
+
expect(actual.dns.dkim1.data).to eq('s1._domainkey.u7.wl.sendgrid.net')
|
500
|
+
expect(actual.dns.dkim1.valid).to eq(true)
|
501
|
+
expect(actual.dns.dkim2).to be_a(Domains::Record)
|
502
|
+
expect(actual.dns.dkim2.host).to eq('s2._domainkey.example.com')
|
503
|
+
expect(actual.dns.dkim2.type).to eq('cname')
|
504
|
+
expect(actual.dns.dkim2.data).to eq('s2._domainkey.u7.wl.sendgrid.net')
|
505
|
+
expect(actual.dns.dkim2.valid).to eq(true)
|
506
|
+
end
|
680
507
|
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
expect(actual.dns.dkim.type).to eq('txt')
|
717
|
-
expect(actual.dns.dkim.data).to eq(
|
718
|
-
'k=rsa; t=s; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ'
|
719
|
-
)
|
720
|
-
expect(actual.dns.dkim.valid).to eq(false)
|
721
|
-
end
|
508
|
+
it 'creates domain2 instance' do
|
509
|
+
actual = Domains.create_domain(domain2)
|
510
|
+
expect(actual).to be_a(Domains::Domain)
|
511
|
+
expect(actual.id).to eq(2)
|
512
|
+
expect(actual.domain).to eq('example.com')
|
513
|
+
expect(actual.subdomain).to eq('mail2')
|
514
|
+
expect(actual.username).to eq('john@example.com')
|
515
|
+
expect(actual.user_id).to eq(2)
|
516
|
+
expect(actual.ips).to be_a(Array)
|
517
|
+
expect(actual.custom_spf).to eq(true)
|
518
|
+
expect(actual.default).to eq(false)
|
519
|
+
expect(actual.legacy).to eq(false)
|
520
|
+
expect(actual.automatic_security).to eq(false)
|
521
|
+
expect(actual.valid).to eq(false)
|
522
|
+
expect(actual.dns).to be_a(Domains::Dns)
|
523
|
+
expect(actual.dns.mail_server).to be_a(Domains::Record)
|
524
|
+
expect(actual.dns.mail_server.host).to eq('mail2.example.com')
|
525
|
+
expect(actual.dns.mail_server.type).to eq('mx')
|
526
|
+
expect(actual.dns.mail_server.data).to eq('mx.sendgrid.net.')
|
527
|
+
expect(actual.dns.mail_server.valid).to eq(false)
|
528
|
+
expect(actual.dns.subdomain_spf).to be_a(Domains::Record)
|
529
|
+
expect(actual.dns.subdomain_spf.host).to eq('mail2.example.com')
|
530
|
+
expect(actual.dns.subdomain_spf.type).to eq('txt')
|
531
|
+
expect(actual.dns.subdomain_spf.data).to eq(
|
532
|
+
'v=spf1 include:sendgrid.net ~all'
|
533
|
+
)
|
534
|
+
expect(actual.dns.subdomain_spf.valid).to eq(false)
|
535
|
+
expect(actual.dns.dkim).to be_a(Domains::Record)
|
536
|
+
expect(actual.dns.dkim.host).to eq('m1._domainkey.example.com')
|
537
|
+
expect(actual.dns.dkim.type).to eq('txt')
|
538
|
+
expect(actual.dns.dkim.data).to eq(
|
539
|
+
'k=rsa; t=s; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ'
|
540
|
+
)
|
541
|
+
expect(actual.dns.dkim.valid).to eq(false)
|
542
|
+
end
|
722
543
|
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
expect(actual.validation_results.dkim2.reason).to be(nil)
|
544
|
+
it 'creates result instance' do
|
545
|
+
actual = Domains.create_result(result)
|
546
|
+
expect(actual).to be_a(Domains::Result)
|
547
|
+
expect(actual.id).to eq(1)
|
548
|
+
expect(actual.valid).to eq(true)
|
549
|
+
expect(actual.validation_results).to be_a(Domains::ValidationResults)
|
550
|
+
expect(actual.validation_results.dkim1).to be_a(
|
551
|
+
Domains::ValidationResult
|
552
|
+
)
|
553
|
+
expect(actual.validation_results.dkim1.valid).to be(true)
|
554
|
+
expect(actual.validation_results.dkim1.reason).to be(nil)
|
555
|
+
expect(actual.validation_results.dkim2).to be_a(
|
556
|
+
Domains::ValidationResult
|
557
|
+
)
|
558
|
+
expect(actual.validation_results.dkim2.valid).to be(true)
|
559
|
+
expect(actual.validation_results.dkim2.reason).to be(nil)
|
560
|
+
end
|
741
561
|
end
|
742
562
|
end
|
743
563
|
end
|