Skip to content

Commit

Permalink
Use default client options for admin connection
Browse files Browse the repository at this point in the history
  • Loading branch information
tatankat committed Aug 24, 2022
1 parent fe4f0ce commit 6cf08f6
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions tests/Unit/Plugin/Authentication/Ldap/LdapPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ private function acceptCertificates(): void
ldap_set_option(null, LDAP_OPT_X_TLS_CACERTFILE, JPATH_ROOT.'/tests/Codeception/_data/certs/CA.crt');
}

private function getAdminConnection(string $encryption): Ldap
private function getAdminConnection(array $options): Ldap
{
$admin_options = [
'host' => "localhost",
'port' => ($encryption == "ssl" ? self::SSLPORT : self::LDAPPORT),
'version' => 3,
'encryption' => $encryption,
'referrals' => false,
'debug' => false,
'host' => $options['host'],
'port' => (int) $options['port'],
'version' => $options['use_ldapV3'] == '1' ? 3 : 2,
'referrals' => (bool) $options['no_referrals'],
'encryption' => $options['encryption'],
'debug' => (bool) $options['ldap_debug'],
];
$ldap = Ldap::create(
'ext_ldap',
Expand All @@ -77,9 +77,9 @@ private function getAdminConnection(string $encryption): Ldap
return $ldap;
}

private function requireEncryption($encryption): void
private function requireEncryption($encryption, $options): void
{
$ldap = $this->getAdminConnection($encryption);
$ldap = $this->getAdminConnection($options);
//TODO configure openldap to require the requested encryption
}

Expand All @@ -95,7 +95,7 @@ public function setUp(): void
// tests are executed in parallel as root
// setUp is executed before every test
$this->default_options = [
'host' => "localhost",
'host' => "openldap",
'port' => self::LDAPPORT,
'use_ldapV3' => 1,
'encryption' => "none",
Expand Down Expand Up @@ -201,7 +201,7 @@ public function testOnUserAuthenticateAnonymousSearchTLS()
$plugin = $this->getPlugin($options);

$this->acceptCertificates();
$this->requireEncryption("tls");
$this->requireEncryption("tls", $options);

$response = new AuthenticationResponse();
$plugin->onUserAuthenticate($this->default_credentials, [], $response);
Expand All @@ -227,7 +227,7 @@ public function testOnUserAuthenticateAnonymousSearchSSL()
$plugin = $this->getPlugin($options);

$this->acceptCertificates();
$this->requireEncryption("ssl");
$this->requireEncryption("ssl",$options);

$response = new AuthenticationResponse();
$plugin->onUserAuthenticate($this->default_credentials, [], $response);
Expand Down

0 comments on commit 6cf08f6

Please sign in to comment.