Net::L...r::Test(3pm)

πŸ“¦
version 0.22 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Net::LDAP::Server::Test β€” bestie, it's literally here to test Net::LDAP code ✨


🌸 SYNOPSIS 🌸

okay so picture this, you wanna test your LDAP stuff but you don't have a server, right? watch this:

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

see how easy that was?? iconic behavior fr πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

no cap, you can now test your Net::LDAP code without having a whole real LDAP server just sitting there being extra. we love a low-maintenance king πŸ‘‘


πŸ’… METHODS πŸ’…

ngl there's literally only one user-level method here: new().

✨ new( port, key_value_args ) ✨

makes you a brand new server. basically all it does is fork() a child process that listens on port and handles requests using Net::LDAP::Server. slay.

  • port defaults to 10636. periodt.
  • port may also be an IO::Socket object listening to a local port. versatile queen πŸ’–

key_value_args may be:

  • data β€” this is optional data to return from the Net::LDAP search() function. typically it would be an array ref of Net::LDAP::Entry objects. like a little snack for your search πŸ“
  • 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. it's giving ✨pretend but make it accurate✨
  • 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. very main character energy πŸ‘‘
⚠️ heads up bestie: 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. that's it, that's the object 🫢

πŸŽ€ 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. πŸ™ˆ

πŸ’€ okay so 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. vibe check passed or failed, no in between ⭐


πŸ‘‘ 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. it's a whole two-way notification situation, we love transparency 🫢


🧚 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. shoutout, real ones fr fr πŸ’œ


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


and that's the whole page bestie!! πŸ¦‹ this one's perl v5.34.0, dated 2022-06-16, and it's part of the User Contributed Perl Documentation β€” go forth and test your LDAP code, you absolute icon πŸ’…βœ¨

πŸ“¦ where this page comes from