-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
70 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,6 +258,69 @@ func TestValidateEmail(t *testing.T) { | |
email: "[email protected]", | ||
expected: false, | ||
}, | ||
{ | ||
name: "precedence - unrelated", | ||
blockedDomains: []string{"blocked.com"}, | ||
blockedEmails: []string{"[email protected]"}, | ||
allowedDomains: []string{"acme.com"}, | ||
allowedEmails: []string{"[email protected]"}, | ||
email: "[email protected]", | ||
expected: false, | ||
}, | ||
{ | ||
name: "precedence - allowed email", | ||
blockedDomains: []string{"blocked.com"}, | ||
blockedEmails: []string{"[email protected]"}, | ||
allowedDomains: []string{"acme.com"}, | ||
allowedEmails: []string{"[email protected]"}, | ||
email: "[email protected]", | ||
expected: true, | ||
}, | ||
{ | ||
name: "precedence - blocked email", | ||
blockedDomains: []string{"blocked.com"}, | ||
blockedEmails: []string{"[email protected]"}, | ||
allowedDomains: []string{"acme.com"}, | ||
allowedEmails: []string{"[email protected]"}, | ||
email: "[email protected]", | ||
expected: false, | ||
}, | ||
{ | ||
name: "precedence - blocked domain", | ||
blockedDomains: []string{"blocked.com"}, | ||
blockedEmails: []string{"[email protected]"}, | ||
allowedDomains: []string{"acme.com"}, | ||
allowedEmails: []string{"[email protected]"}, | ||
email: "[email protected]", | ||
expected: false, | ||
}, | ||
{ | ||
name: "precedence - allowed domain", | ||
blockedDomains: []string{"blocked.com"}, | ||
blockedEmails: []string{"[email protected]"}, | ||
allowedDomains: []string{"acme.com"}, | ||
allowedEmails: []string{"[email protected]"}, | ||
email: "[email protected]", | ||
expected: true, | ||
}, | ||
{ | ||
name: "blocking take precedence over allowing", | ||
blockedDomains: []string{"acme.com"}, | ||
blockedEmails: []string{"[email protected]"}, | ||
allowedDomains: []string{"acme.com"}, | ||
allowedEmails: []string{"[email protected]"}, | ||
email: "[email protected]", | ||
expected: false, | ||
}, | ||
{ | ||
name: "blocking take precedence over allowing", | ||
blockedDomains: []string{"acme.com"}, | ||
blockedEmails: []string{"[email protected]"}, | ||
allowedDomains: []string{"acme.com"}, | ||
allowedEmails: []string{"[email protected]"}, | ||
email: "[email protected]", | ||
expected: false, | ||
}, | ||
} | ||
|
||
for _, tc := range cases { | ||
|