Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure-e2e-test: Add test for key release in kbs #1735

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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") {
kartikjoshi21 marked this conversation as resolved.
Show resolved Hide resolved
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()
}
Loading