use of org.apache.directory.api.asn1.ber.Asn1Container in project directory-ldap-api by apache.
the class AddRequestTest method testDecodeAddRequestNullVals.
/**
* Test the decoding of a AddRequest with a empty attributeList
*/
@Test
public void testDecodeAddRequestNullVals() {
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(0x32);
stream.put(new byte[] { 0x30, // LDAPMessage ::= SEQUENCE {
0x30, 0x02, 0x01, // messageID MessageID
0x01, 0x68, // CHOICE { ..., addRequest AddRequest, ...
0x2B, // 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 {
0x07, 0x30, // attribute 1
0x05, 0x04, 0x01, // type AttributeDescription,
'A', 0x31, 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 BindResponseTest method testDecodeAddResponseEmptyResult.
/**
* Test the decoding of a BindResponse with no LdapResult
*/
@Test
public void testDecodeAddResponseEmptyResult() {
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(0x07);
stream.put(new byte[] { // LDAPMessage ::=SEQUENCE {
0x30, // LDAPMessage ::=SEQUENCE {
0x05, 0x02, 0x01, // messageID MessageID
0x01, 0x61, // CHOICE { ..., bindResponse BindResponse, ...
0x00 });
stream.flip();
// Allocate a LdapMessage Container
Asn1Container container = new LdapMessageContainer<MessageDecorator<? extends Message>>(codec);
// Decode a BindResponse message
try {
ldapDecoder.decode(stream, container);
} 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 LdapControlTest method testDecodeRequestWithControlsBadCriticality.
/**
* Test the decoding of a Request with bad criticality
*/
@Test
public void testDecodeRequestWithControlsBadCriticality() {
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(0x25);
stream.put(new byte[] { // LDAPMessage ::=SEQUENCE {
0x30, // LDAPMessage ::=SEQUENCE {
0x23, 0x02, 0x01, // messageID MessageID
0x03, 0x50, 0x01, // CHOICE { ..., abandonRequest
0x02, // AbandonRequest,...
(byte) 0xA0, // controls [0] Controls OPTIONAL }
0x1B, 0x30, // Control ::= SEQUENCE {
0x19, // controlType LDAPOID,
0x04, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '1', // criticality BOOLEAN DEFAULT FALSE,
0x01, 0x00, // controlValue OCTET STRING OPTIONAL }
0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f' });
stream.flip();
// Allocate a LdapMessageContainer Container
Asn1Container ldapMessageContainer = new LdapMessageContainer<MessageDecorator<? extends Message>>(codec);
// Decode the PDU
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 LdapControlTest method testDecodeRequestWithControlsNullOID.
/**
* Test the decoding of a Request with null OID controls
*/
@Test
public void testDecodeRequestWithControlsNullOID() {
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(0x19);
stream.put(new byte[] { // LDAPMessage ::=SEQUENCE {
0x30, // LDAPMessage ::=SEQUENCE {
0x17, 0x02, 0x01, // messageID MessageID
0x03, 0x50, 0x01, // CHOICE { ..., abandonRequest
0x02, // AbandonRequest,...
(byte) 0xA0, // controls [0] Controls OPTIONAL }
0x0F, 0x30, // Control ::= SEQUENCE {
0x0D, // controlType LDAPOID,
0x04, 0x00, // criticality BOOLEAN DEFAULT FALSE,
0x01, 0x01, (byte) 0xFF, // controlValue OCTET STRING OPTIONAL }
0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f' });
stream.flip();
// Allocate a LdapMessageContainer Container
Asn1Container ldapMessageContainer = new LdapMessageContainer<MessageDecorator<? extends Message>>(codec);
// Decode the PDU
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 LdapControlTest method testDecodeRequestWithControlsBadOID.
/**
* Test the decoding of a Request with bad OID controls
*/
@Test
public void testDecodeRequestWithControlsBadOID() {
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(0x20);
stream.put(new byte[] { // LDAPMessage ::=SEQUENCE {
0x30, // LDAPMessage ::=SEQUENCE {
0x1E, 0x02, 0x01, // messageID MessageID
0x03, 0x50, 0x01, // CHOICE { ..., abandonRequest
0x02, // AbandonRequest,...
(byte) 0xA0, // controls [0] Controls OPTIONAL }
0x16, 0x30, // Control ::= SEQUENCE {
0x14, // controlType LDAPOID,
0x04, 0x07, 'b', 'a', 'd', ' ', 'o', 'i', 'd', // criticality BOOLEAN DEFAULT FALSE,
0x01, 0x01, (byte) 0xFF, // controlValue OCTET STRING OPTIONAL }
0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f' });
stream.flip();
// Allocate a LdapMessageContainer Container
Asn1Container ldapMessageContainer = new LdapMessageContainer<MessageDecorator<? extends Message>>(codec);
// Decode the PDU
try {
ldapDecoder.decode(stream, ldapMessageContainer);
} catch (DecoderException de) {
assertTrue(true);
return;
}
fail("We should not reach this point");
}
Aggregations