@@ -26,7 +26,6 @@ import (
26
26
"testing"
27
27
28
28
authenticationv1 "k8s.io/api/authentication/v1"
29
- authenticationv1alpha1 "k8s.io/api/authentication/v1alpha1"
30
29
authenticationv1beta1 "k8s.io/api/authentication/v1beta1"
31
30
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
32
31
"k8s.io/apiserver/pkg/authentication/authenticator"
@@ -39,7 +38,7 @@ import (
39
38
40
39
func TestGetsSelfAttributes (t * testing.T ) {
41
40
// KUBE_APISERVER_SERVE_REMOVED_APIS_FOR_ONE_RELEASE allows for APIs pending removal to not block tests
42
- // TODO: Remove this line once authentication v1alpha1 types to be removed in 1.32 are fully removed
41
+ // TODO: Remove this line when oldest emulation version is 1.34, along with removal of v1beta1 SelfSubjectReview (unservable by default but still servable via this envvar in 1.33)
43
42
t .Setenv ("KUBE_APISERVER_SERVE_REMOVED_APIS_FOR_ONE_RELEASE" , "true" )
44
43
45
44
tests := []struct {
@@ -98,7 +97,6 @@ func TestGetsSelfAttributes(t *testing.T) {
98
97
99
98
kubeClient , _ , tearDownFn := framework .StartTestServer (tCtx , t , framework.TestServerSetup {
100
99
ModifyServerRunOptions : func (opts * options.ServerRunOptions ) {
101
- opts .APIEnablement .RuntimeConfig .Set ("authentication.k8s.io/v1alpha1=true" )
102
100
opts .APIEnablement .RuntimeConfig .Set ("authentication.k8s.io/v1beta1=true" )
103
101
opts .APIEnablement .RuntimeConfig .Set ("authentication.k8s.io/v1=true" )
104
102
opts .Authorization .Modes = []string {"AlwaysAllow" }
@@ -121,85 +119,58 @@ func TestGetsSelfAttributes(t *testing.T) {
121
119
response = tc .userInfo
122
120
respMu .Unlock ()
123
121
124
- res , err := kubeClient .AuthenticationV1alpha1 ().
125
- SelfSubjectReviews ().
126
- Create (tCtx , & authenticationv1alpha1.SelfSubjectReview {}, metav1.CreateOptions {})
127
- if err != nil {
128
- t .Fatalf ("unexpected error: %v" , err )
129
- }
130
-
131
- if res == nil {
132
- t .Fatalf ("empty response" )
133
- }
134
-
135
- if res .Status .UserInfo .Username != tc .expectedName {
136
- t .Fatalf ("unexpected username: wanted %s, got %s" , tc .expectedName , res .Status .UserInfo .Username )
137
- }
138
-
139
- if res .Status .UserInfo .UID != tc .expectedUID {
140
- t .Fatalf ("unexpected uid: wanted %s, got %s" , tc .expectedUID , res .Status .UserInfo .UID )
141
- }
142
-
143
- if ! reflect .DeepEqual (res .Status .UserInfo .Groups , tc .expectedGroups ) {
144
- t .Fatalf ("unexpected groups: wanted %v, got %v" , tc .expectedGroups , res .Status .UserInfo .Groups )
145
- }
146
-
147
- if ! reflect .DeepEqual (res .Status .UserInfo .Extra , tc .expectedExtra ) {
148
- t .Fatalf ("unexpected extra: wanted %v, got %v" , tc .expectedExtra , res .Status .UserInfo .Extra )
149
- }
150
-
151
- res2 , err := kubeClient .AuthenticationV1beta1 ().
122
+ resBeta , err := kubeClient .AuthenticationV1beta1 ().
152
123
SelfSubjectReviews ().
153
124
Create (tCtx , & authenticationv1beta1.SelfSubjectReview {}, metav1.CreateOptions {})
154
125
if err != nil {
155
126
t .Fatalf ("unexpected error: %v" , err )
156
127
}
157
128
158
- if res2 == nil {
129
+ if resBeta == nil {
159
130
t .Fatalf ("empty response" )
160
131
}
161
132
162
- if res2 .Status .UserInfo .Username != tc .expectedName {
163
- t .Fatalf ("unexpected username: wanted %s, got %s" , tc .expectedName , res .Status .UserInfo .Username )
133
+ if resBeta .Status .UserInfo .Username != tc .expectedName {
134
+ t .Fatalf ("unexpected username: wanted %s, got %s" , tc .expectedName , resBeta .Status .UserInfo .Username )
164
135
}
165
136
166
- if res2 .Status .UserInfo .UID != tc .expectedUID {
167
- t .Fatalf ("unexpected uid: wanted %s, got %s" , tc .expectedUID , res .Status .UserInfo .UID )
137
+ if resBeta .Status .UserInfo .UID != tc .expectedUID {
138
+ t .Fatalf ("unexpected uid: wanted %s, got %s" , tc .expectedUID , resBeta .Status .UserInfo .UID )
168
139
}
169
140
170
- if ! reflect .DeepEqual (res2 .Status .UserInfo .Groups , tc .expectedGroups ) {
171
- t .Fatalf ("unexpected groups: wanted %v, got %v" , tc .expectedGroups , res .Status .UserInfo .Groups )
141
+ if ! reflect .DeepEqual (resBeta .Status .UserInfo .Groups , tc .expectedGroups ) {
142
+ t .Fatalf ("unexpected groups: wanted %v, got %v" , tc .expectedGroups , resBeta .Status .UserInfo .Groups )
172
143
}
173
144
174
- if ! reflect .DeepEqual (res2 .Status .UserInfo .Extra , tc .expectedExtra ) {
175
- t .Fatalf ("unexpected extra: wanted %v, got %v" , tc .expectedExtra , res .Status .UserInfo .Extra )
145
+ if ! reflect .DeepEqual (resBeta .Status .UserInfo .Extra , tc .expectedExtra ) {
146
+ t .Fatalf ("unexpected extra: wanted %v, got %v" , tc .expectedExtra , resBeta .Status .UserInfo .Extra )
176
147
}
177
148
178
- res3 , err := kubeClient .AuthenticationV1 ().
149
+ resV1 , err := kubeClient .AuthenticationV1 ().
179
150
SelfSubjectReviews ().
180
151
Create (context .TODO (), & authenticationv1.SelfSubjectReview {}, metav1.CreateOptions {})
181
152
if err != nil {
182
153
t .Fatalf ("unexpected error: %v" , err )
183
154
}
184
155
185
- if res3 == nil {
156
+ if resV1 == nil {
186
157
t .Fatalf ("empty response" )
187
158
}
188
159
189
- if res3 .Status .UserInfo .Username != tc .expectedName {
190
- t .Fatalf ("unexpected username: wanted %s, got %s" , tc .expectedName , res .Status .UserInfo .Username )
160
+ if resV1 .Status .UserInfo .Username != tc .expectedName {
161
+ t .Fatalf ("unexpected username: wanted %s, got %s" , tc .expectedName , resV1 .Status .UserInfo .Username )
191
162
}
192
163
193
- if res3 .Status .UserInfo .UID != tc .expectedUID {
194
- t .Fatalf ("unexpected uid: wanted %s, got %s" , tc .expectedUID , res .Status .UserInfo .UID )
164
+ if resV1 .Status .UserInfo .UID != tc .expectedUID {
165
+ t .Fatalf ("unexpected uid: wanted %s, got %s" , tc .expectedUID , resV1 .Status .UserInfo .UID )
195
166
}
196
167
197
- if ! reflect .DeepEqual (res3 .Status .UserInfo .Groups , tc .expectedGroups ) {
198
- t .Fatalf ("unexpected groups: wanted %v, got %v" , tc .expectedGroups , res .Status .UserInfo .Groups )
168
+ if ! reflect .DeepEqual (resV1 .Status .UserInfo .Groups , tc .expectedGroups ) {
169
+ t .Fatalf ("unexpected groups: wanted %v, got %v" , tc .expectedGroups , resV1 .Status .UserInfo .Groups )
199
170
}
200
171
201
- if ! reflect .DeepEqual (res3 .Status .UserInfo .Extra , tc .expectedExtra ) {
202
- t .Fatalf ("unexpected extra: wanted %v, got %v" , tc .expectedExtra , res .Status .UserInfo .Extra )
172
+ if ! reflect .DeepEqual (resV1 .Status .UserInfo .Extra , tc .expectedExtra ) {
173
+ t .Fatalf ("unexpected extra: wanted %v, got %v" , tc .expectedExtra , resV1 .Status .UserInfo .Extra )
203
174
}
204
175
})
205
176
}
@@ -212,7 +183,6 @@ func TestGetsSelfAttributesError(t *testing.T) {
212
183
tCtx := ktesting .Init (t )
213
184
kubeClient , _ , tearDownFn := framework .StartTestServer (tCtx , t , framework.TestServerSetup {
214
185
ModifyServerRunOptions : func (opts * options.ServerRunOptions ) {
215
- opts .APIEnablement .RuntimeConfig .Set ("authentication.k8s.io/v1alpha1=true" )
216
186
opts .APIEnablement .RuntimeConfig .Set ("authentication.k8s.io/v1beta1=true" )
217
187
opts .APIEnablement .RuntimeConfig .Set ("authentication.k8s.io/v1=true" )
218
188
opts .Authorization .Modes = []string {"AlwaysAllow" }
@@ -237,22 +207,6 @@ func TestGetsSelfAttributesError(t *testing.T) {
237
207
238
208
expected := fmt .Errorf ("Unauthorized" )
239
209
240
- { // v1alpha1
241
- toggle .Store (! toggle .Load ().(bool ))
242
-
243
- _ , err := kubeClient .AuthenticationV1alpha1 ().
244
- SelfSubjectReviews ().
245
- Create (tCtx , & authenticationv1alpha1.SelfSubjectReview {}, metav1.CreateOptions {})
246
- if err == nil {
247
- t .Fatalf ("expected error: %v, got nil" , err )
248
- }
249
-
250
- toggle .Store (! toggle .Load ().(bool ))
251
- if expected .Error () != err .Error () {
252
- t .Fatalf ("expected error: %v, got %v" , expected , err )
253
- }
254
- }
255
-
256
210
{ // v1beta1
257
211
toggle .Store (! toggle .Load ().(bool ))
258
212
0 commit comments