From a471b061a81fe626794b9bc226c06a2bf07873e2 Mon Sep 17 00:00:00 2001 From: Jean-Laurent <jean-laurent.duzant@xelians.fr> Date: Fri, 8 Apr 2022 17:53:44 +0200 Subject: [PATCH] FEAT #20145 TIME 0:10 remove phone key in test obj && set fingerprint back to optional --- phpunit.xml | 2 +- src/app/user/controllers/UserController.php | 9 ++++----- src/app/user/models/UserModel.php | 4 +--- test/unitTests/app/user/UserControllerTest.php | 7 ++----- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 99f13c440e..8648b358c7 100755 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,7 +1,7 @@ <?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='HTTP_HOST' value='http://localhost/MaarchParapheur' /> <server name='SERVER_PORT' value='80' /> </php> <coverage> diff --git a/src/app/user/controllers/UserController.php b/src/app/user/controllers/UserController.php index 8929b5f1eb..151204693c 100755 --- a/src/app/user/controllers/UserController.php +++ b/src/app/user/controllers/UserController.php @@ -135,8 +135,6 @@ 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']); @@ -145,6 +143,10 @@ class UserController return $response->withStatus(400)->withJson(['errors' => 'Login already exists', 'lang' => 'userLoginAlreadyExists']); } + if (!empty($body['x509Fingerprint'])) { + $body['x509_fingerprint'] = $body['x509Fingerprint']; + } + if (!empty($body['isRest'])) { $body['"isRest"'] = true; } @@ -205,8 +207,6 @@ 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]]); @@ -218,7 +218,6 @@ class UserController 'firstname' => $body['firstname'], 'lastname' => $body['lastname'], 'email' => $body['email'], - 'phone' => $body['phone'], 'signature_modes' => [] ]; diff --git a/src/app/user/models/UserModel.php b/src/app/user/models/UserModel.php index 69c7d660dc..5c0835aae0 100755 --- a/src/app/user/models/UserModel.php +++ b/src/app/user/models/UserModel.php @@ -96,12 +96,10 @@ class UserModel 'password' => $args['password'], 'firstname' => $args['firstname'], 'lastname' => $args['lastname'], - 'phone' => $args['phone'], '"isRest"' => empty($args['isRest']) ? 'false' : 'true', 'picture' => $args['picture'], 'password_modification_date' => 'CURRENT_TIMESTAMP', - 'signature_modes' => $args['signatureModes'], - 'x509_fingerprint' => $args['x509_fingerprint'] + 'signature_modes' => $args['signatureModes'] ] ]); diff --git a/test/unitTests/app/user/UserControllerTest.php b/test/unitTests/app/user/UserControllerTest.php index 1960aea027..e3a5961a55 100755 --- a/test/unitTests/app/user/UserControllerTest.php +++ b/test/unitTests/app/user/UserControllerTest.php @@ -25,9 +25,7 @@ class UserControllerTest extends TestCase 'login' => 'emailLogin', 'firstname' => 'Prénom', 'lastname' => 'Nom', - 'email' => 'email@test.fr', - 'phone' => '0701020304', - 'x509_fingerprint' => 'fingerprint' + 'email' => 'email@test.fr' ]; $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); @@ -206,8 +204,7 @@ class UserControllerTest extends TestCase $aArgs = [ 'firstname' => 'Jolly', 'lastname' => 'Jumper', - 'email' => 'email@test.fr', - 'phone' => '0701020304' + 'email' => 'email@test.fr' ]; $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); -- GitLab