Test::...P::Util(3pm)
π Test::Net::LDAP::Util β it's giving testing utilities for Test::Net::LDAP π
okay bestie, sit down, hydrate, because this is the little module that makes testing LDAP stuff not a whole entire nightmare. it's Test::Net::LDAP::Util, a Perl manual page (3pm, perl v5.34.0, dated 2022-06-28 β more on that at the end π), and it's literally just a lil grab-bag of helper subs for poking at LDAP test results. no cap.
β¨ NAME β¨
Test::Net::LDAP::Util β Testing utilities for Test::Net::LDAP π¦
πΈ EXPORT πΈ
the following subroutines are exported on demand β like, you have to ask for them, they're not just gonna show up uninvited:
use Test::Net::LDAP::Util qw(
ldap_result_ok
ldap_result_is
ldap_mockify
ldap_dn_is
);
and if you're feeling extra and want everything, just say ":all":
use Test::Net::LDAP::Util ':all';
all the subroutines get exported if ":all" is specified. periodt. π
π§ SUBROUTINES π§
π ldap_result_ok
ldap_result_ok($mesg, $name);
this one tests the result of an LDAP operation to see if the code is "LDAP_SUCCESS". like, did it work? yes or no? vibe check complete. β¨
$mesg is either a Net::LDAP::Message object returned by LDAP operation methods or a result code.
$name is the optional test name.
π ldap_result_is
ldap_result_is($mesg, $expect, $name);
this one tests the result of an LDAP operation to see if the code is equal to $expect. not just "did it succeed" β you're checking a specific code, main character energy. π
the values of $mesg and $expect are either a Net::LDAP::Message object returned by LDAP operation methods or a result code.
$name is the optional test name.
π¦ ldap_mockify
ldap_mockify {
# CODE
};
okay this one is lowkey iconic. inside the code block (recursively, so it goes all the way down), all the occurrences of "Net::LDAP::new" are replaced by "Test::Net::LDAP::Mock::new". boom, mocked. π
subclasses of "Net::LDAP" are also mockified. "Test::Net::LDAP::Mock" is inserted into @ISA of each subclass, only within the context of "ldap_mockify" β so when you're done, everything goes back to normal. cute, right?
see Test::Net::LDAP::Mock for more details.
π ldap_dn_is
ldap_dn_is($actual_dn, $expect_dn, $name);
tests equality of two DNs that are not necessarily canonicalized. so like, they don't have to match letter-for-letter in the strictest sense β you're just checking they're the same DN. π«
the comparison is case-insensitive. so don't come for me about capitalization, it genuinely does not care.
π reminder bestie: keep your DNs, your messages, and your expectations straight.$mesgcan be aNet::LDAP::Messageor a result code in bothldap_result_okandldap_result_is, and$nameis optional everywhere it shows up. iykyk.
that's the whole page, fr fr. this beauty comes to you from the User Contributed Perl Documentation, shipped as part of perl v5.34.0, dated 2022-06-28. slay, go write some tests, and remember: mock it before you clock it. π«Άβ¨πΈ
π¦ where this page comes from
- debian bookworm: libtest-net-ldap-perl 0.07-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtest-net-ldap-perl 0.07-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtest-net-ldap-perl 0.07-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtest-net-ldap-perl 0.07-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest-net-ldap-perl 0.07-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms