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.
@@ -274,6 +274,24 @@ public void issuerWhenOAuth2TokenEndpointAuthMethodsNullThenDefaulted() throws E
274
274
.isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
275
275
}
276
276
277
+ // gh-9780
278
+ @ Test
279
+ public void issuerWhenClientSecretBasicAuthMethodThenMethodIsBasic () throws Exception {
280
+ this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("client_secret_basic" ));
281
+ ClientRegistration registration = registration ("" ).build ();
282
+ assertThat (registration .getClientAuthenticationMethod ())
283
+ .isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
284
+ }
285
+
286
+ // gh-9780
287
+ @ Test
288
+ public void issuerWhenOAuth2ClientSecretBasicAuthMethodThenMethodIsBasic () throws Exception {
289
+ this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("client_secret_basic" ));
290
+ ClientRegistration registration = registrationOAuth2 ("" , null ).build ();
291
+ assertThat (registration .getClientAuthenticationMethod ())
292
+ .isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
293
+ }
294
+
277
295
@ Test
278
296
public void issuerWhenTokenEndpointAuthMethodsPostThenMethodIsPost () throws Exception {
279
297
this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("client_secret_post" ));
@@ -290,6 +308,46 @@ public void issuerWhenOAuth2TokenEndpointAuthMethodsPostThenMethodIsPost() throw
290
308
.isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_POST );
291
309
}
292
310
311
+ // gh-9780
312
+ @ Test
313
+ public void issuerWhenClientSecretJwtAuthMethodThenMethodIsClientSecretBasic () throws Exception {
314
+ this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("client_secret_jwt" ));
315
+ ClientRegistration registration = registration ("" ).build ();
316
+ // The client_secret_basic auth method is still the default
317
+ assertThat (registration .getClientAuthenticationMethod ())
318
+ .isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
319
+ }
320
+
321
+ // gh-9780
322
+ @ Test
323
+ public void issuerWhenOAuth2ClientSecretJwtAuthMethodThenMethodIsClientSecretBasic () throws Exception {
324
+ this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("client_secret_jwt" ));
325
+ ClientRegistration registration = registrationOAuth2 ("" , null ).build ();
326
+ // The client_secret_basic auth method is still the default
327
+ assertThat (registration .getClientAuthenticationMethod ())
328
+ .isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
329
+ }
330
+
331
+ // gh-9780
332
+ @ Test
333
+ public void issuerWhenPrivateKeyJwtAuthMethodThenMethodIsClientSecretBasic () throws Exception {
334
+ this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("private_key_jwt" ));
335
+ ClientRegistration registration = registration ("" ).build ();
336
+ // The client_secret_basic auth method is still the default
337
+ assertThat (registration .getClientAuthenticationMethod ())
338
+ .isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
339
+ }
340
+
341
+ // gh-9780
342
+ @ Test
343
+ public void issuerWhenOAuth2PrivateKeyJwtAuthMethodThenMethodIsClientSecretBasic () throws Exception {
344
+ this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("private_key_jwt" ));
345
+ ClientRegistration registration = registrationOAuth2 ("" , null ).build ();
346
+ // The client_secret_basic auth method is still the default
347
+ assertThat (registration .getClientAuthenticationMethod ())
348
+ .isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
349
+ }
350
+
293
351
@ Test
294
352
public void issuerWhenTokenEndpointAuthMethodsNoneThenMethodIsNone () throws Exception {
295
353
this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("none" ));
@@ -304,32 +362,24 @@ public void issuerWhenOAuth2TokenEndpointAuthMethodsNoneThenMethodIsNone() throw
304
362
assertThat (registration .getClientAuthenticationMethod ()).isEqualTo (ClientAuthenticationMethod .NONE );
305
363
}
306
364
307
- /**
308
- * We currently only support client_secret_basic, so verify we have a meaningful error
309
- * until we add support.
310
- */
365
+ // gh-9780
311
366
@ Test
312
- public void issuerWhenTokenEndpointAuthMethodsInvalidThenException () {
367
+ public void issuerWhenTlsClientAuthMethodThenSuccess () throws Exception {
313
368
this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("tls_client_auth" ));
314
- // @formatter:off
315
- assertThatIllegalArgumentException ()
316
- .isThrownBy (() -> registration ("" ))
317
- .withMessageContaining ("Only ClientAuthenticationMethod.CLIENT_SECRET_BASIC, ClientAuthenticationMethod.CLIENT_SECRET_POST and "
318
- + "ClientAuthenticationMethod.NONE are supported. The issuer \" " + this .issuer
319
- + "\" returned a configuration of [tls_client_auth]" );
320
- // @formatter:on
369
+ ClientRegistration registration = registration ("" ).build ();
370
+ // The client_secret_basic auth method is still the default
371
+ assertThat (registration .getClientAuthenticationMethod ())
372
+ .isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
321
373
}
322
374
375
+ // gh-9780
323
376
@ Test
324
- public void issuerWhenOAuth2TokenEndpointAuthMethodsInvalidThenException () {
377
+ public void issuerWhenOAuth2TlsClientAuthMethodThenSuccess () throws Exception {
325
378
this .response .put ("token_endpoint_auth_methods_supported" , Arrays .asList ("tls_client_auth" ));
326
- // @formatter:off
327
- assertThatIllegalArgumentException ()
328
- .isThrownBy (() -> registrationOAuth2 ("" , null ))
329
- .withMessageContaining ("Only ClientAuthenticationMethod.CLIENT_SECRET_BASIC, ClientAuthenticationMethod.CLIENT_SECRET_POST and "
330
- + "ClientAuthenticationMethod.NONE are supported. The issuer \" " + this .issuer
331
- + "\" returned a configuration of [tls_client_auth]" );
332
- // @formatter:on
379
+ ClientRegistration registration = registrationOAuth2 ("" , null ).build ();
380
+ // The client_secret_basic auth method is still the default
381
+ assertThat (registration .getClientAuthenticationMethod ())
382
+ .isEqualTo (ClientAuthenticationMethod .CLIENT_SECRET_BASIC );
333
383
}
334
384
335
385
@ Test
0 commit comments