Search in sources :

Example 76 with ASN1StreamReader

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

the class SearchResultDoneProtocolOpTestCase method testReadMalformedSearchResultDone.

/**
 * Tests the behavior when trying to read a malformed search result done.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testReadMalformedSearchResultDone() throws Exception {
    byte[] opBytes = { 0x65, 0x00 };
    ByteArrayInputStream inputStream = new ByteArrayInputStream(opBytes);
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    new SearchResultDoneProtocolOp(reader);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Example 77 with ASN1StreamReader

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

the class SearchResultReferenceProtocolOpTestCase method testReadMalformedRequest.

/**
 * Tests the behavior when trying to read a malformed search result
 * reference.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testReadMalformedRequest() throws Exception {
    byte[] requestBytes = { (byte) 0x73 };
    ByteArrayInputStream inputStream = new ByteArrayInputStream(requestBytes);
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    new SearchResultReferenceProtocolOp(reader);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Example 78 with ASN1StreamReader

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

the class UnbindRequestProtocolOpTestCase method testUnbindRequestProtocolOp.

/**
 * Provides test coverage for the unbind request protocol op.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testUnbindRequestProtocolOp() throws Exception {
    UnbindRequestProtocolOp op = new UnbindRequestProtocolOp();
    ASN1Buffer buffer = new ASN1Buffer();
    op.writeTo(buffer);
    byte[] opBytes = buffer.toByteArray();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(opBytes);
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    op = new UnbindRequestProtocolOp(reader);
    op = UnbindRequestProtocolOp.decodeProtocolOp(op.encodeProtocolOp());
    assertEquals(op.getProtocolOpType(), (byte) 0x42);
    assertNotNull(op.toString());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1Buffer(com.unboundid.asn1.ASN1Buffer) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Example 79 with ASN1StreamReader

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

the class CompareResponseProtocolOpTestCase method testReadMalformedCompareResponse.

/**
 * Tests the behavior when trying to read a malformed compare response.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testReadMalformedCompareResponse() throws Exception {
    byte[] opBytes = { 0x6F, 0x00 };
    ByteArrayInputStream inputStream = new ByteArrayInputStream(opBytes);
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    new CompareResponseProtocolOp(reader);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Example 80 with ASN1StreamReader

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

the class DeleteRequestProtocolOpTestCase method testReadMalformedRequest.

/**
 * Tests the behavior when trying to read a malformed delete request.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(expectedExceptions = { LDAPException.class })
public void testReadMalformedRequest() throws Exception {
    byte[] requestBytes = { (byte) 0x4A };
    ByteArrayInputStream inputStream = new ByteArrayInputStream(requestBytes);
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    new DeleteRequestProtocolOp(reader);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Aggregations

ASN1StreamReader (com.unboundid.asn1.ASN1StreamReader)121 ByteArrayInputStream (java.io.ByteArrayInputStream)114 Test (org.testng.annotations.Test)114 ASN1Buffer (com.unboundid.asn1.ASN1Buffer)91 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)31 LinkedList (java.util.LinkedList)28 ASN1BufferSequence (com.unboundid.asn1.ASN1BufferSequence)22 DN (com.unboundid.ldap.sdk.DN)21 Control (com.unboundid.ldap.sdk.Control)18 NotNull (com.unboundid.util.NotNull)13 ASN1StreamReaderSequence (com.unboundid.asn1.ASN1StreamReaderSequence)11 ArrayList (java.util.ArrayList)10 ASN1Exception (com.unboundid.asn1.ASN1Exception)8 IOException (java.io.IOException)8 LDAPException (com.unboundid.ldap.sdk.LDAPException)5 InterruptedIOException (java.io.InterruptedIOException)5 SocketTimeoutException (java.net.SocketTimeoutException)5 Attribute (com.unboundid.ldap.sdk.Attribute)4 SSLSocket (javax.net.ssl.SSLSocket)4 ASN1Element (com.unboundid.asn1.ASN1Element)3