@@ -240,22 +240,72 @@ public void issuerWhenOAuth2GrantTypesSupportedNullThenDefaulted() throws Except
240
240
assertThat (registration .getAuthorizationGrantType ()).isEqualTo (AuthorizationGrantType .AUTHORIZATION_CODE );
241
241
}
242
242
243
+ // gh-9795
244
+ @ Test
245
+ public void issuerWhenMultipleGrantTypesThenDefaulted () throws Exception {
246
+ this .response .put ("grant_types_supported" , Arrays .asList ("client_credentials" , "password" ));
247
+ ClientRegistration registration = registration ("" ).build ();
248
+ assertThat (registration .getAuthorizationGrantType ()).isEqualTo (AuthorizationGrantType .AUTHORIZATION_CODE );
249
+ }
250
+
243
251
// gh-9828
244
252
@ Test
245
253
public void issuerWhenImplicitGrantTypeThenSuccess () throws Exception {
246
254
this .response .put ("grant_types_supported" , Arrays .asList ("implicit" ));
247
255
ClientRegistration registration = registration ("" ).build ();
248
- // The authorization_code grant type is still the default
249
- assertThat (registration .getAuthorizationGrantType ()).isEqualTo (AuthorizationGrantType .AUTHORIZATION_CODE );
256
+ assertThat (registration .getAuthorizationGrantType ()).isEqualTo (AuthorizationGrantType .IMPLICIT );
257
+ }
258
+
259
+ // gh-9795
260
+ @ Test
261
+ public void issuerWhenRefreshTokenGrantTypeThenSuccess () throws Exception {
262
+ this .response .put ("grant_types_supported" , Arrays .asList ("refresh_token" ));
263
+ ClientRegistration registration = registration ("" ).build ();
264
+ assertThat (registration .getAuthorizationGrantType ()).isEqualTo (AuthorizationGrantType .REFRESH_TOKEN );
265
+ }
266
+
267
+ // gh-9795
268
+ @ Test
269
+ public void issuerWhenClientCredentialsGrantTypeThenSuccess () throws Exception {
270
+ this .response .put ("grant_types_supported" , Arrays .asList ("client_credentials" ));
271
+ ClientRegistration registration = registration ("" ).build ();
272
+ assertThat (registration .getAuthorizationGrantType ()).isEqualTo (AuthorizationGrantType .CLIENT_CREDENTIALS );
273
+ }
274
+
275
+ // gh-9795
276
+ @ Test
277
+ public void issuerWhenPasswordGrantTypeThenSuccess () throws Exception {
278
+ this .response .put ("grant_types_supported" , Arrays .asList ("password" ));
279
+ ClientRegistration registration = registration ("" ).build ();
280
+ assertThat (registration .getAuthorizationGrantType ()).isEqualTo (AuthorizationGrantType .PASSWORD );
250
281
}
251
282
252
283
// gh-9828
253
284
@ Test
254
285
public void issuerWhenOAuth2JwtBearerGrantTypeThenSuccess () throws Exception {
255
286
this .response .put ("grant_types_supported" , Arrays .asList ("urn:ietf:params:oauth:grant-type:jwt-bearer" ));
256
287
ClientRegistration registration = registrationOAuth2 ("" , null ).build ();
257
- // The authorization_code grant type is still the default
258
- assertThat (registration .getAuthorizationGrantType ()).isEqualTo (AuthorizationGrantType .AUTHORIZATION_CODE );
288
+ assertThat (registration .getAuthorizationGrantType ()).isEqualTo (AuthorizationGrantType .JWT_BEARER );
289
+ }
290
+
291
+ // gh-9795
292
+ @ Test
293
+ public void issuerWhenSaml2BearerGrantTypeThenSuccess () throws Exception {
294
+ this .response .put ("grant_types_supported" , Arrays .asList ("urn:ietf:params:oauth:grant-type:saml2-bearer" ));
295
+ ClientRegistration registration = registration ("" ).build ();
296
+ assertThat (registration .getAuthorizationGrantType ().getValue ())
297
+ .isEqualTo ("urn:ietf:params:oauth:grant-type:saml2-bearer" );
298
+ }
299
+
300
+ // gh-9795
301
+ @ Test
302
+ public void issuerWhenResponseAuthorizationEndpointIsNullThenSuccess () throws Exception {
303
+ this .response .put ("grant_types_supported" , Arrays .asList ("urn:ietf:params:oauth:grant-type:jwt-bearer" ));
304
+ this .response .remove ("authorization_endpoint" );
305
+ ClientRegistration registration = registration ("" ).build ();
306
+ assertThat (registration .getAuthorizationGrantType ()).isEqualTo (AuthorizationGrantType .JWT_BEARER );
307
+ ClientRegistration .ProviderDetails provider = registration .getProviderDetails ();
308
+ assertThat (provider .getAuthorizationUri ()).isNull ();
259
309
}
260
310
261
311
@ Test
0 commit comments