Test::Net::LDAP - A Net::LDAP subclass for testing
Version 0.03
use Test::More tests => 1; use Test::Net::LDAP; # Create an object, just like Net::LDAP->new() my $ldap = Test::Net::LDAP->new(...); # Same as $ldap->search(), testing the result to see if it is success my $search = $ldap->search_ok(...search args...);
This module provides some testing methods for LDAP operations, such as search, add, and modify, where each method is suffixed with either _ok or _is.
search
add
modify
_ok
_is
Test::Net::LDAP is a subclass of Net::LDAP, so all the methods defined for Net::LDAP are available in addition to search_ok, add_is, etc.
Test::Net::LDAP
Net::LDAP
search_ok
add_is
See Test::Net::LDAP::Mock for in-memory testing with fake data, without connecting to the real LDAP servers.
See Test::Net::LDAP::Util for some helper subroutines.
Creates a new object. The parameters are the same as Net::LDAP::new.
Net::LDAP::new
my $ldap = Test::Net::LDAP->new('ldap.example.com');
Synopsis:
$ldap->search_ok(@params); $ldap->search_ok(\@params, $name);
Invokes the corresponding method with @params passed as arguments, and tests the result to see if the code is LDAP_SUCCESS.
@params
LDAP_SUCCESS
Alternatively, @params can be given as an array ref, so that the second argument $name is specified as the test name.
$name
$name is an optional test name, and if it is omitted, the test name is automatically configured based on $method and @params.
$method
my $search = $ldap->search_ok( base => 'dc=example, dc=com', scope => 'sub', filter => '(cn=*)', ); my $search = $ldap->search_ok( [base => 'dc=example, dc=com', scope => 'sub', filter => '(cn=*)'], 'Testing search (cn=*)' );
$ldap->search_is(\@params, $expect, $name);
Invokes the corresponding method with @params passed as arguments, and tests the result to see if the code is equal to $expect.
$expect
$expect can be a result code such as LDAP_NO_SUCH_OBJECT or an object of Net::LDAP::Message returned by LDAP operations.
LDAP_NO_SUCH_OBJECT
Net::LDAP::Message
use Net::LDAP::Constant qw(LDAP_ALREADY_EXISTS); my $mesg = $ldap->add_is( ['uid=duplicate, dc=example, dc=com'], LDAP_ALREADY_EXISTS );
$ldap->method_ok($method, @params); $ldap->method_ok($method, \@params, $name);
Invokes the method as $ldap->$method(@params) and tests the result to see if the code is LDAP_SUCCESS.
$ldap->$method(@params)
$ldap->method_is($method, \@params, $expect, $name);
Invokes the method as $ldap->$method(@params) and tests the result to see if the code is equal to $expect.
Test::More
Test::Net::LDAP::Mock
Test::Net::LDAP::Util
Mahiro Ando, <mahiro at cpan.org>
<mahiro at cpan.org>
Please report any bugs or feature requests to bug-test-net-ldap at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Net-LDAP. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-test-net-ldap at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Test::Net::LDAP
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Net-LDAP
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Test-Net-LDAP
CPAN Ratings
http://cpanratings.perl.org/d/Test-Net-LDAP
Search CPAN
http://search.cpan.org/dist/Test-Net-LDAP/
Copyright 2013 Mahiro Ando.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Test::Net::LDAP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Net::LDAP
CPAN shell
perl -MCPAN -e shell install Test::Net::LDAP
For more information on module installation, please visit the detailed CPAN module installation guide.