use of io.jans.ca.rs.protect.RsResource 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.rs.protect.RsResource in project jans by JanssenProject.
the class OpClientFactoryMockImpl method getResourceMap.
private static Map<Key, RsResource> getResourceMap(String rsProtect) {
Map<Key, RsResource> rsResourceMap = new HashMap<>();
try {
rsProtect = StringUtils.replace(rsProtect, "'", "\"");
RsResourceList rsResourceList = Jackson2.createJsonMapper().readValue(rsProtect, RsResourceList.class);
for (RsResource rsResource : rsResourceList.getResources()) {
for (Condition condition : rsResource.getConditions()) {
Key key = new Key();
key.setHttpMethods(condition.getHttpMethods());
key.setPath(rsResource.getPath());
rsResourceMap.put(key, rsResource);
}
}
} catch (Exception e) {
LOG.error("Failed to parse uma-rs-protect resource json .", e);
}
return rsResourceMap;
}
Aggregations