Search in sources :

Example 91 with RealmContext

use of org.forgerock.openam.rest.RealmContext in project OpenAM by OpenRock.

the class ResourceSetServiceTest method mockContext.

private Context mockContext(String realm) {
    RealmContext realmContext = mock(RealmContext.class);
    given(realmContext.getResolvedRealm()).willReturn(realm);
    return realmContext;
}
Also used : RealmContext(org.forgerock.openam.rest.RealmContext)

Example 92 with RealmContext

use of org.forgerock.openam.rest.RealmContext in project OpenAM by OpenRock.

the class UmaEnabledFilterTest method setup.

@BeforeMethod
public void setup() throws Exception {
    MockitoAnnotations.initMocks(this);
    context = ClientContext.newInternalClientContext(new RealmContext(new RootContext()));
    requestHandler = mock(RequestHandler.class);
    when(requestHandler.handleAction(any(Context.class), any(ActionRequest.class))).thenReturn(promise(newActionResponse(null)));
    when(requestHandler.handleCreate(any(Context.class), any(CreateRequest.class))).thenReturn(promise(newResourceResponse(null, null, null)));
    when(requestHandler.handleDelete(any(Context.class), any(DeleteRequest.class))).thenReturn(promise(newResourceResponse(null, null, null)));
    when(requestHandler.handlePatch(any(Context.class), any(PatchRequest.class))).thenReturn(promise(newResourceResponse(null, null, null)));
    when(requestHandler.handleQuery(any(Context.class), any(QueryRequest.class), any(QueryResourceHandler.class))).thenReturn(promise(newQueryResponse()));
    when(requestHandler.handleRead(any(Context.class), any(ReadRequest.class))).thenReturn(promise(newResourceResponse(null, null, null)));
    when(requestHandler.handleUpdate(any(Context.class), any(UpdateRequest.class))).thenReturn(promise(newResourceResponse(null, null, null)));
}
Also used : RootContext(org.forgerock.services.context.RootContext) RootContext(org.forgerock.services.context.RootContext) ClientContext(org.forgerock.services.context.ClientContext) RealmContext(org.forgerock.openam.rest.RealmContext) Context(org.forgerock.services.context.Context) RealmContext(org.forgerock.openam.rest.RealmContext) RequestHandler(org.forgerock.json.resource.RequestHandler) QueryRequest(org.forgerock.json.resource.QueryRequest) ActionRequest(org.forgerock.json.resource.ActionRequest) UpdateRequest(org.forgerock.json.resource.UpdateRequest) CreateRequest(org.forgerock.json.resource.CreateRequest) QueryResourceHandler(org.forgerock.json.resource.QueryResourceHandler) PatchRequest(org.forgerock.json.resource.PatchRequest) DeleteRequest(org.forgerock.json.resource.DeleteRequest) ReadRequest(org.forgerock.json.resource.ReadRequest) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 93 with RealmContext

use of org.forgerock.openam.rest.RealmContext in project OpenAM by OpenRock.

the class ResourceSetServiceTest method createContext.

private Context createContext() {
    RealmContext realmContext = new RealmContext(new RootContext());
    realmContext.setDnsAlias("/", "REALM");
    return realmContext;
}
Also used : RootContext(org.forgerock.services.context.RootContext) RealmContext(org.forgerock.openam.rest.RealmContext)

Example 94 with RealmContext

use of org.forgerock.openam.rest.RealmContext in project OpenAM by OpenRock.

the class UmaPolicyServiceImplDelegationTest method getContext.

private Context getContext() throws Exception {
    SubjectContext subjectContext = mock(SSOTokenContext.class);
    SSOToken ssoToken = mock(SSOToken.class);
    Principal principal = mock(Principal.class);
    given(subjectContext.getCallerSSOToken()).willReturn(ssoToken);
    given(ssoToken.getProperty(Constants.UNIVERSAL_IDENTIFIER)).willReturn("id=" + loggedInUserId + ",ou=REALM,dc=forgerock,dc=org");
    given(ssoToken.getPrincipal()).willReturn(principal);
    given(principal.getName()).willReturn(loggedInUserId);
    return ClientContext.newInternalClientContext(new RealmContext(subjectContext));
}
Also used : SSOToken(com.iplanet.sso.SSOToken) RealmContext(org.forgerock.openam.rest.RealmContext) SubjectContext(org.forgerock.openam.rest.resource.SubjectContext) JwtPrincipal(com.sun.identity.entitlement.JwtPrincipal) Principal(java.security.Principal)

Aggregations

RealmContext (org.forgerock.openam.rest.RealmContext)94 ResourceException (org.forgerock.json.resource.ResourceException)63 ResourceResponse (org.forgerock.json.resource.ResourceResponse)58 Context (org.forgerock.services.context.Context)53 Test (org.testng.annotations.Test)53 Subject (javax.security.auth.Subject)42 ClientContext (org.forgerock.services.context.ClientContext)41 SSOTokenContext (org.forgerock.openam.rest.resource.SSOTokenContext)40 JsonValue (org.forgerock.json.JsonValue)35 Matchers.anyString (org.mockito.Matchers.anyString)27 SubjectContext (org.forgerock.openam.rest.resource.SubjectContext)20 BadRequestException (org.forgerock.json.resource.BadRequestException)19 SSOException (com.iplanet.sso.SSOException)17 Application (com.sun.identity.entitlement.Application)16 ForbiddenException (org.forgerock.json.resource.ForbiddenException)16 NotFoundException (org.forgerock.json.resource.NotFoundException)15 PermanentException (org.forgerock.json.resource.PermanentException)15 QueryResourceHandler (org.forgerock.json.resource.QueryResourceHandler)15 ReadRequest (org.forgerock.json.resource.ReadRequest)15 SSOToken (com.iplanet.sso.SSOToken)14