use of io.jans.ca.common.params.GetAuthorizationUrlParams in project jans by JanssenProject.
the class GoogleTest method getAuthorizationUrl.
private static String getAuthorizationUrl(ClientInterface client, RegisterSiteResponse site) {
final GetAuthorizationUrlParams params = new GetAuthorizationUrlParams();
params.setRpId(site.getRpId());
final GetAuthorizationUrlResponse resp = client.getAuthorizationUrl(Tester.getAuthorization(site), null, params);
assertNotNull(resp);
notEmpty(resp.getAuthorizationUrl());
System.out.println("Authorization url: " + resp.getAuthorizationUrl());
return resp.getAuthorizationUrl();
}
use of io.jans.ca.common.params.GetAuthorizationUrlParams in project jans by JanssenProject.
the class GetRequestUriTest method test.
@Parameters({ "host", "redirectUrls", "opHost" })
@Test
public void test(String host, String redirectUrls, String opHost) {
ClientInterface client = Tester.newClient(host);
// client registration
final RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls);
// jwks generation
JsonNode jwks = client.getRpJwks();
// update jwks in OP
UpdateSiteParams updateSiteParams = new UpdateSiteParams();
updateSiteParams.setRpId(site.getRpId());
updateSiteParams.setJwks(jwks.asText());
updateSiteParams.setRequestObjectSigningAlg("RS256");
client.updateSite(Tester.getAuthorization(site), null, updateSiteParams);
// Request uri
GetRequestObjectUriParams getRequestUriParams = new GetRequestObjectUriParams();
getRequestUriParams.setRpId(site.getRpId());
getRequestUriParams.setRpHostUrl("http://localhost" + ":" + SetUpTest.SUPPORT.getLocalPort());
GetRequestObjectUriResponse getRequestUriResponse = client.getRequestObjectUri(Tester.getAuthorization(site), null, getRequestUriParams);
assertNotNull(getRequestUriResponse.getRequestUri());
// Get Request object
String requestObjectId = getRequestUriResponse.getRequestUri().substring(getRequestUriResponse.getRequestUri().lastIndexOf('/') + 1);
String requestObject = client.getRequestObject(requestObjectId);
assertNotNull(requestObject);
Map<String, String> paramsMap = new HashMap<>();
paramsMap.put("request", requestObject);
final GetAuthorizationUrlParams commandParams = new GetAuthorizationUrlParams();
commandParams.setRpId(site.getRpId());
commandParams.setParams(paramsMap);
final GetAuthorizationUrlResponse resp = client.getAuthorizationUrl(Tester.getAuthorization(site), null, commandParams);
assertNotNull(resp);
TestUtils.notEmpty(resp.getAuthorizationUrl());
}
use of io.jans.ca.common.params.GetAuthorizationUrlParams in project jans by JanssenProject.
the class GetAuthorizationUrlTest method testWithCustomStateParameter.
@Parameters({ "host", "opHost", "redirectUrls", "postLogoutRedirectUrl", "logoutUrl", "paramRedirectUrl", "state" })
@Test
public void testWithCustomStateParameter(String host, String opHost, String redirectUrls, String postLogoutRedirectUrl, String logoutUrl, String paramRedirectUrl, String state) throws IOException {
ClientInterface client = Tester.newClient(host);
final RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls, postLogoutRedirectUrl, logoutUrl, false);
final GetAuthorizationUrlParams commandParams = new GetAuthorizationUrlParams();
commandParams.setRpId(site.getRpId());
commandParams.setRedirectUri(paramRedirectUrl);
commandParams.setState(state);
final GetAuthorizationUrlResponse resp = client.getAuthorizationUrl(Tester.getAuthorization(site), null, commandParams);
assertNotNull(resp);
notEmpty(resp.getAuthorizationUrl());
assertTrue(resp.getAuthorizationUrl().contains(paramRedirectUrl));
Map<String, String> parameters = CoreUtils.splitQuery(resp.getAuthorizationUrl());
assertTrue(StringUtils.isNotBlank(parameters.get("state")));
assertEquals(parameters.get("state"), state);
}
use of io.jans.ca.common.params.GetAuthorizationUrlParams in project jans by JanssenProject.
the class GetAuthorizationUrlTest method testWithParameterAuthorizationUrl.
@Parameters({ "host", "opHost", "redirectUrls", "postLogoutRedirectUrl", "logoutUrl", "paramRedirectUrl" })
@Test
public void testWithParameterAuthorizationUrl(String host, String opHost, String redirectUrls, String postLogoutRedirectUrl, String logoutUrl, String paramRedirectUrl) {
ClientInterface client = Tester.newClient(host);
final RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls, postLogoutRedirectUrl, logoutUrl, false);
final GetAuthorizationUrlParams commandParams = new GetAuthorizationUrlParams();
commandParams.setRpId(site.getRpId());
commandParams.setRedirectUri(paramRedirectUrl);
final GetAuthorizationUrlResponse resp = client.getAuthorizationUrl(Tester.getAuthorization(site), null, commandParams);
assertNotNull(resp);
notEmpty(resp.getAuthorizationUrl());
assertTrue(resp.getAuthorizationUrl().contains(paramRedirectUrl));
}
use of io.jans.ca.common.params.GetAuthorizationUrlParams in project jans by JanssenProject.
the class StressTest method test.
@Parameters({ "host", "redirectUrl", "opHost" })
@Test(invocationCount = 10, threadPoolSize = 10, enabled = true)
public void test(String host, String redirectUrl, String opHost) {
ClientInterface client = Tester.newClient(host);
final RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrl);
final GetAuthorizationUrlParams params = new GetAuthorizationUrlParams();
params.setRpId(site.getRpId());
final GetAuthorizationUrlResponse resp = client.getAuthorizationUrl(Tester.getAuthorization(site), null, params);
assertNotNull(resp);
notEmpty(resp.getAuthorizationUrl());
assertTrue(resp.getAuthorizationUrl().contains("acr_values"));
}
Aggregations