Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Open
LU Authorization
Commits
6d01ff8a
Commit
6d01ff8a
authored
Feb 22, 2022
by
Dainis Abols
Browse files
LDAPConnectionTest
parent
a5993f16
Changes
1
Hide whitespace changes
Inline
Side-by-side
Tests/Functional/LDAPConnectionTest.php
0 → 100644
View file @
6d01ff8a
<?php
declare
(
strict_types
=
1
);
namespace
Lu\LuAuth\Tests\Functional
;
use
Lu\LuAuth\Models\LDAP
;
use
Vendor\MyExtension\Service\AbstractSomethingService
;
use
TYPO3\TestingFramework\Core\Unit\UnitTestCase
;
/**
* Test for LDAP connection
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @since 21.02.2022
*/
class
LDAPConnectionTest
extends
UnitTestCase
{
protected
$resetSingletonInstances
=
true
;
/**
* LocalConfiguration file name and relative location
*
* @var string
*/
private
$LocalConfiguration
=
'public/typo3conf/LocalConfiguration.php'
;
/**
* Test connection
*
* @test
*/
public
function
connectionTest
():
void
{
// Fetch config data
$conf
=
@
include
$this
->
LocalConfiguration
;
// Assert configuration file fouind
$this
->
assertNotEmpty
(
$conf
,
'LocalConfiguration file not found ['
.
$this
->
LocalConfiguration
.
']'
);
$conf
=
@
$conf
[
'EXTENSIONS'
][
'lu_auth'
];
// Assert LDAP configured
$this
->
assertNotEmpty
(
$conf
[
'ldapServer'
],
'LDAP Server not configured'
);
$this
->
assertNotEmpty
(
$conf
[
'ldapDC'
],
'LDAP DC not configured'
);
// Assert connection
$ldap
=
new
LDAP
(
$conf
[
'ldapServer'
],
$conf
[
'ldapDC'
]);
$this
->
assertIsResource
(
$ldap
->
getConn
(),
'LDAP Resource not created'
);
// Assert test user configured
$this
->
assertNotEmpty
(
$conf
[
'ldapTestUser'
],
'LDAP Test user not configured'
);
$this
->
assertNotEmpty
(
$conf
[
'ldapTestPass'
],
'LDAP Test pass not configured'
);
// Assert user check
$user
=
$ldap
->
authorize
(
$conf
[
'ldapTestUser'
],
$conf
[
'ldapTestPass'
]);
$this
->
assertIsArray
(
$user
,
'LDAP User data not received'
);
$this
->
assertNotEmpty
(
$user
,
'LDAP User data is empty'
);
// Assert clear
$ldap
->
delConn
();
$this
->
assertNull
(
$ldap
->
getConn
(),
'LDAP Resource not cleared'
);
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment