diff --git a/controllers/authpolicy_authconfig.go b/controllers/authpolicy_authconfig.go index 15d0c95aa..dfd673cb4 100644 --- a/controllers/authpolicy_authconfig.go +++ b/controllers/authpolicy_authconfig.go @@ -195,7 +195,7 @@ func (r *AuthPolicyReconciler) desiredAuthConfig(ctx context.Context, ap *api.Au return mergeConditionsFromRouteSelectorsIntoConfigs(ap, route, authConfig) } -// routeGatewayAuthOverrides returns the GW auth policies that has a +// routeGatewayAuthOverrides returns the GW auth policies that has an override field set func routeGatewayAuthOverrides(t *kuadrantgatewayapi.Topology, ap *api.AuthPolicy) []client.ObjectKey { affectedPolicies := getAffectedPolicies(t, ap) diff --git a/controllers/authpolicy_controller_test.go b/controllers/authpolicy_controller_test.go index 68a7c43a8..72e718298 100644 --- a/controllers/authpolicy_controller_test.go +++ b/controllers/authpolicy_controller_test.go @@ -1136,10 +1136,10 @@ var _ = Describe("AuthPolicy controller", func() { ), 30*time.Second, 5*time.Second).Should(BeTrue()) }) - It("Invalid reason", func() { + It("Invalid reason", func(ctx SpecContext) { var otherNamespace string CreateNamespace(&otherNamespace) - defer DeleteNamespaceCallback(&otherNamespace) + defer DeleteNamespaceCallback(&otherNamespace)() policy := policyFactory(func(policy *api.AuthPolicy) { policy.Namespace = otherNamespace // create the policy in a different namespace than the target @@ -1147,10 +1147,10 @@ var _ = Describe("AuthPolicy controller", func() { policy.Spec.TargetRef.Name = gatewayapiv1.ObjectName(testGatewayName) policy.Spec.TargetRef.Namespace = ptr.To(gatewayapiv1.Namespace(testNamespace)) }) - Expect(k8sClient.Create(context.Background(), policy)).To(Succeed()) + Expect(k8sClient.Create(ctx, policy)).To(Succeed()) - Eventually(assertAcceptedCondFalseAndEnforcedCondNil(policy, string(gatewayapiv1alpha2.PolicyReasonInvalid), fmt.Sprintf("AuthPolicy target is invalid: invalid targetRef.Namespace %s. Currently only supporting references to the same namespace", testNamespace)), 30*time.Second, 5*time.Second).Should(BeTrue()) - }) + Eventually(assertAcceptedCondFalseAndEnforcedCondNil(policy, string(gatewayapiv1alpha2.PolicyReasonInvalid), fmt.Sprintf("AuthPolicy target is invalid: invalid targetRef.Namespace %s. Currently only supporting references to the same namespace", testNamespace))).WithContext(ctx).Should(BeTrue()) + }, SpecTimeout(time.Minute)) }) Context("AuthPolicy enforced condition reasons", func() { diff --git a/controllers/ratelimitpolicy_controller_test.go b/controllers/ratelimitpolicy_controller_test.go index 218779b77..014f08f26 100644 --- a/controllers/ratelimitpolicy_controller_test.go +++ b/controllers/ratelimitpolicy_controller_test.go @@ -662,7 +662,7 @@ var _ = Describe("RateLimitPolicy controller", func() { It("Invalid reason", func(ctx SpecContext) { var otherNamespace string CreateNamespace(&otherNamespace) - defer DeleteNamespaceCallback(&otherNamespace) + defer DeleteNamespaceCallback(&otherNamespace)() policy := policyFactory(func(policy *kuadrantv1beta2.RateLimitPolicy) { policy.Namespace = otherNamespace // create the policy in a different namespace than the target @@ -672,7 +672,7 @@ var _ = Describe("RateLimitPolicy controller", func() { }) Expect(k8sClient.Create(ctx, policy)).To(Succeed()) - Eventually(assertAcceptedConditionFalse(ctx, policy, string(gatewayapiv1alpha2.PolicyReasonInvalid), fmt.Sprintf("RateLimitPolicy target is invalid: invalid targetRef.Namespace %s. Currently only supporting references to the same namespace", testNamespace)), 30*time.Second, 5*time.Second).Should(BeTrue()) + Eventually(assertAcceptedConditionFalse(ctx, policy, string(gatewayapiv1alpha2.PolicyReasonInvalid), fmt.Sprintf("RateLimitPolicy target is invalid: invalid targetRef.Namespace %s. Currently only supporting references to the same namespace", testNamespace))).WithContext(ctx).Should(Succeed()) }, SpecTimeout(time.Minute)) }) diff --git a/controllers/ratelimitpolicy_limits.go b/controllers/ratelimitpolicy_limits.go index e248ee10f..a90817570 100644 --- a/controllers/ratelimitpolicy_limits.go +++ b/controllers/ratelimitpolicy_limits.go @@ -189,7 +189,7 @@ func (r *RateLimitPolicyReconciler) getAffectedPoliciesInfo(rlp *kuadrantv1beta2 } // applyGatewayOverrides a Gateway RLP is not affected if there is untargetted routes or affects other policies -// Otherwise, it +// Otherwise, it has no free routes, and therefore "overridden" by the route policies func (r *RateLimitPolicyReconciler) applyGatewayOverrides(logger logr.Logger, rlp *kuadrantv1beta2.RateLimitPolicy, numUnTargetedRoutes int, affectedPolicies []kuadrantgatewayapi.Policy) { if rlp.Spec.Overrides == nil && numUnTargetedRoutes == 0 { r.AffectedPolicyMap.SetAffectedPolicy(rlp, utils.Map(affectedPolicies, func(p kuadrantgatewayapi.Policy) client.ObjectKey {