use of org.forgerock.json.resource.ActionRequest in project OpenAM by OpenRock.
the class ResourceSetResourceTest method actionCollectionShouldNotBeSupported.
@Test
public void actionCollectionShouldNotBeSupported() {
//Given
Context context = mock(Context.class);
ActionRequest request = mock(ActionRequest.class);
//When
Promise<ActionResponse, ResourceException> promise = resource.actionCollection(context, request);
//Then
assertThat(promise).failedWithException().isInstanceOf(NotSupportedException.class);
}
use of org.forgerock.json.resource.ActionRequest in project OpenAM by OpenRock.
the class PrivilegeAuthzModuleTest method crestActionNoMappingFails.
@Test
public void crestActionNoMappingFails() throws SSOException, DelegationException {
// When...
final FilterChain chain = AuthorizationFilters.createAuthorizationFilter(provider, module);
final Router router = new Router();
router.addRoute(RoutingMode.STARTS_WITH, Router.uriTemplate("/policies"), chain);
final Context context = new RealmContext(subjectContext);
final ActionRequest request = Requests.newActionRequest("/policies", "unknownAction");
Promise<ActionResponse, ResourceException> promise = router.handleAction(context, request);
// Then...
assertThat(promise).failedWithException().isInstanceOf(ForbiddenException.class);
}
use of org.forgerock.json.resource.ActionRequest in project OpenAM by OpenRock.
the class ScriptResourceTest method prepareActionRequestForValidate.
private ActionRequest prepareActionRequestForValidate(String script, String language, String action) {
String encodeScript = Base64.encode(script.getBytes());
JsonValue requestJson = json(object(field(SCRIPT_TEXT, encodeScript), field(SCRIPT_LANGUAGE, language)));
ActionRequest actionRequest = mock(ActionRequest.class);
when(actionRequest.getContent()).thenReturn(requestJson);
when(actionRequest.getAction()).thenReturn(action);
return actionRequest;
}
use of org.forgerock.json.resource.ActionRequest in project OpenAM by OpenRock.
the class ScriptResourceTest method shouldReturnErrorWhenLanguageNotRecognised.
@Test(expectedExceptions = BadRequestException.class)
@SuppressWarnings("unchecked")
public void shouldReturnErrorWhenLanguageNotRecognised() throws ResourceException {
// given
ActionRequest request = prepareActionRequestForValidate("var a = 123;var b = 456;", "INVALID_LANG", "validate");
// when
scriptResource.actionCollection(context, request).getOrThrowUninterruptibly();
// then - exception
}
use of org.forgerock.json.resource.ActionRequest in project OpenAM by OpenRock.
the class ScriptResourceTest method shouldReturnErrorWhenNoLanguageSpecified.
@Test(expectedExceptions = BadRequestException.class)
@SuppressWarnings("unchecked")
public void shouldReturnErrorWhenNoLanguageSpecified() throws ResourceException {
// given
String encodeScript = Base64.encode("var a = 123;var b = 456;".getBytes());
JsonValue requestJson = json(object(field(SCRIPT_TEXT, encodeScript)));
ActionRequest request = mock(ActionRequest.class);
when(request.getContent()).thenReturn(requestJson);
when(request.getAction()).thenReturn("validate");
// when
scriptResource.actionCollection(context, request).getOrThrowUninterruptibly();
// then - exception
}
Aggregations