From 0dc6089f8a8766462e126d9b9f73d3ea42c9aab3 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Wed, 1 May 2024 16:44:18 +0200 Subject: [PATCH] mvc - replace \Phalcon\Filter\Validation\Exception with \OPNsense\Base\ValidationException (both simple empty Exception classes). for https://github.com/opnsense/core/issues/6389 --- plist | 1 + .../Base/ApiMutableModelControllerBase.php | 14 ++++---- .../OPNsense/Cron/Api/SettingsController.php | 6 ++-- .../Diagnostics/Api/NetflowController.php | 2 +- .../OPNsense/Firewall/Api/AliasController.php | 8 ++--- .../Firewall/Api/CategoryController.php | 6 ++-- .../OPNsense/Firewall/Api/GroupController.php | 6 ++-- .../OPNsense/IDS/Api/ServiceController.php | 2 +- .../OPNsense/IDS/Api/SettingsController.php | 34 +++++++++--------- .../OPNsense/Monit/Api/SettingsController.php | 22 ++++++------ .../OPNsense/Routes/Api/RoutesController.php | 8 ++--- .../Syslog/Api/SettingsController.php | 8 ++--- .../TrafficShaper/Api/SettingsController.php | 22 ++++++------ .../app/models/OPNsense/Base/BaseModel.php | 2 +- .../OPNsense/Base/ValidationException.php | 35 +++++++++++++++++++ .../models/OPNsense/Base/BaseModelTest.php | 4 +-- .../Base/FieldTypes/AuthGroupFieldTest.php | 4 +-- .../AuthenticationServerFieldTest.php | 4 +-- .../Base/FieldTypes/Base64FieldTest.php | 2 +- .../Base/FieldTypes/BooleanFieldTest.php | 6 ++-- .../Base/FieldTypes/CertificateFieldTest.php | 4 +-- .../Base/FieldTypes/CountryFieldTest.php | 6 ++-- .../FieldTypes/Field_Framework_TestCase.php | 4 +-- .../Base/FieldTypes/HostnameFieldTest.php | 2 +- .../Base/FieldTypes/IPPortFieldTest.php | 14 ++++---- .../Base/FieldTypes/IntegerFieldTest.php | 6 ++-- .../Base/FieldTypes/InterfaceFieldTest.php | 6 ++-- .../Base/FieldTypes/OptionFieldTest.php | 2 +- .../Base/FieldTypes/PortFieldTest.php | 2 +- .../Base/FieldTypes/ProtocolFieldTest.php | 2 +- .../Base/FieldTypes/TextFieldTest.php | 2 +- 31 files changed, 141 insertions(+), 105 deletions(-) create mode 100644 src/opnsense/mvc/app/models/OPNsense/Base/ValidationException.php diff --git a/plist b/plist index 310bddd97..9f1910940 100644 --- a/plist +++ b/plist @@ -588,6 +588,7 @@ /usr/local/opnsense/mvc/app/models/OPNsense/Base/Messages/Message.php /usr/local/opnsense/mvc/app/models/OPNsense/Base/ModelException.php /usr/local/opnsense/mvc/app/models/OPNsense/Base/Validation.php +/usr/local/opnsense/mvc/app/models/OPNsense/Base/ValidationException.php /usr/local/opnsense/mvc/app/models/OPNsense/Base/Validators/CallbackValidator.php /usr/local/opnsense/mvc/app/models/OPNsense/Base/Validators/CsvListValidator.php /usr/local/opnsense/mvc/app/models/OPNsense/Base/Validators/Email.php diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php b/src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php index 2d3e2a054..dad11104b 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php @@ -226,7 +226,7 @@ abstract class ApiMutableModelControllerBase extends ApiControllerBase * @param string $node reference node, to use as relative offset * @param string $prefix prefix to use when $node is provided (defaults to static::$internalModelName) * @return array result / validation output - * @throws \Phalcon\Filter\Validation\Exception on validation issues + * @throws \OPNsense\Base\ValidationException on validation issues * @throws \ReflectionException when binding to the model class fails * @throws UserException when denied write access */ @@ -296,7 +296,7 @@ abstract class ApiMutableModelControllerBase extends ApiControllerBase * @param bool $validateFullModel by default we only validate the fields we have changed * @param bool $disable_validation skip validation, be careful to use this! * @return array result / validation output - * @throws \Phalcon\Filter\Validation\Exception on validation issues + * @throws \OPNsense\Base\ValidationException on validation issues * @throws \ReflectionException when binding to the model class fails * @throws \OPNsense\Base\UserException when denied write access */ @@ -340,7 +340,7 @@ abstract class ApiMutableModelControllerBase extends ApiControllerBase /** * Update model settings * @return array status / validation errors - * @throws \Phalcon\Filter\Validation\Exception on validation issues + * @throws \OPNsense\Base\ValidationException on validation issues * @throws \ReflectionException when binding to the model class fails * @throws UserException when denied write access */ @@ -445,7 +445,7 @@ abstract class ApiMutableModelControllerBase extends ApiControllerBase * @param string $path relative model path * @param array|null $overlay properties to overlay when available (call setNodes) * @return array - * @throws \Phalcon\Filter\Validation\Exception on validation issues + * @throws \OPNsense\Base\ValidationException on validation issues * @throws \ReflectionException when binding to the model class fails * @throws UserException when denied write access */ @@ -485,7 +485,7 @@ abstract class ApiMutableModelControllerBase extends ApiControllerBase * @param string $path relative model path * @param null|string $uuid node key * @return array - * @throws \Phalcon\Filter\Validation\Exception on validation issues + * @throws \OPNsense\Base\ValidationException on validation issues * @throws \ReflectionException when binding to the model class fails * @throws UserException when denied write access */ @@ -520,7 +520,7 @@ abstract class ApiMutableModelControllerBase extends ApiControllerBase * @param string $uuid node key * @param array|null $overlay properties to overlay when available (call setNodes) * @return array - * @throws \Phalcon\Filter\Validation\Exception on validation issues + * @throws \OPNsense\Base\ValidationException on validation issues * @throws \ReflectionException when binding to the model class fails * @throws UserException when denied write access */ @@ -569,7 +569,7 @@ abstract class ApiMutableModelControllerBase extends ApiControllerBase * @param string $uuid node key * @param string $enabled desired state enabled(1)/disabled(0), leave empty for toggle * @return array - * @throws \Phalcon\Filter\Validation\Exception on validation issues + * @throws \OPNsense\Base\ValidationException on validation issues * @throws \ReflectionException when binding to the model class fails * @throws UserException when denied write access */ diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php index f4b1d3103..c83960e17 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php @@ -103,7 +103,7 @@ class SettingsController extends ApiMutableModelControllerBase * add new job and set with attributes from post * @return array save result + validation output * @throws \OPNsense\Base\ModelException when not bound to model - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException */ public function addJobAction() @@ -116,7 +116,7 @@ class SettingsController extends ApiMutableModelControllerBase * delete job by uuid ( only if origin is cron) * @param string $uuid item unique id * @return array status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model * @throws \OPNsense\Base\ModelException when not bound to model */ @@ -136,7 +136,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid item unique id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleJobAction($uuid, $enabled = null) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/NetflowController.php b/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/NetflowController.php index 7b6edf258..dd8c524c5 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/NetflowController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/NetflowController.php @@ -74,7 +74,7 @@ class NetflowController extends ApiControllerBase /** * update netflow configuration fields * @return array - * @throws \Phalcon\Filter\Validation\Exception + * @throws \OPNsense\Base\ValidationException */ public function setconfigAction() { diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php b/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php index 75181677b..ac840ea7d 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php @@ -133,7 +133,7 @@ class AliasController extends ApiMutableModelControllerBase * Update alias with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function setItemAction($uuid) @@ -159,7 +159,7 @@ class AliasController extends ApiMutableModelControllerBase * Add new alias and set with attributes from post * @return array save result + validation output * @throws \OPNsense\Base\ModelException when not bound to model - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function addItemAction() @@ -210,7 +210,7 @@ class AliasController extends ApiMutableModelControllerBase * Delete alias by uuid, save contents to tmp for removal on apply * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model * @throws \OPNsense\Base\UserException when unable to delete */ @@ -237,7 +237,7 @@ class AliasController extends ApiMutableModelControllerBase * @param string $uuid id to toggled * @param string|null $enabled set enabled by default * @return array status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleItemAction($uuid, $enabled = null) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/CategoryController.php b/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/CategoryController.php index f15407288..81211121a 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/CategoryController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/CategoryController.php @@ -64,7 +64,7 @@ class CategoryController extends ApiMutableModelControllerBase * Update category with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function setItemAction($uuid) @@ -85,7 +85,7 @@ class CategoryController extends ApiMutableModelControllerBase * Add new category and set with attributes from post * @return array save result + validation output * @throws \OPNsense\Base\ModelException when not bound to model - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function addItemAction() @@ -108,7 +108,7 @@ class CategoryController extends ApiMutableModelControllerBase * Delete alias by uuid, save contents to tmp for removal on apply * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model * @throws \OPNsense\Base\UserException when unable to delete */ diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/GroupController.php b/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/GroupController.php index ecc5c7a73..67b546721 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/GroupController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/GroupController.php @@ -57,7 +57,7 @@ class GroupController extends ApiMutableModelControllerBase * Update group with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function setItemAction($uuid) @@ -84,7 +84,7 @@ class GroupController extends ApiMutableModelControllerBase * Add new group and set with attributes from post * @return array save result + validation output * @throws \OPNsense\Base\ModelException when not bound to model - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function addItemAction() @@ -107,7 +107,7 @@ class GroupController extends ApiMutableModelControllerBase * Delete alias by uuid, save contents to tmp for removal on apply * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model * @throws \OPNsense\Base\UserException when unable to delete */ diff --git a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/ServiceController.php b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/ServiceController.php index 131aed21f..ab9bf08a3 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/ServiceController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/ServiceController.php @@ -52,7 +52,7 @@ class ServiceController extends ApiMutableServiceControllerBase * @return array result status * @throws \Exception when configd action fails * @throws \OPNsense\Base\ModelException when unable to construct model - * @throws \Phalcon\Filter\Validation\Exception when one or more model validations fail + * @throws \OPNsense\Base\ValidationException when one or more model validations fail */ public function reconfigureAction() { diff --git a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php index 9e2ba648d..7a50dccde 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php @@ -319,7 +319,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update ruleset properties * @return array result status * @throws \Exception when config action fails - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function setRulesetpropertiesAction() @@ -408,7 +408,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $filename rule filename (key) * @return array result status * @throws \Exception when configd action fails - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function setRulesetAction($filename) @@ -445,7 +445,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array status 0/1 or error * @throws \Exception - * @throws \Phalcon\Filter\Validation\Exception + * @throws \OPNsense\Base\ValidationException */ public function toggleRulesetAction($filenames, $enabled = null) { @@ -488,7 +488,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param string|int $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array empty * @throws \Exception when configd action fails - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleRuleAction($sids, $enabled = null) @@ -543,7 +543,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $sid item unique id * @return array result status * @throws \Exception when configd action fails - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function setRuleAction($sid) @@ -584,7 +584,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update user defined rules * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function setUserRuleAction($uuid) @@ -595,7 +595,7 @@ class SettingsController extends ApiMutableModelControllerBase /** * Add new user defined rule * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function addUserRuleAction() @@ -618,7 +618,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete user rule item * @param string $uuid user rule internal id * @return array save status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function delUserRuleAction($uuid) @@ -631,7 +631,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid user defined rule internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleUserRuleAction($uuid, $enabled = null) @@ -653,7 +653,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update policy * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function setPolicyAction($uuid) @@ -664,7 +664,7 @@ class SettingsController extends ApiMutableModelControllerBase /** * Add new policy * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function addPolicyAction() @@ -687,7 +687,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete policy item * @param string $uuid user rule internal id * @return array save status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function delPolicyAction($uuid) @@ -700,7 +700,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid user defined rule internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function togglePolicyAction($uuid, $enabled = null) @@ -726,7 +726,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update policy rule adjustment * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function setPolicyRuleAction($uuid) @@ -737,7 +737,7 @@ class SettingsController extends ApiMutableModelControllerBase /** * Add new policy rule adjustment * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function addPolicyRuleAction() @@ -760,7 +760,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete policy rule adjustment item * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function delPolicyRuleAction($uuid) @@ -773,7 +773,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid user internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function togglePolicyRuleAction($uuid, $enabled = null) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Monit/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/Monit/Api/SettingsController.php index 6bfca3b66..a3e8ec973 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Monit/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Monit/Api/SettingsController.php @@ -69,7 +69,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update alert with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function setAlertAction($uuid) @@ -80,7 +80,7 @@ class SettingsController extends ApiMutableModelControllerBase /** * Add alert with given properties * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function addAlertAction() @@ -92,7 +92,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete alert by uuid * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function delAlertAction($uuid) @@ -119,7 +119,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid alert internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleAlertAction($uuid, $enabled = null) @@ -142,7 +142,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update service with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function setServiceAction($uuid) @@ -153,7 +153,7 @@ class SettingsController extends ApiMutableModelControllerBase /** * Add service with given properties * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function addServiceAction() @@ -165,7 +165,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete service by uuid * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function delServiceAction($uuid) @@ -188,7 +188,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid service internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleServiceAction($uuid, $enabled = null) @@ -211,7 +211,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update test with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function setTestAction($uuid) @@ -222,7 +222,7 @@ class SettingsController extends ApiMutableModelControllerBase /** * Add test with given properties * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function addTestAction() @@ -234,7 +234,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete test by uuid * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function delTestAction($uuid) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Routes/Api/RoutesController.php b/src/opnsense/mvc/app/controllers/OPNsense/Routes/Api/RoutesController.php index 86ec39e67..f7c62e5d7 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Routes/Api/RoutesController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Routes/Api/RoutesController.php @@ -60,7 +60,7 @@ class RoutesController extends ApiMutableModelControllerBase * Update route with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function setrouteAction($uuid) @@ -80,7 +80,7 @@ class RoutesController extends ApiMutableModelControllerBase * Add new route and set with attributes from post * @return array save result + validation output * @throws \OPNsense\Base\ModelException when not bound to model - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException */ public function addrouteAction() @@ -103,7 +103,7 @@ class RoutesController extends ApiMutableModelControllerBase * Delete route by uuid, save contents to tmp for removal on apply * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model * @throws \OPNsense\Base\ModelException when not bound to model */ @@ -123,7 +123,7 @@ class RoutesController extends ApiMutableModelControllerBase * @param string $uuid id to toggled * @param string|null $disabled set disabled by default * @return array status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model * @throws \OPNsense\Base\ModelException when not bound to model */ diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Syslog/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/Syslog/Api/SettingsController.php index 216a9ed6b..329902aa3 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Syslog/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Syslog/Api/SettingsController.php @@ -72,7 +72,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update destination with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function setDestinationAction($uuid) @@ -84,7 +84,7 @@ class SettingsController extends ApiMutableModelControllerBase * Add new destination and set with attributes from post * @return array save result + validation output * @throws \OPNsense\Base\ModelException when not bound to model - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail */ public function addDestinationAction() { @@ -94,7 +94,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete destination by uuid * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function delDestinationAction($uuid) @@ -107,7 +107,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid user defined rule internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleDestinationAction($uuid, $enabled = null) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/Api/SettingsController.php index 2054cf361..76692e20a 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/Api/SettingsController.php @@ -59,7 +59,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update pipe with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function setPipeAction($uuid) @@ -71,7 +71,7 @@ class SettingsController extends ApiMutableModelControllerBase * Add new pipe and set with attributes from post * @return array save result + validation output * @throws \OPNsense\Base\ModelException when not bound to model - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail */ public function addPipeAction() { @@ -85,7 +85,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete pipe by uuid * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function delPipeAction($uuid) @@ -99,7 +99,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid user defined rule internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function togglePipeAction($uuid, $enabled = null) @@ -151,7 +151,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update queue with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function setQueueAction($uuid) @@ -175,7 +175,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete queue by uuid * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function delQueueAction($uuid) @@ -188,7 +188,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid user defined rule internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleQueueAction($uuid, $enabled = null) @@ -232,7 +232,7 @@ class SettingsController extends ApiMutableModelControllerBase * Update rule with given properties * @param string $uuid internal id * @return array save result + validation output - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function setRuleAction($uuid) @@ -244,7 +244,7 @@ class SettingsController extends ApiMutableModelControllerBase * Add new rule and set with attributes from post * @return array save result + validation output * @throws \OPNsense\Base\ModelException when not bound to model - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail */ public function addRuleAction() { @@ -254,7 +254,7 @@ class SettingsController extends ApiMutableModelControllerBase * Delete rule by uuid * @param string $uuid internal id * @return array save status - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function delRuleAction($uuid) @@ -267,7 +267,7 @@ class SettingsController extends ApiMutableModelControllerBase * @param $uuid user defined rule internal id * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @return array save result - * @throws \Phalcon\Filter\Validation\Exception when field validations fail + * @throws \OPNsense\Base\ValidationException when field validations fail * @throws \ReflectionException when not bound to model */ public function toggleRuleAction($uuid, $enabled = null) diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php b/src/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php index 4b47aa652..9829f6b45 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php @@ -645,7 +645,7 @@ abstract class BaseModel $logger->error($exception_msg_part); } if (!$disable_validation) { - throw new \Phalcon\Filter\Validation\Exception($exception_msg); + throw new ValidationException($exception_msg); } } diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/ValidationException.php b/src/opnsense/mvc/app/models/OPNsense/Base/ValidationException.php new file mode 100644 index 000000000..828448d66 --- /dev/null +++ b/src/opnsense/mvc/app/models/OPNsense/Base/ValidationException.php @@ -0,0 +1,35 @@ +expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("not a valid number"); // replace all numbers foreach (BaseModelTest::$model->arraytypes->item->iterateItems() as $nodeid => $node) { @@ -244,7 +244,7 @@ class BaseModelTest extends \PHPUnit\Framework\TestCase */ public function testConstraintsNok() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("number should be unique"); $count = 2; foreach (BaseModelTest::$model->arraytypes->item->iterateItems() as $nodeid => $node) { diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/AuthGroupFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/AuthGroupFieldTest.php index e7b8f5705..d78a2f34a 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/AuthGroupFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/AuthGroupFieldTest.php @@ -70,7 +70,7 @@ class AuthGroupFieldTest extends Field_Framework_TestCase */ public function testSelectSetWithUnknownValue() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("CsvListValidator"); // init field $field = new AuthGroupField(); @@ -99,7 +99,7 @@ class AuthGroupFieldTest extends Field_Framework_TestCase */ public function testSelectSetOnSingleValue() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("InclusionIn"); // init field $field = new AuthGroupField(); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/AuthenticationServerFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/AuthenticationServerFieldTest.php index 99d5c1cbd..ee1af54fa 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/AuthenticationServerFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/AuthenticationServerFieldTest.php @@ -83,7 +83,7 @@ class AuthenticationServerFieldTest extends Field_Framework_TestCase */ public function testSelectSetWithUnknownValue() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("CsvListValidator"); // init field $field = new AuthenticationServerField(); @@ -112,7 +112,7 @@ class AuthenticationServerFieldTest extends Field_Framework_TestCase */ public function testSelectSetOnSingleValue() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("InclusionIn"); // init field $field = new AuthenticationServerField(); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/Base64FieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/Base64FieldTest.php index 718f561bd..ab8dd8a11 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/Base64FieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/Base64FieldTest.php @@ -45,7 +45,7 @@ class Base64FieldTest extends Field_Framework_TestCase public function testRequiredEmpty() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("PresenceOf"); $field = new Base64Field(); $field->setRequired("Y"); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/BooleanFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/BooleanFieldTest.php index 724fd93a1..4a6da8b28 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/BooleanFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/BooleanFieldTest.php @@ -50,7 +50,7 @@ class BooleanFieldTest extends Field_Framework_TestCase */ public function testShouldNotBeANumber() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("Regex"); $field = new BooleanField(); $field->setValue("90"); @@ -61,7 +61,7 @@ class BooleanFieldTest extends Field_Framework_TestCase */ public function testShouldNotBeAString() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("Regex"); $field = new BooleanField(); $field->setValue("xx"); @@ -73,7 +73,7 @@ class BooleanFieldTest extends Field_Framework_TestCase */ public function testRequiredEmpty() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("PresenceOf"); $field = new BooleanField(); $field->setRequired("Y"); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/CertificateFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/CertificateFieldTest.php index 78ca235fb..b75d07608 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/CertificateFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/CertificateFieldTest.php @@ -83,7 +83,7 @@ class CertificateFieldTest extends Field_Framework_TestCase */ public function testSelectSetWithUnknownValue() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("CsvListValidator"); // init field $field = new CertificateField(); @@ -112,7 +112,7 @@ class CertificateFieldTest extends Field_Framework_TestCase */ public function testSelectSetOnSingleValue() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("InclusionIn"); // init field $field = new CertificateField(); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/CountryFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/CountryFieldTest.php index beaf157b1..f41d8f528 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/CountryFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/CountryFieldTest.php @@ -50,7 +50,7 @@ class CountryFieldTest extends Field_Framework_TestCase */ public function testRequiredEmpty() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("PresenceOf"); $field = new CountryField(); $field->eventPostLoading(); @@ -101,7 +101,7 @@ class CountryFieldTest extends Field_Framework_TestCase */ public function testSelectSetWithUnknownValue() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("CsvListValidator"); // init field $field = new CountryField(); @@ -144,7 +144,7 @@ class CountryFieldTest extends Field_Framework_TestCase */ public function testSelectSetOnSingleValue() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("InclusionIn"); // init field $field = new CountryField(); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/Field_Framework_TestCase.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/Field_Framework_TestCase.php index 068b3c979..91b443d1b 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/Field_Framework_TestCase.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/Field_Framework_TestCase.php @@ -37,7 +37,7 @@ class Field_Framework_TestCase extends \PHPUnit\Framework\TestCase /** * Validate and throw exception * @param string $field field type - * @throws \Phalcon\Filter\Validation\Exception + * @throws \OPNsense\Base\ValidationException */ public function validateThrow($field) { @@ -49,7 +49,7 @@ class Field_Framework_TestCase extends \PHPUnit\Framework\TestCase $messages = $validation->validate(array("testfield" => (string)$field)); if (count($messages)) { foreach ($messages as $message) { - throw new \Phalcon\Filter\Validation\Exception($message->getType()); + throw new \OPNsense\Base\ValidationException($message->getType()); } } return; diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/HostnameFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/HostnameFieldTest.php index 069946086..bc940db88 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/HostnameFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/HostnameFieldTest.php @@ -45,7 +45,7 @@ class HostnameFieldTest extends Field_Framework_TestCase public function testRequiredEmpty() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("PresenceOf"); $field = new HostnameField(); $field->setRequired("Y"); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/IPPortFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/IPPortFieldTest.php index 729d852b9..1a7f91ce1 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/IPPortFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/IPPortFieldTest.php @@ -45,7 +45,7 @@ class IPPortFieldTest extends Field_Framework_TestCase public function testRequiredEmpty() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("PresenceOf"); $field = new IPPortField(); $field->setRequired("Y"); @@ -100,7 +100,7 @@ class IPPortFieldTest extends Field_Framework_TestCase public function testInvalidValueIpv4() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $field = new IPPortField(); $field->setValue("abcdefg"); $this->validateThrow($field); @@ -108,7 +108,7 @@ class IPPortFieldTest extends Field_Framework_TestCase public function testInvalidValueAsListIpv4() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $field = new IPPortField(); $field->setAsList("Y"); $field->setValue("127.0.0.1:2056,abcdefg"); @@ -117,7 +117,7 @@ class IPPortFieldTest extends Field_Framework_TestCase public function testInvalidValueIpv6() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $field = new IPPortField(); $field->setValue("[::1]"); $this->validateThrow($field); @@ -125,7 +125,7 @@ class IPPortFieldTest extends Field_Framework_TestCase public function testInvalidValueAsListIpv6() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $field = new IPPortField(); $field->setAsList("Y"); $field->setValue("[::1]:2056,[fe80::]"); @@ -134,7 +134,7 @@ class IPPortFieldTest extends Field_Framework_TestCase public function testAddressFamilyIpv4() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $field = new IPPortField(); $field->setAddressFamily("ipv4"); $field->setValue("[::1]:2056"); @@ -143,7 +143,7 @@ class IPPortFieldTest extends Field_Framework_TestCase public function testAddressFamilyIpv6() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $field = new IPPortField(); $field->setAddressFamily("ipv6"); $field->setValue("192.168.1.1:1111"); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/IntegerFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/IntegerFieldTest.php index ac1f2f2ff..304c844ae 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/IntegerFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/IntegerFieldTest.php @@ -50,7 +50,7 @@ class IntegerFieldTest extends Field_Framework_TestCase */ public function testValueLargerThenMax() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("MinMaxValidator"); $field = new IntegerField(); $field->setMaximumValue(100); @@ -64,7 +64,7 @@ class IntegerFieldTest extends Field_Framework_TestCase */ public function testValueSmallerThenMin() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("MinMaxValidator"); $field = new IntegerField(); $field->setMaximumValue(100); @@ -104,7 +104,7 @@ class IntegerFieldTest extends Field_Framework_TestCase */ public function testRequiredEmpty() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("PresenceOf"); $field = new IntegerField(); $field->setRequired("Y"); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/InterfaceFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/InterfaceFieldTest.php index e37f40264..191ef2eda 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/InterfaceFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/InterfaceFieldTest.php @@ -70,7 +70,7 @@ class InterfaceFieldTest extends Field_Framework_TestCase */ public function testSelectHasNoParents() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("InclusionIn"); // init field $field = new InterfaceField(); @@ -111,7 +111,7 @@ class InterfaceFieldTest extends Field_Framework_TestCase */ public function testSelectSetWithUnknownValue() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("CsvListValidator"); // init field $field = new InterfaceField(); @@ -140,7 +140,7 @@ class InterfaceFieldTest extends Field_Framework_TestCase */ public function testSelectSetOnSingleValue() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("InclusionIn"); // init field $field = new InterfaceField(); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/OptionFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/OptionFieldTest.php index eecd19459..a39d5996b 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/OptionFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/OptionFieldTest.php @@ -50,7 +50,7 @@ class OptionFieldTest extends Field_Framework_TestCase */ public function testRequiredEmpty() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("PresenceOf"); $field = new OptionField(); $field->setRequired("Y"); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/PortFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/PortFieldTest.php index 2f5b9b036..6b05fa029 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/PortFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/PortFieldTest.php @@ -50,7 +50,7 @@ class PortFieldTest extends Field_Framework_TestCase */ public function testRequiredEmpty() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("PresenceOf"); $field = new PortField(); $field->setRequired("Y"); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/ProtocolFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/ProtocolFieldTest.php index e332cca60..3803d5140 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/ProtocolFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/ProtocolFieldTest.php @@ -50,7 +50,7 @@ class ProtocolFieldTest extends Field_Framework_TestCase */ public function testRequiredEmpty() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("PresenceOf"); $field = new ProtocolField(); $field->eventPostLoading(); diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/TextFieldTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/TextFieldTest.php index fd20500b9..79ab28baf 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/TextFieldTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/FieldTypes/TextFieldTest.php @@ -128,7 +128,7 @@ class TextFieldTest extends Field_Framework_TestCase */ public function testRequiredEmpty() { - $this->expectException(\Phalcon\Filter\Validation\Exception::class); + $this->expectException(\OPNsense\Base\ValidationException::class); $this->expectExceptionMessage("PresenceOf"); $field = new TextField(); $field->setRequired("Y");