Search in sources :

Example 6 with ASN1Enumerated

use of com.github.zhenwei.core.asn1.ASN1Enumerated 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 7 with ASN1Enumerated

use of com.github.zhenwei.core.asn1.ASN1Enumerated in project ldapsdk by pingidentity.

the class GetSubtreeAccessibilityExtendedResultTestCase method testGetAccessibilityValueSequenceMissingBaseDN.

/**
 * Tests the behavior when trying to decode a result whose value sequence is
 * missing a base DN element.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testGetAccessibilityValueSequenceMissingBaseDN() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Enumerated((byte) 0x81, 1), new ASN1OctetString((byte) 0x82, "uid=bypass,dc=example,dc=com"), new ASN1OctetString((byte) 0x83, "20120101012345.678Z"));
    new GetSubtreeAccessibilityExtendedResult(new ExtendedResult(1234, ResultCode.OTHER, null, null, null, GetSubtreeAccessibilityExtendedResult.GET_SUBTREE_ACCESSIBILITY_RESULT_OID, new ASN1OctetString(new ASN1Sequence(valueSequence).encode()), null));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ExtendedResult(com.unboundid.ldap.sdk.ExtendedResult) Test(org.testng.annotations.Test)

Example 8 with ASN1Enumerated

use of com.github.zhenwei.core.asn1.ASN1Enumerated in project ldapsdk by pingidentity.

the class GetConfigurationExtendedResultTestCase method testDecodeInvalidConfigType.

/**
 * Tests the behavior when trying to decode a result whose value sequence
 * recognizes an unexpected configuration type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeInvalidConfigType() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Enumerated((byte) 0x80, 123), new ASN1OctetString((byte) 0x81, "config.ldif"), new ASN1OctetString((byte) 0x82, TEST_CONFIG_FILE_BYTES));
    new GetConfigurationExtendedResult(new ExtendedResult(123, ResultCode.SUCCESS, null, null, null, "1.3.6.1.4.1.30221.2.6.29", new ASN1OctetString(valueSequence.encode()), null));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ExtendedResult(com.unboundid.ldap.sdk.ExtendedResult) Test(org.testng.annotations.Test)

Example 9 with ASN1Enumerated

use of com.github.zhenwei.core.asn1.ASN1Enumerated in project ldapsdk by pingidentity.

the class GetSubtreeAccessibilityExtendedResultTestCase method testGetAccessibilityValueSequenceMissingEffectiveTime.

/**
 * Tests the behavior when trying to decode a result whose value sequence has
 * an invalid accessibility state element.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testGetAccessibilityValueSequenceMissingEffectiveTime() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x80, "ou=subtree,dc=example,dc=com"), new ASN1Enumerated((byte) 0x81, 1), new ASN1OctetString((byte) 0x82, "uid=bypass,dc=example,dc=com"));
    new GetSubtreeAccessibilityExtendedResult(new ExtendedResult(1234, ResultCode.OTHER, null, null, null, GetSubtreeAccessibilityExtendedResult.GET_SUBTREE_ACCESSIBILITY_RESULT_OID, new ASN1OctetString(new ASN1Sequence(valueSequence).encode()), null));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ExtendedResult(com.unboundid.ldap.sdk.ExtendedResult) Test(org.testng.annotations.Test)

Example 10 with ASN1Enumerated

use of com.github.zhenwei.core.asn1.ASN1Enumerated in project ldapsdk by pingidentity.

the class MultiUpdateExtendedRequestTestCase method testDecodeInvalidErrorBehavior.

/**
 * Tests the behavior when trying to decode a multi-update extended request
 * that contains an invalid error behavior value.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeInvalidErrorBehavior() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Enumerated(1234), new ASN1Sequence(new ASN1Sequence(new ASN1OctetString(LDAPMessage.PROTOCOL_OP_TYPE_DELETE_REQUEST, "uid=test.user,ou=People,dc=example,dc=com"))));
    new MultiUpdateExtendedRequest(new ExtendedRequest(MultiUpdateExtendedRequest.MULTI_UPDATE_REQUEST_OID, new ASN1OctetString(valueSequence.encode())));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ExtendedRequest(com.unboundid.ldap.sdk.ExtendedRequest) PasswordModifyExtendedRequest(com.unboundid.ldap.sdk.extensions.PasswordModifyExtendedRequest) Test(org.testng.annotations.Test)

Aggregations

ASN1Enumerated (com.unboundid.asn1.ASN1Enumerated)95 ASN1Sequence (com.unboundid.asn1.ASN1Sequence)95 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)92 Test (org.testng.annotations.Test)62 ASN1Element (com.unboundid.asn1.ASN1Element)59 ArrayList (java.util.ArrayList)32 NotNull (com.unboundid.util.NotNull)30 ASN1Integer (com.unboundid.asn1.ASN1Integer)21 ExtendedRequest (com.unboundid.ldap.sdk.ExtendedRequest)15 ASN1Boolean (com.unboundid.asn1.ASN1Boolean)12 IOException (java.io.IOException)12 ASN1Set (com.unboundid.asn1.ASN1Set)11 Control (com.unboundid.ldap.sdk.Control)9 ASN1Enumerated (org.bouncycastle.asn1.ASN1Enumerated)9 ASN1Enumerated (com.github.zhenwei.core.asn1.ASN1Enumerated)6 ExtendedResult (com.unboundid.ldap.sdk.ExtendedResult)6 DEROctetString (org.bouncycastle.asn1.DEROctetString)6 DERSequence (org.bouncycastle.asn1.DERSequence)6 IntermediateResponse (com.unboundid.ldap.sdk.IntermediateResponse)5 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)5