-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
mx_blacklist_test.go
30 lines (24 loc) · 1.13 KB
/
mx_blacklist_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package truemail
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestValidationMxBlacklistCheck(t *testing.T) {
t.Run("MX blacklist validation: successful", func(t *testing.T) {
validatorResult := createSuccessfulValidatorResult(randomEmail(), createConfiguration())
new(validationMxBlacklist).check(validatorResult)
assert.True(t, validatorResult.Success)
assert.Empty(t, validatorResult.Errors)
assert.Empty(t, validatorResult.usedValidations)
})
t.Run("MX blacklist validation: failure", func(t *testing.T) {
blacklistedMxIpAddress := randomIpAddress()
configuration, _ := NewConfiguration(ConfigurationAttr{VerifierEmail: randomEmail(), BlacklistedMxIpAddresses: []string{blacklistedMxIpAddress}})
validatorResult := createSuccessfulValidatorResult(randomEmail(), configuration)
validatorResult.MailServers = []string{blacklistedMxIpAddress}
new(validationMxBlacklist).check(validatorResult)
assert.False(t, validatorResult.Success)
assert.Equal(t, map[string]string{validationTypeMxBlacklist: mxBlacklistErrorContext}, validatorResult.Errors)
assert.Empty(t, validatorResult.usedValidations)
})
}