use of org.forgerock.json.JsonPointer in project OpenAM by OpenRock.
the class PrivilegePolicyStoreTest method shouldRejectUnsupportedQueryOperators.
@Test(dataProvider = "UnsupportedOperators", expectedExceptions = EntitlementException.class, expectedExceptionsMessageRegExp = ".*not supported.*")
public void shouldRejectUnsupportedQueryOperators(String queryOperator) throws Exception {
// Given
QueryRequest request = mockQueryRequest(QueryFilter.comparisonFilter(new JsonPointer(NUMERIC_ATTRIBUTE), queryOperator, 123l));
// When
testStore.query(request);
// Then - exception
}
use of org.forgerock.json.JsonPointer in project OpenAM by OpenRock.
the class JsonPolicyParserTest method shouldPrintSimpleSubjects.
@Test
public void shouldPrintSimpleSubjects() throws Exception {
// Given
Privilege policy = new StubPrivilege();
policy.setSubject(new AuthenticatedUsers());
// When
JsonValue result = parser.printPolicy(policy);
// Then
assertThat(result.get(new JsonPointer("subject/type")).asString()).isEqualTo("AuthenticatedUsers");
}
use of org.forgerock.json.JsonPointer in project OpenAM by OpenRock.
the class JsonPolicyParserTest method shouldPrintResourceAttributes.
@Test
public void shouldPrintResourceAttributes() throws Exception {
// Given
Privilege policy = new StubPrivilege();
ResourceAttribute userAttrs = new UserAttributes();
String userAttrName = "testUserAttribute";
userAttrs.setPropertyName(userAttrName);
StaticAttributes staticAttributes = new StaticAttributes();
String staticAttrName = "testStaticAttribute";
staticAttributes.setPropertyName(staticAttrName);
Set<String> staticAttrValue = CollectionUtils.asSet("one", "two", "three");
staticAttributes.setPropertyValues(staticAttrValue);
policy.setResourceAttributes(new LinkedHashSet<ResourceAttribute>(Arrays.asList(userAttrs, staticAttributes)));
// When
JsonValue result = parser.printPolicy(policy);
// Then
assertThat(result.get("resourceAttributes").asList()).hasSize(2);
assertThat(result.get(new JsonPointer("resourceAttributes/0/type")).asString()).isEqualTo("User");
assertThat(result.get(new JsonPointer("resourceAttributes/0/propertyName")).asString()).isEqualTo(userAttrName);
assertThat(result.get(new JsonPointer("resourceAttributes/1/type")).asString()).isEqualTo("Static");
assertThat(result.get(new JsonPointer("resourceAttributes/1/propertyName")).asString()).isEqualTo(staticAttrName);
assertThat(result.get(new JsonPointer("resourceAttributes/1/propertyValues")).asList(String.class)).containsOnly(staticAttrValue.toArray());
}
use of org.forgerock.json.JsonPointer in project OpenAM by OpenRock.
the class PrivilegePolicyStoreTest method shouldHandleAndQueries.
@Test
public void shouldHandleAndQueries() throws Exception {
// Given
String value1 = "value1";
String value2 = "value2";
QueryRequest request = mockQueryRequest(QueryFilter.and(QueryFilter.equalTo(new JsonPointer(STRING_ATTRIBUTE), value1), QueryFilter.equalTo(new JsonPointer(STRING_ATTRIBUTE), value2)));
// When
testStore.query(request);
// Then
verify(mockManager).search(asSet(new SearchFilter(STRING_SEARCH_ATTRIBUTE, value1), new SearchFilter(STRING_SEARCH_ATTRIBUTE, value2)));
}
Aggregations