Skip to content

Commit

Permalink
Update OperatorPolicy tests for upgradeApproval
Browse files Browse the repository at this point in the history
Per a recent change in the controller, it is now invalid to specify
installPlanApproval in an OperatorPolicy, and it is necessary to specify
upgradeApproval.

Refs:
 - open-cluster-management-io/config-policy-controller#249

Signed-off-by: Justin Kulikauskas <jkulikau@redhat.com>
  • Loading branch information
JustinKuli authored and openshift-merge-bot[bot] committed May 29, 2024
1 parent 7656ed8 commit c128d83
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions test/integration/operator_policy_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ var _ = Describe("GRC: [P1][Sev1][policy-grc] Test operatorpolicy errors",
Expect(err).ToNot(HaveOccurred())
})

It(operatorPolicyName+" should be patched with incorrect installPlanApproval", func() {
It(operatorPolicyName+" should be patched to specify installPlanApproval", func() {
_, err := common.OcHub(
"patch", "policies.policy.open-cluster-management.io", policyName,
"-n", userNamespace, "--type=json", "-p", `[{
"op":"replace",
"path":"/spec/policy-templates/0/objectDefinition/spec/subscription/installPlanApproval",
"value":"Invalid"
"value":"Automatic"
}]`)
Expect(err).ToNot(HaveOccurred())
})
Expand All @@ -121,6 +121,6 @@ var _ = Describe("GRC: [P1][Sev1][policy-grc] Test operatorpolicy errors",
common.GetOpPolicyCompMsg(operatorPolicyName),
defaultTimeoutSeconds,
1,
).Should(ContainSubstring("the policy spec.subscription.installPlanApproval ('Invalid') is invalid"))
).Should(ContainSubstring("installPlanApproval is prohibited in spec.subscription"))
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ spec:
channel: stable-3.8
name: quay-operator
namespace: ch-operator-policy-test-ns
installPlanApproval: Automatic
# correct one: redhat-operators
source: invalid
sourceNamespace: openshift-marketplace
upgradeApproval: Automatic
---
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
Expand Down
2 changes: 1 addition & 1 deletion test/resources/compliance_history/policy-install-gk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ spec:
channel: stable
name: gatekeeper-operator-product
namespace: openshift-operators
installPlanApproval: Automatic
source: redhat-operators
sourceNamespace: openshift-marketplace
upgradeApproval: Automatic
- objectDefinition:
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
Expand Down
2 changes: 1 addition & 1 deletion test/resources/operator_policy/test-op-err-correct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ spec:
channel: stable-3.8
name: quay-operator
namespace: grcqeoptest-ns-43568
installPlanApproval: Automatic
source: redhat-operators
sourceNamespace: openshift-marketplace
upgradeApproval: Automatic
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
2 changes: 1 addition & 1 deletion test/resources/operator_policy/test-op-err-initial.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ spec:
channel: stable-3.8
name: quay-operator
namespace: grcqeoptest-notcreated
installPlanApproval: Automatic
source: redhat-operators
sourceNamespace: openshift-marketplace
upgradeApproval: Automatic
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
subscription:
name: quay-operator
namespace: grcqeoptest-ns-47229
installPlanApproval: Automatic
upgradeApproval: Automatic
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ spec:
channel: stable-3.8
name: quay-operator
namespace: grcqeoptest-ns-43544
installPlanApproval: Automatic
source: redhat-operators
sourceNamespace: openshift-marketplace
upgradeApproval: Automatic
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ spec:
channel: stable-3.8
name: quay-operator
namespace: grcqeoptest-ns-43545
installPlanApproval: Automatic
source: redhat-operators
sourceNamespace: openshift-marketplace
upgradeApproval: Automatic
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down

0 comments on commit c128d83

Please sign in to comment.