|
|
|
@ -53,7 +53,7 @@ public class RegisteredClientTests { |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC) |
|
|
|
.build() |
|
|
|
.build() |
|
|
|
).isInstanceOf(IllegalArgumentException.class); |
|
|
|
).isInstanceOf(IllegalArgumentException.class); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -69,7 +69,7 @@ public class RegisteredClientTests { |
|
|
|
.clientSecretExpiresAt(clientSecretExpiresAt) |
|
|
|
.clientSecretExpiresAt(clientSecretExpiresAt) |
|
|
|
.clientName("client-name") |
|
|
|
.clientName("client-name") |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.build(); |
|
|
|
.build(); |
|
|
|
@ -100,7 +100,7 @@ public class RegisteredClientTests { |
|
|
|
.clientId(null) |
|
|
|
.clientId(null) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.build() |
|
|
|
.build() |
|
|
|
@ -114,7 +114,7 @@ public class RegisteredClientTests { |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.build() |
|
|
|
.build() |
|
|
|
).isInstanceOf(IllegalArgumentException.class); |
|
|
|
).isInstanceOf(IllegalArgumentException.class); |
|
|
|
@ -127,7 +127,7 @@ public class RegisteredClientTests { |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC) |
|
|
|
.redirectUri("https://example.com") |
|
|
|
.redirectUri("https://example.com") |
|
|
|
.redirectUris(Set::clear) |
|
|
|
.redirectUris(Set::clear) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
@ -155,7 +155,7 @@ public class RegisteredClientTests { |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.build(); |
|
|
|
.build(); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -166,7 +166,7 @@ public class RegisteredClientTests { |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.build(); |
|
|
|
.build(); |
|
|
|
@ -180,7 +180,7 @@ public class RegisteredClientTests { |
|
|
|
RegisteredClient.withId(ID) |
|
|
|
RegisteredClient.withId(ID) |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.scope("openid profile") |
|
|
|
.scope("openid profile") |
|
|
|
.build() |
|
|
|
.build() |
|
|
|
@ -194,7 +194,7 @@ public class RegisteredClientTests { |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.scope("an\"invalid\"scope") |
|
|
|
.scope("an\"invalid\"scope") |
|
|
|
.build() |
|
|
|
.build() |
|
|
|
@ -208,7 +208,7 @@ public class RegisteredClientTests { |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC) |
|
|
|
.redirectUri("invalid URI") |
|
|
|
.redirectUri("invalid URI") |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.build() |
|
|
|
.build() |
|
|
|
@ -222,7 +222,7 @@ public class RegisteredClientTests { |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC) |
|
|
|
.redirectUri("https://example.com/page#fragment") |
|
|
|
.redirectUri("https://example.com/page#fragment") |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.build() |
|
|
|
.build() |
|
|
|
@ -236,7 +236,7 @@ public class RegisteredClientTests { |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.build(); |
|
|
|
.build(); |
|
|
|
@ -254,7 +254,7 @@ public class RegisteredClientTests { |
|
|
|
authorizationGrantTypes.add(AuthorizationGrantType.AUTHORIZATION_CODE); |
|
|
|
authorizationGrantTypes.add(AuthorizationGrantType.AUTHORIZATION_CODE); |
|
|
|
authorizationGrantTypes.add(AuthorizationGrantType.CLIENT_CREDENTIALS); |
|
|
|
authorizationGrantTypes.add(AuthorizationGrantType.CLIENT_CREDENTIALS); |
|
|
|
}) |
|
|
|
}) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.build(); |
|
|
|
.build(); |
|
|
|
@ -271,7 +271,7 @@ public class RegisteredClientTests { |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.authorizationGrantTypes(Set::clear) |
|
|
|
.authorizationGrantTypes(Set::clear) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.build(); |
|
|
|
.build(); |
|
|
|
@ -294,22 +294,6 @@ public class RegisteredClientTests { |
|
|
|
.containsExactlyInAnyOrder(ClientAuthenticationMethod.CLIENT_SECRET_BASIC, ClientAuthenticationMethod.CLIENT_SECRET_POST); |
|
|
|
.containsExactlyInAnyOrder(ClientAuthenticationMethod.CLIENT_SECRET_BASIC, ClientAuthenticationMethod.CLIENT_SECRET_POST); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void buildWhenBothDeprecatedClientAuthenticationMethodsAreProvidedThenBothNonDeprecatedAreRegistered() { |
|
|
|
|
|
|
|
RegisteredClient registration = RegisteredClient.withId(ID) |
|
|
|
|
|
|
|
.clientId(CLIENT_ID) |
|
|
|
|
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
|
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
|
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC) |
|
|
|
|
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.POST) |
|
|
|
|
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
|
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
|
|
|
|
.build(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertThat(registration.getClientAuthenticationMethods()) |
|
|
|
|
|
|
|
.containsExactlyInAnyOrder(ClientAuthenticationMethod.CLIENT_SECRET_BASIC, ClientAuthenticationMethod.CLIENT_SECRET_POST); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void buildWhenClientAuthenticationMethodsConsumerIsProvidedThenConsumerAccepted() { |
|
|
|
public void buildWhenClientAuthenticationMethodsConsumerIsProvidedThenConsumerAccepted() { |
|
|
|
RegisteredClient registration = RegisteredClient.withId(ID) |
|
|
|
RegisteredClient registration = RegisteredClient.withId(ID) |
|
|
|
@ -328,24 +312,6 @@ public class RegisteredClientTests { |
|
|
|
.containsExactlyInAnyOrder(ClientAuthenticationMethod.CLIENT_SECRET_BASIC, ClientAuthenticationMethod.CLIENT_SECRET_POST); |
|
|
|
.containsExactlyInAnyOrder(ClientAuthenticationMethod.CLIENT_SECRET_BASIC, ClientAuthenticationMethod.CLIENT_SECRET_POST); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void buildWhenConsumerAddsDeprecatedClientAuthenticationMethodsThenNonDeprecatedAreRegistered() { |
|
|
|
|
|
|
|
RegisteredClient registration = RegisteredClient.withId(ID) |
|
|
|
|
|
|
|
.clientId(CLIENT_ID) |
|
|
|
|
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
|
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
|
|
|
|
.clientAuthenticationMethods(clientAuthenticationMethods -> { |
|
|
|
|
|
|
|
clientAuthenticationMethods.add(ClientAuthenticationMethod.BASIC); |
|
|
|
|
|
|
|
clientAuthenticationMethods.add(ClientAuthenticationMethod.POST); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
|
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
|
|
|
|
.build(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertThat(registration.getClientAuthenticationMethods()) |
|
|
|
|
|
|
|
.containsExactlyInAnyOrder(ClientAuthenticationMethod.CLIENT_SECRET_BASIC, ClientAuthenticationMethod.CLIENT_SECRET_POST); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void buildWhenOverrideIdThenOverridden() { |
|
|
|
public void buildWhenOverrideIdThenOverridden() { |
|
|
|
String overriddenId = "override"; |
|
|
|
String overriddenId = "override"; |
|
|
|
@ -354,7 +320,7 @@ public class RegisteredClientTests { |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.clientId(CLIENT_ID) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.clientSecret(CLIENT_SECRET) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC) |
|
|
|
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.redirectUris(redirectUris -> redirectUris.addAll(REDIRECT_URIS)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.scopes(scopes -> scopes.addAll(SCOPES)) |
|
|
|
.build(); |
|
|
|
.build(); |
|
|
|
|