Permalink
Browse files

ptidy only

  • Loading branch information...
1 parent 4da8421 commit f6c28bcc401147f93849f4a7a8e2328afd32e01d @karpet committed Jul 28, 2012
Showing with 33 additions and 23 deletions.
  1. +17 −10 lib/Net/LDAP/Server/Test.pm
  2. +16 −13 t/05-scope.t
@@ -81,7 +81,8 @@ Only one user-level method is implemented: new().
sub new {
my ( $class, $sock, %args ) = @_;
my $self = $class->SUPER::new($sock);
- warn sprintf "Accepted connection from: %s\n", $sock->peerhost() if $ENV{LDAP_DEBUG};
+ warn sprintf "Accepted connection from: %s\n", $sock->peerhost()
+ if $ENV{LDAP_DEBUG};
$self->{_flags} = \%args;
return $self;
}
@@ -129,10 +130,12 @@ Only one user-level method is implemented: new().
#warn 'SEARCH SCHEMA: ' . Data::Dump::dump \@_;
my @results;
- my $base = $reqData->{baseObject};
+ my $base = $reqData->{baseObject};
+
# $reqData->{scope} is a enum but we want a word
- my $scope = $Scopes[defined $reqData->{scope} ? $reqData->{scope} : 2];
- my @attrs = @{$reqData->{attributes} || []};
+ my $scope
+ = $Scopes[ defined $reqData->{scope} ? $reqData->{scope} : 2 ];
+ my @attrs = @{ $reqData->{attributes} || [] };
my @filters = ();
if ( exists $reqData->{filter} ) {
@@ -201,7 +204,7 @@ Only one user-level method is implemented: new().
my $dn_depth = scalar @{ ldap_explode_dn($dn) };
my $base_depth = scalar @{ ldap_explode_dn($base) };
- # We're guaranteed to be at or under $base thanks to the m// above
+ # We're guaranteed to be at or under $base thanks to the m// above
next unless $dn_depth == $base_depth + 1;
}
@@ -419,13 +422,13 @@ Only one user-level method is implemented: new().
my $attr = $mod->{modification}->{type};
my $vals = $mod->{modification}->{vals};
my $entry = $Data{$key};
- if ($mod->{operation} == 0) {
+ if ( $mod->{operation} == 0 ) {
$entry->add( $attr => $vals );
}
- elsif ($mod->{operation} == 1) {
+ elsif ( $mod->{operation} == 1 ) {
$entry->delete( $attr => $vals );
}
- elsif ($mod->{operation} == 2) {
+ elsif ( $mod->{operation} == 2 ) {
$entry->replace( $attr => $vals );
}
else {
@@ -874,7 +877,10 @@ sub new {
}
elsif ( $pid == 0 ) {
- warn "Creating new LDAP server on port " . (ref $port ? $port->sockport : $port) . " ... \n" if $ENV{LDAP_DEBUG};
+ warn "Creating new LDAP server on port "
+ . ( ref $port ? $port->sockport : $port )
+ . " ... \n"
+ if $ENV{LDAP_DEBUG};
# the child (server)
my $sock = ref $port ? $port : IO::Socket::INET->new(
@@ -913,7 +919,8 @@ sub new {
# if there are no open connections,
# exit the child process.
if ( !keys %Handlers ) {
- warn " ... shutting down server\n" if $ENV{LDAP_DEBUG};
+ warn " ... shutting down server\n"
+ if $ENV{LDAP_DEBUG};
exit(0);
}
}
View
@@ -8,7 +8,8 @@ use Net::LDAP::Server::Test;
my $port = 1024 + int rand(10000) + $$ % 1024;
-ok( my $server = Net::LDAP::Server::Test->new( $port, auto_schema => 1 ), "spawn new server" );
+ok( my $server = Net::LDAP::Server::Test->new( $port, auto_schema => 1 ),
+ "spawn new server" );
ok( my $ldap = Net::LDAP->new("localhost:$port"), "new LDAP connection" );
ok( my $rc = $ldap->bind(), "LDAP bind()" );
@@ -36,26 +37,28 @@ my %expected = (
);
for my $scope (@scopes) {
- my $cns = $expected{$scope};
+ my $cns = $expected{$scope};
my $count = scalar @$cns;
- my $msg = $ldap->search(
- base => "cn=base group,$base",
- scope => $scope,
- filter => '(objectClass=group)',
+ 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");
+ 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" );
# test that filters apply correctly on all scopes
$msg = $ldap->search(
- base => "cn=base group,$base",
- scope => $scope,
- filter => '(objectClass=404)',
+ base => "cn=base group,$base",
+ scope => $scope,
+ filter => '(objectClass=404)',
);
ok $msg, "searched with scope $scope with a non-matching filter";
is $msg->count, 0, "found no entries";

0 comments on commit f6c28bc

Please sign in to comment.