use of com.unboundid.asn1.ASN1Buffer in project ldapsdk by pingidentity.
the class BindRequestProtocolOpTestCase method testBindRequestProtocolOpSASLWithCredentials.
/**
* Provides test coverage for the constructor which takes a SASL mechanism
* and credentials.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testBindRequestProtocolOpSASLWithCredentials() throws Exception {
BindRequestProtocolOp op = new BindRequestProtocolOp(null, "PLAIN", new ASN1OctetString("\u0000u:test.user\u00000password"));
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());
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(), "PLAIN");
assertNotNull(op.getSASLCredentials());
assertEquals(op.getProtocolOpType(), (byte) 0x60);
assertNotNull(op.toString());
}
use of com.unboundid.asn1.ASN1Buffer in project ldapsdk by pingidentity.
the class BindRequestProtocolOpTestCase method testBindRequestProtocolOpSimpleBinaryPasswordAnonymous.
/**
* Provides test coverage for the constructor which takes a string DN and a
* binary password.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testBindRequestProtocolOpSimpleBinaryPasswordAnonymous() throws Exception {
BindRequestProtocolOp op = new BindRequestProtocolOp(null, (byte[]) null);
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((SimpleBindRequest) op.toBindRequest());
assertEquals(op.getVersion(), 3);
assertEquals(new DN(op.getBindDN()), DN.NULL_DN);
assertEquals(op.getCredentialsType(), BindRequestProtocolOp.CRED_TYPE_SIMPLE);
assertEquals(op.getSimplePassword().stringValue(), "");
assertNull(op.getSASLMechanism());
assertNull(op.getSASLCredentials());
assertEquals(op.getProtocolOpType(), (byte) 0x60);
assertNotNull(op.toString());
}
use of com.unboundid.asn1.ASN1Buffer in project ldapsdk by pingidentity.
the class BindRequestProtocolOpTestCase method testBindRequestProtocolOpSimpleBinaryPassword.
/**
* Provides test coverage for the constructor which takes a string DN and a
* binary password.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testBindRequestProtocolOpSimpleBinaryPassword() throws Exception {
BindRequestProtocolOp op = new BindRequestProtocolOp("uid=test.user,ou=People,dc=example,dc=com", "password".getBytes());
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((SimpleBindRequest) op.toBindRequest());
assertEquals(op.getVersion(), 3);
assertEquals(new DN(op.getBindDN()), new DN("uid=test.user,ou=People,dc=example,dc=com"));
assertEquals(op.getCredentialsType(), BindRequestProtocolOp.CRED_TYPE_SIMPLE);
assertEquals(op.getSimplePassword().stringValue(), "password");
assertNull(op.getSASLMechanism());
assertNull(op.getSASLCredentials());
assertEquals(op.getProtocolOpType(), (byte) 0x60);
assertNotNull(op.toString());
}
use of com.unboundid.asn1.ASN1Buffer in project ldapsdk by pingidentity.
the class BindRequestProtocolOpTestCase method testBindRequestProtocolOpSimpleStringPasswordAnonymous.
/**
* Provides test coverage for the constructor which takes a string DN and a
* string password with an anonymous bind.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testBindRequestProtocolOpSimpleStringPasswordAnonymous() throws Exception {
BindRequestProtocolOp op = new BindRequestProtocolOp(null, (String) null);
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((SimpleBindRequest) op.toBindRequest());
assertEquals(op.getVersion(), 3);
assertEquals(new DN(op.getBindDN()), DN.NULL_DN);
assertEquals(op.getCredentialsType(), BindRequestProtocolOp.CRED_TYPE_SIMPLE);
assertEquals(op.getSimplePassword().stringValue(), "");
assertNull(op.getSASLMechanism());
assertNull(op.getSASLCredentials());
assertEquals(op.getProtocolOpType(), (byte) 0x60);
assertNotNull(op.toString());
}
use of com.unboundid.asn1.ASN1Buffer in project ldapsdk by pingidentity.
the class BindRequestProtocolOpTestCase method testReadMalformedRequest.
/**
* Tests the behavior when attempting to read a malformed bind request
* protocol op.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testReadMalformedRequest() throws Exception {
ASN1Buffer b = new ASN1Buffer();
ASN1BufferSequence s = b.beginSequence((byte) 0x60);
b.addOctetString();
s.end();
ByteArrayInputStream inputStream = new ByteArrayInputStream(b.toByteArray());
ASN1StreamReader reader = new ASN1StreamReader(inputStream);
new BindRequestProtocolOp(reader);
}
Aggregations