Mahiro Ando > Test-Net-LDAP-0.02 > Test::Net::LDAP

Download:
Test-Net-LDAP-0.02.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.02   Source   Latest Release: Test-Net-LDAP-0.04

NAME ^

Test::Net::LDAP - A Net::LDAP subclass for testing

VERSION ^

Version 0.02

SYNOPSIS ^

    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...);

DESCRIPTION ^

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.

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.

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.

METHODS ^

new

Creates a new object. The parameters are the same as Net::LDAP::new.

    my $ldap = Test::Net::LDAP->new('ldap.example.com');

search_ok

compare_ok

add_ok

modify_ok

delete_ok

moddn_ok

bind_ok

unbind_ok

abandon_ok

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.

Alternatively, @params can be given as an array ref, so that the second argument $name is specified as the test name.

$name is an optional test name, and if it is omitted, the test name is automatically configured based on $method and @params.

    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=*)'
    );

search_is

compare_is

add_is

modify_is

delete_is

moddn_is

bind_is

unbind_is

abandon_is

Synopsis:

    $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 can be a result code such as LDAP_NO_SUCH_OBJECT or an object of Net::LDAP::Message returned by LDAP operations.

$name is an optional test name, and if it is omitted, the test name is automatically configured based on $method and @params.

    use Net::LDAP::Constant qw(LDAP_ALREADY_EXISTS);

    my $mesg = $ldap->add_is(
        ['uid=duplicate, dc=example, dc=com'],
        LDAP_ALREADY_EXISTS
    );

method_ok

    $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.

$name is an optional test name, and if it is omitted, the test name is automatically configured based on $method and @params.

method_is

    $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.

$expect can be a result code such as LDAP_NO_SUCH_OBJECT or an object of Net::LDAP::Message returned by LDAP operations.

$name is an optional test name, and if it is omitted, the test name is automatically configured based on $method and @params.

SEE ALSO ^

AUTHOR ^

Mahiro Ando, <mahiro at cpan.org>

BUGS ^

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.

SUPPORT ^

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

    perldoc Test::Net::LDAP

You can also look for information at:

ACKNOWLEDGEMENTS ^

LICENSE AND COPYRIGHT ^

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.

syntax highlighting: