use of com.unboundid.ldap.sdk.controls.DontUseCopyRequestControl in project ldapsdk by pingidentity.
the class RequestControlPreProcessorTestCase method testDontUseCopyControl.
/**
* Provides test coverage for the don't use copy request control.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testDontUseCopyControl() throws Exception {
final String oid = DontUseCopyRequestControl.DONT_USE_COPY_REQUEST_OID;
final Control vc = new DontUseCopyRequestControl();
final Control vn = new Control(oid, false);
final Control ic = new Control(oid, true, new ASN1OctetString("foo"));
final Control in = new Control(oid, false, new ASN1OctetString("foo"));
final Class<?> c = DontUseCopyRequestControl.class;
// Test with acceptable operation types.
for (final byte opType : Arrays.asList(LDAPMessage.PROTOCOL_OP_TYPE_COMPARE_REQUEST, LDAPMessage.PROTOCOL_OP_TYPE_SEARCH_REQUEST)) {
// A valid critical control.
ensureControlHandled(opType, Arrays.asList(vc), oid, c);
// A valid non-critical control.
ensureControlHandled(opType, Arrays.asList(vn), oid, c);
// Multiple instances of the control.
ensureException(opType, Arrays.asList(vc, vn));
// Malformed critical control.
ensureException(opType, Arrays.asList(ic));
// Malformed non-critical control.
ensureException(opType, Arrays.asList(in));
}
// Test with unacceptable operation types.
for (final byte opType : Arrays.asList(LDAPMessage.PROTOCOL_OP_TYPE_ABANDON_REQUEST, LDAPMessage.PROTOCOL_OP_TYPE_ADD_REQUEST, LDAPMessage.PROTOCOL_OP_TYPE_BIND_REQUEST, LDAPMessage.PROTOCOL_OP_TYPE_DELETE_REQUEST, LDAPMessage.PROTOCOL_OP_TYPE_EXTENDED_REQUEST, LDAPMessage.PROTOCOL_OP_TYPE_MODIFY_REQUEST, LDAPMessage.PROTOCOL_OP_TYPE_MODIFY_DN_REQUEST, LDAPMessage.PROTOCOL_OP_TYPE_UNBIND_REQUEST)) {
// A valid critical control.
ensureException(opType, Arrays.asList(vc));
// A valid non-critical control.
ensureControlIgnored(opType, Arrays.asList(vn), oid);
// Malformed critical control.
ensureException(opType, Arrays.asList(ic));
// Malformed non-critical control.
ensureControlIgnored(opType, Arrays.asList(in), oid);
}
}
Aggregations