tests update

This commit is contained in:
Tore S. Loenoey 2023-11-23 20:44:07 +01:00 committed by Tore Stendal Lønøy
parent 2be120664e
commit d9c575f73d
No known key found for this signature in database

View file

@ -435,25 +435,16 @@ func TestBuildAuthLocation(t *testing.T) {
authURL string
globalAuthURL string
enableglobalExternalAuth bool
globalAuthDefaultEnable bool
expected string
}{
{"authURL, globalAuthURL and enabled", authURL, globalAuthURL, true, true, externalAuthPath},
{"authURL, globalAuthURL and disabled", authURL, globalAuthURL, false, true, externalAuthPath},
{"authURL, empty globalAuthURL and enabled", authURL, "", true, true, externalAuthPath},
{"authURL, empty globalAuthURL and disabled", authURL, "", false, true, externalAuthPath},
{"globalAuthURL and enabled", "", globalAuthURL, true, true, externalAuthPath},
{"globalAuthURL and disabled", "", globalAuthURL, false, true, ""},
{"all empty and enabled", "", "", true, true, ""},
{"all empty and disabled", "", "", false, true, ""},
{"authURL, globalAuthURL and enabled, defaultEnable is false", authURL, globalAuthURL, true, false, externalAuthPath},
{"authURL, globalAuthURL and disabled, defaultEnable is false", authURL, globalAuthURL, false, false, externalAuthPath},
{"authURL, empty globalAuthURL and enabled, defaultEnable is false", authURL, "", true, false, externalAuthPath},
{"authURL, empty globalAuthURL and disabled, defaultEnable is false", authURL, "", false, false, externalAuthPath},
{"globalAuthURL and enabled, defaultEnable is false", "", globalAuthURL, true, false, externalAuthPath},
{"globalAuthURL and disabled, defaultEnable is false", "", globalAuthURL, false, false, ""},
{"all empty and enabled, defaultEnable is false", "", "", true, false, ""},
{"all empty and disabled, defaultEnable is false", "", "", false, false, ""},
{"authURL, globalAuthURL and enabled", authURL, globalAuthURL, true, externalAuthPath},
{"authURL, globalAuthURL and disabled", authURL, globalAuthURL, false, externalAuthPath},
{"authURL, empty globalAuthURL and enabled", authURL, "", true, externalAuthPath},
{"authURL, empty globalAuthURL and disabled", authURL, "", false, externalAuthPath},
{"globalAuthURL and enabled", "", globalAuthURL, true, externalAuthPath},
{"globalAuthURL and disabled", "", globalAuthURL, false, ""},
{"all empty and enabled", "", "", true, ""},
{"all empty and disabled", "", "", false, ""},
}
for _, testCase := range testCases {
@ -507,47 +498,6 @@ func TestShouldApplyGlobalAuth(t *testing.T) {
}
}
// func TestShouldApplyGlobalAuthWhenEnableDefaultIsFalse(t *testing.T) {
// authURL := fooAuthHost
// globalAuthURL := "foo.com/global-auth"
// 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)
// if result != testCase.expected {
// t.Errorf("%v: expected '%v' but returned '%v'", testCase.title, testCase.expected, result)
// }
// }
// }
func TestBuildAuthResponseHeaders(t *testing.T) {
externalAuthResponseHeaders := []string{"h1", "H-With-Caps-And-Dashes"}
tests := []struct {