-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jans-auth-server): authorized acr values (#1068)
Signed-off-by: Javier Rojas Blum <javier.rojas.blum@gmail.com>
- Loading branch information
Showing
6 changed files
with
175 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/AuthorizedAcrValuesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. | ||
* | ||
* Copyright (c) 2020, Janssen Project | ||
*/ | ||
|
||
package io.jans.as.client.ws.rs; | ||
|
||
import io.jans.as.client.*; | ||
import io.jans.as.client.client.AssertBuilder; | ||
import io.jans.as.model.common.ResponseType; | ||
import io.jans.as.model.register.ApplicationType; | ||
import io.jans.as.model.util.StringUtils; | ||
import org.testng.annotations.Parameters; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
/** | ||
* @author Javier Rojas Blum | ||
* @version March 17, 2022 | ||
*/ | ||
public class AuthorizedAcrValuesTest extends BaseTest { | ||
|
||
@Parameters({"userId", "userSecret", "redirectUris", "redirectUri", "sectorIdentifierUri"}) | ||
@Test | ||
public void authorizedAcrValues( | ||
final String userId, final String userSecret, final String redirectUris, final String redirectUri, | ||
final String sectorIdentifierUri) { | ||
showTitle("authorizedAcrValues"); | ||
|
||
List<ResponseType> responseTypes = Arrays.asList(ResponseType.CODE, ResponseType.ID_TOKEN); | ||
|
||
// 1. Register client | ||
RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "jans test app", | ||
StringUtils.spaceSeparatedToList(redirectUris)); | ||
registerRequest.setResponseTypes(responseTypes); | ||
registerRequest.setSectorIdentifierUri(sectorIdentifierUri); | ||
registerRequest.setAuthorizedAcrValues(Arrays.asList( | ||
"acr_1", "acr_2", "acr_3", "basic" | ||
)); | ||
|
||
RegisterClient registerClient = newRegisterClient(registerRequest); | ||
RegisterResponse registerResponse = registerClient.exec(); | ||
|
||
showClient(registerClient); | ||
AssertBuilder.registerResponse(registerResponse) | ||
.created() | ||
.check(); | ||
|
||
String clientId = registerResponse.getClientId(); | ||
|
||
List<String> scopes = Arrays.asList("openid", "profile", "address", "email"); | ||
String state = UUID.randomUUID().toString(); | ||
String nonce = UUID.randomUUID().toString(); | ||
|
||
AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId, scopes, redirectUri, nonce); | ||
authorizationRequest.setState(state); | ||
authorizationRequest.setAcrValues(Arrays.asList("basic")); | ||
|
||
AuthorizationResponse authorizationResponse = authenticateResourceOwnerAndGrantAccess(authorizationEndpoint, | ||
authorizationRequest, userId, userSecret); | ||
|
||
AssertBuilder.authorizationResponse(authorizationResponse) | ||
.responseTypes(responseTypes) | ||
.check(); | ||
} | ||
|
||
@Parameters({"userId", "userSecret", "redirectUris", "redirectUri", "sectorIdentifierUri"}) | ||
@Test | ||
public void authorizedAcrValuesFail( | ||
final String userId, final String userSecret, final String redirectUris, final String redirectUri, | ||
final String sectorIdentifierUri) { | ||
showTitle("authorizedAcrValuesFail"); | ||
|
||
List<ResponseType> responseTypes = Arrays.asList(ResponseType.CODE, ResponseType.ID_TOKEN); | ||
|
||
// 1. Register client | ||
RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "jans test app", | ||
StringUtils.spaceSeparatedToList(redirectUris)); | ||
registerRequest.setResponseTypes(responseTypes); | ||
registerRequest.setSectorIdentifierUri(sectorIdentifierUri); | ||
registerRequest.setAuthorizedAcrValues(Arrays.asList( | ||
"acr_1", "acr_2", "acr_3" | ||
)); | ||
|
||
RegisterClient registerClient = newRegisterClient(registerRequest); | ||
RegisterResponse registerResponse = registerClient.exec(); | ||
|
||
showClient(registerClient); | ||
AssertBuilder.registerResponse(registerResponse) | ||
.created() | ||
.check(); | ||
|
||
String clientId = registerResponse.getClientId(); | ||
|
||
List<String> scopes = Arrays.asList("openid", "profile", "address", "email"); | ||
String state = UUID.randomUUID().toString(); | ||
String nonce = UUID.randomUUID().toString(); | ||
|
||
AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId, scopes, redirectUri, nonce); | ||
authorizationRequest.setState(state); | ||
authorizationRequest.setAcrValues(Arrays.asList("basic")); | ||
|
||
AuthorizeClient authorizeClient = new AuthorizeClient(authorizationEndpoint); | ||
authorizeClient.setRequest(authorizationRequest); | ||
|
||
AuthorizationResponse authorizationResponse = authorizeClient.exec(); | ||
|
||
showClient(authorizeClient); | ||
AssertBuilder.authorizationResponse(authorizationResponse) | ||
.status(302) | ||
.check(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters