use of org.forgerock.json.resource.QueryRequest in project OpenAM by OpenRock.
the class UmaPolicyServiceImplTest method shouldQueryUmaPoliciesByUnknownResourceServer.
@Test
@SuppressWarnings("unchecked")
public void shouldQueryUmaPoliciesByUnknownResourceServer() throws Exception {
//Given
Context context = createContext();
QueryRequest request = Requests.newQueryRequest("").setQueryFilter(QueryFilter.equalTo(new JsonPointer("resourceServer"), "OTHER_CLIENT_ID"));
mockBackendQuery(context);
//When
Pair<QueryResponse, Collection<UmaPolicy>> queryResult = policyService.queryPolicies(context, request).getOrThrowUninterruptibly();
//Then
assertThat(queryResult.getSecond()).hasSize(0);
}
use of org.forgerock.json.resource.QueryRequest in project OpenAM by OpenRock.
the class UmaPolicyServiceImplTest method shouldQueryUmaPoliciesByUnknownSubjectOrResourceServer.
@Test
@SuppressWarnings("unchecked")
public void shouldQueryUmaPoliciesByUnknownSubjectOrResourceServer() throws Exception {
//Given
Context context = createContext();
QueryRequest request = Requests.newQueryRequest("").setQueryFilter(QueryFilter.or(QueryFilter.equalTo(new JsonPointer("permissions/subject"), "SUBJECT_OTHER"), QueryFilter.equalTo(new JsonPointer("resourceServer"), "CLIENT_ID")));
mockBackendQuery(context, createBackendSubjectOnePolicyJson(), createBackendSubjectTwoPolicyJson());
//When
Pair<QueryResponse, Collection<UmaPolicy>> queryResult = policyService.queryPolicies(context, request).getOrThrowUninterruptibly();
//Then
assertThat(queryResult.getSecond()).hasSize(1);
}
use of org.forgerock.json.resource.QueryRequest in project OpenAM by OpenRock.
the class UmaPolicyServiceImplTest method shouldQueryUmaPoliciesByUnknownSubjectOrUnknownResourceServer.
@Test
@SuppressWarnings("unchecked")
public void shouldQueryUmaPoliciesByUnknownSubjectOrUnknownResourceServer() throws Exception {
//Given
Context context = createContext();
QueryRequest request = Requests.newQueryRequest("").setQueryFilter(QueryFilter.or(QueryFilter.equalTo(new JsonPointer("permissions/subject"), "SUBJECT_OTHER"), QueryFilter.equalTo(new JsonPointer("resourceServer"), "OTHER_CLIENT_ID")));
mockBackendQuery(context);
//When
Pair<QueryResponse, Collection<UmaPolicy>> queryResult = policyService.queryPolicies(context, request).getOrThrowUninterruptibly();
//Then
assertThat(queryResult.getSecond()).hasSize(0);
}
use of org.forgerock.json.resource.QueryRequest in project OpenAM by OpenRock.
the class UmaPolicyServiceImplTest method shouldQueryUmaPoliciesBySubjectAndUnknownResourceServer.
@Test
@SuppressWarnings("unchecked")
public void shouldQueryUmaPoliciesBySubjectAndUnknownResourceServer() throws Exception {
//Given
Context context = createContext();
QueryRequest request = Requests.newQueryRequest("").setQueryFilter(QueryFilter.and(QueryFilter.equalTo(new JsonPointer("permissions/subject"), "SUBJECT_ONE"), QueryFilter.equalTo(new JsonPointer("resourceServer"), "OTHER_CLIENT_ID")));
mockBackendQuery(context);
//When
Pair<QueryResponse, Collection<UmaPolicy>> queryResult = policyService.queryPolicies(context, request).getOrThrowUninterruptibly();
//Then
assertThat(queryResult.getSecond()).hasSize(0);
}
use of org.forgerock.json.resource.QueryRequest in project OpenAM by OpenRock.
the class UmaEnabledFilterTest method testFilterQuery.
@Test(dataProvider = "factories")
public void testFilterQuery(UmaProviderSettingsFactory factory, boolean expectFailure) throws Exception {
// Given
UmaEnabledFilter filter = new UmaEnabledFilter(factory);
QueryResourceHandler resultHandler = mock(QueryResourceHandler.class);
QueryRequest request = Requests.newQueryRequest("test");
// When
Promise<QueryResponse, ResourceException> promise = filter.filterQuery(context, request, resultHandler, requestHandler);
// Then
checkResult(expectFailure, promise);
if (expectFailure) {
verifyNoMoreInteractions(requestHandler);
} else {
verify(requestHandler).handleQuery(context, request, resultHandler);
}
}
Aggregations