Permalink
Browse files

More robust depth checking for scopes of 'one' in auto_schema search

DNs may contain spaces which the depth checking regex didn't expect.
Use a Net::LDAP utility method to count the depth level properly and
compare against the base's depth.

t/05-scope.t now passes the previously TODOed tests.
  • Loading branch information...
tsibley committed Jul 27, 2012
1 parent b703620 commit c1440a7c331ceb2cfc0069010153c7a29c282e25
Showing with 8 additions and 6 deletions.
  1. +7 −1 lib/Net/LDAP/Server/Test.pm
  2. +1 −5 t/05-scope.t
@@ -55,6 +55,7 @@ Only one user-level method is implemented: new().
LDAP_OPERATIONS_ERROR
LDAP_UNWILLING_TO_PERFORM
);
+ use Net::LDAP::Util qw(ldap_explode_dn);
use Net::LDAP::Entry;
use Net::LDAP::Filter;
use Net::LDAP::FilterMatch;
@@ -199,7 +200,12 @@ Only one user-level method is implemented: new().
next unless $dn eq $base;
}
elsif ( $scope eq 'one' ) {
- next unless $dn =~ m/^(\w+=\w+,)?$base$/;
+ my $dn_depth = scalar @{ ldap_explode_dn($dn) };
+ my $base_depth = scalar @{ ldap_explode_dn($base) };
+
+ # If we're deeper, we're guaranteed to be under $base thanks to
+ # the m// above
+ next unless $dn eq $base or $dn_depth == $base_depth + 1;
}
my $entry = $Data{$dn};
View
@@ -42,11 +42,7 @@ for my $scope (@scopes) {
filter => '(objectClass=group)',
);
ok $msg, "searched with scope $scope";
- TODO: {
- local $TODO = "scope of 'one' doesn't work with spaces in the DN (yet)"
- if $scope eq 'one';
- is $msg->count, $count, "found $count";
- }
+ is $msg->count, $count, "found $count";
}
ok $ldap->unbind, "unbound";

0 comments on commit c1440a7

Please sign in to comment.