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);
}
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.");
}
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;
}
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);
}
Aggregations