Search in sources :

Example 1 with GetUserInfoParams

use of io.jans.ca.common.params.GetUserInfoParams in project jans by JanssenProject.

the class DifferentAuthServerTest method getUserInfo_withDifferentAuthServer.

@Parameters({ "host", "opHost", "authServer", "redirectUrls", "clientId", "clientSecret", "userId", "userSecret" })
@Test
public void getUserInfo_withDifferentAuthServer(String host, String opHost, String authServer, String redirectUrls, String clientId, String clientSecret, String userId, String userSecret) {
    ClientInterface client = Tester.newClient(host);
    RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls);
    RegisterSiteResponse authServerResp = RegisterSiteTest.registerSite(client, authServer, redirectUrls);
    final GetTokensByCodeResponse2 tokens = requestTokens(client, opHost, site, authServerResp, userId, userSecret, site.getClientId(), redirectUrls);
    GetUserInfoParams params = new GetUserInfoParams();
    params.setRpId(site.getRpId());
    params.setAccessToken(tokens.getAccessToken());
    params.setIdToken(tokens.getIdToken());
    final JsonNode resp = client.getUserInfo(Tester.getAuthorization(authServerResp), authServerResp.getRpId(), params);
    assertNotNull(resp);
    assertNotNull(resp.get("sub"));
}
Also used : GetUserInfoParams(io.jans.ca.common.params.GetUserInfoParams) JsonNode(com.fasterxml.jackson.databind.JsonNode) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) GetTokensByCodeResponse2(io.jans.ca.client.GetTokensByCodeResponse2) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 2 with GetUserInfoParams

use of io.jans.ca.common.params.GetUserInfoParams in project jans by JanssenProject.

the class GetUserInfoTest method test.

@Parameters({ "host", "opHost", "redirectUrls", "userId", "userSecret" })
@Test
public void test(String host, String opHost, String redirectUrls, String userId, String userSecret) {
    ClientInterface client = Tester.newClient(host);
    final RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls);
    final GetTokensByCodeResponse2 tokens = requestTokens(client, opHost, site, userId, userSecret, site.getClientId(), redirectUrls);
    GetUserInfoParams params = new GetUserInfoParams();
    params.setRpId(site.getRpId());
    params.setAccessToken(tokens.getAccessToken());
    params.setIdToken(tokens.getIdToken());
    final JsonNode resp = client.getUserInfo(Tester.getAuthorization(site), null, params);
    assertNotNull(resp);
    assertNotNull(resp.get("sub"));
}
Also used : GetUserInfoParams(io.jans.ca.common.params.GetUserInfoParams) JsonNode(com.fasterxml.jackson.databind.JsonNode) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) GetTokensByCodeResponse2(io.jans.ca.client.GetTokensByCodeResponse2) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ClientInterface (io.jans.ca.client.ClientInterface)2 GetTokensByCodeResponse2 (io.jans.ca.client.GetTokensByCodeResponse2)2 GetUserInfoParams (io.jans.ca.common.params.GetUserInfoParams)2 RegisterSiteResponse (io.jans.ca.common.response.RegisterSiteResponse)2 Parameters (org.testng.annotations.Parameters)2 Test (org.testng.annotations.Test)2