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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations