use of org.apache.directory.api.ldap.model.filter.EqualityNode in project directory-ldap-api by apache.
the class SearchRequestTest method testDecodeSearchRequestDIRSERVER_651.
/**
* Test the decoding of a SearchRequest with a greaterOrEqual filter and an
* empty attributeValue, and an '*' attribute List
*/
@Test
public void testDecodeSearchRequestDIRSERVER_651() {
byte[] asn1BER = new byte[] { 0x30, 0x60, 0x02, 0x01, 0x02, 0x63, 0x5b, 0x04, 0x0a, 'd', 'c', '=', 'p', 'g', 'p', 'k', 'e', 'y', 's', 0x0a, 01, 02, 0x0a, 01, 00, 0x02, 01, 00, 0x02, 01, 00, 0x01, 01, 00, (byte) 0xa0, 0x3c, (byte) 0xa4, 0x28, 0x04, 0x09, 'p', 'g', 'p', 'u', 's', 'e', 'r', 'i', 'd', 0x30, 0x1b, (byte) 0x80, 0x19, 'v', 'g', 'j', 'o', 'k', 'j', 'e', 'v', '@', 'n', 'e', 't', 'c', 'e', 't', 'e', 'r', 'a', '.', 'c', 'o', 'm', '.', 'm', 'k', (byte) 0xa3, 0x10, 0x04, 0x0b, 'p', 'g', 'p', 'd', 'i', 's', 'a', 'b', 'l', 'e', 'd', 0x04, 0x01, '0', 0x30, 0x00 };
Asn1Decoder ldapDecoder = new Asn1Decoder();
ByteBuffer stream = ByteBuffer.allocate(asn1BER.length);
stream.put(asn1BER);
String decodedPdu = Strings.dumpBytes(stream.array());
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) {
de.printStackTrace();
fail(de.getMessage());
}
assertEquals(TLVStateEnum.PDU_DECODED, ldapMessageContainer.getState());
SearchRequest searchRequest = ldapMessageContainer.getMessage();
assertEquals(2, searchRequest.getMessageId());
assertEquals("dc=pgpkeys", searchRequest.getBase().toString());
assertEquals(SearchScope.SUBTREE, searchRequest.getScope());
assertEquals(AliasDerefMode.NEVER_DEREF_ALIASES, searchRequest.getDerefAliases());
assertEquals(0, searchRequest.getSizeLimit());
assertEquals(0, searchRequest.getTimeLimit());
assertEquals(false, searchRequest.getTypesOnly());
// And
ExprNode filter = searchRequest.getFilter();
AndNode andNode = (AndNode) filter;
assertNotNull(andNode);
List<ExprNode> andNodes = andNode.getChildren();
assertEquals(2, andNodes.size());
SubstringNode substringNode = (SubstringNode) andNodes.get(0);
assertNotNull(substringNode);
assertEquals("pgpuserid", substringNode.getAttribute());
assertEquals("vgjokjev@netcetera.com.mk", substringNode.getInitial());
assertEquals(0, substringNode.getAny().size());
assertEquals(null, substringNode.getFinal());
EqualityNode<?> equalityNode = (EqualityNode<?>) andNodes.get(1);
assertNotNull(equalityNode);
assertEquals("pgpdisabled", equalityNode.getAttribute());
assertEquals("0", equalityNode.getValue().getValue());
// attributes may have been reordered
try {
ByteBuffer bb = encoder.encodeMessage(searchRequest);
// Check the length
assertEquals(0x62, bb.limit());
String encodedPdu = Strings.dumpBytes(bb.array());
assertEquals(encodedPdu, decodedPdu);
} catch (EncoderException ee) {
ee.printStackTrace();
fail(ee.getMessage());
}
}
Aggregations