From e13d80f5cf396946ab131cdf451c2be63d7dca1a Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 11 Feb 2022 11:02:04 -0500 Subject: [PATCH] LDAPContext: take a root_password argument or generate one --- t/lib/LDAPContext.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/t/lib/LDAPContext.pm b/t/lib/LDAPContext.pm index 47188c2b..2cd1a19d 100644 --- a/t/lib/LDAPContext.pm +++ b/t/lib/LDAPContext.pm @@ -12,9 +12,15 @@ use Hydra::Helper::Exec; # It creates a top level organization and structure, and provides # add_user and add_group. # +# Hash Parameters: +# +# * root_password: The clear text password required for connecting to the LDAP server +# # The server is automatically terminated when the class is dropped. sub new { - my ($class) = @_; + my ($class, %opts) = @_; + + my $rootPassword = $opts{'root_password'} // rand_chars(); my $root = File::Temp->newdir(); mkdir $root; @@ -36,6 +42,7 @@ sub new { _slapd_dir => $slapd_dir, _socket => $socket, _tmpdir => $root, + root_password => $rootPassword, }; my $blessed = bless $self, $class; @@ -128,7 +135,7 @@ objectClass: olcMdbConfig olcDatabase: {1}mdb olcDbDirectory: ${\$self->{"_db_dir"}} olcRootDN: cn=root,dc=example -olcRootPW: notapassword +olcRootPW: ${\$self->{"root_password"}} olcSuffix: dc=example EOF }