Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@
import org.opends.server.types.Control;
import org.opends.server.types.Operation;
import org.opends.server.types.OperationType;
import org.opends.server.util.TestTimer;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import static java.util.concurrent.TimeUnit.*;
import static org.assertj.core.api.Assertions.*;
import static org.forgerock.opendj.ldap.ModificationType.*;
import static org.forgerock.opendj.ldap.requests.Requests.*;
Expand Down Expand Up @@ -1527,7 +1529,16 @@ public void testSubtreeDeleteClearsAuthInfo()
};
assertEquals(LDAPDelete.run(nullPrintStream(), System.err, args), 0);

assertNull(DirectoryServer.getAuthenticatedUsers().get(userDN));
// AuthenticatedUsers is a POST_RESPONSE plugin: the registry is updated
// after the client already received the response, so poll briefly.
newAuthInfoTimer().repeatUntilSuccess(new TestTimer.CallableVoid()
{
@Override
public void call() throws Exception
{
assertNull(DirectoryServer.getAuthenticatedUsers().get(userDN));
}
});
}
finally
{
Expand Down Expand Up @@ -1591,16 +1602,38 @@ public void testSubtreeModifyUpdatesAuthInfo()
};
assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0);

DN newUserDN = DN.valueOf("uid=test,ou=users,dc=example,dc=com");
assertNotNull(DirectoryServer.getAuthenticatedUsers().get(newUserDN));
assertEquals(DirectoryServer.getAuthenticatedUsers().get(newUserDN).size(), 1);
final DN newUserDN = DN.valueOf("uid=test,ou=users,dc=example,dc=com");
// AuthenticatedUsers is a POST_RESPONSE plugin: the registry is updated
// after the client already received the response, so poll briefly.
newAuthInfoTimer().repeatUntilSuccess(new TestTimer.CallableVoid()
{
@Override
public void call() throws Exception
{
assertNotNull(DirectoryServer.getAuthenticatedUsers().get(newUserDN));
assertEquals(DirectoryServer.getAuthenticatedUsers().get(newUserDN).size(), 1);
}
});
}
finally
{
TestCaseUtils.clearBackend("userRoot");
}
}

/**
* Timer to await the asynchronous {@link AuthenticatedUsers} registry
* update: it is performed by a POST_RESPONSE plugin, i.e. after the client
* already received the operation response.
*/
private TestTimer newAuthInfoTimer()
{
return new TestTimer.Builder()
.maxSleep(10, SECONDS)
.sleepTimes(100, MILLISECONDS)
.toTimer();
}

/**
* Tests to ensure that the "ignore" password policy state update policy
* works as expected.
Expand Down
Loading