Search in sources :

Example 36 with ASN1Sequence

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

the class GetChangelogBatchExtendedResultTestCase method testDecodeMissingResumeToken.

/**
 * Tests the behavior when attempting to decode an instance of the extended
 * result with a value sequence that is missing a resume token.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testDecodeMissingResumeToken() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Boolean((byte) 0x81, true));
    final GetChangelogBatchExtendedResult r = new GetChangelogBatchExtendedResult(new ExtendedResult(1, ResultCode.SUCCESS, null, null, null, null, new ASN1OctetString(valueSequence.encode()), null), -1);
    assertTrue(r.hasValue());
    assertNotNull(r.getValue());
    assertNull(r.getResumeToken());
    assertTrue(r.moreChangesAvailable());
    assertFalse(r.changesAlreadyPurged());
    assertNull(r.getAdditionalInfo());
    assertEquals(r.getEntryCount(), -1);
    assertNull(r.getChangelogEntries());
    assertNotNull(r.getExtendedResultName());
    assertNotNull(r.toString());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ExtendedResult(com.unboundid.ldap.sdk.ExtendedResult) ASN1Boolean(com.unboundid.asn1.ASN1Boolean) Test(org.testng.annotations.Test)

Example 37 with ASN1Sequence

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

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

the class GetSubtreeAccessibilityExtendedResultTestCase method testGetAccessibilityValueSequenceInvalidElementType.

/**
 * Tests the behavior when trying to decode a result whose value sequence has
 * an invalid element type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testGetAccessibilityValueSequenceInvalidElementType() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString("invalid type"));
    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) ExtendedResult(com.unboundid.ldap.sdk.ExtendedResult) Test(org.testng.annotations.Test)

Example 39 with ASN1Sequence

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

the class GetSupportedOTPDeliveryMechanismsExtendedResultTestCase method testDecodeMalformedDeliveryMechanismInfo.

/**
 * Tests the behavior when trying to decode an extended result whose
 * value contains a malformed delivery mechanism info object.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeMalformedDeliveryMechanismInfo() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Sequence(new ASN1OctetString((byte) 0x80, "foo"), new ASN1OctetString((byte) 0x12, "bar"), new ASN1OctetString((byte) 0x56, "baz")));
    new GetSupportedOTPDeliveryMechanismsExtendedResult(new ExtendedResult(1234, ResultCode.SUCCESS, null, null, null, "1.3.6.1.4.1.30221.2.6.48", new ASN1OctetString(valueSequence.encode()), null));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ExtendedResult(com.unboundid.ldap.sdk.ExtendedResult) Test(org.testng.annotations.Test)

Example 40 with ASN1Sequence

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

the class IdentifyBackupCompatibilityProblemsExtendedResultTestCase method testDecodeValueSequenceUnexpectedType.

/**
 * Tests the behavior when trying to decode an extended result in which the
 * value sequence has an element with an unexpected type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueSequenceUnexpectedType() throws Exception {
    final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString((byte) 123, "foo"));
    final ExtendedResult r = new ExtendedResult(-1, ResultCode.SUCCESS, null, null, null, "1.3.6.1.4.1.30221.2.6.31", new ASN1OctetString(valueSequence.encode()), null);
    new IdentifyBackupCompatibilityProblemsExtendedResult(r);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ExtendedResult(com.unboundid.ldap.sdk.ExtendedResult) Test(org.testng.annotations.Test)

Aggregations

ASN1Sequence (com.unboundid.asn1.ASN1Sequence)455 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)397 Test (org.testng.annotations.Test)311 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)297 ASN1Element (com.unboundid.asn1.ASN1Element)231 ArrayList (java.util.ArrayList)184 IOException (java.io.IOException)141 NotNull (com.unboundid.util.NotNull)116 ASN1Enumerated (com.unboundid.asn1.ASN1Enumerated)95 ASN1Integer (com.unboundid.asn1.ASN1Integer)94 ASN1Sequence (com.github.zhenwei.core.asn1.ASN1Sequence)85 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)76 ASN1InputStream (org.bouncycastle.asn1.ASN1InputStream)73 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)69 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)64 ASN1Primitive (org.bouncycastle.asn1.ASN1Primitive)57 Enumeration (java.util.Enumeration)54 ASN1Boolean (com.unboundid.asn1.ASN1Boolean)53 X509Certificate (java.security.cert.X509Certificate)53 BigInteger (java.math.BigInteger)50