test extend existing test instead of creating new
This commit is contained in:
parent
1f021724bd
commit
967b96f91f
1 changed files with 1 additions and 43 deletions
|
@ -459,7 +459,7 @@ func TestBuildAuthLocation(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestShouldApplyGlobalAuthWhenDefaultEnableIsChanged(t *testing.T) {
|
func TestShouldApplyGlobalAuth(t *testing.T) {
|
||||||
authURL := fooAuthHost
|
authURL := fooAuthHost
|
||||||
globalAuthURL := "foo.com/global-auth"
|
globalAuthURL := "foo.com/global-auth"
|
||||||
cfg := config.Configuration{}
|
cfg := config.Configuration{}
|
||||||
|
@ -509,48 +509,6 @@ func TestShouldApplyGlobalAuthWhenDefaultEnableIsChanged(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestShouldApplyGlobalAuth(t *testing.T) {
|
|
||||||
authURL := fooAuthHost
|
|
||||||
globalAuthURL := "foo.com/global-auth"
|
|
||||||
cfg := config.Configuration{}
|
|
||||||
|
|
||||||
loc := &ingress.Location{
|
|
||||||
ExternalAuth: authreq.Config{
|
|
||||||
URL: authURL,
|
|
||||||
},
|
|
||||||
Path: "/cat",
|
|
||||||
EnableGlobalAuth: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
testCases := []struct {
|
|
||||||
title string
|
|
||||||
authURL string
|
|
||||||
globalAuthURL string
|
|
||||||
enableglobalExternalAuth bool
|
|
||||||
globalAuthDefaultEnable bool
|
|
||||||
expected bool
|
|
||||||
}{
|
|
||||||
{"authURL, globalAuthURL and enabled", authURL, globalAuthURL, true, true, false},
|
|
||||||
{"authURL, globalAuthURL and disabled", authURL, globalAuthURL, false, true, false},
|
|
||||||
{"authURL, empty globalAuthURL and enabled", authURL, "", true, true, false},
|
|
||||||
{"authURL, empty globalAuthURL and disabled", authURL, "", false, true, false},
|
|
||||||
{"globalAuthURL and enabled", "", globalAuthURL, true, true, true},
|
|
||||||
{"globalAuthURL and disabled", "", globalAuthURL, false, true, false},
|
|
||||||
{"all empty and enabled", "", "", true, true, false},
|
|
||||||
{"all empty and disabled", "", "", false, true, false},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
|
||||||
loc.ExternalAuth.URL = testCase.authURL
|
|
||||||
loc.EnableGlobalAuth = testCase.enableglobalExternalAuth
|
|
||||||
|
|
||||||
result := shouldApplyGlobalAuth(loc, testCase.globalAuthURL, cfg)
|
|
||||||
if result != testCase.expected {
|
|
||||||
t.Errorf("%v: expected '%v' but returned '%v'", testCase.title, testCase.expected, result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestBuildAuthResponseHeaders(t *testing.T) {
|
func TestBuildAuthResponseHeaders(t *testing.T) {
|
||||||
externalAuthResponseHeaders := []string{"h1", "H-With-Caps-And-Dashes"}
|
externalAuthResponseHeaders := []string{"h1", "H-With-Caps-And-Dashes"}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
|
Loading…
Reference in a new issue