Skip to content

Commit

Permalink
azure: Add test for key release in kbs
Browse files Browse the repository at this point in the history
Fixes: #1785
Signed-off-by: Kartik Joshi <kartikjoshi@microsoft.com>
  • Loading branch information
kartikjoshi21 authored and Qi Feng Huo committed Apr 30, 2024
1 parent 9e28a61 commit 1a4c306
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/cloud-api-adaptor/test/e2e/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package e2e

import (
"os"
"testing"

_ "github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/provisioner/azure"
Expand Down Expand Up @@ -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)
}
23 changes: 23 additions & 0 deletions src/cloud-api-adaptor/test/e2e/common_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

0 comments on commit 1a4c306

Please sign in to comment.