use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser in project jackrabbit-oak by apache.
the class LdapProviderTest method testAuthenticateValidateTrueTrue.
@Test
public void testAuthenticateValidateTrueTrue() throws Exception {
providerConfig.getAdminPoolConfig().setMaxActive(2).setLookupOnValidate(true);
providerConfig.getUserPoolConfig().setMaxActive(2).setLookupOnValidate(true);
idp.close();
idp = new LdapIdentityProvider(providerConfig);
SimpleCredentials creds = new SimpleCredentials(TEST_USER1_UID, "pass".toCharArray());
for (int i = 0; i < 8; i++) {
ExternalUser user = idp.authenticate(creds);
assertNotNull("User 1 must authenticate (i=" + i + ")", user);
assertEquals("User Ref", TEST_USER1_DN, user.getExternalId().getId());
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser in project jackrabbit-oak by apache.
the class LdapProviderTest method testGetGroups2.
@Test
public void testGetGroups2() throws Exception {
ExternalIdentityRef ref = new ExternalIdentityRef(TEST_USER0_DN, IDP_NAME);
ExternalIdentity id = idp.getIdentity(ref);
assertTrue("User instance", id instanceof ExternalUser);
assertIfEquals("Groups", TEST_USER0_GROUPS, id.getDeclaredGroups());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser in project jackrabbit-oak by apache.
the class LdapProviderTest method testSplitDNIntermediatePath2.
@Test
public void testSplitDNIntermediatePath2() throws Exception {
providerConfig.getUserConfig().setMakeDnPath(true);
ExternalUser user = idp.getUser(TEST_USER5_UID);
assertNotNull("User 5 must exist", user);
assertEquals("Intermediate path must be the split dn", TEST_USER5_PATH, user.getIntermediatePath());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser in project jackrabbit-oak by apache.
the class LdapProviderTest method testAuthenticateValidateFalseFalse.
@Test
public void testAuthenticateValidateFalseFalse() throws Exception {
providerConfig.getAdminPoolConfig().setMaxActive(2).setLookupOnValidate(false);
providerConfig.getUserPoolConfig().setMaxActive(2).setLookupOnValidate(false);
idp.close();
idp = new LdapIdentityProvider(providerConfig);
SimpleCredentials creds = new SimpleCredentials(TEST_USER1_UID, "pass".toCharArray());
for (int i = 0; i < 8; i++) {
ExternalUser user = idp.authenticate(creds);
assertNotNull("User 1 must authenticate", user);
assertEquals("User Ref", TEST_USER1_DN, user.getExternalId().getId());
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser in project jackrabbit-oak by apache.
the class LdapProviderTest method testListUsersWithMissingUid.
/**
* Test case to reproduce OAK-3396 where an ldap user entry
* without a uid caused a NullpointerException in LdapIdentityProvider.createUser
*/
@Test
public void testListUsersWithMissingUid() throws Exception {
// the ERRONEOUS_LDIF contains an entry without uid
InputStream erroneousDIF = LdapProviderTest.class.getResourceAsStream(ERRONEOUS_LDIF);
LDAP_SERVER.loadLdif(erroneousDIF);
Iterator<ExternalUser> users = idp.listUsers();
// without the LdapInvalidAttributeValueException a NPE would result here:
while (users.hasNext()) {
ExternalUser user = users.next();
// the 'Faulty Entry' of the ERRONEOUS_LDIF should be filtered out
// (by LdapIdentityProvider.listUsers.getNext())
assertTrue(!user.getPrincipalName().startsWith("cn=Faulty Entry"));
}
}
Aggregations