Fix type inconsistencies, standardize password placeholder, and clean up dead test code (#3332)

* Initial plan

* Fix: Standardize password placeholder, fix type inconsistencies, and clean up dead test code

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>
This commit is contained in:
Copilotandadmdly authored and GitHub committed 2026-03-16 23:48:10 +00:00
1 parent 6a20628411
commit 2d4599cb35
2 files changed
+8 -10

No files matched your search

+5 -3
View File
@@ -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));
}
@@ -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)