Skip Menu |
 

This queue is for tickets about the Net-LDAP-Server-Test CPAN distribution.

Report information
The Basics
Id: 80360
Status: resolved
Priority: 0/
Queue: Net-LDAP-Server-Test

People
Owner: Nobody in particular
Requestors: rporres [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Test server returns success in base searches to non-existing entries
Download (untitled) / with headers
text/plain 462b
The server returns a 0 (success) message code when receives a search request to a non-existing base dn with a base scope whereas it should return an error code 32 (noSuchObject). I attach a test case (no-such-entry.t) and a patch proposal (patch.txt). If any of this goes upstream, please do also credit Joni Salonen for the bug discovery and patch proposal. Best regards, Rafael Porres PS. Thanks a lot for writing this module. It's been very helpful ;-)
Subject: patch.txt
Download patch.txt
text/plain 775b
--- /var/tmp/Test.pm 2012-10-23 19:36:49.000000000 +0200 +++ Test.pm 2012-10-23 19:37:15.000000000 +0200 @@ -51,6 +51,7 @@ use Carp; use Net::LDAP::Constant qw( LDAP_SUCCESS + LDAP_NO_SUCH_OBJECT LDAP_CONTROL_PAGED LDAP_OPERATIONS_ERROR LDAP_UNWILLING_TO_PERFORM @@ -145,6 +146,15 @@ } + # Return LDAP_NO_SUCH_OBJECT if base does not exist + unless (exists $Data{$base}) { + return { + matchedDN => '', + errorMessage => 'No such object: '.$base, + resultCode => LDAP_NO_SUCH_OBJECT + }; + } + #warn "stored Data: " . Data::Dump::dump \%Data; #warn "searching for " . Data::Dump::dump \@filters;
Subject: no-such-entry.t
Download no-such-entry.t
text/x-perl 1.3k
use strict; use warnings; use Test::More; use Net::LDAP::Server::Test; use Net::LDAP; use Net::LDAP::LDIF; use File::Temp qw(tempfile); # Create ldif my $ldif_entries =<<EOL; dn: app=test app: test objectClass: top objectClass: application dn: msisdn=34610123123,app=test objectClass: msisdn msisdn: 34610123123 EOL my ($fh, $filename) = tempfile(); print $fh $ldif_entries; close $fh; # Create and connect to server ok(my $server = Net::LDAP::Server::Test->new(12389, auto_schema => 1), "test LDAP server spawned"); ok(my $ldap = Net::LDAP->new('localhost', port => 12389), "new LDAP connection" ); # Load ldif my $ldif = Net::LDAP::LDIF->new($filename, 'r', onerror => 'die', lowercase => 1); while (not $ldif->eof) { my $entry = $ldif->read_entry or die "Unable to parse entry"; my $mesg = $ldap->add($entry); $mesg->code and die sprintf "Error adding entry [%s]: [%s]", $entry->dn, $mesg->error; } $ldif->done; # Just make sure everything is ok :) my $mesg = $ldap->search(base => 'msisdn=34610123123,app=test', scope => 'base', filter => 'objectClass=*'); is($mesg->code, 0, 'msisdn found'); # This should work. A base search to a non-existing entry should return 32 $mesg = $ldap->search(base => 'msisdn=123456789,app=test', scope => 'base', filter => 'objectClass=*'); is($mesg->code, 32, 'msisdn not found'); is(scalar($mesg->entries), 0, 'number of entries equals zero'); done_testing;
patched and released as 0.16. See also RT #80377.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.