Commit a3f6363e authored by Dainis Abols's avatar Dainis Abols
Browse files

Fixed notices, fixed missing configuration errors and removed dead code

Version 5.0.3
parent 5db4ecae
......@@ -82,15 +82,15 @@ class LDAP
*/
public function authorize($username, $password)
{
if (@ldap_bind($this->conn, "uid={$username},{$this->dc}", $password)) {
if (ldap_bind($this->conn, "uid={$username},{$this->dc}", $password)) {
if ($search = ldap_search($this->conn, "uid={$username},{$this->dc}", "(cn=*)")) {
$info = ldap_get_entries($this->conn, $search)[0];
$user = [
'username' => $username,
'display_name' => $info['displayname']['0'],
'email' => $info['mail']['0'],
'phone' => $info['telephonenumber']['0'],
'email' => $info['mail']['0'] ?? "",
'phone' => $info['telephonenumber']['0'] ?? "",
];
return $user;
......
......@@ -80,21 +80,22 @@ class Server
// Set config value
try {
$this->conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('lu_auth');
} catch (ExtensionConfigurationExtensionNotConfiguredException | ExtensionConfigurationPathDoesNotExistException $e) {
} catch (ExtensionConfigurationExtensionNotConfiguredException|ExtensionConfigurationPathDoesNotExistException|\ArgumentCountError $e) {
$this->logger->info("Extension `lu_auth` not configured!");
}
// Set server variables
$this->remoteIdentityProvider = $_SERVER[$this->conf['remoteIdentityProvider']] ?: "";
$this->remoteSessionId = $_SERVER[$this->conf['remoteSessionId']] ?: "";
$this->remoteUser = $_SERVER[$this->conf['remoteUser']] ?: "";
$this->remoteSessionId = $_SERVER[$this->conf['remoteSessionId']] ?: "";
$this->remoteUser = $_SERVER[$this->conf['remoteUser']] ?: "";
}
/**
* @param $OK
* @param $user
* @param $auth
* @param $OK
* @param $user
* @param $auth
* @param false $log
*
* @return false|mixed
*/
public function checkDomainLock($OK, $user, $auth, bool $log = false)
......@@ -113,5 +114,5 @@ class Server
}
return $OK;
}
}
}
\ No newline at end of file
......@@ -24,7 +24,7 @@ class LDAPConnectionTest extends UnitTestCase
*
* @var string
*/
private $LocalConfiguration = 'public/typo3conf/LocalConfiguration.php';
private string $LocalConfiguration = 'public/typo3conf/LocalConfiguration.php';
/**
* Test connection
......
<?php
declare(strict_types=1);
namespace Lu\LuAuth\Tests\Unit;
use Vendor\MyExtension\Service\AbstractSomethingService;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
/**
* Tests for Frontend authorization
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @since 21.02.2022
*/
class FEAuthorizationTest extends UnitTestCase
{
public function initTest() {}
public function getUserTest() {}
public function authUserTest() {}
private function syncSingleUserDataTest() {}
private function setLogoutTest() {}
}
Add to composer, when tests finished!
```
"autoload-dev": {
"psr-4": {
"Lu\\LuAuth\\Tests\\": "Tests"
}
},
```
\ No newline at end of file
{
"name": "luitd/lu-auth",
"version": "5.0.2",
"version": "5.0.3",
"description": "TYPO3 Authentication for University of Latvia",
"type": "typo3-cms-extension",
"keywords": [
......
......@@ -14,7 +14,7 @@ $EM_CONF[$_EXTKEY] = [
'title' => 'LU Authentication',
'description' => 'TYPO3 Authentication for University of Latvia',
'category' => 'misc',
'version' => '5.0.2',
'version' => '5.0.3',
'dependencies' => 'typo3,lu_api',
'state' => 'stable',
'clearCacheOnLoad' => 1,
......
......@@ -3,7 +3,7 @@
## Version
5.0.2
5.0.3
## Dependencies
......@@ -17,7 +17,7 @@ Dainis Abols <dainis.abols@lu.lv>
## Configuration
| Tab | Var name | Meaning |
| Tab | Test name | Meaning |
|------------|------------------------|------------------------------|
| LDAP | ldapServer | LDAP Server |
| LDAP | ldapDC | LDAP Domain Component |
......@@ -35,9 +35,8 @@ Dainis Abols <dainis.abols@lu.lv>
## Testing
```shell
./vendor/bin/phpunit public/typo3conf/ext/lu_auth/Tests/<test-file>
./vendor/bin/phpunit public/typo3conf/ext/lu_auth/Tests (or /<test-file>)
```
| Test name | Test File | Assertions |
|----------------|--------------------------------|------------|
| connectionTest | Functional/LDAPConnection.php | 11 |
| Test File | Assertions |
|-----------------------------------|------------|
| Functional/LDAPConnectionTest.php | 11 |
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment