1
1
/*
2
- * Copyright 2002-2020 the original author or authors.
2
+ * Copyright 2002-2021 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -298,6 +298,24 @@ public void issuerWhenOAuth2TokenEndpointAuthMethodsNullThenDefaulted() throws E
298
298
.isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
299
299
}
300
300
301
+ // gh-9780
302
+ @ Test
303
+ public void issuerWhenClientSecretBasicAuthMethodThenMethodIsBasic () throws Exception {
304
+ this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("client_secret_basic" ));
305
+ ClientRegistration registration = registration ("" ).build ();
306
+ assertThat (registration .getClientAuthenticationMethod ())
307
+ .isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
308
+ }
309
+
310
+ // gh-9780
311
+ @ Test
312
+ public void issuerWhenOAuth2ClientSecretBasicAuthMethodThenMethodIsBasic () throws Exception {
313
+ this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("client_secret_basic" ));
314
+ ClientRegistration registration = registrationOAuth2 ("" , null ).build ();
315
+ assertThat (registration .getClientAuthenticationMethod ())
316
+ .isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
317
+ }
318
+
301
319
@ Test
302
320
public void issuerWhenTokenEndpointAuthMethodsPostThenMethodIsPost () throws Exception {
303
321
this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("client_secret_post" ));
@@ -314,6 +332,46 @@ public void issuerWhenOAuth2TokenEndpointAuthMethodsPostThenMethodIsPost() throw
314
332
.isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_POST );
315
333
}
316
334
335
+ // gh-9780
336
+ @ Test
337
+ public void issuerWhenClientSecretJwtAuthMethodThenMethodIsClientSecretBasic () throws Exception {
338
+ this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("client_secret_jwt" ));
339
+ ClientRegistration registration = registration ("" ).build ();
340
+ // The client_secret_basic auth method is still the default
341
+ assertThat (registration .getClientAuthenticationMethod ())
342
+ .isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
343
+ }
344
+
345
+ // gh-9780
346
+ @ Test
347
+ public void issuerWhenOAuth2ClientSecretJwtAuthMethodThenMethodIsClientSecretBasic () throws Exception {
348
+ this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("client_secret_jwt" ));
349
+ ClientRegistration registration = registrationOAuth2 ("" , null ).build ();
350
+ // The client_secret_basic auth method is still the default
351
+ assertThat (registration .getClientAuthenticationMethod ())
352
+ .isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
353
+ }
354
+
355
+ // gh-9780
356
+ @ Test
357
+ public void issuerWhenPrivateKeyJwtAuthMethodThenMethodIsClientSecretBasic () throws Exception {
358
+ this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("private_key_jwt" ));
359
+ ClientRegistration registration = registration ("" ).build ();
360
+ // The client_secret_basic auth method is still the default
361
+ assertThat (registration .getClientAuthenticationMethod ())
362
+ .isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
363
+ }
364
+
365
+ // gh-9780
366
+ @ Test
367
+ public void issuerWhenOAuth2PrivateKeyJwtAuthMethodThenMethodIsClientSecretBasic () throws Exception {
368
+ this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("private_key_jwt" ));
369
+ ClientRegistration registration = registrationOAuth2 ("" , null ).build ();
370
+ // The client_secret_basic auth method is still the default
371
+ assertThat (registration .getClientAuthenticationMethod ())
372
+ .isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
373
+ }
374
+
317
375
@ Test
318
376
public void issuerWhenTokenEndpointAuthMethodsNoneThenMethodIsNone () throws Exception {
319
377
this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("none" ));
@@ -328,32 +386,24 @@ public void issuerWhenOAuth2TokenEndpointAuthMethodsNoneThenMethodIsNone() throw
328
386
assertThat (registration .getClientAuthenticationMethod ()).isEqualTo (ClientAuthenticationMethod .NONE );
329
387
}
330
388
331
- /**
332
- * We currently only support client_secret_basic, so verify we have a meaningful error
333
- * until we add support.
334
- */
389
+ // gh-9780
335
390
@ Test
336
- public void issuerWhenTokenEndpointAuthMethodsInvalidThenException () {
391
+ public void issuerWhenTlsClientAuthMethodThenSuccess () throws Exception {
337
392
this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("tls_client_auth" ));
338
- // @formatter:off
339
- assertThatIllegalArgumentException ()
340
- .isThrownBy (() -> registration ("" ))
341
- .withMessageContaining ("Only ClientAuthenticationMethod.CLIENT_SECRET_BASIC, ClientAuthenticationMethod.CLIENT_SECRET_POST and "
342
- + "ClientAuthenticationMethod.NONE are supported. The issuer \" " + this .issuer
343
- + "\" returned a configuration of [tls_client_auth]" );
344
- // @formatter:on
393
+ ClientRegistration registration = registration ("" ).build ();
394
+ // The client_secret_basic auth method is still the default
395
+ assertThat (registration .getClientAuthenticationMethod ())
396
+ .isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
345
397
}
346
398
399
+ // gh-9780
347
400
@ Test
348
- public void issuerWhenOAuth2TokenEndpointAuthMethodsInvalidThenException () {
401
+ public void issuerWhenOAuth2TlsClientAuthMethodThenSuccess () throws Exception {
349
402
this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("tls_client_auth" ));
350
- // @formatter:off
351
- assertThatIllegalArgumentException ()
352
- .isThrownBy (() -> registrationOAuth2 ("" , null ))
353
- .withMessageContaining ("Only ClientAuthenticationMethod.CLIENT_SECRET_BASIC, ClientAuthenticationMethod.CLIENT_SECRET_POST and "
354
- + "ClientAuthenticationMethod.NONE are supported. The issuer \" " + this .issuer
355
- + "\" returned a configuration of [tls_client_auth]" );
356
- // @formatter:on
403
+ ClientRegistration registration = registrationOAuth2 ("" , null ).build ();
404
+ // The client_secret_basic auth method is still the default
405
+ assertThat (registration .getClientAuthenticationMethod ())
406
+ .isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
357
407
}
358
408
359
409
@ Test
0 commit comments