| | |
| | | import org.forgerock.opendj.ldap.AuthorizationException; |
| | | import org.forgerock.opendj.ldap.Connection; |
| | | import org.forgerock.opendj.ldap.ConnectionFactory; |
| | | import org.forgerock.opendj.ldap.Connections; |
| | | import org.forgerock.opendj.ldap.ConstraintViolationException; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * This class defines a set of tests for the Adapters.class. |
| | | */ |
| | | /** This class defines a set of tests for the Adapters.class. */ |
| | | @SuppressWarnings("javadoc") |
| | | @Test(sequential=true) |
| | | public class AdaptersTestCase extends DirectoryServerTestCase { |
| | | |
| | | private static final String USER_0_DN_STRING = "uid=user.0,o=test"; |
| | | |
| | | /** |
| | |
| | | connection.close(); |
| | | } |
| | | |
| | | /** |
| | | * Clean up data at the end of tests. |
| | | */ |
| | | /** Clean up data at the end of tests. */ |
| | | @AfterClass |
| | | public void shutDownEmbeddedServerServer() throws Exception { |
| | | // Delete all added entries but user.3 which is already removed in one test |
| | |
| | | @Test(dataProvider = "rootConnectionFactories") |
| | | public void testAdapterSearchRequestWithNoResults(final ConnectionFactory factory) |
| | | throws Exception { |
| | | |
| | | final SearchRequest request = |
| | | Requests.newSearchRequest("o=test", SearchScope.WHOLE_SUBTREE, |
| | | "(uid=unknown)").addControl( |
| | |
| | | expectedExceptions = EntryNotFoundException.class) |
| | | public void testAdapterSearchSingleEntryWithNoResults(final ConnectionFactory factory) |
| | | throws Exception { |
| | | |
| | | final Connection connection = factory.getConnection(); |
| | | try { |
| | | connection.searchSingleEntry(Requests.newSearchRequest("o=test", |
| | |
| | | "uid=user.2, o=test", SearchScope.BASE_OBJECT, "(uid=user.2)")); |
| | | assertThat(srEntry.getAttribute("mail").firstValueAsString()).isEqualTo( |
| | | "modified@example.com"); |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Test(dataProvider = "rootConnectionFactories") |
| | | public void testAdapterUsePermissiveModifyRequest(final ConnectionFactory factory) throws LdapException { |
| | | |
| | | final ModifyRequest changeRequest = |
| | | Requests.newModifyRequest("uid=user.2, o=test").addControl( |
| | | PermissiveModifyRequestControl.newControl(true)).addModification( |
| | |
| | | Requests.newModifyDNRequest("uid=user.test,o=test", "uid=user.4") |
| | | .setDeleteOldRDN(true); |
| | | connection.modifyDN(changeRequest); |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | expectedExceptions = AuthorizationException.class) |
| | | public void testAdapterAsAnonymousCannotPerformDeleteRequest(final ConnectionFactory factory) |
| | | throws LdapException { |
| | | |
| | | final DeleteRequest deleteRequest = |
| | | Requests.newDeleteRequest("uid=user.2,o=test"); |
| | | |
| | |
| | | expectedExceptions = AuthorizationException.class) |
| | | public void testAdapterAsAnonymousCannotPerformAddRequest(final ConnectionFactory factory) |
| | | throws LdapException { |
| | | |
| | | // @formatter:off |
| | | final AddRequest addRequest = Requests.newAddRequest( |
| | | "dn: sn=scarter,o=test", |
| | |
| | | expectedExceptions = AuthorizationException.class) |
| | | public void testAdapterAsAnonymousCannotPerformModifyDNRequest(final ConnectionFactory factory) |
| | | throws LdapException { |
| | | |
| | | final Connection connection = factory.getConnection(); |
| | | |
| | | final ModifyDNRequest changeRequest = |
| | |
| | | expectedExceptions = LdapException.class) |
| | | public void testAdapterAsAnonymousCannotPerformModifyRequest(final ConnectionFactory factory) |
| | | throws LdapException { |
| | | |
| | | final ModifyRequest changeRequest = |
| | | Requests.newModifyRequest("uid=user.2,o=test").addControl( |
| | | PreReadRequestControl.newControl(true, "mail")).addModification( |
| | |
| | | @Test(dataProvider = "anonymousConnectionFactories") |
| | | public void testAdapterAsAnonymousPerformsCompareRequest(final ConnectionFactory factory) |
| | | throws LdapException { |
| | | |
| | | final CompareRequest compareRequest = |
| | | Requests.newCompareRequest(USER_0_DN_STRING, "uid", "user.0"); |
| | | |
| | |
| | | @Test(dataProvider = "anonymousConnectionFactories") |
| | | public void testAdapterAsAnonymousPerformsSearchRequest(final ConnectionFactory factory) |
| | | throws Exception { |
| | | |
| | | final SearchRequest request = |
| | | Requests.newSearchRequest("o=test", SearchScope.WHOLE_SUBTREE, |
| | | "(uid=user.1)"); |