@@ -60,6 +60,9 @@ func runKubeletAuthzTest(ctx context.Context, f *framework.Framework, endpoint,
60
60
crName := authzSubresource
61
61
verb := "get"
62
62
resource := "nodes"
63
+
64
+ ginkgo .By (fmt .Sprintf ("Creating Service Account:%s/%s" , ns , saName ))
65
+
63
66
_ , err := f .ClientSet .CoreV1 ().ServiceAccounts (ns ).Create (ctx , & v1.ServiceAccount {
64
67
ObjectMeta : metav1.ObjectMeta {
65
68
Name : saName ,
@@ -68,12 +71,15 @@ func runKubeletAuthzTest(ctx context.Context, f *framework.Framework, endpoint,
68
71
}, metav1.CreateOptions {})
69
72
framework .ExpectNoError (err )
70
73
74
+ ginkgo .By (fmt .Sprintf ("Creating ClusterRole %s with for %s/%s" , crName , resource , authzSubresource ))
75
+
71
76
_ , err = f .ClientSet .RbacV1 ().ClusterRoles ().Create (ctx , & rbacv1.ClusterRole {
72
77
ObjectMeta : metav1.ObjectMeta {
73
78
Name : crName ,
74
79
},
75
80
Rules : []rbacv1.PolicyRule {
76
81
{
82
+ APIGroups : []string {"" },
77
83
Verbs : []string {verb },
78
84
Resources : []string {resource + "/" + authzSubresource },
79
85
},
@@ -87,9 +93,13 @@ func runKubeletAuthzTest(ctx context.Context, f *framework.Framework, endpoint,
87
93
Name : saName ,
88
94
}
89
95
96
+ ginkgo .By (fmt .Sprintf ("Creating ClusterRoleBinding with ClusterRole %s with subject %s/%s" , crName , ns , saName ))
97
+
90
98
err = e2eauth .BindClusterRole (ctx , f .ClientSet .RbacV1 (), crName , ns , subject )
91
99
framework .ExpectNoError (err )
92
100
101
+ ginkgo .By ("Waiting for Authorization Update." )
102
+
93
103
err = e2eauth .WaitForAuthzUpdate (ctx , f .ClientSet .AuthorizationV1 (),
94
104
serviceaccount .MakeUsername (ns , saName ),
95
105
& authorizationv1.ResourceAttributes {
@@ -102,6 +112,8 @@ func runKubeletAuthzTest(ctx context.Context, f *framework.Framework, endpoint,
102
112
)
103
113
framework .ExpectNoError (err )
104
114
115
+ ginkgo .By (fmt .Sprintf ("Getting token for ServiceAccount %s/%s." , ns , saName ))
116
+
105
117
tr , err := f .ClientSet .CoreV1 ().ServiceAccounts (ns ).CreateToken (ctx , saName , & authenticationv1.TokenRequest {}, metav1.CreateOptions {})
106
118
framework .ExpectNoError (err )
107
119
0 commit comments