Search in sources :

Example 1 with URLResourceName

use of com.sun.identity.entitlement.URLResourceName 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();
}
Also used : URLResourceName(com.sun.identity.entitlement.URLResourceName) ResourceType(org.forgerock.openam.entitlement.ResourceType) Test(org.testng.annotations.Test)

Example 2 with URLResourceName

use of com.sun.identity.entitlement.URLResourceName 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();
}
Also used : URLResourceName(com.sun.identity.entitlement.URLResourceName) ResourceType(org.forgerock.openam.entitlement.ResourceType) Test(org.testng.annotations.Test)

Example 3 with URLResourceName

use of com.sun.identity.entitlement.URLResourceName in project OpenAM by OpenRock.

the class ConstraintValidatorImplTest method invalidResourcesFail.

@Test
public void invalidResourcesFail() {
    // 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");
    boolean successful = validator.verifyResources(resources).using(new URLResourceName()).against(resourceType).isSuccessful();
    // Then
    assertThat(successful).isFalse();
}
Also used : URLResourceName(com.sun.identity.entitlement.URLResourceName) ResourceType(org.forgerock.openam.entitlement.ResourceType) Test(org.testng.annotations.Test)

Aggregations

URLResourceName (com.sun.identity.entitlement.URLResourceName)3 ResourceType (org.forgerock.openam.entitlement.ResourceType)3 Test (org.testng.annotations.Test)3