use of org.forgerock.openam.entitlement.ResourceType in project OpenAM by OpenRock.
the class RemoveReferralsStep method instateAssociatedResourceType.
private String instateAssociatedResourceType(String resourceTypeId, String sourceRealm, String destinationRealm) throws EntitlementException, UpgradeException {
Pair<String, String> key = Pair.of(destinationRealm, resourceTypeId);
if (clonedResourceTypes.containsKey(key)) {
return clonedResourceTypes.get(key);
}
ResourceType resourceType = resourceTypeService.getResourceType(getAdminSubject(), sourceRealm, resourceTypeId);
if (resourceType == null) {
throw new UpgradeException(format("Expected resource type %s in realm %s", resourceTypeId, sourceRealm));
}
ResourceType clonedResourceType = cloneResourceType(resourceType);
resourceTypeService.saveResourceType(getAdminSubject(), destinationRealm, clonedResourceType);
clonedResourceTypes.put(key, clonedResourceType.getUUID());
return clonedResourceType.getUUID();
}
use of org.forgerock.openam.entitlement.ResourceType in project OpenAM by OpenRock.
the class ConstraintValidatorImplTest method subsetActionsPass.
@Test
public void subsetActionsPass() {
// Given
ResourceType resourceType = ResourceType.builder().setName("test").setUUID("abc").addAction("GET", true).addAction("POST", true).addAction("DELETE", true).addAction("PATCH", true).build();
// When
Set<String> actions = CollectionUtils.asSet("GET", "POST");
boolean successful = validator.verifyActions(actions).against(resourceType).isSuccessful();
// Then
assertThat(successful).isTrue();
}
use of org.forgerock.openam.entitlement.ResourceType in project OpenAM by OpenRock.
the class ConstraintValidatorImplTest method throwsExceptionWhenActionsFail.
@Test(expectedExceptions = ConstraintFailureException.class, expectedExceptionsMessageRegExp = "Invalid value DELETE for property actionValues")
public void throwsExceptionWhenActionsFail() throws ConstraintFailureException {
// Given
ResourceType resourceType = ResourceType.builder().setName("test").setUUID("abc").addAction("GET", true).addAction("POST", true).build();
// When
Set<String> actions = CollectionUtils.asSet("GET", "POST", "DELETE");
validator.verifyActions(actions).against(resourceType).throwExceptionIfFailure();
}
use of org.forgerock.openam.entitlement.ResourceType in project OpenAM by OpenRock.
the class ConstraintValidatorImplTest method validResourcesPass.
@Test
public void validResourcesPass() {
// Given
ResourceType resourceType = ResourceType.builder().setName("test").setUUID("abc").addPattern("a://b:c/*").addPattern("d://*:*/*").build();
// When
Set<String> resources = CollectionUtils.asSet("a://b:c/def/hij", "d://fried:egg/test/home");
boolean successful = validator.verifyResources(resources).using(new URLResourceName()).against(resourceType).isSuccessful();
// Then
assertThat(successful).isTrue();
}
use of org.forgerock.openam.entitlement.ResourceType in project OpenAM by OpenRock.
the class ConstraintValidatorImplTest method throwsExceptionWhenResourcesFail.
@Test(expectedExceptions = ConstraintFailureException.class, expectedExceptionsMessageRegExp = "Invalid value fail://uri:blah/goodbye for property resources")
public void throwsExceptionWhenResourcesFail() throws ConstraintFailureException {
// Given
ResourceType resourceType = ResourceType.builder().setName("test").setUUID("abc").addPattern("a://b:c/*").addPattern("d://*:*/*").build();
// When
Set<String> resources = CollectionUtils.asSet("a://b:c/def/hij", "fail://uri:blah/goodbye");
validator.verifyResources(resources).using(new URLResourceName()).against(resourceType).throwExceptionIfFailure();
}
Aggregations