Search in sources :

Example 1 with ASN1BufferSequence

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

the class LDAPMessageTestCase method testReadLDAPResponseFromInvalidControlElementType.

/**
 * Tests the behavior when trying to read a result containing a control with
 * an invalid element type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testReadLDAPResponseFromInvalidControlElementType() 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.addInteger(5);
    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 2 with ASN1BufferSequence

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

the class LDAPMessageTestCase method testReadLDAPResponseFromInvalidResult.

/**
 * Tests the behavior when trying to read an invalid result.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testReadLDAPResponseFromInvalidResult() throws Exception {
    ASN1Buffer b = new ASN1Buffer();
    ASN1BufferSequence msgSequence = b.beginSequence();
    b.addInteger(1);
    ASN1BufferSequence opSequence = b.beginSequence(LDAPMessage.PROTOCOL_OP_TYPE_ADD_RESPONSE);
    b.addOctetString();
    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 3 with ASN1BufferSequence

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

the class ModifyRequestProtocolOpTestCase method testDecodeRequestMalformedAttr.

/**
 * Tests the behavior when trying to decode a modify request with a malformed
 * modification list.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeRequestMalformedAttr() throws Exception {
    ASN1Buffer b = new ASN1Buffer();
    ASN1BufferSequence opSequence = b.beginSequence((byte) 0x66);
    b.addOctetString("dc=example,dc=com");
    ASN1BufferSequence attrsSequence = b.beginSequence();
    b.addOctetString();
    attrsSequence.end();
    opSequence.end();
    byte[] requestBytes = b.toByteArray();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(requestBytes);
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    new ModifyRequestProtocolOp(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 4 with ASN1BufferSequence

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

the class SearchResultEntryProtocolOpTestCase method testDecodeRequestMalformedAttr.

/**
 * Tests the behavior when trying to decode a search result entry with a
 * malformed attribute list.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeRequestMalformedAttr() throws Exception {
    ASN1Buffer b = new ASN1Buffer();
    ASN1BufferSequence opSequence = b.beginSequence((byte) 0x64);
    b.addOctetString("dc=example,dc=com");
    ASN1BufferSequence attrsSequence = b.beginSequence();
    b.addOctetString();
    attrsSequence.end();
    opSequence.end();
    byte[] requestBytes = b.toByteArray();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(requestBytes);
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    new SearchResultEntryProtocolOp(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 5 with ASN1BufferSequence

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

the class AddRequestProtocolOpTestCase method testDecodeRequestMalformedAttr.

/**
 * Tests the behavior when trying to decode an add request with a malformed
 * attribute list.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeRequestMalformedAttr() throws Exception {
    ASN1Buffer b = new ASN1Buffer();
    ASN1BufferSequence opSequence = b.beginSequence((byte) 0x68);
    b.addOctetString("dc=example,dc=com");
    ASN1BufferSequence attrsSequence = b.beginSequence();
    b.addOctetString();
    attrsSequence.end();
    opSequence.end();
    byte[] requestBytes = b.toByteArray();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(requestBytes);
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    new AddRequestProtocolOp(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)

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