diff --git a/test/README.md b/test/README.md index 60c0e83c78..ccc834af40 100644 --- a/test/README.md +++ b/test/README.md @@ -67,6 +67,14 @@ mode, use test/local-e2e-tests.sh -short ``` +### Running tests with HTTPS + +When running tests against a cluster configured to use HTTPS, use the `--https` flag to make tests expect HTTPS URLs: + +```bash + test/local-e2e-tests.sh --https +``` + ### Running E2E tests as a project admin It is possible to run the E2E tests by a user with reduced privileges, e.g. project admin. diff --git a/test/e2e/domain_mapping_test.go b/test/e2e/domain_mapping_test.go index 049caf2c49..b7f75c1ca5 100644 --- a/test/e2e/domain_mapping_test.go +++ b/test/e2e/domain_mapping_test.go @@ -146,7 +146,8 @@ func domainDescribe(r *test.KnRunResultCollector, domainName string, tls bool) { out := r.KnTest().Kn().Run("domain", "describe", domainName) r.AssertNoError(out) var url string - if tls { + // Use HTTPS if either TLS is explicitly configured or the --https flag is set + if tls || ClientFlags.HTTPS { url = "https://" + domainName } else { url = "http://" + domainName diff --git a/test/e2e/e2e_flags.go b/test/e2e/e2e_flags.go new file mode 100644 index 0000000000..4b45c4c252 --- /dev/null +++ b/test/e2e/e2e_flags.go @@ -0,0 +1,41 @@ +/* +Copyright 2025 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// This file contains logic to encapsulate flags which are needed to specify +// what cluster, etc. to use for e2e tests. + +package e2e + +import ( + "flag" + + _ "knative.dev/pkg/test" +) + +var ClientFlags = initializeClientFlags() + +type ClientEnvironmentFlags struct { + HTTPS bool +} + +func initializeClientFlags() *ClientEnvironmentFlags { + var f ClientEnvironmentFlags + + flag.BoolVar(&f.HTTPS, "https", false, + "Set this flag to true to run all tests with https.") + + return &f +}