Search in sources :

Example 16 with JsonPointer

use of org.forgerock.json.JsonPointer in project OpenAM by OpenRock.

the class PrivilegePolicyStoreTest method shouldHandleStringEquality.

@Test
public void shouldHandleStringEquality() throws Exception {
    // Given
    String value = "testValue";
    QueryRequest request = mockQueryRequest(QueryFilter.equalTo(new JsonPointer(STRING_ATTRIBUTE), value));
    // When
    testStore.query(request);
    // Then
    verify(mockManager).search(singleton(new SearchFilter(STRING_SEARCH_ATTRIBUTE, value)));
}
Also used : QueryRequest(org.forgerock.json.resource.QueryRequest) SearchFilter(com.sun.identity.entitlement.util.SearchFilter) JsonPointer(org.forgerock.json.JsonPointer) Test(org.testng.annotations.Test)

Example 17 with JsonPointer

use of org.forgerock.json.JsonPointer in project OpenAM by OpenRock.

the class PrivilegePolicyStoreTest method shouldRejectPresenceQueries.

@Test(expectedExceptions = EntitlementException.class, expectedExceptionsMessageRegExp = ".*not supported.*")
public void shouldRejectPresenceQueries() throws Exception {
    // Given
    QueryRequest request = mockQueryRequest(QueryFilter.present(new JsonPointer((STRING_ATTRIBUTE))));
    // When
    testStore.query(request);
// Then - exception
}
Also used : QueryRequest(org.forgerock.json.resource.QueryRequest) JsonPointer(org.forgerock.json.JsonPointer) Test(org.testng.annotations.Test)

Example 18 with JsonPointer

use of org.forgerock.json.JsonPointer in project OpenAM by OpenRock.

the class ApplicationsResourceTest method shouldRejectOrQueries.

@Test(expectedExceptions = EntitlementException.class, expectedExceptionsMessageRegExp = ".*'Or' not supported.*")
public void shouldRejectOrQueries() throws Exception {
    // Given
    QueryRequest request = mockQueryRequest(or(QueryFilter.<JsonPointer>alwaysTrue(), QueryFilter.<JsonPointer>alwaysTrue()));
    Subject subject = new Subject();
    // When
    applicationsResource.query(request, subject, "/abc");
// Then - exception
}
Also used : QueryRequest(org.forgerock.json.resource.QueryRequest) JsonPointer(org.forgerock.json.JsonPointer) Subject(javax.security.auth.Subject) Test(org.testng.annotations.Test)

Example 19 with JsonPointer

use of org.forgerock.json.JsonPointer in project OpenAM by OpenRock.

the class ApplicationsResourceTest method shouldRejectUnsupportedQueryOperators.

@Test(dataProvider = "UnsupportedOperators", expectedExceptions = EntitlementException.class, expectedExceptionsMessageRegExp = ".*not supported.*")
public void shouldRejectUnsupportedQueryOperators(String queryOperator) throws Exception {
    // Given
    QueryRequest request = mockQueryRequest(comparisonFilter(new JsonPointer(NUMERIC_ATTRIBUTE), queryOperator, 123l));
    Subject subject = new Subject();
    // When
    applicationsResource.query(request, subject, "/abc");
// Then - exception
}
Also used : QueryRequest(org.forgerock.json.resource.QueryRequest) JsonPointer(org.forgerock.json.JsonPointer) Subject(javax.security.auth.Subject) Test(org.testng.annotations.Test)

Example 20 with JsonPointer

use of org.forgerock.json.JsonPointer in project OpenAM by OpenRock.

the class ApplicationsResourceTest method shouldHandleAndQueries.

@Test
public void shouldHandleAndQueries() throws Exception {
    // Given
    String value1 = "value1";
    String value2 = "value2";
    QueryRequest request = mockQueryRequest(and(equalTo(new JsonPointer(STRING_ATTRIBUTE), value1), equalTo(new JsonPointer(STRING_ATTRIBUTE), value2)));
    Subject subject = new Subject();
    // When
    applicationsResource.query(request, subject, "/abc");
    // Then
    SearchFilter searchFilter1 = new SearchFilter(new SearchAttribute(STRING_ATTRIBUTE, "ou"), value1);
    SearchFilter searchFilter2 = new SearchFilter(new SearchAttribute(STRING_ATTRIBUTE, "ou"), value2);
    verify(applicationManagerWrapper).search(eq(subject), eq("/abc"), eq(asSet(searchFilter1, searchFilter2)));
}
Also used : SearchAttribute(com.sun.identity.entitlement.util.SearchAttribute) QueryRequest(org.forgerock.json.resource.QueryRequest) SearchFilter(com.sun.identity.entitlement.util.SearchFilter) Matchers.anyString(org.mockito.Matchers.anyString) JsonPointer(org.forgerock.json.JsonPointer) Subject(javax.security.auth.Subject) Test(org.testng.annotations.Test)

Aggregations

JsonPointer (org.forgerock.json.JsonPointer)64 Test (org.testng.annotations.Test)40 QueryRequest (org.forgerock.json.resource.QueryRequest)34 JsonValue (org.forgerock.json.JsonValue)21 QueryResponse (org.forgerock.json.resource.QueryResponse)19 Context (org.forgerock.services.context.Context)18 RealmContext (org.forgerock.openam.rest.RealmContext)17 Collection (java.util.Collection)15 SSOTokenContext (org.forgerock.openam.rest.resource.SSOTokenContext)13 SubjectContext (org.forgerock.openam.rest.resource.SubjectContext)13 ClientContext (org.forgerock.services.context.ClientContext)13 Subject (javax.security.auth.Subject)10 ResourceException (org.forgerock.json.resource.ResourceException)10 ResourceResponse (org.forgerock.json.resource.ResourceResponse)10 ArrayList (java.util.ArrayList)9 BadRequestException (org.forgerock.json.resource.BadRequestException)9 SearchFilter (com.sun.identity.entitlement.util.SearchFilter)8 HashMap (java.util.HashMap)7 HashSet (java.util.HashSet)7 List (java.util.List)7