Skip to content
Snippets Groups Projects
Commit 52190d8b authored by Jean-Laurent DUZANT's avatar Jean-Laurent DUZANT
Browse files

FEAT #18301 TIME 3:00 analyse et correction pour php 8.1

parent 239f780d
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="test/unitTests/define.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<php>
<server name='HTTP_HOST' value='http://localhost/MaarchParapheurDevelop' />
<server name='SERVER_PORT' value='80' />
</php>
<coverage>
<include>
<directory suffix="Test.php">test</directory>
......
......@@ -135,6 +135,8 @@ class UserController
return $response->withStatus(400)->withJson(['errors' => 'Body email is empty or not a valid email']);
} elseif (!empty($body['x509Fingerprint']) && !Validator::stringType()->validate($body['x509Fingerprint'])) {
return $response->withStatus(400)->withJson(['errors' => 'Body x509Fingerprint is not a string']);
} elseif (!Validator::stringType()->notEmpty()->validate($body['phone'])) {
return $response->withStatus(400)->withJson(['errors' => 'Body phone is empty or not a string']);
}
$body['login'] = strtolower($body['login']);
......@@ -143,8 +145,6 @@ class UserController
return $response->withStatus(400)->withJson(['errors' => 'Login already exists', 'lang' => 'userLoginAlreadyExists']);
}
$body['x509_fingerprint'] = $body['x509Fingerprint'];
if (!empty($body['isRest'])) {
$body['"isRest"'] = true;
}
......@@ -205,6 +205,8 @@ class UserController
return $response->withStatus(400)->withJson(['errors' => 'Body email is empty or not a valid email']);
} elseif (!empty($body['x509Fingerprint']) && !Validator::stringType()->validate($body['x509Fingerprint'])) {
return $response->withStatus(400)->withJson(['errors' => 'Body x509Fingerprint is not a string']);
} elseif (!Validator::stringType()->notEmpty()->validate($body['phone'])) {
return $response->withStatus(400)->withJson(['errors' => 'Body phone is empty or not a string']);
}
$user = UserModel::getById(['id' => $args['id'], 'select' => [1]]);
......
......@@ -101,7 +101,7 @@ class UserModel
'picture' => $args['picture'],
'password_modification_date' => 'CURRENT_TIMESTAMP',
'signature_modes' => $args['signatureModes'],
'x509_fingerprint' => $args['x509_fingerprint'],
'x509_fingerprint' => $args['x509_fingerprint']
]
]);
......
......@@ -105,7 +105,7 @@ class AuthenticationController
$connection = ConfigurationModel::getConnection();
if (in_array($connection, ['default', 'ldap'])) {
if (!Validator::stringType()->notEmpty()->validate($body['login']) || !Validator::stringType()->notEmpty()->validate($body['password'])) {
if (!array_key_exists('login', $body) || !array_key_exists('password', $body) || !Validator::stringType()->notEmpty()->validate($body['login']) || !Validator::stringType()->notEmpty()->validate($body['password'])) {
return $response->withStatus(400)->withJson(['errors' => 'Bad Request']);
}
}
......
......@@ -23,8 +23,8 @@ class PasswordModel
$aRules = DatabaseModel::select([
'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
'table' => ['password_rules'],
'where' => $aArgs['where'],
'data' => $aArgs['data'],
'where' => $aArgs['where'] ?? [],
'data' => $aArgs['data'] ?? [],
]);
return $aRules;
......
......@@ -22,10 +22,12 @@ class UserControllerTest extends TestCase
$request = \Slim\Http\Request::createFromEnvironment($environment);
$aArgs = [
'login' => 'emailLogin',
'firstname' => 'Prénom',
'lastname' => 'Nom',
'email' => 'email@test.fr'
'login' => 'emailLogin',
'firstname' => 'Prénom',
'lastname' => 'Nom',
'email' => 'email@test.fr',
'phone' => '0701020304',
'x509_fingerprint' => 'fingerprint'
];
$fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request);
......@@ -164,9 +166,9 @@ class UserControllerTest extends TestCase
$this->assertSame('Nom', $responseBody->user->lastname);
$response = $userController->getById($request, new \Slim\Http\Response(), ['id' => -1]);
$this->assertSame(400, $response->getStatusCode());
$responseBody = json_decode((string)$response->getBody());
$this->assertEmpty($responseBody->users);
$this->assertSame('User does not exist', $responseBody->errors);
}
public function testUpdate()
......@@ -204,7 +206,8 @@ class UserControllerTest extends TestCase
$aArgs = [
'firstname' => 'Jolly',
'lastname' => 'Jumper',
'email' => 'email@test.fr'
'email' => 'email@test.fr',
'phone' => '0701020304'
];
$fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment