Net::LDAP::Server::Test(3)

NAME
Net::LDAP::Server::Test - test Net::LDAP code

SYNOPSIS
    use Test::More tests => 10;
    use Net::LDAP::Server::Test;

    ok( my $server = Net::LDAP::Server::Test->new(8080),
            "test LDAP server spawned");

    # connect to port 8080 with your Net::LDAP code.
    ok(my $ldap = Net::LDAP->new( 'localhost', port => 8080 ),
             "new LDAP connection" );

    # ... test stuff with $ldap ...

    # server will exit when you call final LDAP unbind().
    ok($ldap->unbind(), "LDAP server unbound");

DESCRIPTION
Now you can test your Net::LDAP code without having a real LDAP server available.

METHODS
Only one user-level method is implemented: new().

  new( port, key_value_args )
Create a new server. Basically this just fork()s a child process listing on port and handling requests using Net::LDAP::Server.

port defaults to 10636.

port may be an IO::Socket object listening to a local port.

key_value_args may be:

data
    data is optional data to return from the Net::LDAP search() function. Typically it would be an array ref of Net::LDAP::Entry objects.

auto_schema
    A true value means the add(), modify() and delete() methods will store internal in-memory data based on DN values, so that search() will mimic working on a real LDAP schema.

active_directory
    Work in Active Directory mode. This means that entries are automatically assigned a objectSID, and some effort is made to mimic the member/memberOf linking between AD Users and Groups.

new() will croak() if there was a problem fork()ing a new server.

Returns a Net::LDAP::Server::Test object, which is just a blessed reference to the PID of the forked server.

  stop
Calls waitpid() on the server's associated child process. You may find it helpful to call this method explicitly, especially if you are creating multiple servers in the same test. Otherwise, this method is typically not needed and may even cause your tests to hang indefinitely if they die prematurely. YMMV.

To prevent waitpid() from blocking and hanging your test server, it is wrapped in an alarm() call, which will wait 2 seconds and then call kill() on the reluctant pid. You have been warned.

  port_is_open
Returns an IO::Socket (or subclass) for the current server port. If the port is already in use, this is a false value.

AUTHOR
Peter Karman, "<karman at cpan.org>"

BUGS
Please report any bugs or feature requests to "bug-net-ldap-server-test at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-LDAP-Server-Test>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT
You can find documentation for this module with the perldoc command.

    perldoc Net::LDAP::Server::Test

You can also look for information at:

•   AnnoCPAN: Annotated CPAN documentation

    <http://annocpan.org/dist/Net-LDAP-Server-Test>

•   CPAN Ratings

    <http://cpanratings.perl.org/d/Net-LDAP-Server-Test>

•   RT: CPAN's request tracker

    <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-LDAP-Server-Test>

•   Search CPAN

    <http://search.cpan.org/dist/Net-LDAP-Server-Test>

ACKNOWLEDGEMENTS
The Minnesota Supercomputing Institute "http://www.msi.umn.edu/" sponsored the development of this software.

COPYRIGHT & LICENSE
Copyright 2007 by the Regents of the University of Minnesota.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO
Net::LDAP::Server