Search in sources :

Example 1 with GetRequestObjectUriParams

use of io.jans.ca.common.params.GetRequestObjectUriParams 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());
}
Also used : GetAuthorizationUrlResponse(io.jans.ca.common.response.GetAuthorizationUrlResponse) HashMap(java.util.HashMap) JsonNode(com.fasterxml.jackson.databind.JsonNode) ClientInterface(io.jans.ca.client.ClientInterface) UpdateSiteParams(io.jans.ca.common.params.UpdateSiteParams) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) GetRequestObjectUriResponse(io.jans.ca.common.response.GetRequestObjectUriResponse) GetRequestObjectUriParams(io.jans.ca.common.params.GetRequestObjectUriParams) GetAuthorizationUrlParams(io.jans.ca.common.params.GetAuthorizationUrlParams) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ClientInterface (io.jans.ca.client.ClientInterface)1 GetAuthorizationUrlParams (io.jans.ca.common.params.GetAuthorizationUrlParams)1 GetRequestObjectUriParams (io.jans.ca.common.params.GetRequestObjectUriParams)1 UpdateSiteParams (io.jans.ca.common.params.UpdateSiteParams)1 GetAuthorizationUrlResponse (io.jans.ca.common.response.GetAuthorizationUrlResponse)1 GetRequestObjectUriResponse (io.jans.ca.common.response.GetRequestObjectUriResponse)1 RegisterSiteResponse (io.jans.ca.common.response.RegisterSiteResponse)1 HashMap (java.util.HashMap)1 Parameters (org.testng.annotations.Parameters)1 Test (org.testng.annotations.Test)1