Skip to content

Commit d6efc4e

Browse files
Merge pull request openshift#2191 from ardaguclu/fix-e2e-kms
NO-JIRA: Set required KMSConfig in e2e tests for KMS mode
2 parents d45f1f2 + b3cf221 commit d6efc4e

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

test/library/encryption/helpers.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
configv1client "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
2525

2626
"github.com/openshift/library-go/test/library"
27+
"github.com/openshift/library-go/test/library/encryption/kms"
2728
)
2829

2930
var (
@@ -66,6 +67,7 @@ func SetAndWaitForEncryptionType(t testing.TB, encryptionType configv1.Encryptio
6667
if needsUpdate {
6768
t.Logf("Updating encryption type in the config file for APIServer to %q", encryptionType)
6869
apiServer.Spec.Encryption.Type = encryptionType
70+
apiServer.Spec.Encryption.KMS = defaultTestKMSConfig(encryptionType)
6971
_, err = clientSet.ApiServerConfig.Update(context.TODO(), apiServer, metav1.UpdateOptions{})
7072
require.NoError(t, err)
7173
} else {
@@ -338,3 +340,23 @@ func setUpTearDown(namespace string) func(testing.TB, bool) {
338340
}
339341
}
340342
}
343+
344+
func defaultTestKMSConfig(encryptionType configv1.EncryptionType) *configv1.KMSConfig {
345+
if encryptionType != configv1.EncryptionTypeKMS {
346+
return nil
347+
}
348+
return &configv1.KMSConfig{
349+
Type: configv1.VaultKMSProvider,
350+
Vault: configv1.VaultKMSConfig{
351+
KMSPluginImage: kms.WellKnownUpstreamMockKMSPluginImage,
352+
VaultAddress: "https://vault.example.com",
353+
Authentication: configv1.VaultAuthentication{
354+
Type: configv1.VaultAuthenticationTypeAppRole,
355+
AppRole: configv1.VaultAppRoleAuthentication{
356+
Secret: configv1.VaultSecretReference{Name: "vault-approle-secret"},
357+
},
358+
},
359+
TransitKey: "test-transit-key",
360+
},
361+
}
362+
}

0 commit comments

Comments
 (0)