Skip to content
Permalink
Browse files
Add tests for DIRSTUDIO-1078/DIRAPI-365: unable to use # pound hash s…
…ign in LDAP filters
  • Loading branch information
seelmann committed Apr 3, 2021
1 parent bc04556 commit 607e52b591450c12c8c4e90a2d3881529d9be2a2
Showing 5 changed files with 56 additions and 7 deletions.
@@ -24,7 +24,6 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.apache.directory.api.ldap.model.filter.FilterParser;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
@@ -27,7 +27,6 @@

import java.text.ParseException;

import org.apache.directory.api.ldap.model.filter.FilterParser;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
@@ -33,14 +33,12 @@
import java.util.Locale;

import org.apache.directory.api.ldap.model.entry.Value;
import org.apache.directory.api.ldap.model.filter.FilterParser;
import org.apache.directory.api.util.Strings;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;



/**
* Tests the FilterParserImpl class.
*
@@ -411,6 +409,62 @@ public void testExtensibleFilterForm3() throws ParseException
}


/**
* Test for DIRSTUDIO-1078/DIRAPI-365: unable to use # pound hash sign in LDAP filters
*/
@Test
public void testEqualsFilterForDnWithLeadingHash() throws ParseException
{
String str = "(memberOf=CN=\\5c#SOME,OU=Groups,OU=EMEA,DC=example,DC=net)";
EqualityNode<?> node = ( EqualityNode<?> ) FilterParser.parse( str, true );
assertEquals( "memberOf", node.getAttribute() );
assertEquals( "CN=\\#SOME,OU=Groups,OU=EMEA,DC=example,DC=net", node.getValue().getString() );
}


/**
* Test for DIRSTUDIO-1078/DIRAPI-365: unable to use # pound hash sign in LDAP filters
*/
@Test
public void testEqualsFilterForDnWithLeadingHashHex() throws ParseException
{
String str = "(memberOf=CN=\\5C23SOME,OU=Groups,OU=EMEA,DC=example,DC=net)";
EqualityNode<?> node = ( EqualityNode<?> ) FilterParser.parse( str, true );
assertEquals( "memberOf", node.getAttribute() );
assertEquals( "CN=\\23SOME,OU=Groups,OU=EMEA,DC=example,DC=net", node.getValue().getString() );
}


/**
* Test for DIRSTUDIO-1078/DIRAPI-365: unable to use # pound hash sign in LDAP filters
*/
@Test
public void testExtensibleFilterForDnWithLeadingHash() throws ParseException
{
String str = "(memberOf:1.2.840.113556.1.4.1941:=CN=\\5c#SOME,OU=Groups,OU=EMEA,DC=example,DC=net)";
ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( str, true );
assertEquals( "memberOf", node.getAttribute() );
assertEquals( "CN=\\#SOME,OU=Groups,OU=EMEA,DC=example,DC=net", node.getValue().getString() );
assertEquals( "1.2.840.113556.1.4.1941", node.getMatchingRuleId() );
assertFalse( node.hasDnAttributes() );
}


/**
* Test for DIRSTUDIO-1078/DIRAPI-365: unable to use # pound hash sign in LDAP filters
*/
@Test
public void testExtensibleFilterForDnWithLeadingHashHex() throws ParseException
{
String str = "(memberOf:1.2.840.113556.1.4.1941:=CN=\\5C23SOME,OU=Groups,OU=EMEA,DC=example,DC=net)";
ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( str, true );
assertEquals( "memberOf", node.getAttribute() );
assertEquals( "CN=\\23SOME,OU=Groups,OU=EMEA,DC=example,DC=net", node.getValue().getString() );
assertEquals( "1.2.840.113556.1.4.1941", node.getMatchingRuleId() );
assertFalse( node.hasDnAttributes() );
}


@Test
public void testReuseParser() throws ParseException
{
@@ -24,7 +24,6 @@

import java.text.ParseException;

import org.apache.directory.api.ldap.model.filter.FilterParser;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
@@ -27,8 +27,6 @@

import java.util.List;

import org.apache.directory.api.ldap.model.filter.FilterVisitor;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;

0 comments on commit 607e52b

Please sign in to comment.