use of com.unboundid.ldap.sdk.TestIntermediateResponseListener in project ldapsdk by pingidentity.
the class InMemoryOperationInterceptorTestCase method testExtendedWithTransformations.
/**
* Tests to ensure that processing works correctly for extended operations.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testExtendedWithTransformations() throws Exception {
final LDAPConnection conn = ds.getConnection();
WhoAmIExtendedRequest whoAmIRequest = new WhoAmIExtendedRequest();
assertResultCodeEquals(conn, whoAmIRequest, ResultCode.SUCCESS);
whoAmIRequest = new WhoAmIExtendedRequest(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ALTER_DN));
assertResultCodeEquals(conn, whoAmIRequest, ResultCode.SUCCESS);
whoAmIRequest = new WhoAmIExtendedRequest(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REJECT_REQUEST));
assertResultCodeEquals(conn, whoAmIRequest, ResultCode.UNWILLING_TO_PERFORM);
whoAmIRequest = new WhoAmIExtendedRequest(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REQUEST_RUNTIME_EXCEPTION));
assertResultCodeEquals(conn, whoAmIRequest, ResultCode.OTHER);
whoAmIRequest = new WhoAmIExtendedRequest(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ERROR_RESULT));
assertResultCodeEquals(conn, whoAmIRequest, ResultCode.UNWILLING_TO_PERFORM);
whoAmIRequest = new WhoAmIExtendedRequest(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.RESULT_RUNTIME_EXCEPTION));
assertResultCodeEquals(conn, whoAmIRequest, ResultCode.OTHER);
whoAmIRequest = new WhoAmIExtendedRequest(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_INTERMEDIATE_RESPONSE));
final TestIntermediateResponseListener testIRListener = new TestIntermediateResponseListener();
whoAmIRequest.setIntermediateResponseListener(testIRListener);
assertResultCodeEquals(conn, whoAmIRequest, ResultCode.SUCCESS);
assertEquals(testIRListener.getCount(), 2);
conn.close();
}
use of com.unboundid.ldap.sdk.TestIntermediateResponseListener in project ldapsdk by pingidentity.
the class InMemoryOperationInterceptorTestCase method testCompareWithTransformations.
/**
* Tests to ensure that processing works correctly for compare operations.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testCompareWithTransformations() throws Exception {
final LDAPConnection conn = ds.getConnection();
CompareRequest compareRequest = new CompareRequest("dc=example,dc=com", "dc", "example");
assertResultCodeEquals(conn, compareRequest, ResultCode.COMPARE_TRUE);
compareRequest = new CompareRequest("dc=example,dc=com", "dc", "example");
compareRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ALTER_DN));
assertResultCodeEquals(conn, compareRequest, ResultCode.NO_SUCH_OBJECT);
compareRequest = new CompareRequest("dc=example,dc=com", "dc", "example");
compareRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REJECT_REQUEST));
assertResultCodeEquals(conn, compareRequest, ResultCode.UNWILLING_TO_PERFORM);
compareRequest = new CompareRequest("dc=example,dc=com", "dc", "example");
compareRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REQUEST_RUNTIME_EXCEPTION));
assertResultCodeEquals(conn, compareRequest, ResultCode.OTHER);
compareRequest = new CompareRequest("dc=example,dc=com", "dc", "example");
compareRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ERROR_RESULT));
assertResultCodeEquals(conn, compareRequest, ResultCode.UNWILLING_TO_PERFORM);
compareRequest = new CompareRequest("dc=example,dc=com", "dc", "example");
compareRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.RESULT_RUNTIME_EXCEPTION));
assertResultCodeEquals(conn, compareRequest, ResultCode.OTHER);
compareRequest = new CompareRequest("dc=example,dc=com", "dc", "example");
compareRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_INTERMEDIATE_RESPONSE));
final TestIntermediateResponseListener testIRListener = new TestIntermediateResponseListener();
compareRequest.setIntermediateResponseListener(testIRListener);
assertResultCodeEquals(conn, compareRequest, ResultCode.COMPARE_TRUE);
assertEquals(testIRListener.getCount(), 2);
conn.close();
}
use of com.unboundid.ldap.sdk.TestIntermediateResponseListener in project ldapsdk by pingidentity.
the class InMemoryOperationInterceptorTestCase method testModifyWithTransformations.
/**
* Tests to ensure that processing works correctly for modify operations.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testModifyWithTransformations() throws Exception {
final LDAPConnection conn = ds.getConnection();
ModifyRequest modifyRequest = new ModifyRequest("dn: dc=example,dc=com", "changetype: modify", "replace: description", "description: test1");
assertResultCodeEquals(conn, modifyRequest, ResultCode.SUCCESS);
assertValueExists(conn, "dc=example,dc=com", "description", "test1");
modifyRequest = new ModifyRequest("dn: dc=example,dc=com", "changetype: modify", "replace: description", "description: test2");
modifyRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ALTER_DN));
assertResultCodeEquals(conn, modifyRequest, ResultCode.NO_SUCH_OBJECT);
assertValueExists(conn, "dc=example,dc=com", "description", "test1");
modifyRequest = new ModifyRequest("dn: dc=example,dc=com", "changetype: modify", "replace: description", "description: test2");
modifyRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REJECT_REQUEST));
assertResultCodeEquals(conn, modifyRequest, ResultCode.UNWILLING_TO_PERFORM);
assertValueExists(conn, "dc=example,dc=com", "description", "test1");
modifyRequest = new ModifyRequest("dn: dc=example,dc=com", "changetype: modify", "replace: description", "description: test2");
modifyRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REQUEST_RUNTIME_EXCEPTION));
assertResultCodeEquals(conn, modifyRequest, ResultCode.OTHER);
assertValueExists(conn, "dc=example,dc=com", "description", "test1");
modifyRequest = new ModifyRequest("dn: dc=example,dc=com", "changetype: modify", "replace: description", "description: test2");
modifyRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ERROR_RESULT));
assertResultCodeEquals(conn, modifyRequest, ResultCode.UNWILLING_TO_PERFORM);
assertValueExists(conn, "dc=example,dc=com", "description", "test2");
modifyRequest = new ModifyRequest("dn: dc=example,dc=com", "changetype: modify", "replace: description", "description: test3");
modifyRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.RESULT_RUNTIME_EXCEPTION));
assertResultCodeEquals(conn, modifyRequest, ResultCode.OTHER);
assertValueExists(conn, "dc=example,dc=com", "description", "test3");
modifyRequest = new ModifyRequest("dn: dc=example,dc=com", "changetype: modify", "replace: description", "description: test4");
modifyRequest.setControls(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_INTERMEDIATE_RESPONSE));
final TestIntermediateResponseListener testIRListener = new TestIntermediateResponseListener();
modifyRequest.setIntermediateResponseListener(testIRListener);
assertResultCodeEquals(conn, modifyRequest, ResultCode.SUCCESS);
assertValueExists(conn, "dc=example,dc=com", "description", "test4");
modifyRequest = new ModifyRequest("dn: dc=example,dc=com", "changetype: modify", "replace: description");
assertResultCodeEquals(conn, modifyRequest, ResultCode.SUCCESS);
assertAttributeMissing(conn, "dc=example,dc=com", "description");
conn.close();
}
use of com.unboundid.ldap.sdk.TestIntermediateResponseListener in project ldapsdk by pingidentity.
the class InMemoryOperationInterceptorTestCase method testIntermediateResponseWithTransformations.
/**
* Tests to ensure that processing works correctly for intermediate responses.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testIntermediateResponseWithTransformations() throws Exception {
final LDAPConnection conn = ds.getConnection();
WhoAmIExtendedRequest whoAmIRequest = new WhoAmIExtendedRequest(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_INTERMEDIATE_RESPONSE));
TestIntermediateResponseListener testIRListener = new TestIntermediateResponseListener();
whoAmIRequest.setIntermediateResponseListener(testIRListener);
assertResultCodeEquals(conn, whoAmIRequest, ResultCode.SUCCESS);
assertEquals(testIRListener.getCount(), 2);
whoAmIRequest = new WhoAmIExtendedRequest(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_INTERMEDIATE_RESPONSE, ControlBasedOperationInterceptor.TransformType.SUPPRESS_INTERMEDIATE_RESPONSE));
testIRListener = new TestIntermediateResponseListener();
whoAmIRequest.setIntermediateResponseListener(testIRListener);
assertResultCodeEquals(conn, whoAmIRequest, ResultCode.SUCCESS);
assertEquals(testIRListener.getCount(), 0);
whoAmIRequest = new WhoAmIExtendedRequest(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_INTERMEDIATE_RESPONSE, ControlBasedOperationInterceptor.TransformType.ALTER_INTERMEDIATE_RESPONSE));
testIRListener = new TestIntermediateResponseListener();
whoAmIRequest.setIntermediateResponseListener(testIRListener);
assertResultCodeEquals(conn, whoAmIRequest, ResultCode.SUCCESS);
assertEquals(testIRListener.getCount(), 2);
whoAmIRequest = new WhoAmIExtendedRequest(ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_INTERMEDIATE_RESPONSE, ControlBasedOperationInterceptor.TransformType.INTERMEDIATE_RESPONSE_RUNTIME_EXCEPTION));
testIRListener = new TestIntermediateResponseListener();
whoAmIRequest.setIntermediateResponseListener(testIRListener);
assertResultCodeEquals(conn, whoAmIRequest, ResultCode.SUCCESS);
assertEquals(testIRListener.getCount(), 0);
conn.close();
}
use of com.unboundid.ldap.sdk.TestIntermediateResponseListener in project ldapsdk by pingidentity.
the class InMemoryOperationInterceptorTestCase method testSASLBindWithTransformations.
/**
* Tests to ensure that processing works correctly for SASL bind operations.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testSASLBindWithTransformations() throws Exception {
final LDAPConnection conn = ds.getConnection();
PLAINBindRequest bindRequest = new PLAINBindRequest("dn:cn=Directory Manager", "password");
assertResultCodeEquals(conn, bindRequest, ResultCode.SUCCESS);
bindRequest = new PLAINBindRequest("dn:cn=Directory Manager", "password", ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ALTER_DN));
assertResultCodeEquals(conn, bindRequest, ResultCode.SUCCESS);
bindRequest = new PLAINBindRequest("dn:cn=Directory Manager", "password", ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REJECT_REQUEST));
assertResultCodeEquals(conn, bindRequest, ResultCode.UNWILLING_TO_PERFORM);
bindRequest = new PLAINBindRequest("dn:cn=Directory Manager", "password", ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.REQUEST_RUNTIME_EXCEPTION));
assertResultCodeEquals(conn, bindRequest, ResultCode.OTHER);
bindRequest = new PLAINBindRequest("dn:cn=Directory Manager", "password", ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.ERROR_RESULT));
assertResultCodeEquals(conn, bindRequest, ResultCode.UNWILLING_TO_PERFORM);
bindRequest = new PLAINBindRequest("dn:cn=Directory Manager", "password", ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.RESULT_RUNTIME_EXCEPTION));
assertResultCodeEquals(conn, bindRequest, ResultCode.OTHER);
bindRequest = new PLAINBindRequest("dn:cn=Directory Manager", "password", ControlBasedOperationInterceptor.createControls(ControlBasedOperationInterceptor.TransformType.INJECT_INTERMEDIATE_RESPONSE));
final TestIntermediateResponseListener testIRListener = new TestIntermediateResponseListener();
bindRequest.setIntermediateResponseListener(testIRListener);
assertResultCodeEquals(conn, bindRequest, ResultCode.SUCCESS);
assertEquals(testIRListener.getCount(), 2);
conn.close();
}
Aggregations