Skip to content

Commit 4c81f5a

Browse files
committed
fixing test
1 parent 464be26 commit 4c81f5a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

test/e2e/framework/auth/helpers.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func BindClusterRole(ctx context.Context, c bindingsGetter, clusterRole, ns stri
108108
return nil
109109
}
110110

111-
clusterRoleBinding, err := c.ClusterRoleBindings().Create(ctx, &rbacv1.ClusterRoleBinding{
111+
_, err := c.ClusterRoleBindings().Create(ctx, &rbacv1.ClusterRoleBinding{
112112
ObjectMeta: metav1.ObjectMeta{
113113
Name: clusterRole,
114114
},
@@ -124,10 +124,6 @@ func BindClusterRole(ctx context.Context, c bindingsGetter, clusterRole, ns stri
124124
return fmt.Errorf("binding clusterrole/%s for %q for %v: %w", clusterRole, ns, subjects, err)
125125
}
126126

127-
defer func() {
128-
framework.ExpectNoError(c.ClusterRoleBindings().Delete(ctx, clusterRoleBinding.Name, metav1.DeleteOptions{}))
129-
}()
130-
131127
return nil
132128
}
133129

test/e2e/node/kubelet_authz.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func runKubeletAuthzTest(ctx context.Context, f *framework.Framework, endpoint,
8888
}, metav1.CreateOptions{})
8989
framework.ExpectNoError(err)
9090
defer func() {
91+
ginkgo.By(fmt.Sprintf("Destroying ClusterRoles %q for this suite.", clusterRole.Name))
9192
framework.ExpectNoError(f.ClientSet.RbacV1().ClusterRoles().Delete(ctx, clusterRole.Name, metav1.DeleteOptions{}))
9293
}()
9394

@@ -101,6 +102,10 @@ func runKubeletAuthzTest(ctx context.Context, f *framework.Framework, endpoint,
101102

102103
err = e2eauth.BindClusterRole(ctx, f.ClientSet.RbacV1(), clusterRole.Name, ns, subject)
103104
framework.ExpectNoError(err)
105+
defer func() {
106+
ginkgo.By(fmt.Sprintf("Destroying ClusterRoleBindings %q for this suite.", clusterRole.Name))
107+
framework.ExpectNoError(f.ClientSet.RbacV1().ClusterRoleBindings().Delete(ctx, clusterRole.Name, metav1.DeleteOptions{}))
108+
}()
104109

105110
ginkgo.By("Waiting for Authorization Update.")
106111

0 commit comments

Comments
 (0)