use of org.apache.directory.api.ldap.model.message.Message in project directory-ldap-api by apache.
the class AddRequestTest method testDecodeAddRequestNullEntry.
/**
* Test the decoding of a AddRequest with a null entry
*/
@Test
public void testDecodeAddRequestNullEntry() {
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(0x39);
stream.put(new byte[] { 0x30, // LDAPMessage ::= SEQUENCE {
0x37, 0x02, 0x01, // messageID MessageID
0x01, 0x68, // CHOICE { ..., addRequest AddRequest, ...
0x26, // entry LDAPDN,
0x04, 0x00, // attributes AttributeList }
0x30, // AttributeList ::= SEQUENCE OF SEQUENCE {
0x2E, 0x30, // attribute 1
0x0c, 0x04, 0x01, // type AttributeDescription,
'l', 0x31, // vals SET OF AttributeValue }
0x07, 0x04, 0x05, 'P', 'a', 'r', 'i', 's', 0x30, // attribute 2
0x1E, // type AttributeDescription,
0x04, 0x05, 'a', 't', 't', 'r', 's', 0x31, // vals SET
0x15, // }
0x04, 0x05, 't', 'e', 's', 't', '1', 0x04, 0x05, 't', 'e', 's', 't', '2', 0x04, 0x05, 't', 'e', 's', 't', '3' });
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(de instanceof ResponseCarryingException);
Message response = ((ResponseCarryingException) de).getResponse();
assertTrue(response instanceof AddResponseImpl);
assertEquals(ResultCodeEnum.NAMING_VIOLATION, ((AddResponseImpl) response).getLdapResult().getResultCode());
return;
}
fail("We should not reach this point");
}
use of org.apache.directory.api.ldap.model.message.Message in project directory-ldap-api by apache.
the class CompareRequestTest method testDecodeCompareRequestEmptyAttributeDesc.
/**
* Test the decoding of an empty attributeDesc ava
*/
@Test
public void testDecodeCompareRequestEmptyAttributeDesc() {
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(0x2D);
stream.put(new byte[] { 0x30, // LDAPMessage ::= SEQUENCE {
0x2B, 0x02, 0x01, // messageID MessageID
0x01, // CHOICE { ..., compareRequest CompareRequest, ...
0x6E, // CompareRequest ::= [APPLICATION 14] SEQUENCE {
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', // ava AttributeValueAssertion }
0x30, // AttributeValueAssertion ::= SEQUENCE {
0x02, 0x04, 0x00 });
stream.flip();
// Allocate a LdapMessage Container
LdapMessageContainer<CompareRequestDecorator> container = new LdapMessageContainer<CompareRequestDecorator>(codec);
// Decode the CompareRequest PDU
try {
ldapDecoder.decode(stream, container);
fail("We should never reach this point !!!");
} catch (DecoderException de) {
assertTrue(de instanceof ResponseCarryingException);
Message response = ((ResponseCarryingException) de).getResponse();
assertTrue(response instanceof CompareResponseImpl);
assertEquals(ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, ((CompareResponseImpl) response).getLdapResult().getResultCode());
return;
}
}
use of org.apache.directory.api.ldap.model.message.Message in project directory-ldap-api by apache.
the class ModifyRequestTest method testDecodeModifyRequestBadDN.
/**
* Test the decoding of a ModifyRequest
*/
@Test
public void testDecodeModifyRequestBadDN() {
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(0x54);
stream.put(new byte[] { 0x30, // LDAPMessage ::= SEQUENCE {
0x52, 0x02, 0x01, // messageID MessageID
0x01, 0x66, // CHOICE { ..., modifyRequest ModifyRequest, ...
0x4d, // object 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', 0x30, 0x29, // modification SEQUENCE OF SEQUENCE {
0x30, 0x11, 0x0A, 0x01, // operation ENUMERATED {
0x02, // modification AttributeTypeAndValues } }
0x30, // AttributeTypeAndValues ::= SEQUENCE {
0x0c, 0x04, 0x01, // type AttributeDescription,
'l', 0x31, // vals SET OF AttributeValue }
0x07, 0x04, 0x05, 'P', 'a', 'r', 'i', 's', 0x30, // modification SEQUENCE OF *SEQUENCE* {
0x14, 0x0A, 0x01, // operation ENUMERATED {
0x00, // modification AttributeTypeAndValues } }
0x30, // AttributeTypeAndValues ::= SEQUENCE {
0x0f, // type AttributeDescription,
0x04, 0x05, 'a', 't', 't', 'r', 's', 0x31, // vals SET OF AttributeValue }
0x06, 0x04, 0x04, 't', 'e', 's', 't' });
stream.flip();
// Allocate a LdapMessage Container
LdapMessageContainer<ModifyRequestDecorator> ldapMessageContainer = new LdapMessageContainer<ModifyRequestDecorator>(codec);
// Decode a ModifyRequest PDU
try {
ldapDecoder.decode(stream, ldapMessageContainer);
} catch (DecoderException de) {
assertTrue(de instanceof ResponseCarryingException);
Message response = ((ResponseCarryingException) de).getResponse();
assertTrue(response instanceof ModifyResponseImpl);
assertEquals(ResultCodeEnum.INVALID_DN_SYNTAX, ((ModifyResponseImpl) response).getLdapResult().getResultCode());
return;
}
fail("We should not reach this point");
}
use of org.apache.directory.api.ldap.model.message.Message in project directory-ldap-api by apache.
the class ModifyDNRequestTest method testDecodeModifyDNRequestBadDN.
/**
* Test the decoding of a bad Dn ModifyDNRequest
*/
@Test
public void testDecodeModifyDNRequestBadDN() {
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(0x48);
stream.put(new byte[] { 0x30, // LDAPMessage ::= SEQUENCE {
0x46, 0x02, 0x01, // messageID MessageID
0x01, 0x6C, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
0x41, // 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', // newrdn RelativeLDAPDN,
0x04, 0x0F, 'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01, 0x01, // deleteoldrdn BOOLEAN,
0x00, // newSuperior [0] LDAPDN OPTIONAL }
(byte) 0x80, 0x09, 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm' });
stream.flip();
// Allocate a ModifyRequest Container
LdapMessageContainer<ModifyDnRequestDecorator> ldapMessageContainer = new LdapMessageContainer<ModifyDnRequestDecorator>(codec);
try {
ldapDecoder.decode(stream, ldapMessageContainer);
} catch (DecoderException de) {
assertTrue(de instanceof ResponseCarryingException);
Message response = ((ResponseCarryingException) de).getResponse();
assertTrue(response instanceof ModifyDnResponseImpl);
assertEquals(ResultCodeEnum.INVALID_DN_SYNTAX, ((ModifyDnResponseImpl) response).getLdapResult().getResultCode());
return;
}
fail("We should not reach this point");
}
use of org.apache.directory.api.ldap.model.message.Message in project directory-ldap-api by apache.
the class ModifyDNRequestTest method testDecodeModifyDNRequestBadRDN.
/**
* Test the decoding of a bad Rdn ModifyDNRequest
*/
@Test
public void testDecodeModifyDNRequestBadRDN() {
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(0x48);
stream.put(new byte[] { 0x30, // LDAPMessage ::= SEQUENCE {
0x46, 0x02, 0x01, // messageID MessageID
0x01, 0x6C, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
0x41, // 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', // newrdn RelativeLDAPDN,
0x04, 0x0F, 'c', 'n', ':', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01, 0x01, // deleteoldrdn BOOLEAN,
0x00, // newSuperior [0] LDAPDN OPTIONAL }
(byte) 0x80, 0x09, 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm' });
stream.flip();
// Allocate a ModifyRequest Container
LdapMessageContainer<ModifyDnRequestDecorator> ldapMessageContainer = new LdapMessageContainer<ModifyDnRequestDecorator>(codec);
try {
ldapDecoder.decode(stream, ldapMessageContainer);
} catch (DecoderException de) {
assertTrue(de instanceof ResponseCarryingException);
Message response = ((ResponseCarryingException) de).getResponse();
assertTrue(response instanceof ModifyDnResponseImpl);
assertEquals(ResultCodeEnum.INVALID_DN_SYNTAX, ((ModifyDnResponseImpl) response).getLdapResult().getResultCode());
return;
}
fail("We should not reach this point");
}
Aggregations