Skip to content

Commit

Permalink
Update e2e tests to use custom certs and image signature verification
Browse files Browse the repository at this point in the history
Signed-off-by: Prem Kumar Kalle <[email protected]>
  • Loading branch information
prkalle committed Apr 27, 2023
1 parent 7b04f5e commit fc8c2b4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,14 @@ test: fmt ## Run Tests
.PHONY: e2e-cli-core ## Execute all CLI Core E2E Tests
e2e-cli-core: start-test-central-repo e2e-cli-core-all ## Execute all CLI Core E2E Tests

.PHONY: setup-custom-cert-for-test-central-repo
setup-custom-cert-for-test-central-repo: build ## Setup up the custom ca cert for test-central-repo in the config
echo "Adding docker test central repo cert to the config file"
TANZU_CLI_CEIP_OPT_IN_PROMPT_ANSWER="No" $(ROOT_DIR)/bin/tanzu config cert delete localhost:9876 || true
$(ROOT_DIR)/bin/tanzu config cert add --hostname localhost:9876 --ca-certificate $(ROOT_DIR)/hack/central-repo/certs/localhost.crt

.PHONY: start-test-central-repo
start-test-central-repo: stop-test-central-repo ## Starts up a test central repository locally with docker
start-test-central-repo: stop-test-central-repo setup-custom-cert-for-test-central-repo ## Starts up a test central repository locally with docker
@if [ ! -d $(ROOT_DIR)/hack/central-repo/registry-content ]; then \
(cd $(ROOT_DIR)/hack/central-repo && tar xjf registry-content.bz2 || true;) \
fi
Expand Down
5 changes: 4 additions & 1 deletion test/e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ ifndef TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_URL
TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_URL = localhost:9876/tanzu-cli/plugins/central:small
endif

ifndef TANZU_CLI_E2E_TEST_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_PUBLIC_KEY_PATH
TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_PUBLIC_KEY_PATH = ${ROOT_DIR}/hack/central-repo/cosign-key-pair/cosign-pub
endif

.PHONY: e2e-cli-core-all ## Execute all CLI Core E2E Tests
e2e-cli-core-all: e2e-cli-lifecycle e2e-cli-config e2e-cli-plugin-compatibility-test e2e-context-k8s-tests e2e-context-tmc-test e2e-cli-plugin-lifecycle-sync-test
Expand Down Expand Up @@ -54,7 +57,7 @@ e2e-cli-plugin-lifecycle-sync-test:
echo "***Skipping Plugin life cycle test cases because environment variables TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_URL is not set***" ; \
else \
export TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_URL=$(TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_URL) ; \
export TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_VERIFICATION_SKIP_LIST=$(TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_URL) ; \
export TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_PUBLIC_KEY_PATH=$(TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_PUBLIC_KEY_PATH) ; \
export TANZU_CLI_CEIP_OPT_IN_PROMPT_ANSWER="Yes" ; \
${GO} test ${ROOT_DIR}/test/e2e/plugin_lifecycle -timeout ${E2E_TEST_TIMEOUT} -race -coverprofile ${E2E_TEST_OUTPUT} ${GOTEST_VERBOSE} ; \
${GO} test ${ROOT_DIR}/test/e2e/plugin_sync -timeout ${E2E_TEST_TIMEOUT} -race -coverprofile ${E2E_TEST_OUTPUT} ${GOTEST_VERBOSE} ; \
Expand Down
5 changes: 3 additions & 2 deletions test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ const (
PluginKey = "%s_%s_%s" // Plugins - Name_Target_Versions

// Central repository
TanzuCliE2ETestCentralRepositoryURL = "TANZU_CLI_E2E_TEST_CENTRAL_REPO_URL"
TanzuCliE2ETestLocalCentralRepositoryURL = "TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_URL"
TanzuCliE2ETestCentralRepositoryURL = "TANZU_CLI_E2E_TEST_CENTRAL_REPO_URL"
TanzuCliE2ETestLocalCentralRepositoryURL = "TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_URL"
TanzuCliE2ETestLocalCentralRepositoryPluginDiscoveryImageSignaturePublicKeyPath = "TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_PUBLIC_KEY_PATH"

// General constants
True = "true"
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/plugin_lifecycle/plugin_lifecycle_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ var _ = BeforeSuite(func() {
e2eTestLocalCentralRepoURL = os.Getenv(framework.TanzuCliE2ETestLocalCentralRepositoryURL)
Expect(e2eTestLocalCentralRepoURL).NotTo(BeEmpty(), fmt.Sprintf("environment variable %s should set with local central repository URL", framework.TanzuCliE2ETestLocalCentralRepositoryURL))

// set up the local central repository discovery image public key path
e2eTestLocalCentralRepoPluginDiscoveryImageSignaturePublicKeyPath := os.Getenv(framework.TanzuCliE2ETestLocalCentralRepositoryPluginDiscoveryImageSignaturePublicKeyPath)
Expect(e2eTestLocalCentralRepoPluginDiscoveryImageSignaturePublicKeyPath).NotTo(BeEmpty(), fmt.Sprintf("environment variable %s should set with local central repository discovery image signature public key path", framework.TanzuCliE2ETestLocalCentralRepositoryPluginDiscoveryImageSignaturePublicKeyPath))
os.Setenv("TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_PUBLIC_KEY_PATH", e2eTestLocalCentralRepoPluginDiscoveryImageSignaturePublicKeyPath)

// setup the test central repo
_, err := tf.PluginCmd.UpdatePluginDiscoverySource(&framework.DiscoveryOptions{Name: "default", SourceType: framework.SourceType, URI: e2eTestLocalCentralRepoURL})
Expect(err).To(BeNil(), "should not get any error for plugin source update")
Expand Down
7 changes: 6 additions & 1 deletion test/e2e/plugin_sync/plugin_sync_lifecycle_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ var _ = BeforeSuite(func() {
e2eTestLocalCentralRepoURL = os.Getenv(framework.TanzuCliE2ETestLocalCentralRepositoryURL)
Expect(e2eTestLocalCentralRepoURL).NotTo(BeEmpty(), fmt.Sprintf("environment variable %s should set with local central repository URL", framework.TanzuCliE2ETestLocalCentralRepositoryURL))

// setup the test central repo
// set up the local central repository discovery image public key path
e2eTestLocalCentralRepoPluginDiscoveryImageSignaturePublicKeyPath := os.Getenv(framework.TanzuCliE2ETestLocalCentralRepositoryPluginDiscoveryImageSignaturePublicKeyPath)
Expect(e2eTestLocalCentralRepoPluginDiscoveryImageSignaturePublicKeyPath).NotTo(BeEmpty(), fmt.Sprintf("environment variable %s should set with local central repository discovery image signature public key path", framework.TanzuCliE2ETestLocalCentralRepositoryPluginDiscoveryImageSignaturePublicKeyPath))
os.Setenv("TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_PUBLIC_KEY_PATH", e2eTestLocalCentralRepoPluginDiscoveryImageSignaturePublicKeyPath)

// set up the test central repo
_, err := tf.PluginCmd.UpdatePluginDiscoverySource(&framework.DiscoveryOptions{Name: "default", SourceType: framework.SourceType, URI: e2eTestLocalCentralRepoURL})
Expect(err).To(BeNil(), "should not get any error for plugin source update")

Expand Down

0 comments on commit fc8c2b4

Please sign in to comment.