TestLDAPFilter.java revision 2efcb9667318c099d8723dd578f198c16b4a22c4
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
* Portions Copyright 2011 ForgeRock AS
*/
public class TestLDAPFilter extends LdapTestCase
{
{
}
{
return new Object[][]
{
{ "", null },
{ "=", null },
{ "()", null },
{ "(&(objectClass=*)(sn=s*s)", null },
{ "(dob>12221)", null },
{ "(cn=bob\\2 doe)", null },
{ "(cn=\\4j\\w2\\yu)", null },
{ "(cn=ds\\2)", null },
{ "(&(givenname=bob)|(sn=pep)dob=12))", null },
{ "(:=bob)", null },
{ "(=sally)", null },
{ "(cn=billy bob", null },
{ "(|(!(title=sweep*)(l=Paris*)))", null },
{ "(|(!))", null },
{ "((uid=user.0))", null },
{ "(&&(uid=user.0))", null },
{ "!uid=user.0", null },
{ "(:dn:=Sally)", null },
};
}
{
any,
any,
any,
"cn",
false);
"cn",
true);
null,
true);
"cn",
true);
null,
false);
return new Object[][]
{
{ "(objectClass=\\5ctest\\2a\\28Value\\29)", equal },
{ "(objectClass=)", equal2 },
{ "(sn~=\\5ctest\\2a\\28Value\\29)", approx },
{ "(employeeNumber>=\\5ctest\\2a\\28Value\\29)", greater },
{ "(dob<=\\5ctest\\2a\\28Value\\29)", less },
{ "(login=*)", presense },
{ "(givenName=\\5cJo\\2a\\28\\29*\\5cn\\2a\\28\\29)", substring1 },
{ "(givenName=\\5cJo\\2a\\28\\29*\\5cwid\\2a\\28get\\29*\\2a*\\5cn\\2a\\28\\29)", substring2 },
{ "(givenName=*\\5cn\\2a\\28\\29)", substring3 },
{ "(givenName=\\5cJo\\2a\\28\\29*)", substring4 },
{ "(givenName=*\\5cwid\\2a\\28get\\29*\\2a*)", substring5 },
{ "(cn:2.4.6.8.19:=\\5cJohn\\2a \\28Doe\\29)", extensible1 },
{ "(cn:dn:2.4.6.8.19:=\\5cJohn\\2a \\28Doe\\29)", extensible2 },
{ "(:dn:2.4.6.8.19:=\\5cJohn\\2a \\28Doe\\29)", extensible3 },
{ "(cn:dn:=\\5cJohn\\2a \\28Doe\\29)", extensible4 },
{ "(:2.4.6.8.19:=\\5cJohn\\2a \\28Doe\\29)", extensible5 },
{ "(&(objectClass=\\5ctest\\2a\\28Value\\29)(sn~=\\5ctest\\2a\\28Value\\29))",
{ "(|(objectClass=\\5ctest\\2a\\28Value\\29)(sn~=\\5ctest\\2a\\28Value\\29))",
{ "(|(givenName=\\5cJo\\2a\\28\\29*\\5cn\\2a\\28\\29)(cn:2.4.6.8.19:=\\5cJohn\\2a \\28Doe\\29)" +
"(&(objectClass=\\5ctest\\2a\\28Value\\29)(sn~=\\5ctest\\2a\\28Value\\29)))",
// OpenDJ issue 23.
{
"(ds-sync-conflict=uid=\\5c+3904211775265,ou=SharedAddressBook,cn=1038372,dc=cab)",
};
}
{
//LDAPFilter decodedFilter = LDAPFilter.decode(filterStr);
//System.out.println(decodedFilter.);
//System.out.println(filter.toString());
{
}
{
}
{
}
{
}
if(decoded.getSubInitialElement() != null && !decoded.getSubInitialElement().toString().equals("") ||
{
}
}
{
}
@Test
public void testToSearchFilter() throws Exception
{
"(&" +
"(cn>=*)" +
"(:2.5.13.2:=Bob)" +
"(cn:=Jane)" +
"(|" +
"(sn<=gh*sh*sl)" +
"(!(cn:dn:2.5.13.5:=Sally))" +
"(cn~=blvd)" +
"(cn=*)" +
")" +
"(cn=*n)" +
"(cn=n*)" +
"(cn=n*n)" +
"(:dn:1.3.6.1.4.1.1466.109.114.1:=Doe)" +
"(cn:2.5.13.2:=)" +
")");
}
{
}
@Test
public void testEncodeDecodeComplex() throws Exception
{
"(&" +
"(cn>=*)" +
"(:1.2.3.4:=Bob)" +
"(cn:=Jane)" +
"(|" +
"(sn<=gh*sh*sl)" +
"(!(cn:dn:2.4.6.8.19:=Sally))" +
"(cn~=blvd)" +
"(cn=*)" +
")" +
"(cn=*n)" +
"(cn=n*)" +
"(cn=n*n)" +
"(:dn:1.2.3.4:=Doe)" +
"(cn:2.4.6.8.10:=)" +
")");
}
}