diff --git a/src/cloud-api-adaptor/test/e2e/azure_test.go b/src/cloud-api-adaptor/test/e2e/azure_test.go index 5eb3eafd6..5330a5b21 100644 --- a/src/cloud-api-adaptor/test/e2e/azure_test.go +++ b/src/cloud-api-adaptor/test/e2e/azure_test.go @@ -6,6 +6,7 @@ package e2e import ( + "os" "testing" _ "github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/provisioner/azure" @@ -40,3 +41,11 @@ func TestCreateNginxDeploymentAzure(t *testing.T) { t.Parallel() DoTestNginxDeployment(t, testEnv, assert) } + +func TestKbsKeyRelease(t *testing.T) { + if os.Getenv("DEPLOY_KBS") == "false" || os.Getenv("DEPLOY_KBS") == "no" { + t.Skip("Skipping kbs related test as kbs is not deployed") + } + t.Parallel() + DoTestKbsKeyRelease(t, testEnv, assert) +} diff --git a/src/cloud-api-adaptor/test/e2e/common_suite.go b/src/cloud-api-adaptor/test/e2e/common_suite.go index 616b7a7e5..33b567d00 100644 --- a/src/cloud-api-adaptor/test/e2e/common_suite.go +++ b/src/cloud-api-adaptor/test/e2e/common_suite.go @@ -572,3 +572,26 @@ func DoTestPodsMTLSCommunication(t *testing.T, e env.Environment, assert CloudAs NewTestCase(t, e, "TestPodsMTLSCommunication", assert, "Pods communication with mTLS").WithPod(serverPod).WithExtraPods(extraPods).WithConfigMap(configMap).WithService(nginxSvc).WithSecret(serverSecret).WithExtraSecrets(extraSecrets).Run() } + +func DoTestKbsKeyRelease(t *testing.T, e env.Environment, assert CloudAssert) { + + log.Info("Do test kbs key release") + pod := NewBusyboxPodWithName(E2eNamespace, "busybox-wget") + testCommands := []TestCommand{ + { + Command: []string{"wget", "-q", "-O-", "http://127.0.0.1:8006/cdh/resource/reponame/workload_key/key.bin"}, + ContainerName: pod.Spec.Containers[0].Name, + TestCommandStdoutFn: func(stdout bytes.Buffer) bool { + if strings.Contains(stdout.String(), "This is my cluster name") { + log.Infof("Success to get key.bin %s", stdout.String()) + return true + } else { + log.Errorf("Failed to access key.bin: %s", stdout.String()) + return false + } + }, + }, + } + + NewTestCase(t, e, "KbsKeyReleasePod", assert, "Kbs key release is successful").WithPod(pod).WithTestCommands(testCommands).Run() +}