Search in sources :

Example 1 with IntrospectRptParams

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

the class UmaSpontaneousScopeTest method init.

@Parameters({ "host", "opHost", "paramRedirectUrl", "userId", "userSecret", "rsProtectWithSpontaneousScope" })
@Test
public void init(String host, String opHost, String paramRedirectUrl, String userId, String userSecret, String rsProtectWithSpontaneousScope) throws Exception {
    List<String> scopes = Lists.newArrayList("openid", "uma_protection", "profile", "address", "email", "phone", "user_name", "jans_client_api");
    List<String> responseTypes = Lists.newArrayList("code", "id_token", "token");
    // register client
    ClientInterface client = Tester.newClient(host);
    final RegisterSiteResponse registerResponse = RegisterSiteTest.registerSite(client, opHost, paramRedirectUrl, scopes, responseTypes, true, null);
    // UMA RP - Get RPT
    // Spontaneous Scope Regress: ^/user/.+$
    RpGetRptResponse response = RpGetRptTest.requestRpt(client, registerResponse, rsProtectWithSpontaneousScope);
    // UMA Introspect RPT
    IntrospectRptParams params = new IntrospectRptParams();
    params.setRpId(registerResponse.getRpId());
    params.setRpt(response.getRpt());
    final CorrectRptIntrospectionResponse rptIntrospectionResponse = client.introspectRpt(Tester.getAuthorization(registerResponse), null, params);
    rptIntrospectionResponse.getPermissions().forEach(permission -> {
        assertTrue(permission.getScopes().contains(USER_2_SCOPE));
    });
}
Also used : CorrectRptIntrospectionResponse(io.jans.ca.common.introspection.CorrectRptIntrospectionResponse) IntrospectRptParams(io.jans.ca.common.params.IntrospectRptParams) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) RpGetRptResponse(io.jans.ca.common.response.RpGetRptResponse) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 2 with IntrospectRptParams

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

the class IntrospectRptTest method test.

@Parameters({ "host", "opHost", "redirectUrls", "rsProtect" })
@Test
public void test(String host, String opHost, String redirectUrls, String rsProtect) throws IOException {
    ClientInterface client = Tester.newClient(host);
    RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls);
    final RpGetRptResponse rptResponse = RpGetRptTest.requestRpt(client, site, rsProtect);
    IntrospectRptParams params = new IntrospectRptParams();
    params.setRpId(site.getRpId());
    params.setRpt(rptResponse.getRpt());
    final CorrectRptIntrospectionResponse response = client.introspectRpt(Tester.getAuthorization(site), null, params);
    assertNotNull(response);
    assertTrue(response.getActive());
    assertTrue(response.getExpiresAt() != null);
    assertTrue(response.getIssuedAt() != null);
}
Also used : CorrectRptIntrospectionResponse(io.jans.ca.common.introspection.CorrectRptIntrospectionResponse) IntrospectRptParams(io.jans.ca.common.params.IntrospectRptParams) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) RpGetRptResponse(io.jans.ca.common.response.RpGetRptResponse) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Aggregations

ClientInterface (io.jans.ca.client.ClientInterface)2 CorrectRptIntrospectionResponse (io.jans.ca.common.introspection.CorrectRptIntrospectionResponse)2 IntrospectRptParams (io.jans.ca.common.params.IntrospectRptParams)2 RegisterSiteResponse (io.jans.ca.common.response.RegisterSiteResponse)2 RpGetRptResponse (io.jans.ca.common.response.RpGetRptResponse)2 Parameters (org.testng.annotations.Parameters)2 Test (org.testng.annotations.Test)2