From d577d1170364596850bc694a9994cb71db835c7d Mon Sep 17 00:00:00 2001 From: Luciano Righetti Date: Wed, 2 Mar 2022 16:31:39 +0100 Subject: [PATCH 1/2] fix: update library, has a boolean validation bug --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 6d48735..7e0ae69 100644 --- a/composer.json +++ b/composer.json @@ -19,9 +19,10 @@ "cakephp/bake": "^2.0.3", "cakephp/cakephp-codesniffer": "~4.0.0", "cakephp/debug_kit": "^4.0", + "cebe/php-openapi": "^1.6", "fzaninotto/faker": "^1.9", "josegonzalez/dotenv": "^3.2", - "league/openapi-psr7-validator": "^0.16.4", + "league/openapi-psr7-validator": "^0.17", "phpunit/phpunit": "^8.5", "psy/psysh": "@stable", "wiremock-php/wiremock-php": "^2.32" @@ -65,4 +66,4 @@ "sort-packages": true }, "minimum-stability": "dev" -} \ No newline at end of file +} From 39e9d866bfb1ee7198fa6580118c9074ea512bf4 Mon Sep 17 00:00:00 2001 From: Luciano Righetti Date: Wed, 2 Mar 2022 16:32:06 +0100 Subject: [PATCH 2/2] fix: warnings, notices, deprecation errors --- .../default/InboxProcessors/LocalToolInboxProcessor.php | 4 ++-- libraries/default/InboxProcessors/UserInboxProcessor.php | 6 +++--- src/Controller/SharingGroupsController.php | 1 + tests/Helper/ApiTestTrait.php | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libraries/default/InboxProcessors/LocalToolInboxProcessor.php b/libraries/default/InboxProcessors/LocalToolInboxProcessor.php index 8852f9e..2dacab8 100644 --- a/libraries/default/InboxProcessors/LocalToolInboxProcessor.php +++ b/libraries/default/InboxProcessors/LocalToolInboxProcessor.php @@ -159,9 +159,9 @@ class LocalToolInboxProcessor extends GenericInboxProcessor { return $validator ->requirePresence('connectorName') - ->notEmpty('connectorName', 'The connector name must be provided') + ->notEmptyString('connectorName', 'The connector name must be provided') ->requirePresence('cerebrateURL') - ->notEmpty('cerebrateURL', 'A url must be provided') + ->notEmptyString('cerebrateURL', 'A url must be provided') ->requirePresence('local_tool_id') ->numeric('local_tool_id', 'A local_tool_id must be provided') ->requirePresence('remote_tool_id') diff --git a/libraries/default/InboxProcessors/UserInboxProcessor.php b/libraries/default/InboxProcessors/UserInboxProcessor.php index 53312d5..abb9550 100644 --- a/libraries/default/InboxProcessors/UserInboxProcessor.php +++ b/libraries/default/InboxProcessors/UserInboxProcessor.php @@ -37,13 +37,13 @@ class RegistrationProcessor extends UserInboxProcessor implements GenericInboxPr protected function addValidatorRules($validator) { return $validator - ->notEmpty('username', 'A username must be provided.') + ->notEmptyString('username', 'A username must be provided.') ->add('email', 'validFormat', [ 'rule' => 'email', 'message' => 'E-mail must be valid' ]) - ->notEmpty('first_name', 'A first name must be provided') - ->notEmpty('last_name', 'A last name must be provided') + ->notEmptyString('first_name', 'A first name must be provided') + ->notEmptyString('last_name', 'A last name must be provided') ->add('password', 'password_complexity', [ 'rule' => function($value, $context) { if (!preg_match('/^((?=.*\d)|(?=.*\W+))(?![\n])(?=.*[A-Z])(?=.*[a-z]).*$|.{16,}/s', $value) || strlen($value) < 12) { diff --git a/src/Controller/SharingGroupsController.php b/src/Controller/SharingGroupsController.php index e03aee5..41a4c66 100644 --- a/src/Controller/SharingGroupsController.php +++ b/src/Controller/SharingGroupsController.php @@ -113,6 +113,7 @@ class SharingGroupsController extends AppController public function delete($id) { $currentUser = $this->ACL->getUser(); + $params = []; if (empty($currentUser['role']['perm_admin'])) { $params['conditions'] = ['organisation_id' => $currentUser['organisation_id']]; } diff --git a/tests/Helper/ApiTestTrait.php b/tests/Helper/ApiTestTrait.php index 4b3986f..3e71622 100644 --- a/tests/Helper/ApiTestTrait.php +++ b/tests/Helper/ApiTestTrait.php @@ -56,6 +56,7 @@ trait ApiTestTrait // somehow this is not set automatically in test environment $_SERVER['HTTP_AUTHORIZATION'] = $authToken; + $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; $this->configRequest([ 'headers' => [