Allow a whitelist of email addresses

This commit is contained in:
Jasper Lammens
2018-08-26 15:19:16 +02:00
committed by Thom Seddon
parent 36fffd2382
commit eaad0a9054
4 changed files with 32 additions and 1 deletions

View File

@ -81,6 +81,20 @@ func TestValidateEmail(t *testing.T) {
if !fw.ValidateEmail("test@test.com") {
t.Error("Should allow user from allowed domain")
}
// Should block non whitelisted email address
fw.Domain = []string{}
fw.Whitelist = []string{"test@test.com"}
if fw.ValidateEmail("one@two.com") {
t.Error("Should not allow user not in whitelist.")
}
// Should allow matching whitelisted email address
fw.Domain = []string{}
fw.Whitelist = []string{"test@test.com"}
if !fw.ValidateEmail("test@test.com") {
t.Error("Should allow user in whitelist.")
}
}
func TestGetLoginURL(t *testing.T) {