forked from thomseddon/traefik-forward-auth
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Max Mitchell
committed
Jan 12, 2021
1 parent
4091bb1
commit 58d555c
Showing
2 changed files
with
19 additions
and
3 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 |
---|---|---|
|
@@ -78,6 +78,12 @@ func TestAuthValidateUser(t *testing.T) { | |
v = ValidateUser("[email protected]", "default") | ||
assert.True(v, "should allow user from allowed domain") | ||
|
||
// Should block non whitelisted email address | ||
config.Domains = []string{} | ||
config.Whitelist = []string{"[email protected]"} | ||
v = ValidateUser("[email protected]", "default") | ||
assert.False(v, "should not allow user not in whitelist") | ||
|
||
// Should allow matching whitelisted email address | ||
config.Domains = []string{} | ||
config.Whitelist = []string{"[email protected]"} | ||
|
@@ -91,6 +97,10 @@ func TestAuthValidateUser(t *testing.T) { | |
config.Domains = []string{"example.com"} | ||
config.Whitelist = []string{"[email protected]"} | ||
config.MatchWhitelistOrDomain = false | ||
v = ValidateUser("[email protected]", "default") | ||
assert.True(v, "should allow user in whitelist") | ||
v = ValidateUser("[email protected]", "default") | ||
assert.False(v, "should not allow user from valid domain") | ||
v = ValidateUser("[email protected]", "default") | ||
assert.False(v, "should not allow user not in either") | ||
v = ValidateUser("[email protected]", "default") | ||
|
@@ -109,6 +119,8 @@ func TestAuthValidateUser(t *testing.T) { | |
assert.True(v, "should allow user from allowed domain") | ||
v = ValidateUser("[email protected]", "default") | ||
assert.True(v, "should allow user in whitelist") | ||
v = ValidateUser("[email protected]", "default") | ||
assert.True(v, "should allow user from valid domain") | ||
|
||
// Rule testing | ||
|
||
|
@@ -138,6 +150,10 @@ func TestAuthValidateUser(t *testing.T) { | |
v = ValidateUser("[email protected]", "test") | ||
assert.True(v, "should allow user from allowed domain") | ||
|
||
// Should allow comma separated email | ||
config.Whitelist = []string{"[email protected]", "[email protected]"} | ||
v = ValidateUser("[email protected]", "default") | ||
|
||
// Should allow matching whitelist in rule | ||
config.Domains = []string{} | ||
config.Whitelist = []string{"[email protected]"} | ||
|