Search in sources :

Example 16 with RootContext

use of org.forgerock.services.context.RootContext in project OpenAM by OpenRock.

the class RealmContextTest method shouldGetBaseRealm.

@Test(dataProvider = "baseRealmData")
public void shouldGetBaseRealm(Pair<String, String> dnsRealm, Pair<String, String> uriRealm1, Pair<String, String> uriRealm2, String expectedRealm) {
    //Given
    RealmContext context = new RealmContext(new RootContext());
    if (dnsRealm != null) {
        context.setDnsAlias(dnsRealm.getFirst(), dnsRealm.getSecond());
    }
    if (uriRealm1 != null) {
        context.setSubRealm(uriRealm1.getFirst(), uriRealm1.getSecond());
    }
    if (uriRealm2 != null) {
        context.setSubRealm(uriRealm2.getFirst(), uriRealm2.getSecond());
    }
    //When
    String baseRealm = context.getBaseRealm();
    //Then
    assertThat(baseRealm).isEqualTo(expectedRealm);
}
Also used : RootContext(org.forgerock.services.context.RootContext) Test(org.testng.annotations.Test)

Example 17 with RootContext

use of org.forgerock.services.context.RootContext in project OpenAM by OpenRock.

the class RealmContextTest method getOverrideRealmShouldReturnNullWhenNotSet.

@Test
public void getOverrideRealmShouldReturnNullWhenNotSet() {
    //Given
    RealmContext context = new RealmContext(new RootContext());
    //When
    String overrideRealm = context.getOverrideRealm();
    //Then
    assertThat(overrideRealm).isNull();
}
Also used : RootContext(org.forgerock.services.context.RootContext) Test(org.testng.annotations.Test)

Example 18 with RootContext

use of org.forgerock.services.context.RootContext in project OpenAM by OpenRock.

the class RealmContextTest method shouldGetRebasedRealm.

@Test(dataProvider = "rebasedRealmData")
public void shouldGetRebasedRealm(Pair<String, String> dnsRealm, Pair<String, String> uriRealm1, Pair<String, String> uriRealm2, String expectedRealm) {
    //Given
    RealmContext context = new RealmContext(new RootContext());
    if (dnsRealm != null) {
        context.setDnsAlias(dnsRealm.getFirst(), dnsRealm.getSecond());
    }
    if (uriRealm1 != null) {
        context.setSubRealm(uriRealm1.getFirst(), uriRealm1.getSecond());
    }
    if (uriRealm2 != null) {
        context.setSubRealm(uriRealm2.getFirst(), uriRealm2.getSecond());
    }
    //When
    String rebasedRealm = context.getRebasedRealm();
    //Then
    assertThat(rebasedRealm).isEqualTo(expectedRealm);
}
Also used : RootContext(org.forgerock.services.context.RootContext) Test(org.testng.annotations.Test)

Example 19 with RootContext

use of org.forgerock.services.context.RootContext in project OpenAM by OpenRock.

the class RealmContextTest method shouldGetOverrideRealm.

@Test
public void shouldGetOverrideRealm() {
    //Given
    RealmContext context = new RealmContext(new RootContext());
    context.setOverrideRealm("/OVERRIDE_REALM");
    //When
    String overrideRealm = context.getOverrideRealm();
    //Then
    assertThat(overrideRealm).isEqualTo("/OVERRIDE_REALM");
}
Also used : RootContext(org.forgerock.services.context.RootContext) Test(org.testng.annotations.Test)

Example 20 with RootContext

use of org.forgerock.services.context.RootContext in project OpenAM by OpenRock.

the class RealmContextTest method shouldGetRelativeRealm.

@Test
public void shouldGetRelativeRealm() {
    //Given
    RealmContext context = new RealmContext(new RootContext());
    context.setSubRealm("SUB_REALM_1", "/REALM_1");
    //When
    String relativeRealm = context.getRelativeRealm();
    //Then
    assertThat(relativeRealm).isEqualTo("/REALM_1");
}
Also used : RootContext(org.forgerock.services.context.RootContext) Test(org.testng.annotations.Test)

Aggregations

RootContext (org.forgerock.services.context.RootContext)24 Test (org.testng.annotations.Test)16 Context (org.forgerock.services.context.Context)7 Request (org.forgerock.http.protocol.Request)5 RealmContext (org.forgerock.openam.rest.RealmContext)5 SessionContext (org.forgerock.http.session.SessionContext)4 AttributesContext (org.forgerock.services.context.AttributesContext)4 Connection (org.forgerock.json.resource.Connection)3 CreateRequest (org.forgerock.json.resource.CreateRequest)3 SSOTokenID (com.iplanet.sso.SSOTokenID)2 Response (org.forgerock.http.protocol.Response)2 ActionRequest (org.forgerock.json.resource.ActionRequest)2 DeleteRequest (org.forgerock.json.resource.DeleteRequest)2 QueryRequest (org.forgerock.json.resource.QueryRequest)2 QueryResourceHandler (org.forgerock.json.resource.QueryResourceHandler)2 ReadRequest (org.forgerock.json.resource.ReadRequest)2 Requests.newCreateRequest (org.forgerock.json.resource.Requests.newCreateRequest)2 ResourceException (org.forgerock.json.resource.ResourceException)2 Resources.newInternalConnection (org.forgerock.json.resource.Resources.newInternalConnection)2 AdminSubjectContext (org.forgerock.openam.rest.resource.AdminSubjectContext)2