email_assessor 0.8.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/assets/data/blacklisted_domains/_prioritization.txt +1 -0
  3. data/assets/data/disposable_domains/0.txt +723 -0
  4. data/assets/data/disposable_domains/1.txt +1500 -0
  5. data/assets/data/disposable_domains/2.txt +1267 -0
  6. data/assets/data/disposable_domains/3.txt +1078 -0
  7. data/assets/data/disposable_domains/4.txt +854 -0
  8. data/assets/data/disposable_domains/5.txt +793 -0
  9. data/assets/data/disposable_domains/6.txt +900 -0
  10. data/assets/data/disposable_domains/7.txt +787 -0
  11. data/assets/data/disposable_domains/8.txt +979 -0
  12. data/assets/data/disposable_domains/9.txt +843 -0
  13. data/assets/data/disposable_domains/_prioritization.txt +1 -0
  14. data/assets/data/disposable_domains/a.txt +10167 -0
  15. data/assets/data/disposable_domains/b.txt +10443 -0
  16. data/assets/data/disposable_domains/c.txt +10152 -0
  17. data/assets/data/disposable_domains/d.txt +7619 -0
  18. data/assets/data/disposable_domains/e.txt +5689 -0
  19. data/assets/data/disposable_domains/f.txt +6375 -0
  20. data/assets/data/disposable_domains/g.txt +6309 -0
  21. data/assets/data/disposable_domains/h.txt +6204 -0
  22. data/assets/data/disposable_domains/i.txt +4814 -0
  23. data/assets/data/disposable_domains/j.txt +3163 -0
  24. data/assets/data/disposable_domains/k.txt +4308 -0
  25. data/assets/data/disposable_domains/l.txt +5903 -0
  26. data/assets/data/disposable_domains/m.txt +11177 -0
  27. data/assets/data/disposable_domains/n.txt +4895 -0
  28. data/assets/data/disposable_domains/o.txt +4161 -0
  29. data/assets/data/disposable_domains/p.txt +8264 -0
  30. data/assets/data/disposable_domains/q.txt +1493 -0
  31. data/assets/data/disposable_domains/r.txt +6199 -0
  32. data/assets/data/disposable_domains/s.txt +12775 -0
  33. data/assets/data/disposable_domains/t.txt +9496 -0
  34. data/assets/data/disposable_domains/u.txt +2662 -0
  35. data/assets/data/disposable_domains/v.txt +3766 -0
  36. data/assets/data/disposable_domains/w.txt +4633 -0
  37. data/assets/data/disposable_domains/x.txt +2449 -0
  38. data/assets/data/disposable_domains/y.txt +2278 -0
  39. data/assets/data/disposable_domains/z.txt +2035 -0
  40. data/assets/data/disposable_domains//351/231/270.txt +1 -0
  41. data/assets/data/disposable_domains//353/234/203.txt +1 -0
  42. data/assets/data/educational_domains/5.txt +1 -0
  43. data/assets/data/educational_domains/_prioritization.txt +1 -0
  44. data/assets/data/educational_domains/a.txt +232 -0
  45. data/assets/data/educational_domains/b.txt +112 -0
  46. data/assets/data/educational_domains/c.txt +126 -0
  47. data/assets/data/educational_domains/d.txt +90 -0
  48. data/assets/data/educational_domains/e.txt +331 -0
  49. data/assets/data/educational_domains/f.txt +156 -0
  50. data/assets/data/educational_domains/g.txt +75 -0
  51. data/assets/data/educational_domains/h.txt +147 -0
  52. data/assets/data/educational_domains/i.txt +179 -0
  53. data/assets/data/educational_domains/j.txt +26 -0
  54. data/assets/data/educational_domains/k.txt +142 -0
  55. data/assets/data/educational_domains/l.txt +88 -0
  56. data/assets/data/educational_domains/m.txt +155 -0
  57. data/assets/data/educational_domains/n.txt +98 -0
  58. data/assets/data/educational_domains/o.txt +39 -0
  59. data/assets/data/educational_domains/p.txt +128 -0
  60. data/assets/data/educational_domains/q.txt +4 -0
  61. data/assets/data/educational_domains/r.txt +69 -0
  62. data/assets/data/educational_domains/s.txt +251 -0
  63. data/assets/data/educational_domains/t.txt +146 -0
  64. data/assets/data/educational_domains/u.txt +975 -0
  65. data/assets/data/educational_domains/v.txt +78 -0
  66. data/assets/data/educational_domains/w.txt +59 -0
  67. data/assets/data/educational_domains/x.txt +1 -0
  68. data/assets/data/educational_domains/y.txt +17 -0
  69. data/assets/data/educational_domains/z.txt +13 -0
  70. data/assets/data/fastpass_domains/_prioritization.txt +1 -0
  71. data/assets/data/fastpass_domains/a.txt +2 -0
  72. data/assets/data/fastpass_domains/c.txt +3 -0
  73. data/assets/data/fastpass_domains/d.txt +1 -0
  74. data/assets/data/fastpass_domains/f.txt +1 -0
  75. data/assets/data/fastpass_domains/g.txt +5 -0
  76. data/assets/data/fastpass_domains/h.txt +33 -0
  77. data/assets/data/fastpass_domains/i.txt +1 -0
  78. data/assets/data/fastpass_domains/l.txt +6 -0
  79. data/assets/data/fastpass_domains/m.txt +4 -0
  80. data/assets/data/fastpass_domains/o.txt +28 -0
  81. data/assets/data/fastpass_domains/p.txt +3 -0
  82. data/assets/data/fastpass_domains/r.txt +1 -0
  83. data/assets/data/fastpass_domains/s.txt +3 -0
  84. data/assets/data/fastpass_domains/t.txt +1 -0
  85. data/assets/data/fastpass_domains/w.txt +2 -0
  86. data/assets/data/fastpass_domains/y.txt +42 -0
  87. data/lib/email_assessor/address.rb +27 -26
  88. data/lib/email_assessor/directory_domain_list.rb +51 -0
  89. data/lib/email_assessor/domain_token_set.rb +46 -0
  90. data/lib/email_assessor/email_validator.rb +0 -16
  91. data/lib/email_assessor/empty_domain_list.rb +23 -0
  92. data/lib/email_assessor/file_domain_list.rb +23 -0
  93. data/lib/email_assessor/version.rb +1 -1
  94. data/lib/email_assessor.rb +64 -17
  95. metadata +94 -22
  96. data/.gitignore +0 -18
  97. data/.travis.yml +0 -9
  98. data/CHANGELOG.md +0 -9
  99. data/Gemfile +0 -4
  100. data/LICENSE.txt +0 -22
  101. data/README.md +0 -132
  102. data/Rakefile +0 -10
  103. data/email_assessor.gemspec +0 -31
  104. data/gemfiles/activemodel4.gemfile +0 -5
  105. data/pull_mailchecker_emails.rb +0 -21
  106. data/spec/email_assessor_spec.rb +0 -209
  107. data/spec/spec_helper.rb +0 -19
  108. data/vendor/disposable_domains.txt +0 -55800
  109. data/vendor/educational_domains.txt +0 -3625
  110. data/vendor/fastpass_domains.txt +0 -35
  111. /data/{vendor/blacklisted_domains.txt → assets/data/blacklisted_domains/b.txt} +0 -0
