diff --git a/src/modules/Servicehosting/Service.php b/src/modules/Servicehosting/Service.php index 06bb9e04f..46c74b7f7 100644 --- a/src/modules/Servicehosting/Service.php +++ b/src/modules/Servicehosting/Service.php @@ -20,6 +20,8 @@ use Symfony\Component\Finder\Finder; class Service implements InjectionAwareInterface { + private const PASSWORD_PLACEHOLDER = '********'; + protected ?\Pimple\Container $di = null; private readonly Filesystem $filesystem; @@ -377,7 +379,7 @@ class Service implements InjectionAwareInterface $adapter->changeAccountPassword($account, $newPassword); } - $model->pass = '******'; + $model->pass = self::PASSWORD_PLACEHOLDER; $model->updated_at = date('Y-m-d H:i:s'); $this->di['db']->store($model); $this->di['logger']->info('Changed hosting account %s password', $model->id); @@ -535,7 +537,7 @@ class Service implements InjectionAwareInterface $result['id'] = $model->id; $result['active'] = $model->active; $result['secure'] = $model->secure; - $result['assigned_ips'] = json_decode($model->assigned_ips ?? '', true) ?? ''; + $result['assigned_ips'] = json_decode($model->assigned_ips ?? '[]', true) ?? []; $result['status_url'] = $model->status_url; $result['max_accounts'] = $model->max_accounts; $result['manager'] = $model->manager; @@ -1169,7 +1171,7 @@ class Service implements InjectionAwareInterface $array = array_filter($array, fn ($ip): bool => $ip !== ''); // Validate that each entry is a valid IP address (works both with IPv4 and IPv6) - $array = array_filter($array, fn ($ip): mixed => filter_var($ip, FILTER_VALIDATE_IP)); + $array = array_filter($array, fn ($ip): bool => (bool) filter_var($ip, FILTER_VALIDATE_IP)); return json_encode(array_values($array)); } diff --git a/tests-legacy/modules/Servicedownloadable/ServiceTest.php b/tests-legacy/modules/Servicedownloadable/ServiceTest.php index d4dce7a4a..907865c48 100644 --- a/tests-legacy/modules/Servicedownloadable/ServiceTest.php +++ b/tests-legacy/modules/Servicedownloadable/ServiceTest.php @@ -35,8 +35,6 @@ final class ServiceTest extends \BBTestCase $expected = array_merge(json_decode($productModel->config ?? '', true), $data); $validatorMock = $this->getMockBuilder(\FOSSBilling\Validate::class)->disableOriginalConstructor()->getMock(); - $validatorMock->expects($this->any())->method('checkRequiredParamsForArray') - ; $di = $this->getDi(); $di['validator'] = $validatorMock; @@ -64,8 +62,6 @@ final class ServiceTest extends \BBTestCase ->method('store') ->willReturn(1); $validatorMock = $this->getMockBuilder(\FOSSBilling\Validate::class)->disableOriginalConstructor()->getMock(); - $validatorMock->expects($this->any())->method('checkRequiredParamsForArray') - ; $di = $this->getDi(); $di['db'] = $dbMock; @@ -107,7 +103,7 @@ final class ServiceTest extends \BBTestCase $productModel->loadBean(new \DummyBean()); $productModel->config = '{"filename": "test.txt"}'; - $dbMock = $this->getMockBuilder(\Box_Database::class)->getMock(); + $dbMock = $this->createMock(\Box_Database::class); $dbMock->expects($this->atLeastOnce()) ->method('store') ->with($productModel) @@ -140,7 +136,7 @@ final class ServiceTest extends \BBTestCase $productModel->loadBean(new \DummyBean()); $productModel->config = '{"filename": "existing.txt", "update_orders": true}'; - $dbMock = $this->getMockBuilder('\Box_Database')->getMock(); + $dbMock = $this->getMockBuilder(\Box_Database::class)->getMock(); $dbMock->expects($this->atLeastOnce()) ->method('store') ->with($productModel) @@ -173,7 +169,7 @@ final class ServiceTest extends \BBTestCase $productModel->loadBean(new \DummyBean()); $productModel->config = null; - $dbMock = $this->getMockBuilder('\Box_Database')->getMock(); + $dbMock = $this->getMockBuilder(\Box_Database::class)->getMock(); $dbMock->expects($this->atLeastOnce()) ->method('store') ->with($productModel)