From b2fa8ad548bb25383bad7053fca895e28eec5648 Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Sat, 8 Mar 2025 18:48:53 -0700 Subject: [PATCH 1/2] fix: correct internal callable name in IPsecChildSAStatus #664 --- .../files/usr/local/pkg/RESTAPI/Models/IPsecChildSAStatus.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/IPsecChildSAStatus.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/IPsecChildSAStatus.inc index 647ff3979..f7bfe3690 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/IPsecChildSAStatus.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/IPsecChildSAStatus.inc @@ -40,7 +40,7 @@ class IPsecChildSAStatus extends Model { public function __construct(mixed $id = null, mixed $parent_id = null, mixed $data = [], ...$options) { # Set model attributes - $this->internal_callable = 'get_ipsec_child SA_statuses'; + $this->internal_callable = 'get_ipsec_sa_statuses'; $this->parent_model_class = 'IPsecSAStatus'; $this->verbose_name = 'IPsec Child SA Status'; $this->many = true; From 877b4f0975b6b47e4bd9564169fdab3a512183e5 Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Sat, 8 Mar 2025 18:53:08 -0700 Subject: [PATCH 2/2] tests: ensure Models only use internal callables that exist #664 --- .../RESTAPI/Tests/APICoreModelTestCase.inc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreModelTestCase.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreModelTestCase.inc index 306928de6..be2a342b9 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreModelTestCase.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreModelTestCase.inc @@ -1248,4 +1248,23 @@ class APICoreModelTestCase extends RESTAPI\Core\TestCase { $dhcp_server->staticmap->value = []; $dhcp_server->update(apply: true); } + + /** + * Checks that all Model classes with an internal_callable assigned have an existing callable assigned. + */ + public function test_model_internal_callables_exist(): void { + # Loop through all Model classes + foreach (Model::get_all_model_classes() as $model_class) { + # Create a new instance of the Model class + $model_obj = new $model_class(skip_init: true); + + # Skip models that don't have an internal callable assigned + if (!$model_obj->internal_callable) { + continue; + } + + # Ensure the internal callable exists + $this->assert_is_true(method_exists($model_obj, $model_obj->internal_callable)); + } + } }