Search in sources :

Example 6 with ASN1BufferSequence

use of com.unboundid.asn1.ASN1BufferSequence in project ldapsdk by pingidentity.

the class ExtendedResponseProtocolOpTestCase method testReadExtendedResponseInvalidElementType.

/**
 * Tests the behavior when trying to read an extended response with an
 * invalid element type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testReadExtendedResponseInvalidElementType() throws Exception {
    ASN1Buffer b = new ASN1Buffer((byte) 0x78);
    ASN1BufferSequence s = b.beginSequence();
    b.addEnumerated(0);
    b.addOctetString();
    b.addOctetString();
    b.addOctetString((byte) 0x80);
    s.end();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(b.toByteArray());
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    new ExtendedResponseProtocolOp(reader);
}
Also used : ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence) ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1Buffer(com.unboundid.asn1.ASN1Buffer) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Example 7 with ASN1BufferSequence

use of com.unboundid.asn1.ASN1BufferSequence in project ldapsdk by pingidentity.

the class IntermediateResponseProtocolOpTestCase method testReadInvalidElementType.

/**
 * Tests the behavior when trying to read an intermediate response with an
 * invalid element type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testReadInvalidElementType() throws Exception {
    ASN1Buffer b = new ASN1Buffer();
    ASN1BufferSequence s = b.beginSequence((byte) 0x79);
    b.addOctetString((byte) 0x99);
    s.end();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(b.toByteArray());
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    new IntermediateResponseProtocolOp(reader);
}
Also used : ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence) ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1Buffer(com.unboundid.asn1.ASN1Buffer) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Example 8 with ASN1BufferSequence

use of com.unboundid.asn1.ASN1BufferSequence in project ldapsdk by pingidentity.

the class LDAPMessageTestCase method testReadLDAPResponseFromMalformedControl.

/**
 * Tests the behavior when trying to read a result containing a malformed
 * control.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testReadLDAPResponseFromMalformedControl() throws Exception {
    ASN1Buffer b = new ASN1Buffer();
    ASN1BufferSequence msgSequence = b.beginSequence();
    b.addInteger(1);
    ASN1BufferSequence opSequence = b.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_ADD_RESPONSE);
    b.addEnumerated(0);
    b.addOctetString();
    b.addOctetString();
    opSequence.end();
    ASN1BufferSequence controlsSequence = b.beginSequence();
    ASN1BufferSequence controlSequence = b.beginSequence();
    b.addOctetString("1.2.3.4");
    b.addOctetString((byte) 0x01);
    controlSequence.end();
    controlsSequence.end();
    msgSequence.end();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(b.toByteArray());
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    LDAPMessage.readLDAPResponseFrom(reader, true);
}
Also used : ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence) ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1Buffer(com.unboundid.asn1.ASN1Buffer) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Example 9 with ASN1BufferSequence

use of com.unboundid.asn1.ASN1BufferSequence in project ldapsdk by pingidentity.

the class SearchResultEntryTestCase method testReadSearchEntryFromMalformedAttribute.

/**
 * Tests the {@code readBindResultFrom} method with an element containing
 * a response sequence with a malformed attribute.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testReadSearchEntryFromMalformedAttribute() throws Exception {
    ASN1Buffer b = new ASN1Buffer();
    ASN1BufferSequence msgSequence = b.beginSequence();
    b.addInteger(1);
    ASN1BufferSequence opSequence = b.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_SEARCH_RESULT_ENTRY);
    b.addOctetString("dc=example,dc=com");
    ASN1BufferSequence attrSequence = b.beginSequence();
    b.addEnumerated(1);
    attrSequence.end();
    opSequence.end();
    msgSequence.end();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(b.toByteArray());
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    LDAPMessage.readLDAPResponseFrom(reader, true);
}
Also used : ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence) ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1Buffer(com.unboundid.asn1.ASN1Buffer) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Example 10 with ASN1BufferSequence

use of com.unboundid.asn1.ASN1BufferSequence in project ldapsdk by pingidentity.

the class SearchResultEntryTestCase method testReadSearchEntryFromTooShort.

/**
 * Tests the {@code readSearchEntryFrom} method with an element containing
 * a response sequence that is too short.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testReadSearchEntryFromTooShort() throws Exception {
    ASN1Buffer b = new ASN1Buffer();
    ASN1BufferSequence msgSequence = b.beginSequence();
    b.addInteger(1);
    ASN1BufferSequence opSequence = b.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_SEARCH_RESULT_ENTRY);
    b.addOctetString("dc=example,dc=com");
    opSequence.end();
    msgSequence.end();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(b.toByteArray());
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    LDAPMessage.readLDAPResponseFrom(reader, true);
}
Also used : ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence) ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1Buffer(com.unboundid.asn1.ASN1Buffer) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Aggregations

ASN1BufferSequence (com.unboundid.asn1.ASN1BufferSequence)47 ASN1Buffer (com.unboundid.asn1.ASN1Buffer)22 ASN1StreamReader (com.unboundid.asn1.ASN1StreamReader)22 ByteArrayInputStream (java.io.ByteArrayInputStream)22 Test (org.testng.annotations.Test)22 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)9 ASN1BufferSet (com.unboundid.asn1.ASN1BufferSet)3 Attribute (com.unboundid.ldap.sdk.Attribute)2 ASN1Element (com.unboundid.asn1.ASN1Element)1 Control (com.unboundid.ldap.sdk.Control)1 Modification (com.unboundid.ldap.sdk.Modification)1 JSONObjectFilter (com.unboundid.ldap.sdk.unboundidds.jsonfilter.JSONObjectFilter)1