use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser in project jackrabbit-oak by apache.
the class LdapProviderTest method testGetUserProperties.
@Test
public void testGetUserProperties() throws Exception {
ExternalUser user = idp.getUser(TEST_USER1_UID);
assertNotNull("User 1 must exist", user);
Map<String, ?> properties = user.getProperties();
assertThat((Map<String, Collection<String>>) properties, Matchers.<String, Collection<String>>hasEntry(Matchers.equalTo("objectclass"), Matchers.containsInAnyOrder("inetOrgPerson", "top", "person", "organizationalPerson")));
assertThat(properties, Matchers.<String, Object>hasEntry("uid", "hhornblo"));
assertThat(properties, Matchers.<String, Object>hasEntry("givenname", "Horatio"));
assertThat(properties, Matchers.<String, Object>hasEntry("description", "Capt. Horatio Hornblower, R.N"));
assertThat(properties, Matchers.<String, Object>hasEntry("sn", "Hornblower"));
assertThat(properties, Matchers.not(Matchers.<String, Object>hasEntry("mail", "hhornblo@royalnavy.mod.uk")));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser in project jackrabbit-oak by apache.
the class LdapProviderTest method testSplitDNIntermediatePath.
@Test
public void testSplitDNIntermediatePath() throws Exception {
providerConfig.getUserConfig().setMakeDnPath(true);
ExternalUser user = idp.getUser(TEST_USER1_UID);
assertNotNull("User 1 must exist", user);
assertEquals("Intermediate path must be the split dn", TEST_USER1_PATH, user.getIntermediatePath());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncPropertiesRemapped.
@Test
public void testSyncPropertiesRemapped() throws Exception {
ExternalUser externalUser = idp.getUser(TestIdentityProvider.ID_SECOND_USER);
Authorizable a = syncCtx.createUser(externalUser);
// create exact mapping
Map<String, String> mapping = new HashMap();
Map<String, ?> extProps = externalUser.getProperties();
for (String propName : extProps.keySet()) {
mapping.put("a/" + propName, propName);
}
syncCtx.syncProperties(externalUser, a, mapping);
for (String propName : extProps.keySet()) {
String relPath = "a/" + propName;
assertTrue(a.hasProperty(relPath));
Object obj = extProps.get(propName);
Value[] vs = a.getProperty(relPath);
if (vs.length == 1) {
assertEquals(syncCtx.createValue(obj), a.getProperty(relPath)[0]);
} else {
Value[] expected = (obj instanceof Collection) ? syncCtx.createValues((Collection) obj) : syncCtx.createValues(Arrays.asList((Object[]) obj));
assertArrayEquals(expected, a.getProperty(relPath));
}
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncPropertiesEmptyMap.
@Test
public void testSyncPropertiesEmptyMap() throws Exception {
ExternalUser externalUser = idp.getUser(TestIdentityProvider.ID_SECOND_USER);
Authorizable a = syncCtx.createUser(externalUser);
syncCtx.syncProperties(externalUser, a, ImmutableMap.<String, String>of());
for (String propName : externalUser.getProperties().keySet()) {
assertFalse(a.hasProperty(propName));
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser in project jackrabbit-oak by apache.
the class DynamicSyncContextTest method testSyncMembershipWithNesting.
@Test
public void testSyncMembershipWithNesting() throws Exception {
long nesting = 1;
syncConfig.user().setMembershipNestingDepth(nesting);
ExternalUser externalUser = idp.getUser(USER_ID);
sync(externalUser, SyncResult.Status.ADD);
Authorizable a = userManager.getAuthorizable(externalUser.getId());
assertDynamicMembership(a, externalUser, nesting);
// verify that the membership is always reflected in the rep:externalPrincipalNames property
// 1. membership nesting = -1
nesting = -1;
syncContext.syncMembership(externalUser, a, nesting);
assertDynamicMembership(a, externalUser, nesting);
// 2. membership nesting is > 0
nesting = Long.MAX_VALUE;
syncContext.syncMembership(externalUser, a, nesting);
assertDynamicMembership(a, externalUser, nesting);
}
Aggregations