use of com.unboundid.asn1.ASN1StreamReader in project ldapsdk by pingidentity.
the class ExtendedResponseProtocolOpTestCase method testReadMalformedExtendedResponse.
/**
* Tests the behavior when trying to read a malformed extended response.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testReadMalformedExtendedResponse() throws Exception {
byte[] opBytes = { 0x78, 0x00 };
ByteArrayInputStream inputStream = new ByteArrayInputStream(opBytes);
ASN1StreamReader reader = new ASN1StreamReader(inputStream);
new ExtendedResponseProtocolOp(reader);
}
use of com.unboundid.asn1.ASN1StreamReader in project ldapsdk by pingidentity.
the class ExtendedResponseProtocolOpTestCase method testExtendedResponseProtocolOpSuccess.
/**
* Provides test coverage for the extended response protocol op for a success
* response, including OID and value.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testExtendedResponseProtocolOpSuccess() throws Exception {
ExtendedResponseProtocolOp op = new ExtendedResponseProtocolOp(0, null, null, null, "1.2.3.4", new ASN1OctetString());
ASN1Buffer buffer = new ASN1Buffer();
op.writeTo(buffer);
byte[] opBytes = buffer.toByteArray();
ByteArrayInputStream inputStream = new ByteArrayInputStream(opBytes);
ASN1StreamReader reader = new ASN1StreamReader(inputStream);
op = new ExtendedResponseProtocolOp(reader);
op = ExtendedResponseProtocolOp.decodeProtocolOp(op.encodeProtocolOp());
op = new ExtendedResponseProtocolOp(op.toExtendedResult());
assertEquals(op.getResultCode(), 0);
assertNull(op.getMatchedDN());
assertNull(op.getDiagnosticMessage());
assertNotNull(op.getReferralURLs());
assertTrue(op.getReferralURLs().isEmpty());
assertNotNull(op.getResponseOID());
assertEquals(op.getResponseOID(), "1.2.3.4");
assertNotNull(op.getResponseValue());
assertEquals(op.getResponseValue().getValue().length, 0);
assertEquals(op.getProtocolOpType(), (byte) 0x78);
assertNotNull(op.toString());
}
use of com.unboundid.asn1.ASN1StreamReader 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.ASN1StreamReader 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.ASN1StreamReader in project ldapsdk by pingidentity.
the class IntermediateResponseProtocolOpTestCase method testReadMalformedResponse.
/**
* Tests the behavior when trying to read a malformed intermediate response.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testReadMalformedResponse() throws Exception {
byte[] requestBytes = { (byte) 0x79 };
ByteArrayInputStream inputStream = new ByteArrayInputStream(requestBytes);
ASN1StreamReader reader = new ASN1StreamReader(inputStream);
new IntermediateResponseProtocolOp(reader);
}
Aggregations