|
45 | 45 | import org.opends.server.types.Control; |
46 | 46 | import org.opends.server.types.Operation; |
47 | 47 | import org.opends.server.types.OperationType; |
| 48 | +import org.opends.server.util.TestTimer; |
48 | 49 | import org.testng.annotations.DataProvider; |
49 | 50 | import org.testng.annotations.Test; |
50 | 51 |
|
| 52 | +import static java.util.concurrent.TimeUnit.*; |
51 | 53 | import static org.assertj.core.api.Assertions.*; |
52 | 54 | import static org.forgerock.opendj.ldap.ModificationType.*; |
53 | 55 | import static org.forgerock.opendj.ldap.requests.Requests.*; |
@@ -1527,7 +1529,16 @@ public void testSubtreeDeleteClearsAuthInfo() |
1527 | 1529 | }; |
1528 | 1530 | assertEquals(LDAPDelete.run(nullPrintStream(), System.err, args), 0); |
1529 | 1531 |
|
1530 | | - assertNull(DirectoryServer.getAuthenticatedUsers().get(userDN)); |
| 1532 | + // AuthenticatedUsers is a POST_RESPONSE plugin: the registry is updated |
| 1533 | + // after the client already received the response, so poll briefly. |
| 1534 | + newAuthInfoTimer().repeatUntilSuccess(new TestTimer.CallableVoid() |
| 1535 | + { |
| 1536 | + @Override |
| 1537 | + public void call() throws Exception |
| 1538 | + { |
| 1539 | + assertNull(DirectoryServer.getAuthenticatedUsers().get(userDN)); |
| 1540 | + } |
| 1541 | + }); |
1531 | 1542 | } |
1532 | 1543 | finally |
1533 | 1544 | { |
@@ -1591,16 +1602,38 @@ public void testSubtreeModifyUpdatesAuthInfo() |
1591 | 1602 | }; |
1592 | 1603 | assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); |
1593 | 1604 |
|
1594 | | - DN newUserDN = DN.valueOf("uid=test,ou=users,dc=example,dc=com"); |
1595 | | - assertNotNull(DirectoryServer.getAuthenticatedUsers().get(newUserDN)); |
1596 | | - assertEquals(DirectoryServer.getAuthenticatedUsers().get(newUserDN).size(), 1); |
| 1605 | + final DN newUserDN = DN.valueOf("uid=test,ou=users,dc=example,dc=com"); |
| 1606 | + // AuthenticatedUsers is a POST_RESPONSE plugin: the registry is updated |
| 1607 | + // after the client already received the response, so poll briefly. |
| 1608 | + newAuthInfoTimer().repeatUntilSuccess(new TestTimer.CallableVoid() |
| 1609 | + { |
| 1610 | + @Override |
| 1611 | + public void call() throws Exception |
| 1612 | + { |
| 1613 | + assertNotNull(DirectoryServer.getAuthenticatedUsers().get(newUserDN)); |
| 1614 | + assertEquals(DirectoryServer.getAuthenticatedUsers().get(newUserDN).size(), 1); |
| 1615 | + } |
| 1616 | + }); |
1597 | 1617 | } |
1598 | 1618 | finally |
1599 | 1619 | { |
1600 | 1620 | TestCaseUtils.clearBackend("userRoot"); |
1601 | 1621 | } |
1602 | 1622 | } |
1603 | 1623 |
|
| 1624 | + /** |
| 1625 | + * Timer to await the asynchronous {@link AuthenticatedUsers} registry |
| 1626 | + * update: it is performed by a POST_RESPONSE plugin, i.e. after the client |
| 1627 | + * already received the operation response. |
| 1628 | + */ |
| 1629 | + private TestTimer newAuthInfoTimer() |
| 1630 | + { |
| 1631 | + return new TestTimer.Builder() |
| 1632 | + .maxSleep(10, SECONDS) |
| 1633 | + .sleepTimes(100, MILLISECONDS) |
| 1634 | + .toTimer(); |
| 1635 | + } |
| 1636 | + |
1604 | 1637 | /** |
1605 | 1638 | * Tests to ensure that the "ignore" password policy state update policy |
1606 | 1639 | * works as expected. |
|
0 commit comments