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