Permalink
Browse files

A scope of 'one' shouldn't include the base entry

From RFC 4511 section 4.5.1.2:

    singleLevel: The scope is constrained to the immediate
    subordinates of the entry named by baseObject.
  • Loading branch information...
1 parent d1bb144 commit 5f4222556af910673a4e3f86289b7665c195c30f @tsibley tsibley committed Jul 27, 2012
Showing with 14 additions and 8 deletions.
  1. +2 −3 lib/Net/LDAP/Server/Test.pm
  2. +12 −5 t/05-scope.t
@@ -201,9 +201,8 @@ Only one user-level method is implemented: new().
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;
+ # We're guaranteed to be at or under $base thanks to the m// above
+ next unless $dn_depth == $base_depth + 1;
}
my $entry = $Data{$dn};
View
@@ -18,31 +18,38 @@ my @scopes = qw(base one sub);
my $dn = my $base = "dc=example,dc=com";
for my $level (@scopes) {
$dn = "cn=$level group,$dn";
- $ldap->add(
+ my $result = $ldap->add(
$dn,
attr => [
cn => "$level group",
objectClass => 'Group',
],
);
+ ok !$result->code, "added $dn: " . $result->error;
}
# Do scopes work?
my %expected = (
- 'base' => 1,
- 'one' => 2,
- 'sub' => 3,
+ 'base' => [qw(base)],
+ 'one' => [qw(one)],
+ 'sub' => [qw(base one sub)],
);
for my $scope (@scopes) {
- my $count = $expected{$scope};
+ my $cns = $expected{$scope};
+ my $count = scalar @$cns;
my $msg = $ldap->search(
base => "cn=base group,$base",
scope => $scope,
filter => '(objectClass=group)',
);
ok $msg, "searched with scope $scope";
is $msg->count, $count, "found $count";
+
+ my %want = map { ("$_ group" => 1) } @$cns;
+ my %found = map { ($_->get_value('cn') => 1) } $msg->entries;
+ is((scalar grep { !$found{$_} } keys %want), 0, "found all expected CNs");
+ is((scalar grep { !$want{$_} } keys %found), 0, "expected all found CNs");
}
ok $ldap->unbind, "unbound";

0 comments on commit 5f42225

Please sign in to comment.