use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.
the class SearchRequestMatchingRuleAssertionTest method testDecodeSearchRequestExtensibleMatchEmptyType.
/**
* Test the decoding of a SearchRequest with an extensible match and an
* empty type
*/
@Test
public void testDecodeSearchRequestExtensibleMatchEmptyType() {
byte[] asn1BER = new byte[] { 0x30, 0x3D, 0x02, 0x01, // messageID
0x04, 0x63, 0x38, 0x04, // baseObject LDAPDN,
0x1F, 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, (byte) 0xFF, (byte) 0xA9, 0x02, (byte) 0x82, // type [2] AttributeDescription OPTIONAL
0x00, 0x30, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
0x02, 0x04, 0x00 };
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(asn1BER.length);
stream.put(asn1BER);
stream.flip();
// Allocate a LdapMessage Container
LdapMessageContainer<SearchRequestDecorator> ldapMessageContainer = new LdapMessageContainer<SearchRequestDecorator>(codec);
// Decode a SearchRequest 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.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.
the class SearchRequestMatchingRuleAssertionTest method testDecodeSearchRequestExtensibleMatchMatchValueAlone.
/**
* Test the decoding of a SearchRequest with an extensible match and a match
* Value and nothing else
*/
@Test
public void testDecodeSearchRequestExtensibleMatchMatchValueAlone() {
byte[] asn1BER = new byte[] { 0x30, 0x43, 0x02, 0x01, // messageID
0x04, 0x63, 0x3E, 0x04, // baseObject LDAPDN,
0x1F, 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, (byte) 0xFF, (byte) 0xA9, 0x06, (byte) 0x83, 0x04, 't', 'e', 's', 't', 0x30, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
0x02, 0x04, 0x00 };
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(asn1BER.length);
stream.put(asn1BER);
stream.flip();
// Allocate a LdapMessage Container
LdapMessageContainer<SearchRequestDecorator> ldapMessageContainer = new LdapMessageContainer<SearchRequestDecorator>(codec);
// Decode a SearchRequest message
try {
ldapDecoder.decode(stream, ldapMessageContainer);
} catch (DecoderException de) {
fail(de.getMessage());
}
SearchRequest searchRequest = ldapMessageContainer.getMessage();
assertEquals(4, searchRequest.getMessageId());
assertEquals("uid=akarasulu,dc=example,dc=com", searchRequest.getBase().toString());
assertEquals(SearchScope.ONELEVEL, searchRequest.getScope());
assertEquals(AliasDerefMode.DEREF_ALWAYS, searchRequest.getDerefAliases());
assertEquals(0, searchRequest.getSizeLimit());
assertEquals(0, searchRequest.getTimeLimit());
assertEquals(true, searchRequest.getTypesOnly());
// Extended
ExprNode filter = searchRequest.getFilter();
ExtensibleNode extensibleNode = (ExtensibleNode) filter;
assertNotNull(extensibleNode);
assertNull(extensibleNode.getMatchingRuleId());
assertNull(extensibleNode.getAttribute());
assertEquals("test", extensibleNode.getValue().getValue());
assertFalse(extensibleNode.hasDnAttributes());
List<String> attributes = searchRequest.getAttributes();
assertEquals(0, attributes.size());
}
use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.
the class SearchRequestSubstringTest method testDecodeSearchRequestSubstringFilterTwoInitials.
/**
* Test the decoding of a SearchRequest with a Substring filter Two initials
*/
@Test
public void testDecodeSearchRequestSubstringFilterTwoInitials() {
byte[] asn1BER = new byte[] { 0x30, 0x49, 0x02, 0x01, // messageID
0x04, 0x63, 0x44, 0x04, // baseObject LDAPDN,
0x1F, 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, (byte) 0xFF, (byte) 0xA4, 0x0E, 0x04, 0x04, 't', 'e', 's', 't', 0x30, 0x06, (byte) 0x80, 0x01, 'a', (byte) 0x80, 0x01, 'b', 0x30, // AttributeDescriptionList
0x02, // AttributeDescription
0x04, 0x00 };
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(asn1BER.length);
stream.put(asn1BER);
stream.flip();
// Allocate a LdapMessage Container
LdapMessageContainer<SearchRequestDecorator> ldapMessageContainer = new LdapMessageContainer<SearchRequestDecorator>(codec);
// Decode a SearchRequest 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.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.
the class SearchRequestSubstringTest method testDecodeSearchRequestSubstringFilterAnyInitial.
/**
* Test the decoding of a SearchRequest with a Substring filter Any before
* initial
*/
@Test
public void testDecodeSearchRequestSubstringFilterAnyInitial() {
byte[] asn1BER = new byte[] { 0x30, 0x49, 0x02, 0x01, // messageID
0x04, 0x63, 0x44, 0x04, // baseObject LDAPDN,
0x1F, 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, (byte) 0xFF, (byte) 0xA4, 0x0E, 0x04, 0x04, 't', 'e', 's', 't', 0x30, 0x06, (byte) 0x81, 0x01, 'a', (byte) 0x80, 0x01, 'b', 0x30, // AttributeDescriptionList
0x02, // AttributeDescription
0x04, 0x00 };
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(asn1BER.length);
stream.put(asn1BER);
stream.flip();
// Allocate a LdapMessage Container
LdapMessageContainer<SearchRequestDecorator> ldapMessageContainer = new LdapMessageContainer<SearchRequestDecorator>(codec);
// Decode a SearchRequest 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.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.
the class SearchRequestSubstringTest method testDecodeSearchRequestSubstringFilterEmptyAny.
/**
* Test the decoding of a SearchRequest with a Substring filter and an empty
* Substring Any
*/
@Test
public void testDecodeSearchRequestSubstringFilterEmptyAny() {
byte[] asn1BER = new byte[] { 0x30, 0x45, 0x02, 0x01, // messageID
0x04, 0x63, 0x40, 0x04, // baseObject LDAPDN,
0x1F, 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, (byte) 0xFF, (byte) 0xA4, 0x0A, 0x04, 0x04, 't', 'e', 's', 't', 0x30, 0x02, (byte) 0x81, 0x00, 0x30, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
0x02, 0x04, 0x00 };
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(asn1BER.length);
stream.put(asn1BER);
stream.flip();
// Allocate a LdapMessage Container
LdapMessageContainer<SearchRequestDecorator> ldapMessageContainer = new LdapMessageContainer<SearchRequestDecorator>(codec);
// Decode a SearchRequest message
try {
ldapDecoder.decode(stream, ldapMessageContainer);
} catch (DecoderException de) {
assertTrue(true);
return;
}
fail("We should not reach this point");
}
Aggregations