diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/BindOperationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/BindOperationTestCase.java index da60729527..d1f8c435d3 100644 --- a/opendj-server-legacy/src/test/java/org/opends/server/core/BindOperationTestCase.java +++ b/opendj-server-legacy/src/test/java/org/opends/server/core/BindOperationTestCase.java @@ -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.*; @@ -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 { @@ -1591,9 +1602,18 @@ 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 { @@ -1601,6 +1621,19 @@ public void testSubtreeModifyUpdatesAuthInfo() } } + /** + * 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.