GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Test::Net::LDAP(3) User Contributed Perl Documentation Test::Net::LDAP(3)

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

Version 0.07

Basic testing utility

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

Mocking (See Test::Net::LDAP::Mock)

    use Test::More tests => 1;
    use Test::Net::LDAP::Util qw(ldap_mockify);
    
    ldap_mockify {
        # Net::LDAP->new() will invoke Test::Net::LDAP::Mock->new()
        my $ldap = Net::LDAP->new('ldap.example.com');
        
        # Add entries to in-memory data tree
        $ldap->add('uid=user1, ou=users, dc=example, dc=com');
        $ldap->add('uid=user2, ou=users, dc=example, dc=com');
        
        # Test your application
        ok my_application_routine();
    };

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.

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

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

Available methods: "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=*)'
    );

Available methods: "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
    );

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

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

  • Test::More
  • Net::LDAP
  • Test::Net::LDAP::Mock
  • Test::Net::LDAP::Util

Mahiro Ando, "<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.

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

    perldoc Test::Net::LDAP

You can also look for information at:

  • GitHub repository (report bugs here)

    <https://github.com/mahiro/perl-Test-Net-LDAP>

  • RT: CPAN's request tracker (report bugs here, alternatively)

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

2015-03-24 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.