From 967b96f91fa553cb1b64ad3983d6d0a88b96f62b Mon Sep 17 00:00:00 2001 From: "Tore S. Loenoey" Date: Thu, 23 Nov 2023 12:01:58 +0100 Subject: [PATCH] test extend existing test instead of creating new --- .../controller/template/template_test.go | 44 +------------------ 1 file changed, 1 insertion(+), 43 deletions(-) diff --git a/internal/ingress/controller/template/template_test.go b/internal/ingress/controller/template/template_test.go index a25e20b43..d8d01cfde 100644 --- a/internal/ingress/controller/template/template_test.go +++ b/internal/ingress/controller/template/template_test.go @@ -459,7 +459,7 @@ func TestBuildAuthLocation(t *testing.T) { } } -func TestShouldApplyGlobalAuthWhenDefaultEnableIsChanged(t *testing.T) { +func TestShouldApplyGlobalAuth(t *testing.T) { authURL := fooAuthHost globalAuthURL := "foo.com/global-auth" 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) { externalAuthResponseHeaders := []string{"h1", "H-With-Caps-And-Dashes"} tests := []struct {