-
Notifications
You must be signed in to change notification settings - Fork 122
bump library-go funcs #935
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
base: master
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -8,7 +8,6 @@ import ( | |
| g "github.com/onsi/ginkgo/v2" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
|
|
||
| operatorencryption "github.com/openshift/cluster-authentication-operator/test/library/encryption" | ||
| library "github.com/openshift/library-go/test/library/encryption" | ||
| librarykms "github.com/openshift/library-go/test/library/encryption/kms" | ||
| ) | ||
|
|
@@ -42,15 +41,15 @@ func testKMSEncryptionOnOff(ctx context.Context, t testing.TB) { | |
| EncryptionConfigSecretName: "encryption-config-openshift-oauth-apiserver", | ||
| EncryptionConfigSecretNamespace: "openshift-config-managed", | ||
| OperatorNamespace: "openshift-authentication-operator", | ||
| TargetGRs: operatorencryption.DefaultTargetGRs, | ||
| AssertFunc: operatorencryption.AssertTokens, | ||
| TargetGRs: library.AuthTargetGRs, | ||
| AssertFunc: library.AssertTokens, | ||
| }, | ||
| CreateResourceFunc: func(t testing.TB, _ library.ClientSet, namespace string) runtime.Object { | ||
| return operatorencryption.CreateAndStoreTokenOfLife(context.TODO(), t, operatorencryption.GetClients(t)) | ||
| return library.CreateAndStoreTokenOfLife(context.TODO(), t, library.GetClients(t)) | ||
| }, | ||
| AssertResourceEncryptedFunc: operatorencryption.AssertTokenOfLifeEncrypted, | ||
| AssertResourceNotEncryptedFunc: operatorencryption.AssertTokenOfLifeNotEncrypted, | ||
| ResourceFunc: func(t testing.TB, _ string) runtime.Object { return operatorencryption.TokenOfLife(t) }, | ||
| AssertResourceEncryptedFunc: library.AssertTokenOfLifeEncrypted, | ||
| AssertResourceNotEncryptedFunc: library.AssertTokenOfLifeNotEncrypted, | ||
| ResourceFunc: library.TokenOfLife, | ||
| ResourceName: "TokenOfLife", | ||
| EncryptionProvider: librarykms.DefaultVaultEncryptionProvider(ctx, t), | ||
| }) | ||
|
|
@@ -72,19 +71,67 @@ func testKMSEncryptionProvidersMigration(ctx context.Context, t testing.TB) { | |
| EncryptionConfigSecretName: "encryption-config-openshift-oauth-apiserver", | ||
| EncryptionConfigSecretNamespace: "openshift-config-managed", | ||
| OperatorNamespace: "openshift-authentication-operator", | ||
| TargetGRs: operatorencryption.DefaultTargetGRs, | ||
| AssertFunc: operatorencryption.AssertTokens, | ||
| TargetGRs: library.AuthTargetGRs, | ||
| AssertFunc: library.AssertTokens, | ||
| }, | ||
| CreateResourceFunc: func(t testing.TB, _ library.ClientSet, namespace string) runtime.Object { | ||
| return operatorencryption.CreateAndStoreTokenOfLife(context.TODO(), t, operatorencryption.GetClients(t)) | ||
| return library.CreateAndStoreTokenOfLife(context.TODO(), t, library.GetClients(t)) | ||
| }, | ||
| AssertResourceEncryptedFunc: operatorencryption.AssertTokenOfLifeEncrypted, | ||
| AssertResourceNotEncryptedFunc: operatorencryption.AssertTokenOfLifeNotEncrypted, | ||
| ResourceFunc: func(t testing.TB, _ string) runtime.Object { return operatorencryption.TokenOfLife(t) }, | ||
| AssertResourceEncryptedFunc: library.AssertTokenOfLifeEncrypted, | ||
| AssertResourceNotEncryptedFunc: library.AssertTokenOfLifeNotEncrypted, | ||
| ResourceFunc: library.TokenOfLife, | ||
| ResourceName: "TokenOfLife", | ||
| EncryptionProviders: library.ShuffleEncryptionProviders([]library.EncryptionProvider{ | ||
| librarykms.DefaultVaultEncryptionProvider(ctx, t), | ||
| library.SupportedStaticEncryptionProviders[rand.IntN(len(library.SupportedStaticEncryptionProviders))], | ||
| }), | ||
| }) | ||
| } | ||
|
|
||
| // testKMSToKMSMigration tests KMS-to-KMS migration (primary → secondary → primary → identity). | ||
| func testKMSToKMSMigration(ctx context.Context, t testing.TB) { | ||
| library.TestKMSToKMSMigration(ctx, t, library.KMSToKMSMigrationScenario{ | ||
| BasicScenario: library.BasicScenario{ | ||
| Namespace: "openshift-config-managed", | ||
| LabelSelector: "encryption.apiserver.operator.openshift.io/component" + "=" + "openshift-oauth-apiserver", | ||
| EncryptionConfigSecretName: "encryption-config-openshift-oauth-apiserver", | ||
| EncryptionConfigSecretNamespace: "openshift-config-managed", | ||
| OperatorNamespace: "openshift-authentication-operator", | ||
| TargetGRs: library.AuthTargetGRs, | ||
| AssertFunc: library.AssertTokens, | ||
| }, | ||
| CreateResourceFunc: func(t testing.TB, _ library.ClientSet, namespace string) runtime.Object { | ||
| return library.CreateAndStoreTokenOfLife(context.TODO(), t, library.GetClients(t)) | ||
| }, | ||
| AssertResourceEncryptedFunc: library.AssertTokenOfLifeEncrypted, | ||
| AssertResourceNotEncryptedFunc: library.AssertTokenOfLifeNotEncrypted, | ||
| ResourceFunc: library.TokenOfLife, | ||
| ResourceName: "TokenOfLife", | ||
| PrimaryProvider: librarykms.DefaultVaultEncryptionProvider(ctx, t), | ||
| SecondaryProvider: librarykms.SecondaryVaultEncryptionProvider(ctx, t), | ||
| }) | ||
| } | ||
|
|
||
| // testKMSToKMSOnOff tests KMS on/off cycle with two distinct KMS providers. | ||
| func testKMSToKMSOnOff(ctx context.Context, t testing.TB) { | ||
| library.TestKMSToKMSOnOff(ctx, t, library.KMSToKMSMigrationScenario{ | ||
| BasicScenario: library.BasicScenario{ | ||
| Namespace: "openshift-config-managed", | ||
| LabelSelector: "encryption.apiserver.operator.openshift.io/component" + "=" + "openshift-oauth-apiserver", | ||
| EncryptionConfigSecretName: "encryption-config-openshift-oauth-apiserver", | ||
| EncryptionConfigSecretNamespace: "openshift-config-managed", | ||
| OperatorNamespace: "openshift-authentication-operator", | ||
| TargetGRs: library.AuthTargetGRs, | ||
| AssertFunc: library.AssertTokens, | ||
| }, | ||
| CreateResourceFunc: func(t testing.TB, _ library.ClientSet, namespace string) runtime.Object { | ||
| return library.CreateAndStoreTokenOfLife(context.TODO(), t, library.GetClients(t)) | ||
| }, | ||
| AssertResourceEncryptedFunc: library.AssertTokenOfLifeEncrypted, | ||
| AssertResourceNotEncryptedFunc: library.AssertTokenOfLifeNotEncrypted, | ||
| ResourceFunc: library.TokenOfLife, | ||
| ResourceName: "TokenOfLife", | ||
| PrimaryProvider: librarykms.DefaultVaultEncryptionProvider(ctx, t), | ||
| SecondaryProvider: librarykms.SecondaryVaultEncryptionProvider(ctx, t), | ||
| }) | ||
| } | ||
|
Comment on lines
+91
to
+137
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. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Wire these new scenarios into the test entrypoint. Line 92 and Line 116 add helper functions that nothing invokes, so the new KMS-to-KMS migration/on-off paths never execute. Please register them alongside the existing encryption scenarios; otherwise this PR adds dead test code instead of coverage. 🧰 Tools🪛 golangci-lint (2.12.2)[error] 92-92: func testKMSToKMSMigration is unused (unused) [error] 116-116: func testKMSToKMSOnOff is unused (unused) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
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.
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.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: openshift/cluster-authentication-operator
Length of output: 665
🏁 Script executed:
Repository: openshift/cluster-authentication-operator
Length of output: 9902
Pass the test context through the token-creation callbacks.
context.TODO()drops the outerctx’s timeout/cancellation, so these paths can outlive the test. Usectxin all fourCreateResourceFuncclosures.🤖 Prompt for AI Agents
Sources: Coding guidelines, Path instructions