Search in sources :

Example 1 with RsProtectParams2

use of io.jans.ca.client.RsProtectParams2 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 2 with RsProtectParams2

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

the class RsProtectTest method overwriteFalse.

@Parameters({ "host", "redirectUrls", "opHost", "rsProtect" })
@Test
public void overwriteFalse(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)));
    try {
        client.umaRsProtect(Tester.getAuthorization(site), null, params);
    } catch (BadRequestException e) {
        assertEquals("uma_protection_exists", TestUtils.asError(e).getError());
        return;
    }
    throw new AssertionError("Expected 400 (bad request) but got successful result.");
}
Also used : RsProtectParams2(io.jans.ca.client.RsProtectParams2) RsResource(io.jans.ca.rs.protect.RsResource) BadRequestException(javax.ws.rs.BadRequestException) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 3 with RsProtectParams2

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

the class RsProtectTest method protectResources.

public static RsProtectResponse protectResources(ClientInterface client, RegisterSiteResponse site, List<RsResource> resources) {
    final RsProtectParams2 params = new RsProtectParams2();
    params.setRpId(site.getRpId());
    try {
        params.setResources(Jackson2.createJsonMapper().readTree(Jackson2.asJsonSilently(resources)));
    } catch (IOException e) {
        e.printStackTrace();
    }
    final RsProtectResponse resp = client.umaRsProtect(Tester.getAuthorization(site), null, params);
    assertNotNull(resp);
    return resp;
}
Also used : RsProtectParams2(io.jans.ca.client.RsProtectParams2) RsProtectResponse(io.jans.ca.common.response.RsProtectResponse) IOException(java.io.IOException)

Example 4 with RsProtectParams2

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

the class NotAllowedTest method main.

public static void main(String[] args) throws IOException {
    ClientInterface client = Tester.newClient(HOST);
    RegisterSiteResponse site = registerSite(client);
    final RsProtectParams2 params = new RsProtectParams2();
    params.setRpId(site.getRpId());
    params.setResources(Jackson2.createJsonMapper().readTree(rsProtect));
    final RsProtectResponse resp = client.umaRsProtect(Tester.getAuthorization(site), null, params);
    assertNotNull(resp);
}
Also used : RsProtectParams2(io.jans.ca.client.RsProtectParams2) RsProtectResponse(io.jans.ca.common.response.RsProtectResponse) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse)

Aggregations

RsProtectParams2 (io.jans.ca.client.RsProtectParams2)4 ClientInterface (io.jans.ca.client.ClientInterface)3 RegisterSiteResponse (io.jans.ca.common.response.RegisterSiteResponse)3 RsProtectResponse (io.jans.ca.common.response.RsProtectResponse)3 RsResource (io.jans.ca.rs.protect.RsResource)2 Parameters (org.testng.annotations.Parameters)2 Test (org.testng.annotations.Test)2 IOException (java.io.IOException)1 BadRequestException (javax.ws.rs.BadRequestException)1