Search in sources :

Example 11 with ClientInterface

use of io.jans.ca.client.ClientInterface in project jans by JanssenProject.

the class RsProtectTest method protectWithScopeExpressionSeconds.

@Parameters({ "host", "redirectUrls", "opHost", "rsProtectScopeExpressionSecond" })
@Test
public void protectWithScopeExpressionSeconds(String host, String redirectUrls, String opHost, String rsProtectScopeExpressionSecond) throws IOException {
    ClientInterface client = Tester.newClient(host);
    final RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls);
    protectResources(client, site, UmaFullTest.resourceList(rsProtectScopeExpressionSecond).getResources());
    final RsCheckAccessParams params = new RsCheckAccessParams();
    params.setRpId(site.getRpId());
    params.setHttpMethod("GET");
    params.setPath("/GetAll");
    params.setRpt("");
    final RsCheckAccessResponse response = client.umaRsCheckAccess(Tester.getAuthorization(site), null, params);
    assertNotNull(response);
    assertTrue(StringUtils.isNotBlank(response.getAccess()));
}
Also used : RsCheckAccessParams(io.jans.ca.common.params.RsCheckAccessParams) RsCheckAccessResponse(io.jans.ca.common.response.RsCheckAccessResponse) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 12 with ClientInterface

use of io.jans.ca.client.ClientInterface in project jans by JanssenProject.

the class RsProtectTest method protect_withResourceCreationExpiration.

@Parameters({ "host", "redirectUrls", "opHost", "rsProtectWithCreationExpiration" })
@Test
public void protect_withResourceCreationExpiration(String host, String redirectUrls, String opHost, String rsProtectWithCreationExpiration) throws IOException {
    ClientInterface client = Tester.newClient(host);
    final RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls);
    protectResources(client, site, UmaFullTest.resourceList(rsProtectWithCreationExpiration).getResources());
    Rp rp = persistenceService.getRp(site.getRpId());
    rp.getUmaProtectedResources().forEach(ele -> {
        assertEquals(1582890956L, ele.getIat().longValue());
        assertEquals(2079299799L, ele.getExp().longValue());
    });
}
Also used : ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) Rp(io.jans.ca.server.service.Rp) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 13 with ClientInterface

use of io.jans.ca.client.ClientInterface in project jans by JanssenProject.

the class RsProtectTest method overwriteTrue.

@Parameters({ "host", "redirectUrls", "opHost", "rsProtect" })
@Test
public void overwriteTrue(String host, String redirectUrls, String opHost, String rsProtect) throws IOException {
    ClientInterface client = Tester.newClient(host);
    final RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls);
    List<RsResource> resources = UmaFullTest.resourceList(rsProtect).getResources();
    protectResources(client, site, resources);
    final RsProtectParams2 params = new RsProtectParams2();
    params.setRpId(site.getRpId());
    params.setResources(Jackson2.createJsonMapper().readTree(Jackson2.asJsonSilently(resources)));
    // force overwrite
    params.setOverwrite(true);
    RsProtectResponse response = client.umaRsProtect(Tester.getAuthorization(site), null, params);
    assertNotNull(response);
}
Also used : RsProtectParams2(io.jans.ca.client.RsProtectParams2) RsResource(io.jans.ca.rs.protect.RsResource) RsProtectResponse(io.jans.ca.common.response.RsProtectResponse) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 14 with ClientInterface

use of io.jans.ca.client.ClientInterface in project jans by JanssenProject.

the class UmaFullTest method test.

@Parameters({ "host", "redirectUrls", "opHost", "rsProtect" })
@Test
public void test(String host, String redirectUrls, String opHost, String rsProtect) throws Exception {
    ClientInterface client = Tester.newClient(host);
    RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls);
    RsProtectTest.protectResources(client, site, UmaFullTest.resourceList(rsProtect).getResources());
    final RsCheckAccessResponse checkAccess = RsCheckAccessTest.checkAccess(client, site, null);
    final RpGetRptParams params = new RpGetRptParams();
    params.setRpId(site.getRpId());
    params.setTicket(checkAccess.getTicket());
    final RpGetRptResponse response = client.umaRpGetRpt(Tester.getAuthorization(site), null, params);
    assertNotNull(response);
    assertTrue(StringUtils.isNotBlank(response.getRpt()));
    assertTrue(StringUtils.isNotBlank(response.getPct()));
}
Also used : RpGetRptParams(io.jans.ca.common.params.RpGetRptParams) RsCheckAccessResponse(io.jans.ca.common.response.RsCheckAccessResponse) 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 15 with ClientInterface

use of io.jans.ca.client.ClientInterface in project jans by JanssenProject.

the class GetJwksTest method test.

@Test(enabled = false)
@Parameters({ "host", "opHost", "opDiscoveryPath" })
public void test(String host, String opHost, @Optional String opDiscoveryPath) {
    final ClientInterface client = Tester.newClient(host);
    final GetJwksParams params = new GetJwksParams();
    params.setOpHost(opHost);
    params.setOpDiscoveryPath(opDiscoveryPath);
    final GetJwksResponse response = client.getJwks(Tester.getAuthorization(), null, params);
    assertNotNull(response);
    assertNotNull(response.getKeys());
    assertFalse(response.getKeys().isEmpty());
}
Also used : GetJwksParams(io.jans.ca.common.params.GetJwksParams) GetJwksResponse(io.jans.ca.common.response.GetJwksResponse) ClientInterface(io.jans.ca.client.ClientInterface) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Aggregations

ClientInterface (io.jans.ca.client.ClientInterface)67 Parameters (org.testng.annotations.Parameters)64 Test (org.testng.annotations.Test)64 RegisterSiteResponse (io.jans.ca.common.response.RegisterSiteResponse)58 GetTokensByCodeResponse2 (io.jans.ca.client.GetTokensByCodeResponse2)21 GetAuthorizationUrlParams (io.jans.ca.common.params.GetAuthorizationUrlParams)8 GetAuthorizationUrlResponse (io.jans.ca.common.response.GetAuthorizationUrlResponse)8 RpGetRptResponse (io.jans.ca.common.response.RpGetRptResponse)7 RsCheckAccessResponse (io.jans.ca.common.response.RsCheckAccessResponse)7 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 RpGetRptParams (io.jans.ca.common.params.RpGetRptParams)4 RsProtectParams2 (io.jans.ca.client.RsProtectParams2)3 GetIssuerParams (io.jans.ca.common.params.GetIssuerParams)3 RpGetClaimsGatheringUrlParams (io.jans.ca.common.params.RpGetClaimsGatheringUrlParams)3 GetIssuerResponse (io.jans.ca.common.response.GetIssuerResponse)3 RpGetClaimsGatheringUrlResponse (io.jans.ca.common.response.RpGetClaimsGatheringUrlResponse)3 BadRequestException (javax.ws.rs.BadRequestException)3 CorrectRptIntrospectionResponse (io.jans.ca.common.introspection.CorrectRptIntrospectionResponse)2 GetDiscoveryParams (io.jans.ca.common.params.GetDiscoveryParams)2 GetJwksParams (io.jans.ca.common.params.GetJwksParams)2