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);
}
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();
}
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);
}
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");
}
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");
}
Aggregations