@@ -1,209 +0,0 @@
1
- # frozen_string_literal: true
2
- require "spec_helper"
3
-
4
- class TestUser < TestModel
5
- validates :email, email: true
6
- end
7
-
8
- class TestUserMX < TestModel
9
- validates :email, email: { mx: true }
10
- end
11
-
12
- class TestUserDisallowDisposable < TestModel
13
- validates :email, email: { disposable: true }
14
- end
15
-
16
- class TestUserDisallowBlacklisted < TestModel
17
- validates :email, email: { blacklist: true }
18
- end
19
-
20
- class TestUserDisallowEducational < TestModel
21
- validates :email, email: { educational: :no_educational }
22
- end
23
-
24
- describe EmailAssessor do
25
- let(:plain_user) { TestUser.new(email: "") }
26
- let(:disposable_user) { TestUserDisallowDisposable.new(email: "foo@gmail.com") }
27
- let(:blacklist_user) { TestUserDisallowBlacklisted.new(email: "foo@gmail.com") }
28
- let(:educational_user) { TestUserDisallowEducational.new(email: "foo@gmail.com") }
29
- let(:mx_user) { TestUserMX.new(email: "foo@gmail.com") }
30
-
31
- let(:blacklisted_domains_file_name) { described_class::BLACKLISTED_DOMAINS_FILE_NAME }
32
- let(:blacklisted_domain) { File.open(blacklisted_domains_file_name, &:readline).chomp }
33
-
34
- let(:disposable_domains_file_name) { described_class::DISPOSABLE_DOMAINS_FILE_NAME }
35
- let(:disposable_domain) { File.open(disposable_domains_file_name, &:readline).chomp }
36
-
37
- let(:educational_domains_file_name) { described_class::EDUCATIONAL_DOMAINS_FILE_NAME }
38
- let(:educational_domain) { File.open(educational_domains_file_name, &:readline).chomp }
39
-
40
- describe "basic validation" do
41
- subject(:user) { plain_user }
42
-
43
- it "is valid when email is empty" do
44
- is_expected.to be_valid
45
- end
46
-
47
- it "is invalid if the address starts with a dot" do
48
- user = TestUser.new(email: ".foo@bar.com")
49
- expect(user.valid?).to be_falsey
50
- end
51
-
52
- it "is invalid if the address contains consecutive dots" do
53
- user = TestUser.new(email: "foo..bar@gmail.com")
54
- expect(user.valid?).to be_falsey
55
- end
56
-
57
- it "is invalid if the address ends with a dot" do
58
- user = TestUser.new(email: "foo.@bar.com")
59
- expect(user.valid?).to be_falsey
60
- end
61
-
62
- it "is invalid when domain is missing" do
63
- user.email = "foo@.com"
64
- is_expected.to be_invalid
65
- end
66
-
67
- it "is invalid when domain starts with a dot" do
68
- user.email = "foo@.example.com"
69
- is_expected.to be_invalid
70
- end
71
-
72
- it "is invalid when email is malformed" do
73
- user.email = "foo@bar"
74
- is_expected.to be_invalid
75
- end
76
-
77
- it "is invalid when email contains a trailing symbol" do
78
- user.email = "foo@bar.com/"
79
- is_expected.to be_invalid
80
- end
81
-
82
- it "is invalid if Mail::AddressListsParser raises exception" do
83
- allow(Mail::Address).to receive(:new).and_raise(Mail::Field::ParseError.new(nil, nil, nil))
84
- user.email = "foo@gmail.com"
85
- is_expected.to be_invalid
86
- end
87
-
88
- it "is invalid if the domain constains consecutives dots" do
89
- user.email = "foo@bar..com"
90
- is_expected.to be_invalid
91
- end
92
-
93
- it "is invalid if the domain contains emoticons" do
94
- user.email = "foo🙈@gmail.com"
95
- is_expected.to be_invalid
96
- end
97
-
98
- it "is invalid if the domain contains spaces" do
99
- user.email = "user@gmail .com"
100
- is_expected.to be_invalid
101
- end
102
-
103
- it "is invalid if the domain contains '.@'" do
104
- user.email = "foo.@gmail.com"
105
- expect(user.valid?).to be_falsy
106
- end
107
-
108
- it "is invalid if the domain begins with a hyphen" do
109
- user.email = "foo@-gmail.com"
110
- expect(user.valid?).to be_falsy
111
- end
112
-
113
- it "is invalid if the domain name ends with a hyphen" do
114
- user.email = "foo@gmail-.com"
115
- expect(user.valid?).to be_falsy
116
- end
117
-
118
- %w[+ _ ! / \ '].each do |invalid_character|
119
- it "is invalid if domain contains a \"#{invalid_character}\" character" do
120
- user.email = "foo@google#{invalid_character}yahoo.com"
121
- is_expected.to be_invalid
122
- end
123
- end
124
- end
125
-
126
- describe "disposable domains" do
127
- subject(:user) { disposable_user }
128
-
129
- it "is valid when email is not in the list of disposable domains" do
130
- is_expected.to be_valid
131
- end
132
-
133
- it "is invalid when email is in the list of disposable domains" do
134
- user.email = "foo@#{disposable_domain}"
135
- is_expected.to be_invalid
136
- end
137
-
138
- it "is invalid when email is in the list of disposable domains regardless of case" do
139
- user.email = "foo@#{disposable_domain.upcase}"
140
- is_expected.to be_invalid
141
- end
142
-
143
- it "is invalid when email is in the list of disposable domains regardless of subdomain" do
144
- user.email = "foo@abc123.#{disposable_domain}"
145
- is_expected.to be_invalid
146
- end
147
- end
148
-
149
- describe "blacklisted domains" do
150
- subject(:user) { blacklist_user }
151
-
152
- it "is valid when email domain is not in the blacklist" do
153
- is_expected.to be_valid
154
- end
155
-
156
- it "is invalid when email domain is in the blacklist" do
157
- user.email = "foo@#{blacklisted_domain}"
158
- is_expected.to be_invalid
159
- end
160
-
161
- it "is invalid when email is in the blacklist regardless of case" do
162
- user.email = "foo@#{blacklisted_domain.upcase}"
163
- is_expected.to be_invalid
164
- end
165
-
166
- it "is invalid when email domain is in the blacklist regardless of subdomain" do
167
- user.email = "foo@abc123.#{blacklisted_domain}"
168
- is_expected.to be_invalid
169
- end
170
- end
171
-
172
- describe "educational domains" do
173
- subject(:user) { educational_user }
174
-
175
- it "is valid when email domain is not in the educational blocklist" do
176
- is_expected.to be_valid
177
- end
178
-
179
- it "is invalid when email domain is in the educational blocklist" do
180
- user.email = "foo@#{educational_domain}"
181
- is_expected.to be_invalid
182
- end
183
-
184
- it "is invalid when email is in the educational blocklist regardless of case" do
185
- user.email = "foo@#{educational_domain.upcase}"
186
- is_expected.to be_invalid
187
- end
188
-
189
- it "is invalid when email domain is in the educational blocklist regardless of subdomain" do
190
- user.email = "foo@abc123.#{educational_domain}"
191
- is_expected.to be_invalid
192
- expect(user.errors.added?(:email, :no_educational)).to be_truthy
193
- end
194
- end
195
-
196
-
197
- describe "mx lookup" do
198
- subject(:user) { mx_user }
199
-
200
- it "is valid if mx records are found" do
201
- is_expected.to be_valid
202
- end
203
-
204
- it "is invalid if no mx records are found" do
205
- user.email = "foo@subdomain.gmail.com"
206
- is_expected.to be_invalid
207
- end
208
- end
209
- end
data/spec/spec_helper.rb DELETED
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
- $:.unshift File.expand_path("../lib",__FILE__)
3
- require "email_assessor"
4
-
5
- class TestModel
6
- include ActiveModel::Validations
7
-
8
- def initialize(attributes = {})
9
- @attributes = attributes
10
- end
11
-
12
- def email=(email)
13
- @attributes[:email] = email
14
- end
15
-
16
- def read_attribute_for_validation(key)
17
- @attributes[key]
18
- end
19
- end