@@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if w
2
2
name : " Authentication"
3
3
crdName : authentications.config.openshift.io
4
4
featureGates :
5
- - ExternalOIDC
5
+ - ExternalOIDC
6
6
tests :
7
7
onCreate :
8
8
- name : Should be able to create a minimal Authentication
@@ -121,6 +121,64 @@ tests:
121
121
username:
122
122
claim: "preferred_username"
123
123
prefixPolicy: NoPrefix
124
+ - name : Cannot set OIDC providers with no claim mappings
125
+ initial : |
126
+ apiVersion: config.openshift.io/v1
127
+ kind: Authentication
128
+ spec:
129
+ type: OIDC
130
+ oidcProviders:
131
+ - name: myoidc
132
+ issuer:
133
+ issuerURL: https://meh.tld
134
+ audiences: ['openshift-aud']
135
+ expectedError : " Required value"
136
+ - name : Cannot set OIDC providers with no username claim mapping
137
+ initial : |
138
+ apiVersion: config.openshift.io/v1
139
+ kind: Authentication
140
+ spec:
141
+ type: OIDC
142
+ oidcProviders:
143
+ - name: myoidc
144
+ issuer:
145
+ issuerURL: https://meh.tld
146
+ audiences: ['openshift-aud']
147
+ claimMappings:
148
+ groups:
149
+ claim: roles
150
+ expectedError : " Required value"
151
+ - name : Can set OIDC providers with empty group claim mapping
152
+ initial : |
153
+ apiVersion: config.openshift.io/v1
154
+ kind: Authentication
155
+ spec:
156
+ type: OIDC
157
+ oidcProviders:
158
+ - name: myoidc
159
+ issuer:
160
+ issuerURL: https://meh.tld
161
+ audiences: ['openshift-aud']
162
+ claimMappings:
163
+ username:
164
+ claim: "username"
165
+ groups:
166
+ claim: ""
167
+ expected : |
168
+ apiVersion: config.openshift.io/v1
169
+ kind: Authentication
170
+ spec:
171
+ type: OIDC
172
+ oidcProviders:
173
+ - name: myoidc
174
+ issuer:
175
+ issuerURL: https://meh.tld
176
+ audiences: ['openshift-aud']
177
+ claimMappings:
178
+ username:
179
+ claim: "username"
180
+ groups:
181
+ claim: ""
124
182
onUpdate :
125
183
- name : Updating OIDC provider with a client that's not in the status
126
184
initial : &initConfig |
@@ -133,6 +191,9 @@ tests:
133
191
issuer :
134
192
issuerURL : https://meh.tld
135
193
audiences : ['openshift-aud']
194
+ claimMappings :
195
+ username :
196
+ claim : username
136
197
oidcClients :
137
198
- componentNamespace : namespace
138
199
componentName : preexisting
@@ -158,6 +219,9 @@ tests:
158
219
issuer:
159
220
issuerURL: https://meh.tld
160
221
audiences: ['openshift-aud']
222
+ claimMappings:
223
+ username:
224
+ claim: username
161
225
oidcClients:
162
226
- componentNamespace: namespace
163
227
componentName: preexisting
@@ -189,6 +253,9 @@ tests:
189
253
issuer:
190
254
issuerURL: https://meh.tld
191
255
audiences: ['openshift-aud']
256
+ claimMappings:
257
+ username:
258
+ claim: username
192
259
oidcClients:
193
260
- componentNamespace: dif-namespace
194
261
componentName: tehName
@@ -214,6 +281,9 @@ tests:
214
281
issuer :
215
282
issuerURL : https://meh.tld
216
283
audiences : ['openshift-aud']
284
+ claimMappings :
285
+ username :
286
+ claim : username
217
287
oidcClients :
218
288
- componentNamespace : namespace
219
289
componentName : preexisting
@@ -239,6 +309,9 @@ tests:
239
309
issuer :
240
310
issuerURL : https://meh.tld
241
311
audiences : ['openshift-aud']
312
+ claimMappings :
313
+ username :
314
+ claim : username
242
315
oidcClients :
243
316
- componentNamespace : namespace
244
317
componentName : preexisting
@@ -265,6 +338,9 @@ tests:
265
338
issuer :
266
339
issuerURL : https://meh.tld
267
340
audiences : ['openshift-aud']
341
+ claimMappings :
342
+ username :
343
+ claim : username
268
344
oidcClients :
269
345
- componentNamespace : namespace
270
346
componentName : preexisting
@@ -298,3 +374,89 @@ tests:
298
374
- componentNamespace : namespace2
299
375
componentName : name3
300
376
expected : *removeFromStatus
377
+ - name : Should allow updating other fields if existing username claim mapping is empty string
378
+ initialCRDPatches :
379
+ - op : remove
380
+ path : /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/oidcProviders/items/properties/claimMappings/properties/username/properties/claim/minLength
381
+ initial : |
382
+ apiVersion: config.openshift.io/v1
383
+ kind: Authentication
384
+ spec:
385
+ type: OIDC
386
+ oidcProviders:
387
+ - name: myoidc
388
+ issuer:
389
+ issuerURL: https://meh.tld
390
+ audiences: ['openshift-aud']
391
+ claimMappings:
392
+ username:
393
+ claim: ""
394
+ updated : |
395
+ apiVersion: config.openshift.io/v1
396
+ kind: Authentication
397
+ spec:
398
+ type: OIDC
399
+ oidcProviders:
400
+ - name: myoidc
401
+ issuer:
402
+ issuerURL: https://huh.tld
403
+ audiences: ['openshift-aud']
404
+ claimMappings:
405
+ username:
406
+ claim: ""
407
+ expected : |
408
+ apiVersion: config.openshift.io/v1
409
+ kind: Authentication
410
+ spec:
411
+ type: OIDC
412
+ oidcProviders:
413
+ - name: myoidc
414
+ issuer:
415
+ issuerURL: https://huh.tld
416
+ audiences: ['openshift-aud']
417
+ claimMappings:
418
+ username:
419
+ claim: ""
420
+ - name : Should allow updating other fields if existing username claim mapping is longer than 256 characters
421
+ initialCRDPatches :
422
+ - op : remove
423
+ path : /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/oidcProviders/items/properties/claimMappings/properties/username/properties/claim/maxLength
424
+ initial : |
425
+ apiVersion: config.openshift.io/v1
426
+ kind: Authentication
427
+ spec:
428
+ type: OIDC
429
+ oidcProviders:
430
+ - name: myoidc
431
+ issuer:
432
+ issuerURL: https://meh.tld
433
+ audiences: ['openshift-aud']
434
+ claimMappings:
435
+ username:
436
+ claim: "thisisanincrediblylongclaimnamethatwhileacceptableinjwtsisgenerallyadvisedagainstbecauseitisextremelylongandnoteasilyusablebutmaybethereisausecaseouttherethathasdecidedthattheyneedtousethisextremelylongclaimnameforsomereasoneventhoughtheyreallyshouldreconsiderthis"
437
+ updated : |
438
+ apiVersion: config.openshift.io/v1
439
+ kind: Authentication
440
+ spec:
441
+ type: OIDC
442
+ oidcProviders:
443
+ - name: myoidc
444
+ issuer:
445
+ issuerURL: https://huh.tld
446
+ audiences: ['openshift-aud']
447
+ claimMappings:
448
+ username:
449
+ claim: "thisisanincrediblylongclaimnamethatwhileacceptableinjwtsisgenerallyadvisedagainstbecauseitisextremelylongandnoteasilyusablebutmaybethereisausecaseouttherethathasdecidedthattheyneedtousethisextremelylongclaimnameforsomereasoneventhoughtheyreallyshouldreconsiderthis"
450
+ expected : |
451
+ apiVersion: config.openshift.io/v1
452
+ kind: Authentication
453
+ spec:
454
+ type: OIDC
455
+ oidcProviders:
456
+ - name: myoidc
457
+ issuer:
458
+ issuerURL: https://huh.tld
459
+ audiences: ['openshift-aud']
460
+ claimMappings:
461
+ username:
462
+ claim: "thisisanincrediblylongclaimnamethatwhileacceptableinjwtsisgenerallyadvisedagainstbecauseitisextremelylongandnoteasilyusablebutmaybethereisausecaseouttherethathasdecidedthattheyneedtousethisextremelylongclaimnameforsomereasoneventhoughtheyreallyshouldreconsiderthis"
0 commit comments