use of org.apache.directory.api.asn1.ber.Asn1Container in project directory-ldap-api by apache.
the class LdapResultTest method testDecodeAddResponseEmptyResultCodesOK.
/**
* Test the decoding of a AddResponse with all the different result codes
*/
@Test
public void testDecodeAddResponseEmptyResultCodesOK() {
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(0x0E);
byte[] buffer = new byte[] { // LDAPMessage ::=SEQUENCE {
0x30, // LDAPMessage ::=SEQUENCE {
0x0C, 0x02, 0x01, // messageID MessageID
0x01, 0x69, // CHOICE { ..., addResponse AddResponse, ...
0x07, 0x0A, 0x01, // resultCode success
0x00, 0x04, // matchedDN LDAPDN,
0x00, 0x04, // errorMessage LDAPString,
0x00 };
for (int i = 0; i < 91; i++) {
buffer[9] = (byte) i;
stream.put(buffer);
stream.flip();
// Allocate a LdapMessage Container
Asn1Container ldapMessageContainer = new LdapMessageContainer<MessageDecorator<? extends Message>>(codec);
// Decode a AddResponse PDU
try {
ldapDecoder.decode(stream, ldapMessageContainer);
} catch (DecoderException de) {
fail("We should never reach this point");
}
stream.clear();
}
assertTrue(true);
}
use of org.apache.directory.api.asn1.ber.Asn1Container in project directory-ldap-api by apache.
the class LdapResultTest method testDecodeAddResponseEmptyResultCodeNoErrorMsg.
/**
* Test the decoding of a AddResponse with no error message
*/
@Test
public void testDecodeAddResponseEmptyResultCodeNoErrorMsg() {
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(0x0C);
stream.put(new byte[] { // LDAPMessage ::=SEQUENCE {
0x30, // LDAPMessage ::=SEQUENCE {
0x0A, 0x02, 0x01, // messageID MessageID
0x01, 0x69, // CHOICE { ..., addResponse AddResponse, ...
0x05, 0x0A, 0x01, // resultCode success
0x00, 0x04, // Empty matched Dn
0x00 });
stream.flip();
// Allocate a LdapMessage Container
Asn1Container ldapMessageContainer = new LdapMessageContainer<MessageDecorator<? extends Message>>(codec);
// Decode a AddResponse message
try {
ldapDecoder.decode(stream, ldapMessageContainer);
} catch (DecoderException de) {
assertTrue(true);
return;
}
fail("We should not reach this point");
}
use of org.apache.directory.api.asn1.ber.Asn1Container in project directory-ldap-api by apache.
the class AddRequestTest method testDecodeAddRequestNullAttributes.
/**
* Test the decoding of a AddRequest with a null attributeList
*/
@Test
public void testDecodeAddRequestNullAttributes() {
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(0x2B);
stream.put(new byte[] { 0x30, // LDAPMessage ::= SEQUENCE {
0x29, 0x02, 0x01, // messageID MessageID
0x01, 0x68, // CHOICE { ..., addRequest AddRequest, ...
0x24, // entry LDAPDN,
0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u', 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', // attributes AttributeList }
0x30, // AttributeList ::= SEQUENCE OF SEQUENCE {
0x00 });
stream.flip();
// Allocate a LdapMessage Container
Asn1Container ldapMessageContainer = new LdapMessageContainer<MessageDecorator<? extends Message>>(codec);
// Decode a AddRequest message
try {
ldapDecoder.decode(stream, ldapMessageContainer);
} catch (DecoderException de) {
assertTrue(true);
return;
}
fail("We should not reach this point");
}
use of org.apache.directory.api.asn1.ber.Asn1Container in project directory-ldap-api by apache.
the class AddRequestTest method testDecodeAddRequestNoVals.
/**
* Test the decoding of a AddRequest with a empty attributeList
*/
@Test
public void testDecodeAddRequestNoVals() {
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(0x30);
stream.put(new byte[] { 0x30, // LDAPMessage ::= SEQUENCE {
0x2E, 0x02, 0x01, // messageID MessageID
0x01, 0x68, // CHOICE { ..., addRequest AddRequest, ...
0x29, // entry LDAPDN,
0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u', 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', // attributes AttributeList }
0x30, // AttributeList ::= SEQUENCE OF SEQUENCE {
0x05, 0x30, // attribute 1
0x03, 0x04, 0x01, // type AttributeDescription,
'A' });
stream.flip();
// Allocate a LdapMessage Container
Asn1Container ldapMessageContainer = new LdapMessageContainer<MessageDecorator<? extends Message>>(codec);
// Decode a AddRequest message
try {
ldapDecoder.decode(stream, ldapMessageContainer);
} catch (DecoderException de) {
assertTrue(true);
return;
}
fail("We should not reach this point");
}
use of org.apache.directory.api.asn1.ber.Asn1Container in project directory-ldap-api by apache.
the class AddRequestTest method testDecodeAddRequestNullAttributeList.
/**
* Test the decoding of a AddRequest with a empty attributeList
*/
@Test
public void testDecodeAddRequestNullAttributeList() {
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(0x2D);
stream.put(new byte[] { 0x30, // LDAPMessage ::= SEQUENCE {
0x2B, 0x02, 0x01, // messageID MessageID
0x01, 0x68, // CHOICE { ..., addRequest AddRequest, ...
0x26, // entry LDAPDN,
0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u', 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', // attributes AttributeList }
0x30, // AttributeList ::= SEQUENCE OF SEQUENCE {
0x02, 0x30, // AttributeList ::= SEQUENCE OF SEQUENCE {
0x00 });
stream.flip();
// Allocate a LdapMessage Container
Asn1Container ldapMessageContainer = new LdapMessageContainer<MessageDecorator<? extends Message>>(codec);
// Decode a AddRequest message
try {
ldapDecoder.decode(stream, ldapMessageContainer);
} catch (DecoderException de) {
assertTrue(true);
return;
}
fail("We should not reach this point");
}
Aggregations