From d781042d455b82e079194728d72c4d451f9422d6 Mon Sep 17 00:00:00 2001 From: Tao Yi Date: Thu, 7 Sep 2023 00:34:14 +0800 Subject: [PATCH] test: enable HTTPS redirect tests with expression router (#4614) --- test/integration/ingress_https_test.go | 4 ++-- test/internal/helpers/kong.go | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/test/integration/ingress_https_test.go b/test/integration/ingress_https_test.go index d7e0822786..a23d60d936 100644 --- a/test/integration/ingress_https_test.go +++ b/test/integration/ingress_https_test.go @@ -30,8 +30,8 @@ import ( ) func TestHTTPSRedirect(t *testing.T) { - // kong does not support HTTPS redirect yet. - skipTestForExpressionRouter(t) + // Kong starts to support HTTPS redirect in expression router from 3.4.0. + RunWhenKongExpressionRouterWithVersion(t, ">=3.4.0") ctx := context.Background() t.Parallel() diff --git a/test/internal/helpers/kong.go b/test/internal/helpers/kong.go index 960e5e43ed..bb9302fd14 100644 --- a/test/internal/helpers/kong.go +++ b/test/internal/helpers/kong.go @@ -90,6 +90,20 @@ func GetKongDBMode(proxyAdminURL *url.URL, kongTestPassword string) (string, err // GetKongRouterFlavor gets router flavor of Kong using the provided Admin API URL. func GetKongRouterFlavor(proxyAdminURL *url.URL, kongTestPassword string) (string, error) { + const ( + // ExpressionRouterMinMajorVersion is the lowest major version of Kong that supports expression router. + // Kong below this version supports only "traditional" router, and does not contain "router_flavor" field in root configuration. + ExpressionRouterMinMajorVersion = 3 + ) + kongVersion, err := GetKongVersion(proxyAdminURL, kongTestPassword) + if err != nil { + return "", err + } + + if kongVersion.Major() < ExpressionRouterMinMajorVersion { + return "traditional", nil + } + jsonResp, err := GetKongRootConfig(proxyAdminURL, kongTestPassword) if err != nil { return "", err