Refactor of e2e/framework/authorizer_util.go

- moves these helper functions into e2e/framework/auth
 - removes logging from helper functions
 - in some cases explicitly returns errors that were implicitly
ignored/logged. In the situations where they should be ignored,
we explicitly check that the condition is met before ignoring it.
 - fixes references of these methods to use the right package and
return values
This commit is contained in:
John Schnake
2019-04-09 11:52:36 -05:00
parent 18b4e1b84c
commit 028df0451d
18 changed files with 156 additions and 54 deletions

View File

@@ -30,6 +30,7 @@ import (
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
commonutils "k8s.io/kubernetes/test/e2e/common"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework/auth"
"k8s.io/kubernetes/test/e2e/framework/testfiles"
. "github.com/onsi/ginkgo"
@@ -51,10 +52,11 @@ var _ = framework.KubeDescribe("[Feature:Example]", func() {
// this test wants powerful permissions. Since the namespace names are unique, we can leave this
// lying around so we don't have to race any caches
framework.BindClusterRoleInNamespace(c.RbacV1beta1(), "edit", f.Namespace.Name,
err := auth.BindClusterRoleInNamespace(c.RbacV1beta1(), "edit", f.Namespace.Name,
rbacv1beta1.Subject{Kind: rbacv1beta1.ServiceAccountKind, Namespace: f.Namespace.Name, Name: "default"})
framework.ExpectNoError(err)
err := framework.WaitForAuthorizationUpdate(c.AuthorizationV1beta1(),
err = auth.WaitForAuthorizationUpdate(c.AuthorizationV1beta1(),
serviceaccount.MakeUsername(f.Namespace.Name, "default"),
f.Namespace.Name, "create", schema.GroupResource{Resource: "pods"}, true)
framework.ExpectNoError(err)