Search in sources :

Example 41 with ActionRequest

use of org.forgerock.json.resource.ActionRequest in project OpenAM by OpenRock.

the class PendingRequestResourceTest method actionCollectionShouldReturnNotSupportedExceptionForUnsupportedAction.

@SuppressWarnings("unchecked")
@Test
public void actionCollectionShouldReturnNotSupportedExceptionForUnsupportedAction() {
    //Given
    Context context = mock(Context.class);
    ActionRequest request = Requests.newActionRequest("", "other");
    //When
    Promise<ActionResponse, ResourceException> promise = resource.actionCollection(context, request);
    //Then
    assertThat(promise).failedWithResourceException().isInstanceOf(NotSupportedException.class);
}
Also used : RealmContext(org.forgerock.openam.rest.RealmContext) Context(org.forgerock.services.context.Context) ActionRequest(org.forgerock.json.resource.ActionRequest) ResourceException(org.forgerock.json.resource.ResourceException) ActionResponse(org.forgerock.json.resource.ActionResponse) Test(org.testng.annotations.Test)

Example 42 with ActionRequest

use of org.forgerock.json.resource.ActionRequest in project OpenAM by OpenRock.

the class UmaEnabledFilterTest method testFilterAction.

@Test(dataProvider = "factories")
public void testFilterAction(UmaProviderSettingsFactory factory, boolean expectFailure) throws Exception {
    // Given
    UmaEnabledFilter filter = new UmaEnabledFilter(factory);
    ActionRequest request = Requests.newActionRequest("test", "test", "test");
    // When
    Promise<ActionResponse, ResourceException> promise = filter.filterAction(context, request, requestHandler);
    // Then
    checkResult(expectFailure, promise);
    if (expectFailure) {
        verifyNoMoreInteractions(requestHandler);
    } else {
        verify(requestHandler).handleAction(context, request);
    }
}
Also used : ActionRequest(org.forgerock.json.resource.ActionRequest) ResourceException(org.forgerock.json.resource.ResourceException) ActionResponse(org.forgerock.json.resource.ActionResponse) Test(org.testng.annotations.Test)

Example 43 with ActionRequest

use of org.forgerock.json.resource.ActionRequest in project OpenAM by OpenRock.

the class ResourceSetResourceTest method revokeAllUserPoliciesActionShouldHandleResourceException.

@Test
public void revokeAllUserPoliciesActionShouldHandleResourceException() {
    //Given
    Context context = mock(Context.class);
    ActionRequest request = mock(ActionRequest.class);
    given(contextHelper.getRealm(context)).willReturn("REALM");
    given(contextHelper.getUserId(context)).willReturn("RESOURCE_OWNER_ID");
    given(request.getAction()).willReturn("revokeAll");
    given(resourceSetService.revokeAllPolicies(context, "REALM", "RESOURCE_OWNER_ID")).willReturn(new NotFoundException().<Void>asPromise());
    //When
    Promise<ActionResponse, ResourceException> promise = resource.actionCollection(context, request);
    //Then
    assertThat(promise).failedWithException().isInstanceOf(ResourceException.class);
}
Also used : Context(org.forgerock.services.context.Context) ActionRequest(org.forgerock.json.resource.ActionRequest) NotFoundException(org.forgerock.json.resource.NotFoundException) ResourceException(org.forgerock.json.resource.ResourceException) ActionResponse(org.forgerock.json.resource.ActionResponse) Test(org.testng.annotations.Test)

Example 44 with ActionRequest

use of org.forgerock.json.resource.ActionRequest in project OpenAM by OpenRock.

the class ResourceSetResourceTest method actionInstanceShouldNotBeSupported.

@Test
public void actionInstanceShouldNotBeSupported() {
    //Given
    Context context = mock(Context.class);
    ActionRequest request = mock(ActionRequest.class);
    //When
    Promise<ActionResponse, ResourceException> promise = resource.actionInstance(context, "RESOURCE_SET_UID", request);
    //Then
    assertThat(promise).failedWithException().isInstanceOf(NotSupportedException.class);
}
Also used : Context(org.forgerock.services.context.Context) ActionRequest(org.forgerock.json.resource.ActionRequest) ResourceException(org.forgerock.json.resource.ResourceException) ActionResponse(org.forgerock.json.resource.ActionResponse) Test(org.testng.annotations.Test)

Aggregations

ActionRequest (org.forgerock.json.resource.ActionRequest)44 Test (org.testng.annotations.Test)39 ResourceException (org.forgerock.json.resource.ResourceException)31 ActionResponse (org.forgerock.json.resource.ActionResponse)28 Context (org.forgerock.services.context.Context)23 JsonValue (org.forgerock.json.JsonValue)12 RealmContext (org.forgerock.openam.rest.RealmContext)10 BeforeTest (org.testng.annotations.BeforeTest)8 AuthorizationResult (org.forgerock.authz.filter.api.AuthorizationResult)6 Router (org.forgerock.json.resource.Router)4 Matchers.anyString (org.mockito.Matchers.anyString)4 FilterChain (org.forgerock.json.resource.FilterChain)3 SubjectContext (org.forgerock.openam.rest.resource.SubjectContext)3 RootContext (org.forgerock.services.context.RootContext)3 DelegationPermission (com.sun.identity.delegation.DelegationPermission)2 HashSet (java.util.HashSet)2 Requests.newActionRequest (org.forgerock.json.resource.Requests.newActionRequest)2 SSOException (com.iplanet.sso.SSOException)1 UriRouterContext (org.forgerock.http.routing.UriRouterContext)1 CreateRequest (org.forgerock.json.resource.CreateRequest)1