@@ -71,11 +71,11 @@ func TestAuthenticationValidate(t *testing.T) {
71
71
{
72
72
name : "test when OIDC and ServiceAccounts are valid" ,
73
73
testOIDC : & OIDCAuthenticationOptions {
74
- UsernameClaim : "sub" ,
75
- SigningAlgs : []string {"RS256" },
76
- IssuerURL : "https://testIssuerURL" ,
77
- ClientID : "testClientID" ,
78
- areFlagsConfigured : func () bool { return true } ,
74
+ UsernameClaim : "sub" ,
75
+ SigningAlgs : []string {"RS256" },
76
+ IssuerURL : "https://testIssuerURL" ,
77
+ ClientID : "testClientID" ,
78
+ FlagsSet : true ,
79
79
},
80
80
testSA : & ServiceAccountAuthenticationOptions {
81
81
Issuers : []string {"http://foo.bar.com" },
@@ -85,10 +85,10 @@ func TestAuthenticationValidate(t *testing.T) {
85
85
{
86
86
name : "test when OIDC is invalid" ,
87
87
testOIDC : & OIDCAuthenticationOptions {
88
- UsernameClaim : "sub" ,
89
- SigningAlgs : []string {"RS256" },
90
- IssuerURL : "https://testIssuerURL" ,
91
- areFlagsConfigured : func () bool { return true } ,
88
+ UsernameClaim : "sub" ,
89
+ SigningAlgs : []string {"RS256" },
90
+ IssuerURL : "https://testIssuerURL" ,
91
+ FlagsSet : true ,
92
92
},
93
93
testSA : & ServiceAccountAuthenticationOptions {
94
94
Issuers : []string {"http://foo.bar.com" },
@@ -99,11 +99,11 @@ func TestAuthenticationValidate(t *testing.T) {
99
99
{
100
100
name : "test when ServiceAccounts doesn't have key file" ,
101
101
testOIDC : & OIDCAuthenticationOptions {
102
- UsernameClaim : "sub" ,
103
- SigningAlgs : []string {"RS256" },
104
- IssuerURL : "https://testIssuerURL" ,
105
- ClientID : "testClientID" ,
106
- areFlagsConfigured : func () bool { return true } ,
102
+ UsernameClaim : "sub" ,
103
+ SigningAlgs : []string {"RS256" },
104
+ IssuerURL : "https://testIssuerURL" ,
105
+ ClientID : "testClientID" ,
106
+ FlagsSet : true ,
107
107
},
108
108
testSA : & ServiceAccountAuthenticationOptions {
109
109
Issuers : []string {"http://foo.bar.com" },
@@ -113,11 +113,11 @@ func TestAuthenticationValidate(t *testing.T) {
113
113
{
114
114
name : "test when ServiceAccounts doesn't have issuer" ,
115
115
testOIDC : & OIDCAuthenticationOptions {
116
- UsernameClaim : "sub" ,
117
- SigningAlgs : []string {"RS256" },
118
- IssuerURL : "https://testIssuerURL" ,
119
- ClientID : "testClientID" ,
120
- areFlagsConfigured : func () bool { return true } ,
116
+ UsernameClaim : "sub" ,
117
+ SigningAlgs : []string {"RS256" },
118
+ IssuerURL : "https://testIssuerURL" ,
119
+ ClientID : "testClientID" ,
120
+ FlagsSet : true ,
121
121
},
122
122
testSA : & ServiceAccountAuthenticationOptions {
123
123
Issuers : []string {},
@@ -127,11 +127,11 @@ func TestAuthenticationValidate(t *testing.T) {
127
127
{
128
128
name : "test when ServiceAccounts has empty string as issuer" ,
129
129
testOIDC : & OIDCAuthenticationOptions {
130
- UsernameClaim : "sub" ,
131
- SigningAlgs : []string {"RS256" },
132
- IssuerURL : "https://testIssuerURL" ,
133
- ClientID : "testClientID" ,
134
- areFlagsConfigured : func () bool { return true } ,
130
+ UsernameClaim : "sub" ,
131
+ SigningAlgs : []string {"RS256" },
132
+ IssuerURL : "https://testIssuerURL" ,
133
+ ClientID : "testClientID" ,
134
+ FlagsSet : true ,
135
135
},
136
136
testSA : & ServiceAccountAuthenticationOptions {
137
137
Issuers : []string {"" },
@@ -141,11 +141,11 @@ func TestAuthenticationValidate(t *testing.T) {
141
141
{
142
142
name : "test when ServiceAccounts has duplicate issuers" ,
143
143
testOIDC : & OIDCAuthenticationOptions {
144
- UsernameClaim : "sub" ,
145
- SigningAlgs : []string {"RS256" },
146
- IssuerURL : "https://testIssuerURL" ,
147
- ClientID : "testClientID" ,
148
- areFlagsConfigured : func () bool { return true } ,
144
+ UsernameClaim : "sub" ,
145
+ SigningAlgs : []string {"RS256" },
146
+ IssuerURL : "https://testIssuerURL" ,
147
+ ClientID : "testClientID" ,
148
+ FlagsSet : true ,
149
149
},
150
150
testSA : & ServiceAccountAuthenticationOptions {
151
151
Issuers : []string {"http://foo.bar.com" , "http://foo.bar.com" },
@@ -155,11 +155,11 @@ func TestAuthenticationValidate(t *testing.T) {
155
155
{
156
156
name : "test when ServiceAccount has bad issuer" ,
157
157
testOIDC : & OIDCAuthenticationOptions {
158
- UsernameClaim : "sub" ,
159
- SigningAlgs : []string {"RS256" },
160
- IssuerURL : "https://testIssuerURL" ,
161
- ClientID : "testClientID" ,
162
- areFlagsConfigured : func () bool { return true } ,
158
+ UsernameClaim : "sub" ,
159
+ SigningAlgs : []string {"RS256" },
160
+ IssuerURL : "https://testIssuerURL" ,
161
+ ClientID : "testClientID" ,
162
+ FlagsSet : true ,
163
163
},
164
164
testSA : & ServiceAccountAuthenticationOptions {
165
165
Issuers : []string {"http://[::1]:namedport" },
@@ -169,11 +169,11 @@ func TestAuthenticationValidate(t *testing.T) {
169
169
{
170
170
name : "test when ServiceAccounts has invalid JWKSURI" ,
171
171
testOIDC : & OIDCAuthenticationOptions {
172
- UsernameClaim : "sub" ,
173
- SigningAlgs : []string {"RS256" },
174
- IssuerURL : "https://testIssuerURL" ,
175
- ClientID : "testClientID" ,
176
- areFlagsConfigured : func () bool { return true } ,
172
+ UsernameClaim : "sub" ,
173
+ SigningAlgs : []string {"RS256" },
174
+ IssuerURL : "https://testIssuerURL" ,
175
+ ClientID : "testClientID" ,
176
+ FlagsSet : true ,
177
177
},
178
178
testSA : & ServiceAccountAuthenticationOptions {
179
179
KeyFiles : []string {"cert" , "key" },
@@ -185,11 +185,11 @@ func TestAuthenticationValidate(t *testing.T) {
185
185
{
186
186
name : "test when ServiceAccounts has invalid JWKSURI (not https scheme)" ,
187
187
testOIDC : & OIDCAuthenticationOptions {
188
- UsernameClaim : "sub" ,
189
- SigningAlgs : []string {"RS256" },
190
- IssuerURL : "https://testIssuerURL" ,
191
- ClientID : "testClientID" ,
192
- areFlagsConfigured : func () bool { return true } ,
188
+ UsernameClaim : "sub" ,
189
+ SigningAlgs : []string {"RS256" },
190
+ IssuerURL : "https://testIssuerURL" ,
191
+ ClientID : "testClientID" ,
192
+ FlagsSet : true ,
193
193
},
194
194
testSA : & ServiceAccountAuthenticationOptions {
195
195
KeyFiles : []string {"cert" , "key" },
@@ -201,11 +201,11 @@ func TestAuthenticationValidate(t *testing.T) {
201
201
{
202
202
name : "test when WebHook has invalid retry attempts" ,
203
203
testOIDC : & OIDCAuthenticationOptions {
204
- UsernameClaim : "sub" ,
205
- SigningAlgs : []string {"RS256" },
206
- IssuerURL : "https://testIssuerURL" ,
207
- ClientID : "testClientID" ,
208
- areFlagsConfigured : func () bool { return true } ,
204
+ UsernameClaim : "sub" ,
205
+ SigningAlgs : []string {"RS256" },
206
+ IssuerURL : "https://testIssuerURL" ,
207
+ ClientID : "testClientID" ,
208
+ FlagsSet : true ,
209
209
},
210
210
testSA : & ServiceAccountAuthenticationOptions {
211
211
KeyFiles : []string {"cert" , "key" },
@@ -234,11 +234,11 @@ func TestAuthenticationValidate(t *testing.T) {
234
234
name : "test when authentication config file and oidc-* flags are set" ,
235
235
testAuthenticationConfigFile : "configfile" ,
236
236
testOIDC : & OIDCAuthenticationOptions {
237
- UsernameClaim : "sub" ,
238
- SigningAlgs : []string {"RS256" },
239
- IssuerURL : "https://testIssuerURL" ,
240
- ClientID : "testClientID" ,
241
- areFlagsConfigured : func () bool { return true } ,
237
+ UsernameClaim : "sub" ,
238
+ SigningAlgs : []string {"RS256" },
239
+ IssuerURL : "https://testIssuerURL" ,
240
+ ClientID : "testClientID" ,
241
+ FlagsSet : true ,
242
242
},
243
243
expectErr : "authentication-config file and oidc-* flags are mutually exclusive" ,
244
244
},
@@ -247,8 +247,8 @@ func TestAuthenticationValidate(t *testing.T) {
247
247
disabledFeatures : []featuregate.Feature {features .AnonymousAuthConfigurableEndpoints },
248
248
testAuthenticationConfigFile : "configfile" ,
249
249
testAnonymous : & AnonymousAuthenticationOptions {
250
- Allow : true ,
251
- areFlagsSet : func () bool { return true } ,
250
+ Allow : true ,
251
+ FlagsSet : true ,
252
252
},
253
253
},
254
254
}
@@ -413,7 +413,8 @@ func TestBuiltInAuthenticationOptionsAddFlags(t *testing.T) {
413
413
expected := & BuiltInAuthenticationOptions {
414
414
APIAudiences : []string {"foo" },
415
415
Anonymous : & AnonymousAuthenticationOptions {
416
- Allow : true ,
416
+ Allow : true ,
417
+ FlagsSet : true ,
417
418
},
418
419
BootstrapToken : & BootstrapTokenAuthenticationOptions {
419
420
Enable : true ,
@@ -428,6 +429,7 @@ func TestBuiltInAuthenticationOptionsAddFlags(t *testing.T) {
428
429
UsernameClaim : "sub" ,
429
430
UsernamePrefix : "-" ,
430
431
SigningAlgs : []string {"RS256" },
432
+ FlagsSet : true ,
431
433
},
432
434
RequestHeader : & apiserveroptions.RequestHeaderAuthenticationOptions {
433
435
ClientCAFile : "testdata/root.pem" ,
@@ -470,19 +472,6 @@ func TestBuiltInAuthenticationOptionsAddFlags(t *testing.T) {
470
472
t .Fatal (err )
471
473
}
472
474
473
- if ! opts .OIDC .areFlagsConfigured () {
474
- t .Fatal ("OIDC flags should be configured" )
475
- }
476
- // nil these out because you cannot compare functions
477
- opts .OIDC .areFlagsConfigured = nil
478
-
479
- if ! opts .Anonymous .areFlagsSet () {
480
- t .Fatalf ("Anonymous flags should be configured" )
481
- }
482
-
483
- // nil these out because you cannot compare functions
484
- opts .Anonymous .areFlagsSet = nil
485
-
486
475
if ! reflect .DeepEqual (opts , expected ) {
487
476
t .Error (cmp .Diff (opts , expected , cmp .AllowUnexported (OIDCAuthenticationOptions {}, AnonymousAuthenticationOptions {})))
488
477
}
0 commit comments