Search in sources :

Example 1 with DontUseCopyRequestControl

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);
    }
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) VirtualListViewRequestControl(com.unboundid.ldap.sdk.controls.VirtualListViewRequestControl) AuthorizationIdentityRequestControl(com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl) DontUseCopyRequestControl(com.unboundid.ldap.sdk.controls.DontUseCopyRequestControl) Control(com.unboundid.ldap.sdk.Control) ProxiedAuthorizationV1RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV1RequestControl) SubtreeDeleteRequestControl(com.unboundid.ldap.sdk.controls.SubtreeDeleteRequestControl) RFC3672SubentriesRequestControl(com.unboundid.ldap.sdk.controls.RFC3672SubentriesRequestControl) SimplePagedResultsControl(com.unboundid.ldap.sdk.controls.SimplePagedResultsControl) AssertionRequestControl(com.unboundid.ldap.sdk.controls.AssertionRequestControl) TransactionSpecificationRequestControl(com.unboundid.ldap.sdk.controls.TransactionSpecificationRequestControl) ManageDsaITRequestControl(com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl) ProxiedAuthorizationV2RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV2RequestControl) ServerSideSortRequestControl(com.unboundid.ldap.sdk.controls.ServerSideSortRequestControl) PostReadRequestControl(com.unboundid.ldap.sdk.controls.PostReadRequestControl) DraftLDUPSubentriesRequestControl(com.unboundid.ldap.sdk.controls.DraftLDUPSubentriesRequestControl) PreReadRequestControl(com.unboundid.ldap.sdk.controls.PreReadRequestControl) PermissiveModifyRequestControl(com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) DontUseCopyRequestControl(com.unboundid.ldap.sdk.controls.DontUseCopyRequestControl) Test(org.testng.annotations.Test)

Aggregations

ASN1OctetString (com.unboundid.asn1.ASN1OctetString)1 Control (com.unboundid.ldap.sdk.Control)1 AssertionRequestControl (com.unboundid.ldap.sdk.controls.AssertionRequestControl)1 AuthorizationIdentityRequestControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl)1 DontUseCopyRequestControl (com.unboundid.ldap.sdk.controls.DontUseCopyRequestControl)1 DraftLDUPSubentriesRequestControl (com.unboundid.ldap.sdk.controls.DraftLDUPSubentriesRequestControl)1 ManageDsaITRequestControl (com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl)1 PermissiveModifyRequestControl (com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl)1 PostReadRequestControl (com.unboundid.ldap.sdk.controls.PostReadRequestControl)1 PreReadRequestControl (com.unboundid.ldap.sdk.controls.PreReadRequestControl)1 ProxiedAuthorizationV1RequestControl (com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV1RequestControl)1 ProxiedAuthorizationV2RequestControl (com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV2RequestControl)1 RFC3672SubentriesRequestControl (com.unboundid.ldap.sdk.controls.RFC3672SubentriesRequestControl)1 ServerSideSortRequestControl (com.unboundid.ldap.sdk.controls.ServerSideSortRequestControl)1 SimplePagedResultsControl (com.unboundid.ldap.sdk.controls.SimplePagedResultsControl)1 SubtreeDeleteRequestControl (com.unboundid.ldap.sdk.controls.SubtreeDeleteRequestControl)1 TransactionSpecificationRequestControl (com.unboundid.ldap.sdk.controls.TransactionSpecificationRequestControl)1 VirtualListViewRequestControl (com.unboundid.ldap.sdk.controls.VirtualListViewRequestControl)1 Test (org.testng.annotations.Test)1