Search in sources :

Example 1 with ExtendedRequest

use of com.unboundid.ldap.sdk.ExtendedRequest in project ldapsdk by pingidentity.

the class GenerateTOTPSharedSecretExtendedRequestTestCase method testDecodeRequestValueEmptySequence.

/**
 * Tests the behavior of the extended request when trying to decode a generic
 * request that has a value that is an empty ASN.1 sequence.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeRequestValueEmptySequence() throws Exception {
    final ExtendedRequest r = new ExtendedRequest("1.3.6.1.4.1.30221.2.6.56", new ASN1OctetString(new ASN1Sequence().encode()));
    new GenerateTOTPSharedSecretExtendedRequest(r);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ExtendedRequest(com.unboundid.ldap.sdk.ExtendedRequest) Test(org.testng.annotations.Test)

Example 2 with ExtendedRequest

use of com.unboundid.ldap.sdk.ExtendedRequest in project ldapsdk by pingidentity.

the class GenerateTOTPSharedSecretExtendedRequestTestCase method testDecodeRequestValueSequenceUnrecognizedElementType.

/**
 * Tests the behavior of the extended request when trying to decode a generic
 * request that has a value that is an ASN.1 sequence with an unrecognized
 * element type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeRequestValueSequenceUnrecognizedElementType() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x80, "u:test.user"), new ASN1OctetString((byte) 0x12, "invalid-type"));
    final ExtendedRequest r = new ExtendedRequest("1.3.6.1.4.1.30221.2.6.56", new ASN1OctetString(valueSequence.encode()));
    new GenerateTOTPSharedSecretExtendedRequest(r);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ExtendedRequest(com.unboundid.ldap.sdk.ExtendedRequest) Test(org.testng.annotations.Test)

Example 3 with ExtendedRequest

use of com.unboundid.ldap.sdk.ExtendedRequest in project ldapsdk by pingidentity.

the class GetBackupCompatibilityDescriptorExtendedRequestTestCase method testDecodeValueNotSequence.

/**
 * Tests the behavior when attempting to decode an extended request whose
 * value is not a valid ASN.1 sequence.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueNotSequence() throws Exception {
    final ExtendedRequest r = new ExtendedRequest("1.3.6.1.4.1.30221.2.6.30", new ASN1OctetString("foo"));
    new GetBackupCompatibilityDescriptorExtendedRequest(r);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ExtendedRequest(com.unboundid.ldap.sdk.ExtendedRequest) Test(org.testng.annotations.Test)

Example 4 with ExtendedRequest

use of com.unboundid.ldap.sdk.ExtendedRequest in project ldapsdk by pingidentity.

the class GetChangelogBatchExtendedRequestTestCase method testDecodeValueSequenceInvalidChangeType.

/**
 * Provides test coverage for an attempt to decode an extended request with a
 * value sequence with an invalid change type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueSequenceInvalidChangeType() throws Exception {
    final ASN1Set changeTypeSet = new ASN1Set((byte) 0xA4, new ASN1Enumerated(0), new ASN1Enumerated(5));
    final ASN1Sequence valueSequence = new ASN1Sequence(new EndOfChangelogStartingPoint().encode(), new ASN1Integer(0), changeTypeSet);
    new GetChangelogBatchExtendedRequest(new ExtendedRequest(GetChangelogBatchExtendedRequest.GET_CHANGELOG_BATCH_REQUEST_OID, new ASN1OctetString(valueSequence.encode())));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Set(com.unboundid.asn1.ASN1Set) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ExtendedRequest(com.unboundid.ldap.sdk.ExtendedRequest) ASN1Integer(com.unboundid.asn1.ASN1Integer) Test(org.testng.annotations.Test)

Example 5 with ExtendedRequest

use of com.unboundid.ldap.sdk.ExtendedRequest in project ldapsdk by pingidentity.

the class GetChangelogBatchExtendedRequestTestCase method testDecodeValueSequenceMalformedIncludeList.

/**
 * Provides test coverage for an attempt to decode an extended request with a
 * value sequence with a set of include base DNs that cannot be parsed.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueSequenceMalformedIncludeList() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new EndOfChangelogStartingPoint().encode(), new ASN1OctetString("foo"), new ASN1OctetString((byte) 0xA2, "bar"));
    new GetChangelogBatchExtendedRequest(new ExtendedRequest(GetChangelogBatchExtendedRequest.GET_CHANGELOG_BATCH_REQUEST_OID, new ASN1OctetString(valueSequence.encode())));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ExtendedRequest(com.unboundid.ldap.sdk.ExtendedRequest) Test(org.testng.annotations.Test)

Aggregations

ExtendedRequest (com.unboundid.ldap.sdk.ExtendedRequest)86 Test (org.testng.annotations.Test)79 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)70 ASN1Sequence (com.unboundid.asn1.ASN1Sequence)43 ASN1Enumerated (com.unboundid.asn1.ASN1Enumerated)15 LDAPException (com.unboundid.ldap.sdk.LDAPException)12 ASN1Element (com.unboundid.asn1.ASN1Element)8 Control (com.unboundid.ldap.sdk.Control)6 ExtendedResult (com.unboundid.ldap.sdk.ExtendedResult)6 ASN1Integer (com.unboundid.asn1.ASN1Integer)5 NotNull (com.unboundid.util.NotNull)5 ExtendedResponseProtocolOp (com.unboundid.ldap.protocol.ExtendedResponseProtocolOp)4 LDAPMessage (com.unboundid.ldap.protocol.LDAPMessage)3 DN (com.unboundid.ldap.sdk.DN)3 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)3 PasswordModifyExtendedRequest (com.unboundid.ldap.sdk.extensions.PasswordModifyExtendedRequest)3 AuthorizationIdentityRequestControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl)2 ManageDsaITRequestControl (com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl)2 EndTransactionExtendedRequest (com.unboundid.ldap.sdk.extensions.EndTransactionExtendedRequest)2 StartTransactionExtendedRequest (com.unboundid.ldap.sdk.extensions.StartTransactionExtendedRequest)2