From 0ee198704246d75de3a94e15e08201c69d0a33ca Mon Sep 17 00:00:00 2001 From: Dario Tranchitella Date: Thu, 9 Jun 2022 17:28:24 +0200 Subject: [PATCH 1/2] refactor: removing unrequired verb for clusterrole namespace deleter --- controllers/rbac/const.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/rbac/const.go b/controllers/rbac/const.go index 1b3395fe..57f4c96e 100644 --- a/controllers/rbac/const.go +++ b/controllers/rbac/const.go @@ -35,7 +35,7 @@ var ( { APIGroups: []string{""}, Resources: []string{"namespaces"}, - Verbs: []string{"delete", "patch"}, + Verbs: []string{"delete"}, }, }, }, From 408072ec9d734a5278174a5336f45ad55c12af83 Mon Sep 17 00:00:00 2001 From: Dario Tranchitella Date: Thu, 9 Jun 2022 17:28:50 +0200 Subject: [PATCH 2/2] fix(tests): cleaning up protected tenant upon test success --- e2e/tenant_protected_webhook_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/e2e/tenant_protected_webhook_test.go b/e2e/tenant_protected_webhook_test.go index e80039b8..108f35e5 100644 --- a/e2e/tenant_protected_webhook_test.go +++ b/e2e/tenant_protected_webhook_test.go @@ -11,6 +11,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" capsulev1beta1 "github.com/clastix/capsule/api/v1beta1" ) @@ -33,6 +34,13 @@ var _ = Describe("Deleting a tenant with protected annotation", func() { }, } + JustAfterEach(func() { + Expect(k8sClient.Get(context.TODO(), types.NamespacedName{Name: tnt.GetName()}, tnt)).Should(Succeed()) + tnt.SetAnnotations(map[string]string{}) + Expect(k8sClient.Update(context.TODO(), tnt)).Should(Succeed()) + Expect(k8sClient.Delete(context.TODO(), tnt)).Should(Succeed()) + }) + It("should fail", func() { Expect(k8sClient.Create(context.TODO(), tnt)).Should(Succeed()) Expect(k8sClient.Delete(context.TODO(), tnt)).ShouldNot(Succeed())