Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 83
🐛 make create verb a fixed namespaced collection verb for preflight checks#2587
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
Merged
openshift-merge-bot
merged 1 commit into
operator-framework:main
from
kuiwang02:fix78211Mar 30, 2026
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 18 additions & 126 deletions
144 internal/operator-controller/authorization/rbac_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -34,6 +34,7 @@ import ( | ||
| "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
| "k8s.io/apimachinery/pkg/util/sets" | ||
| k8sresource "k8s.io/cli-runtime/pkg/resource" | ||
| "k8s.io/component-base/featuregate" | ||
| "k8s.io/utils/ptr" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||
| "sigs.k8s.io/yaml" | ||
| @@ -120,6 +121,7 @@ func RegisterSteps(sc *godog.ScenarioContext) { | ||
| sc.Step(`^(?i)ServiceAccount "([^"]*)" with permissions to install extensions is available in "([^"]*)" namespace$`, ServiceAccountWithNeededPermissionsIsAvailableInGivenNamespace) | ||
| sc.Step(`^(?i)ServiceAccount "([^"]*)" with needed permissions is available in test namespace$`, ServiceAccountWithNeededPermissionsIsAvailableInTestNamespace) | ||
| sc.Step(`^(?i)ServiceAccount "([^"]*)" with needed permissions is available in \${TEST_NAMESPACE}$`, ServiceAccountWithNeededPermissionsIsAvailableInTestNamespace) | ||
| sc.Step(`^(?i)ServiceAccount "([^"]*)" without create permissions is available in \${TEST_NAMESPACE}$`, ServiceAccountWithoutCreatePermissionsIsAvailableInTestNamespace) | ||
| sc.Step(`^(?i)ServiceAccount "([^"]*)" is available in \${TEST_NAMESPACE}$`, ServiceAccountIsAvailableInNamespace) | ||
| sc.Step(`^(?i)ServiceAccount "([^"]*)" in test namespace is cluster admin$`, ServiceAccountWithClusterAdminPermissionsIsAvailableInNamespace) | ||
| sc.Step(`^(?i)ServiceAccount "([^"]+)" in test namespace has permissions to fetch "([^"]+)" metrics$`, ServiceAccountWithFetchMetricsPermissions) | ||
| @@ -418,6 +420,11 @@ type msgMatchFn func(string) bool | ||
| func alwaysMatch(_ string) bool { return true } | ||
| func isFeatureGateEnabled(feature featuregate.Feature) bool { | ||
| enabled, found := featureGates[feature] | ||
| return enabled && found | ||
| } | ||
| func messageComparison(ctx context.Context, msg *godog.DocString) msgMatchFn { | ||
| msgCmp := alwaysMatch | ||
| if msg != nil { | ||
| @@ -877,6 +884,23 @@ func ServiceAccountWithNeededPermissionsIsAvailableInTestNamespace(ctx context.C | ||
| return applyPermissionsToServiceAccount(ctx, serviceAccount, rbacTemplate) | ||
| } | ||
| // ServiceAccountWithoutCreatePermissionsIsAvailableInTestNamespace creates a ServiceAccount with permissions that | ||
| // intentionally exclude the "create" verb to test preflight permission validation for Boxcutter applier. | ||
| // This is used to verify that the preflight check properly detects missing CREATE permissions. | ||
| // Note: This function requires both @BoxcutterRuntime and @PreflightPermissions tags. | ||
| func ServiceAccountWithoutCreatePermissionsIsAvailableInTestNamespace(ctx context.Context, serviceAccount string) error { | ||
| // This test is only valid with Boxcutter runtime enabled | ||
| if !isFeatureGateEnabled(features.BoxcutterRuntime) { | ||
| return fmt.Errorf("this step requires BoxcutterRuntime feature gate to be enabled") | ||
| } | ||
kuiwang02 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| // It also requires preflight permissions checks to be enabled | ||
| if !isFeatureGateEnabled(features.PreflightPermissions) { | ||
| return fmt.Errorf("this step requires PreflightPermissions feature gate to be enabled") | ||
| } | ||
| rbacTemplate := fmt.Sprintf("%s-boxcutter-no-create-rbac-template.yaml", serviceAccount) | ||
| return applyPermissionsToServiceAccount(ctx, serviceAccount, rbacTemplate) | ||
| } | ||
| // ServiceAccountWithNeededPermissionsIsAvailableInGivenNamespace creates a ServiceAccount and enables creation of any cluster extension on behalf of this account. | ||
| func ServiceAccountWithNeededPermissionsIsAvailableInGivenNamespace(ctx context.Context, serviceAccount string, ns string) error { | ||
| sc := scenarioCtx(ctx) | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.