Search in sources :

Example 56 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class IntegerMatchingRuleTestCase method testNormalizeSubstring.

/**
 * Tests to ensure that the normalizeSubstring method will always throw an
 * exception.
 *
 * @param  valueStr  The string representation of the value.
 * @param  bigInt    The parsed value.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(dataProvider = "validValues", expectedExceptions = { LDAPException.class })
public void testNormalizeSubstring(String valueStr, BigInteger bigInt) throws Exception {
    IntegerMatchingRule mr = IntegerMatchingRule.getInstance();
    mr.normalizeSubstring(new ASN1OctetString(valueStr), (byte) 0x80);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 57 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class BindRequestProtocolOpTestCase method testBindRequestProtocolOpGenericSASLMechanism.

/**
 * Provides test coverage for the bind request protocol op when using a
 * generic SASL bind request.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testBindRequestProtocolOpGenericSASLMechanism() throws Exception {
    BindRequestProtocolOp op = new BindRequestProtocolOp("", "TEST", new ASN1OctetString(BindRequestProtocolOp.CRED_TYPE_SASL, "foo"));
    ASN1Buffer buffer = new ASN1Buffer();
    op.writeTo(buffer);
    byte[] opBytes = buffer.toByteArray();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(opBytes);
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    op = new BindRequestProtocolOp(reader);
    op = BindRequestProtocolOp.decodeProtocolOp(op.encodeProtocolOp());
    op = new BindRequestProtocolOp((GenericSASLBindRequest) op.toBindRequest());
    assertEquals(op.getVersion(), 3);
    assertNotNull(op.getBindDN());
    assertEquals(op.getBindDN(), "");
    assertEquals(op.getCredentialsType(), BindRequestProtocolOp.CRED_TYPE_SASL);
    assertNull(op.getSimplePassword());
    assertNotNull(op.getSASLMechanism());
    assertEquals(op.getSASLMechanism(), "TEST");
    assertNotNull(op.getSASLCredentials());
    assertEquals(op.getSASLCredentials().stringValue(), "foo");
    assertEquals(op.getProtocolOpType(), (byte) 0x60);
    assertNotNull(op.toString());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1Buffer(com.unboundid.asn1.ASN1Buffer) GenericSASLBindRequest(com.unboundid.ldap.sdk.GenericSASLBindRequest) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Example 58 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class BindResponseProtocolOpTestCase method testBindResponseProtocolOpSuccess.

/**
 * Provides test coverage for the bind response protocol op for a success
 * response, including server SASL credentials.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testBindResponseProtocolOpSuccess() throws Exception {
    BindResponseProtocolOp op = new BindResponseProtocolOp(0, null, null, null, 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 BindResponseProtocolOp(reader);
    op = BindResponseProtocolOp.decodeProtocolOp(op.encodeProtocolOp());
    op = new BindResponseProtocolOp(op.toBindResult());
    assertEquals(op.getResultCode(), 0);
    assertNull(op.getMatchedDN());
    assertNull(op.getDiagnosticMessage());
    assertNotNull(op.getReferralURLs());
    assertTrue(op.getReferralURLs().isEmpty());
    assertNotNull(op.getServerSASLCredentials());
    assertEquals(op.getServerSASLCredentials().getValue().length, 0);
    assertEquals(op.getProtocolOpType(), (byte) 0x61);
    assertNotNull(op.toString());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1Buffer(com.unboundid.asn1.ASN1Buffer) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Example 59 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class CompareRequestProtocolOpTestCase method testCompareRequestProtocolOp.

/**
 * Provides test coverage for the compare request protocol op.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testCompareRequestProtocolOp() throws Exception {
    CompareRequestProtocolOp op = new CompareRequestProtocolOp("dc=example,dc=com", "dc", new ASN1OctetString("example"));
    ASN1Buffer buffer = new ASN1Buffer();
    op.writeTo(buffer);
    byte[] opBytes = buffer.toByteArray();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(opBytes);
    ASN1StreamReader reader = new ASN1StreamReader(inputStream);
    op = new CompareRequestProtocolOp(reader);
    op = CompareRequestProtocolOp.decodeProtocolOp(op.encodeProtocolOp());
    op = new CompareRequestProtocolOp(op.toCompareRequest());
    assertEquals(new DN(op.getDN()), new DN("dc=example,dc=com"));
    assertNotNull(op.getAttributeName());
    assertEquals(op.getAttributeName(), "dc");
    assertNotNull(op.getAssertionValue());
    assertEquals(op.getAssertionValue().stringValue(), "example");
    assertEquals(op.getProtocolOpType(), (byte) 0x6E);
    assertNotNull(op.toString());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1Buffer(com.unboundid.asn1.ASN1Buffer) DN(com.unboundid.ldap.sdk.DN) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Example 60 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString 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());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1Buffer(com.unboundid.asn1.ASN1Buffer) ASN1StreamReader(com.unboundid.asn1.ASN1StreamReader) Test(org.testng.annotations.Test)

Aggregations

ASN1OctetString (com.unboundid.asn1.ASN1OctetString)1173 Test (org.testng.annotations.Test)852 ASN1Sequence (com.unboundid.asn1.ASN1Sequence)382 Control (com.unboundid.ldap.sdk.Control)310 ASN1Element (com.unboundid.asn1.ASN1Element)237 ArrayList (java.util.ArrayList)204 NotNull (com.unboundid.util.NotNull)191 LDAPException (com.unboundid.ldap.sdk.LDAPException)142 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)133 ExtendedResult (com.unboundid.ldap.sdk.ExtendedResult)99 ASN1Enumerated (com.unboundid.asn1.ASN1Enumerated)92 IOException (java.io.IOException)88 ASN1Integer (com.unboundid.asn1.ASN1Integer)80 ExtendedRequest (com.unboundid.ldap.sdk.ExtendedRequest)69 DN (com.unboundid.ldap.sdk.DN)65 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)64 ByteArrayInputStream (java.io.ByteArrayInputStream)56 AuthorizationIdentityRequestControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl)53 ASN1Boolean (com.unboundid.asn1.ASN1Boolean)52 AuthorizationIdentityResponseControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityResponseControl)49