-
Notifications
You must be signed in to change notification settings - Fork 198
[WIP]Adding KMS TestKMSEncryptionOnOff test #2018
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,47 @@ | ||
| package e2e_encryption_kms | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "testing" | ||
|
|
||
| configv1 "github.com/openshift/api/config/v1" | ||
| "github.com/openshift/cluster-kube-apiserver-operator/pkg/operator/operatorclient" | ||
| operatorencryption "github.com/openshift/cluster-kube-apiserver-operator/test/library/encryption" | ||
| library "github.com/openshift/library-go/test/library/encryption" | ||
| librarykms "github.com/openshift/library-go/test/library/encryption/kms" | ||
| ) | ||
|
|
||
| // TestKMSEncryptionOnOff tests KMS encryption on/off cycle. | ||
| // This test: | ||
| // 1. Deploys the mock KMS plugin | ||
| // 2. Enables KMS encryption | ||
| // 3. Verifies secrets are encrypted | ||
| // 4. Disables encryption (Identity) | ||
| // 5. Verifies secrets are not encrypted | ||
| // 6. Re-enables KMS encryption | ||
| // 7. Cleans up | ||
| // | ||
| // TODO: Implement full KMS encryption test once the CI job is validated. | ||
| // 2. Creates a test secret (SecretOfLife) | ||
| // 3. Enables KMS encryption | ||
| // 4. Verifies secret is encrypted | ||
| // 5. Disables encryption (Identity) | ||
| // 6. Verifies secret is NOT encrypted | ||
| // 7. Re-enables KMS encryption | ||
| // 8. Verifies secret is encrypted again | ||
| // 9. Disables encryption (Identity) again | ||
| // 10. Verifies secret is NOT encrypted again | ||
| // 11. Cleans up the KMS plugin | ||
| func TestKMSEncryptionOnOff(t *testing.T) { | ||
| t.Log("KMS encryption on/off test placeholder - CI job validation") | ||
| t.Cleanup(librarykms.DeployUpstreamMockKMSPlugin(context.Background(), t, library.GetClients(t).Kube, librarykms.WellKnownUpstreamMockKMSPluginNamespace, librarykms.WellKnownUpstreamMockKMSPluginImage)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, once openshift/library-go#2113 merges |
||
| library.TestEncryptionTurnOnAndOff(t, library.OnOffScenario{ | ||
| BasicScenario: library.BasicScenario{ | ||
| Namespace: operatorclient.GlobalMachineSpecifiedConfigNamespace, | ||
| LabelSelector: "encryption.apiserver.operator.openshift.io/component" + "=" + operatorclient.TargetNamespace, | ||
| EncryptionConfigSecretName: fmt.Sprintf("encryption-config-%s", operatorclient.TargetNamespace), | ||
| EncryptionConfigSecretNamespace: operatorclient.GlobalMachineSpecifiedConfigNamespace, | ||
| OperatorNamespace: operatorclient.OperatorNamespace, | ||
| TargetGRs: operatorencryption.DefaultTargetGRs, | ||
| AssertFunc: operatorencryption.AssertSecretsAndConfigMaps, | ||
| }, | ||
| CreateResourceFunc: operatorencryption.CreateAndStoreSecretOfLife, | ||
| AssertResourceEncryptedFunc: operatorencryption.AssertSecretOfLifeEncrypted, | ||
| AssertResourceNotEncryptedFunc: operatorencryption.AssertSecretOfLifeNotEncrypted, | ||
| ResourceFunc: operatorencryption.SecretOfLife, | ||
| ResourceName: "SecretOfLife", | ||
| EncryptionProvider: configv1.EncryptionTypeKMS, | ||
| }) | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s also add a comment stating that this step is only required for v1. In the future, the platform will manage the plugins, and this code will no longer be needed.