chore(tests): UT for MasterPass service

Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
Rubén D
2024-01-16 14:15:30 +01:00
parent 162105d073
commit c263a8bef9
78 changed files with 584 additions and 347 deletions

View File

@@ -33,8 +33,8 @@ use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Config\Ports\ConfigFileService;
use SP\Domain\Config\Ports\ConfigService;
use SP\Domain\Config\Services\Config;
use SP\Domain\Crypt\Ports\MasterPassServiceInterface;
use SP\Domain\Crypt\Services\MasterPassService;
use SP\Domain\Crypt\Ports\MasterPassService;
use SP\Domain\Crypt\Services\MasterPass;
use SP\Domain\Crypt\Services\UpdateMasterPassRequest;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
use SP\Modules\Cli\Commands\CommandBase;
@@ -67,13 +67,13 @@ final class UpdateMasterPasswordCommand extends CommandBase
/**
* @var string
*/
protected static $defaultName = 'sp:crypt:update-master-password';
private MasterPassServiceInterface $masterPassService;
private Config $configService;
protected static $defaultName = 'sp:crypt:update-master-password';
private MasterPassService $masterPassService;
private Config $configService;
private Account $accountService;
public function __construct(
MasterPassServiceInterface $masterPassService,
MasterPassService $masterPassService,
AccountService $accountService,
ConfigService $configService,
LoggerInterface $logger,
@@ -141,7 +141,7 @@ final class UpdateMasterPasswordCommand extends CommandBase
$request = new UpdateMasterPassRequest(
$currentMasterPassword,
$masterPassword,
$this->configService->getByParam(MasterPassService::PARAM_MASTER_PASS_HASH)
$this->configService->getByParam(MasterPass::PARAM_MASTER_PASS_HASH)
);
if (!$this->getUpdate($input, $style)) {

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -35,7 +35,7 @@ use SP\Core\Events\EventMessage;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Acl\UnauthorizedPageException;
use SP\Domain\Core\Exceptions\SessionTimeout;
use SP\Domain\Crypt\Ports\MasterPassServiceInterface;
use SP\Domain\Crypt\Ports\MasterPassService;
use SP\Http\JsonMessage;
use SP\Modules\Web\Controllers\SimpleControllerBase;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
@@ -48,12 +48,12 @@ final class RefreshController extends SimpleControllerBase
{
use JsonTrait;
private MasterPassServiceInterface $masterPassService;
private MasterPassService $masterPassService;
public function __construct(
Application $application,
SimpleControllerHelper $simpleControllerHelper,
MasterPassServiceInterface $masterPassService
MasterPassService $masterPassService
) {
parent::__construct($application, $simpleControllerHelper);

View File

@@ -35,8 +35,8 @@ use SP\Domain\Config\Ports\ConfigService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Acl\UnauthorizedPageException;
use SP\Domain\Core\Exceptions\SessionTimeout;
use SP\Domain\Crypt\Ports\MasterPassServiceInterface;
use SP\Domain\Crypt\Services\MasterPassService;
use SP\Domain\Crypt\Ports\MasterPassService;
use SP\Domain\Crypt\Services\MasterPass;
use SP\Domain\Crypt\Services\UpdateMasterPassRequest;
use SP\Domain\Task\Ports\TaskInterface;
use SP\Domain\Task\Services\Task;
@@ -55,14 +55,14 @@ final class SaveController extends SimpleControllerBase
{
use JsonTrait;
private MasterPassServiceInterface $masterPassService;
private ConfigService $configService;
private MasterPassService $masterPassService;
private ConfigService $configService;
public function __construct(
Application $application,
Application $application,
SimpleControllerHelper $simpleControllerHelper,
MasterPassServiceInterface $masterPassService,
ConfigService $configService
MasterPassService $masterPassService,
ConfigService $configService
) {
parent::__construct($application, $simpleControllerHelper);
@@ -150,7 +150,7 @@ final class SaveController extends SimpleControllerBase
$request = new UpdateMasterPassRequest(
$currentMasterPass,
$newMasterPass,
$this->configService->getByParam(MasterPassService::PARAM_MASTER_PASS_HASH),
$this->configService->getByParam(MasterPass::PARAM_MASTER_PASS_HASH),
$task
);

View File

@@ -49,7 +49,7 @@ use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\NoSuchPropertyException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\Crypt\Ports\MasterPassServiceInterface;
use SP\Domain\Crypt\Ports\MasterPassService;
use SP\Domain\CustomField\Ports\CustomFieldServiceInterface;
use SP\Domain\Http\RequestInterface;
use SP\Domain\ItemPreset\Ports\ItemPresetInterface;
@@ -76,9 +76,9 @@ final class AccountHelper extends AccountHelperBase
private AccountService $accountService;
private AccountHistoryService $accountHistoryService;
private PublicLinkService $publicLinkService;
private ItemPresetServiceInterface $itemPresetService;
private MasterPassServiceInterface $masterPassService;
private AccountAclService $accountAclService;
private ItemPresetServiceInterface $itemPresetService;
private MasterPassService $masterPassService;
private AccountAclService $accountAclService;
private CategoryService $categoryService;
private ClientService $clientService;
private CustomFieldServiceInterface $customFieldService;
@@ -97,7 +97,7 @@ final class AccountHelper extends AccountHelperBase
AccountHistoryService $accountHistoryService,
PublicLinkService $publicLinkService,
ItemPresetServiceInterface $itemPresetService,
MasterPassServiceInterface $masterPassService,
MasterPassService $masterPassService,
AccountActionsHelper $accountActionsHelper,
AccountAclService $accountAclService,
CategoryService $categoryService,

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -31,7 +31,7 @@ use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Acl\AclInterface;
use SP\Domain\Core\Acl\UnauthorizedPageException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\Crypt\Ports\MasterPassServiceInterface;
use SP\Domain\Crypt\Ports\MasterPassService;
use SP\Domain\Http\RequestInterface;
use SP\Domain\User\Services\UpdatedMasterPassException;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
@@ -46,8 +46,8 @@ abstract class AccountHelperBase extends HelperBase
protected ?int $actionId = null;
protected AccountActionsHelper $accountActionsHelper;
protected bool $isView = false;
protected Acl $acl;
private MasterPassServiceInterface $masterPassService;
protected Acl $acl;
private MasterPassService $masterPassService;
public function __construct(
Application $application,
@@ -55,7 +55,7 @@ abstract class AccountHelperBase extends HelperBase
RequestInterface $request,
AclInterface $acl,
AccountActionsHelper $accountActionsHelper,
MasterPassServiceInterface $masterPassService
MasterPassService $masterPassService
) {
parent::__construct($application, $template, $request);

View File

@@ -41,7 +41,7 @@ use SP\Domain\Core\Acl\UnauthorizedPageException;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\Crypt\Ports\MasterPassServiceInterface;
use SP\Domain\Crypt\Ports\MasterPassService;
use SP\Domain\Http\RequestInterface;
use SP\Domain\User\Services\UpdatedMasterPassException;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
@@ -64,7 +64,7 @@ final class AccountHistoryHelper extends AccountHelperBase
RequestInterface $request,
AclInterface $acl,
AccountActionsHelper $accountActionsHelper,
MasterPassServiceInterface $masterPassService,
MasterPassService $masterPassService,
private AccountHistoryService $accountHistoryService,
private AccountAclService $accountAclService,
private CategoryService $categoryService,

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -37,7 +37,7 @@ use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Acl\AclInterface;
use SP\Domain\Core\Exceptions\FileNotFoundException;
use SP\Domain\Crypt\Ports\MasterPassServiceInterface;
use SP\Domain\Crypt\Ports\MasterPassService;
use SP\Domain\Http\RequestInterface;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
use SP\Modules\Web\Controllers\Helpers\HelperBase;
@@ -54,8 +54,8 @@ use SP\Util\ImageUtilInterface;
final class AccountPasswordHelper extends HelperBase
{
private Acl $acl;
private ImageUtil $imageUtil;
private MasterPassServiceInterface $masterPassService;
private ImageUtil $imageUtil;
private MasterPassService $masterPassService;
public function __construct(
Application $application,
@@ -63,7 +63,7 @@ final class AccountPasswordHelper extends HelperBase
RequestInterface $request,
AclInterface $acl,
ImageUtilInterface $imageUtil,
MasterPassServiceInterface $masterPassService
MasterPassService $masterPassService
) {
parent::__construct($application, $template, $request);

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -26,7 +26,7 @@ namespace SP\Domain\Account\Ports;
use SP\DataModel\FileData;
use SP\DataModel\ItemSearchData;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Database\QueryResult;
@@ -36,7 +36,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Account\Repositories
*/
interface AccountFileRepository extends RepositoryInterface
interface AccountFileRepository extends Repository
{
/**
* Creates an item

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -27,7 +27,7 @@ namespace SP\Domain\Account\Ports;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Dtos\AccountHistoryCreateDto;
use SP\Domain\Account\Dtos\EncryptedPassword;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Infrastructure\Database\QueryResult;
/**
@@ -35,7 +35,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package Services
*/
interface AccountHistoryRepository extends RepositoryInterface
interface AccountHistoryRepository extends Repository
{
/**
* Creates an item

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -27,7 +27,7 @@ namespace SP\Domain\Account\Ports;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Dtos\EncryptedPassword;
use SP\Domain\Account\Models\Account;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
@@ -38,7 +38,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Domain\Account\Ports
*/
interface AccountRepository extends RepositoryInterface
interface AccountRepository extends Repository
{
/**
* Devolver el número total de cuentas

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -26,13 +26,13 @@ namespace SP\Domain\Account\Ports;
use Aura\SqlQuery\Common\SelectInterface;
use SP\Domain\Account\Dtos\AccountSearchFilterDto;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Infrastructure\Database\QueryResult;
/**
* Class AccountSearchRepository
*/
interface AccountSearchRepository extends RepositoryInterface
interface AccountSearchRepository extends Repository
{
/**
* Obtener las cuentas de una búsqueda.

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -24,7 +24,7 @@
namespace SP\Domain\Account\Ports;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Database\QueryResult;
@@ -34,7 +34,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Account\Repositories
*/
interface AccountToFavoriteRepository extends RepositoryInterface
interface AccountToFavoriteRepository extends Repository
{
/**
* Obtener un array con los Ids de cuentas favoritas

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -24,7 +24,7 @@
namespace SP\Domain\Account\Ports;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Database\QueryResult;
@@ -34,7 +34,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Account\Repositories
*/
interface AccountToTagRepository extends RepositoryInterface
interface AccountToTagRepository extends Repository
{
/**
* Devolver las etiquetas de una cuenta

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -24,7 +24,7 @@
namespace SP\Domain\Account\Ports;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Database\QueryResult;
@@ -34,7 +34,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Account\Repositories
*/
interface AccountToUserGroupRepository extends RepositoryInterface
interface AccountToUserGroupRepository extends Repository
{
/**
* Obtiene el listado con el nombre de los grupos de una cuenta.

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -24,7 +24,7 @@
namespace SP\Domain\Account\Ports;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Database\QueryResult;
@@ -34,7 +34,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Account\Repositories
*/
interface AccountToUserRepository extends RepositoryInterface
interface AccountToUserRepository extends Repository
{
/**
* Eliminar la asociación de grupos con cuentas.

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -26,7 +26,7 @@ namespace SP\Domain\Account\Ports;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Models\PublicLink;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
@@ -38,7 +38,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Common\Repositories\PublicLink
*/
interface PublicLinkRepository extends RepositoryInterface
interface PublicLinkRepository extends Repository
{
/**
* Deletes an item

View File

@@ -27,7 +27,7 @@ namespace SP\Domain\Auth\Ports;
use Exception;
use SP\DataModel\ItemSearchData;
use SP\Domain\Auth\Models\AuthToken as AuthTokenModel;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\DuplicatedItemException;
@@ -38,7 +38,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @template T of AuthTokenModel
*/
interface AuthTokenRepository extends RepositoryInterface
interface AuthTokenRepository extends Repository
{
/**
* @param int $id

View File

@@ -27,7 +27,7 @@ namespace SP\Domain\Category\Ports;
use Exception;
use SP\DataModel\ItemSearchData;
use SP\Domain\Category\Models\Category;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\DuplicatedItemException;
@@ -38,7 +38,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @template T of Category
*/
interface CategoryRepository extends RepositoryInterface
interface CategoryRepository extends Repository
{
/**
* Creates an item

View File

@@ -27,7 +27,7 @@ namespace SP\Domain\Client\Ports;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Ports\AccountFilterBuilder;
use SP\Domain\Client\Models\Client as ClientModel;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
@@ -39,7 +39,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @template T of ClientModel
*/
interface ClientRepository extends RepositoryInterface
interface ClientRepository extends Repository
{
/**
* Creates an item

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -30,17 +30,15 @@ use SP\Domain\Common\Services\ServiceException;
use SP\Infrastructure\Database\QueryResult;
/**
* Interface RepositoryItemInterface
*
* @package SP\Domain\Common\Ports
* Interface Repository
*/
interface RepositoryInterface
interface Repository
{
/**
* Bubbles a Closure in a database transaction
*
* @param Closure $closure
* @param object $newThis
* @param object $newThis
*
* @return mixed
* @throws ServiceException
@@ -51,15 +49,15 @@ interface RepositoryInterface
/**
* Run a SQL select query to get any data from any table
*
* @param array $columns
* @param string $from
* @param string|null $where
* @param array|null $bindValues
* @param array $columns
* @param string $from
* @param string|null $where
* @param array|null $bindValues
*
* @return QueryResult
*/
public function getAny(
array $columns,
array $columns,
string $from,
?string $where = null,
?array $bindValues = null

View File

@@ -24,7 +24,7 @@
namespace SP\Domain\Config\Ports;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Config\Models\Config as ConfigModel;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -35,7 +35,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @template T of ConfigModel
*/
interface ConfigRepository extends RepositoryInterface
interface ConfigRepository extends Repository
{
/**
* @param ConfigModel $config

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -25,28 +25,27 @@
namespace SP\Domain\Crypt\Ports;
use Exception;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Crypt\Services\UpdateMasterPassRequest;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
/**
* Class MasterPassService
*
* @package SP\Domain\Crypt\Services
*/
interface MasterPassServiceInterface
interface MasterPassService
{
/**
* @throws ServiceException
* @throws NoSuchItemException
* Check whether the user's master password was updated
*
* @param int $userMPassTime
* @return bool false if it needs to be updated, false otherwise
*/
public function checkUserUpdateMPass(int $userMPassTime): bool;
/**
* @throws ServiceException
* @throws NoSuchItemException
* Check whether the provided master paswword matches with the current one
*/
public function checkMasterPassword(string $masterPassword): bool;

View File

@@ -28,64 +28,65 @@ use Exception;
use SP\Core\Application;
use SP\Core\Crypt\Hash;
use SP\Domain\Account\Ports\AccountCryptService;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Common\Services\Service;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Config\Ports\ConfigService;
use SP\Domain\Config\Services\Config;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Crypt\Ports\MasterPassServiceInterface;
use SP\Domain\Crypt\Ports\MasterPassService;
use SP\Domain\CustomField\Ports\CustomFieldCryptServiceInterface;
use SP\Domain\CustomField\Services\CustomFieldCryptService;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
use function SP\processException;
/**
* Class MasterPassService
*
* @package SP\Domain\Crypt\Services
* Class MasterPass
*/
final class MasterPassService extends Service implements MasterPassServiceInterface
final class MasterPass extends Service implements MasterPassService
{
public const PARAM_MASTER_PASS_TIME = 'lastupdatempass';
public const PARAM_MASTER_PASS_HASH = 'masterPwd';
protected Config $configService;
protected AccountCryptService $accountCryptService;
protected CustomFieldCryptService $customFieldCryptService;
public function __construct(
Application $application,
ConfigService $configService,
AccountCryptService $accountCryptService,
CustomFieldCryptServiceInterface $customFieldCryptService
Application $application,
private readonly ConfigService $configService,
private readonly AccountCryptService $accountCryptService,
private readonly CustomFieldCryptServiceInterface $customFieldCryptService,
private readonly Repository $repository
) {
parent::__construct($application);
$this->configService = $configService;
$this->accountCryptService = $accountCryptService;
$this->customFieldCryptService = $customFieldCryptService;
}
/**
* @throws ServiceException
* @throws NoSuchItemException
* @inheritDoc
*/
public function checkUserUpdateMPass(int $userMPassTime): bool
{
return $userMPassTime >= $this->configService->getByParam(self::PARAM_MASTER_PASS_TIME, 0);
try {
return $userMPassTime >= (int)$this->configService->getByParam(self::PARAM_MASTER_PASS_TIME, 0);
} catch (ServiceException|NoSuchItemException $e) {
processException($e);
}
return true;
}
/**
* @throws ServiceException
* @throws NoSuchItemException
* @inheritDoc
*/
public function checkMasterPassword(string $masterPassword): bool
{
return Hash::checkHashKey(
$masterPassword,
$this->configService->getByParam(self::PARAM_MASTER_PASS_HASH)
);
try {
return Hash::checkHashKey(
$masterPassword,
$this->configService->getByParam(self::PARAM_MASTER_PASS_HASH)
);
} catch (ServiceException|NoSuchItemException $e) {
processException($e);
}
return false;
}
/**
@@ -93,17 +94,16 @@ final class MasterPassService extends Service implements MasterPassServiceInterf
*/
public function changeMasterPassword(UpdateMasterPassRequest $request): void
{
$this->transactionAware(
$this->repository->transactionAware(
function () use ($request) {
$this->accountCryptService->updateMasterPassword($request);
$this->accountCryptService->updateHistoryMasterPassword($request);
$this->customFieldCryptService->updateMasterPassword($request);
$this->updateConfig($request->getHash());
}
},
$this
);
$this->updateConfig($request->getHash());
}
/**

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -24,12 +24,14 @@
namespace SP\Domain\CustomField\Ports;
use SP\Domain\Common\Ports\Repository;
/**
* Class CustomFieldDefRepository
*
* @package SP\Infrastructure\CustomField\Repositories
*/
interface CustomFieldDefRepositoryInterface extends \SP\Domain\Common\Ports\RepositoryInterface
interface CustomFieldDefRepository extends Repository
{
/**
* Resets the custom fields collection cache

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -25,7 +25,7 @@
namespace SP\Domain\CustomField\Ports;
use SP\DataModel\CustomFieldData;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Database\QueryResult;
@@ -35,7 +35,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Domain\Common\Services
*/
interface CustomFieldRepositoryInterface extends RepositoryInterface
interface CustomFieldRepository extends Repository
{
/**
* Comprueba si el elemento tiene campos personalizados con datos

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -24,11 +24,13 @@
namespace SP\Domain\CustomField\Ports;
use SP\Domain\Common\Ports\Repository;
/**
* Class CustomFieldTypeRepository
*
* @package SP\Infrastructure\CustomField\Repositories
*/
interface CustomFieldTypeRepositoryInterface extends \SP\Domain\Common\Ports\RepositoryInterface
interface CustomFieldTypeRepository extends Repository
{
}

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -34,9 +34,9 @@ use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\CustomField\Ports\CustomFieldDefRepositoryInterface;
use SP\Domain\CustomField\Ports\CustomFieldDefRepository;
use SP\Domain\CustomField\Ports\CustomFieldDefServiceInterface;
use SP\Domain\CustomField\Ports\CustomFieldRepositoryInterface;
use SP\Domain\CustomField\Ports\CustomFieldRepository;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
use SP\Infrastructure\Database\DatabaseInterface;
use SP\Infrastructure\Database\QueryResult;
@@ -50,15 +50,15 @@ final class CustomFieldDefService extends Service implements CustomFieldDefServi
{
use ServiceItemTrait;
protected CustomFieldDefRepositoryInterface $customFieldDefRepository;
protected CustomFieldRepositoryInterface $customFieldRepository;
private DatabaseInterface $database;
protected CustomFieldDefRepository $customFieldDefRepository;
protected CustomFieldRepository $customFieldRepository;
private DatabaseInterface $database;
public function __construct(
Application $application,
CustomFieldDefRepositoryInterface $customFieldDefRepository,
CustomFieldRepositoryInterface $customFieldRepository,
DatabaseInterface $database
Application $application,
CustomFieldDefRepository $customFieldDefRepository,
CustomFieldRepository $customFieldRepository,
DatabaseInterface $database
) {
parent::__construct($application);

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -33,8 +33,8 @@ use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\CustomField\Ports\CustomFieldDefRepositoryInterface;
use SP\Domain\CustomField\Ports\CustomFieldRepositoryInterface;
use SP\Domain\CustomField\Ports\CustomFieldDefRepository;
use SP\Domain\CustomField\Ports\CustomFieldRepository;
use SP\Domain\CustomField\Ports\CustomFieldServiceInterface;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
@@ -45,13 +45,13 @@ use SP\Infrastructure\Common\Repositories\NoSuchItemException;
*/
final class CustomFieldService extends Service implements CustomFieldServiceInterface
{
protected CustomFieldRepositoryInterface $customFieldRepository;
protected CustomFieldDefRepositoryInterface $customFieldDefRepository;
protected CustomFieldRepository $customFieldRepository;
protected CustomFieldDefRepository $customFieldDefRepository;
public function __construct(
Application $application,
CustomFieldRepositoryInterface $customFieldRepository,
CustomFieldDefRepositoryInterface $customFieldDefRepository
Application $application,
CustomFieldRepository $customFieldRepository,
CustomFieldDefRepository $customFieldDefRepository
) {
parent::__construct($application);

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -30,10 +30,10 @@ use SP\Domain\Common\Services\Service;
use SP\Domain\Common\Services\ServiceItemTrait;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\CustomField\Ports\CustomFieldTypeRepositoryInterface;
use SP\Domain\CustomField\Ports\CustomFieldTypeRepository;
use SP\Domain\CustomField\Ports\CustomFieldTypeServiceInterface;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
use SP\Infrastructure\CustomField\Repositories\CustomFieldTypeRepository;
use SP\Infrastructure\CustomField\Repositories\CustomFieldTypeBaseRepository;
/**
* Class CustomFieldTypeService
@@ -44,9 +44,9 @@ final class CustomFieldTypeService extends Service implements CustomFieldTypeSer
{
use ServiceItemTrait;
private CustomFieldTypeRepository $customFieldTypeRepository;
private CustomFieldTypeBaseRepository $customFieldTypeRepository;
public function __construct(Application $application, CustomFieldTypeRepositoryInterface $customFieldTypeRepository)
public function __construct(Application $application, CustomFieldTypeRepository $customFieldTypeRepository)
{
parent::__construct($application);

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -24,7 +24,7 @@
namespace SP\Domain\ItemPreset\Ports;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Database\QueryResult;
@@ -34,7 +34,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Account\Repositories
*/
interface ItemPresetRepositoryInterface extends RepositoryInterface
interface ItemPresetRepository extends Repository
{
/**
* Returns the item for given id

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -32,11 +32,11 @@ use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\ItemPreset\Ports\ItemPresetRepositoryInterface;
use SP\Domain\ItemPreset\Ports\ItemPresetRepository;
use SP\Domain\ItemPreset\Ports\ItemPresetServiceInterface;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
use SP\Infrastructure\Database\QueryResult;
use SP\Infrastructure\ItemPreset\Repositories\ItemPresetRepository;
use SP\Infrastructure\ItemPreset\Repositories\ItemPresetBaseRepository;
/**
* Class ItemPresetService
@@ -45,9 +45,9 @@ use SP\Infrastructure\ItemPreset\Repositories\ItemPresetRepository;
*/
final class ItemPresetService extends Service implements ItemPresetServiceInterface
{
private ItemPresetRepository $itemPresetRepository;
private ItemPresetBaseRepository $itemPresetRepository;
public function __construct(Application $application, ItemPresetRepositoryInterface $itemPresetRepository)
public function __construct(Application $application, ItemPresetRepository $itemPresetRepository)
{
parent::__construct($application);

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -25,7 +25,7 @@
namespace SP\Domain\Notification\Ports;
use SP\DataModel\ItemSearchData;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Database\QueryResult;
@@ -35,7 +35,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Notification\Repositories
*/
interface NotificationRepositoryInterface extends RepositoryInterface
interface NotificationRepository extends Repository
{
/**
* Deletes an item

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -32,11 +32,11 @@ use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\Notification\Ports\NotificationRepositoryInterface;
use SP\Domain\Notification\Ports\NotificationRepository;
use SP\Domain\Notification\Ports\NotificationServiceInterface;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
use SP\Infrastructure\Database\QueryResult;
use SP\Infrastructure\Notification\Repositories\NotificationRepository;
use SP\Infrastructure\Notification\Repositories\NotificationBaseRepository;
/**
* Class NotificationService
@@ -45,9 +45,9 @@ use SP\Infrastructure\Notification\Repositories\NotificationRepository;
*/
final class NotificationService extends Service implements NotificationServiceInterface
{
protected NotificationRepository $notificationRepository;
protected NotificationBaseRepository $notificationRepository;
public function __construct(Application $application, NotificationRepositoryInterface $notificationRepository)
public function __construct(Application $application, NotificationRepository $notificationRepository)
{
parent::__construct($application);

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -24,7 +24,7 @@
namespace SP\Domain\Plugin\Ports;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Database\QueryResult;
@@ -34,7 +34,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Plugin\Repositories
*/
interface PluginRepositoryInterface extends RepositoryInterface
interface PluginRepository extends Repository
{
/**
* Devuelve los datos de un plugin por su nombre

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -33,11 +33,11 @@ use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\Plugin\Ports\PluginManagerInterface;
use SP\Domain\Plugin\Ports\PluginRepositoryInterface;
use SP\Domain\Plugin\Ports\PluginRepository;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
use SP\Infrastructure\Database\QueryResult;
use SP\Infrastructure\Plugin\Repositories\PluginBaseRepository;
use SP\Infrastructure\Plugin\Repositories\PluginModel;
use SP\Infrastructure\Plugin\Repositories\PluginRepository;
use function SP\__u;
@@ -46,9 +46,9 @@ use function SP\__u;
*/
final class PluginManager extends Service implements PluginManagerInterface
{
private PluginRepository $pluginRepository;
private PluginBaseRepository $pluginRepository;
public function __construct(Application $application, PluginRepositoryInterface $pluginRepository)
public function __construct(Application $application, PluginRepository $pluginRepository)
{
parent::__construct($application);

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -35,7 +35,7 @@ use SP\Domain\Http\RequestInterface;
use SP\Domain\Security\Ports\EventlogRepositoryInterface;
use SP\Domain\Security\Ports\EventlogServiceInterface;
use SP\Infrastructure\Database\QueryResult;
use SP\Infrastructure\Security\Repositories\EventlogRepository;
use SP\Infrastructure\Security\Repositories\EventlogBaseRepository;
/**
* Class EventlogService
@@ -44,8 +44,8 @@ use SP\Infrastructure\Security\Repositories\EventlogRepository;
*/
final class EventlogService extends Service implements EventlogServiceInterface
{
protected EventlogRepository $eventLogRepository;
protected RequestInterface $request;
protected EventlogBaseRepository $eventLogRepository;
protected RequestInterface $request;
public function __construct(
Application $application,

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -40,7 +40,7 @@ use SP\Domain\Security\Ports\TrackRepositoryInterface;
use SP\Domain\Security\Ports\TrackServiceInterface;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
use SP\Infrastructure\Database\QueryResult;
use SP\Infrastructure\Security\Repositories\TrackRepository;
use SP\Infrastructure\Security\Repositories\TrackBaseRepository;
use SP\Infrastructure\Security\Repositories\TrackRequest;
/**
@@ -57,8 +57,8 @@ final class TrackService extends Service implements TrackServiceInterface
public const TIME_TRACKING_MAX_ATTEMPTS = 10;
public const TIME_SLEEP = 0.5;
private TrackRepository $trackRepository;
private RequestInterface $request;
private TrackBaseRepository $trackRepository;
private RequestInterface $request;
public function __construct(
Application $application,

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -24,7 +24,7 @@
namespace SP\Domain\Tag\Ports;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Database\QueryResult;
@@ -34,7 +34,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Common\Repositories\Tag
*/
interface TagRepositoryInterface extends RepositoryInterface
interface TagRepository extends Repository
{
/**
* Returns the item for given id

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -33,12 +33,12 @@ use SP\Domain\Common\Services\ServiceItemTrait;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\Tag\Ports\TagRepositoryInterface;
use SP\Domain\Tag\Ports\TagRepository;
use SP\Domain\Tag\Ports\TagServiceInterface;
use SP\Infrastructure\Common\Repositories\DuplicatedItemException;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
use SP\Infrastructure\Database\QueryResult;
use SP\Infrastructure\Tag\Repositories\TagRepository;
use SP\Infrastructure\Tag\Repositories\TagBaseRepository;
/**
* Class TagService
@@ -49,9 +49,9 @@ final class TagService extends Service implements TagServiceInterface
{
use ServiceItemTrait;
private TagRepository $tagRepository;
private TagBaseRepository $tagRepository;
public function __construct(Application $application, TagRepositoryInterface $tagRepository)
public function __construct(Application $application, TagRepository $tagRepository)
{
parent::__construct($application);

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -24,7 +24,7 @@
namespace SP\Domain\User\Ports;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Database\QueryResult;
@@ -34,7 +34,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\User\Repositories
*/
interface UserGroupRepositoryInterface extends RepositoryInterface
interface UserGroupRepository extends Repository
{
/**
* Returns the items that are using the given group id

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -24,7 +24,7 @@
namespace SP\Domain\User\Ports;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Database\QueryResult;
@@ -34,7 +34,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\User\Repositories
*/
interface UserProfileRepositoryInterface extends RepositoryInterface
interface UserProfileRepository extends Repository
{
/**
* Obtener el nombre de los usuarios que usan un perfil.

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -26,7 +26,7 @@ namespace SP\Domain\User\Ports;
use SP\DataModel\UserData;
use SP\DataModel\UserPreferencesData;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\User\Services\UpdatePassRequest;
@@ -37,7 +37,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\User\Repositories
*/
interface UserRepositoryInterface extends RepositoryInterface
interface UserRepository extends Repository
{
/**
* Updates an user's pass

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -34,13 +34,13 @@ use SP\Domain\Common\Services\ServiceItemTrait;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\User\Ports\UserGroupRepositoryInterface;
use SP\Domain\User\Ports\UserGroupRepository;
use SP\Domain\User\Ports\UserGroupServiceInterface;
use SP\Domain\User\Ports\UserToUserGroupServiceInterface;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
use SP\Infrastructure\Database\DatabaseInterface;
use SP\Infrastructure\Database\QueryResult;
use SP\Infrastructure\User\Repositories\UserGroupRepository;
use SP\Infrastructure\User\Repositories\UserGroupBaseRepository;
/**
* Class UserGroupService
@@ -51,15 +51,15 @@ final class UserGroupService extends Service implements UserGroupServiceInterfac
{
use ServiceItemTrait;
protected UserGroupRepository $userGroupRepository;
protected UserGroupBaseRepository $userGroupRepository;
protected UserToUserGroupServiceInterface $userToUserGroupService;
private DatabaseInterface $database;
public function __construct(
Application $application,
UserGroupRepositoryInterface $userGroupRepository,
Application $application,
UserGroupRepository $userGroupRepository,
UserToUserGroupServiceInterface $userToUserGroupService,
DatabaseInterface $database
DatabaseInterface $database
) {
parent::__construct($application);

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -36,7 +36,7 @@ use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\User\Ports\UserPassRecoverRepositoryInterface;
use SP\Domain\User\Ports\UserPassRecoverServiceInterface;
use SP\Html\Html;
use SP\Infrastructure\User\Repositories\UserPassRecoverRepository;
use SP\Infrastructure\User\Repositories\UserPassRecoverBaseRepository;
use SP\Util\PasswordUtil;
/**
@@ -55,7 +55,7 @@ final class UserPassRecoverService extends Service implements UserPassRecoverSer
*/
public const MAX_PASS_RECOVER_LIMIT = 3;
protected UserPassRecoverRepository $userPassRecoverRepository;
protected UserPassRecoverBaseRepository $userPassRecoverRepository;
public function __construct(Application $application, UserPassRecoverRepositoryInterface $userPassRecoverRepository)
{

View File

@@ -36,9 +36,9 @@ use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\User\Ports\UserPassServiceInterface;
use SP\Domain\User\Ports\UserRepositoryInterface;
use SP\Domain\User\Ports\UserRepository;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
use SP\Infrastructure\User\Repositories\UserRepository;
use SP\Infrastructure\User\Repositories\UserBaseRepository;
/**
* Class UserPassService
@@ -59,13 +59,13 @@ final class UserPassService extends Service implements UserPassServiceInterface
public const MPASS_CHECKOLD = 4;
private ConfigDataInterface $configData;
private UserRepository $userRepository;
private UserBaseRepository $userRepository;
private ConfigService $configService;
public function __construct(
Application $application,
UserRepositoryInterface $userRepository,
ConfigService $configService
Application $application,
UserRepository $userRepository,
ConfigService $configService
) {
parent::__construct($application);

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -34,12 +34,12 @@ use SP\Domain\Common\Services\ServiceItemTrait;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\User\Ports\UserProfileRepositoryInterface;
use SP\Domain\User\Ports\UserProfileRepository;
use SP\Domain\User\Ports\UserProfileServiceInterface;
use SP\Infrastructure\Common\Repositories\DuplicatedItemException;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
use SP\Infrastructure\Database\QueryResult;
use SP\Infrastructure\User\Repositories\UserProfileRepository;
use SP\Infrastructure\User\Repositories\UserProfileBaseRepository;
use SP\Util\Util;
use function SP\__u;
@@ -53,9 +53,9 @@ final class UserProfileService extends Service implements UserProfileServiceInte
{
use ServiceItemTrait;
protected UserProfileRepository $userProfileRepository;
protected UserProfileBaseRepository $userProfileRepository;
public function __construct(Application $application, UserProfileRepositoryInterface $userProfileRepository)
public function __construct(Application $application, UserProfileRepository $userProfileRepository)
{
parent::__construct($application);

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -37,12 +37,12 @@ use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\User\Ports\UserPassServiceInterface;
use SP\Domain\User\Ports\UserRepositoryInterface;
use SP\Domain\User\Ports\UserRepository;
use SP\Domain\User\Ports\UserServiceInterface;
use SP\Infrastructure\Common\Repositories\DuplicatedItemException;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
use SP\Infrastructure\Database\QueryResult;
use SP\Infrastructure\User\Repositories\UserRepository;
use SP\Infrastructure\User\Repositories\UserBaseRepository;
use SP\Util\Util;
/**
@@ -54,12 +54,12 @@ final class UserService extends Service implements UserServiceInterface
{
use ServiceItemTrait;
private UserRepository $userRepository;
private UserPassService $userPassService;
private UserBaseRepository $userRepository;
private UserPassService $userPassService;
public function __construct(
Application $application,
UserRepositoryInterface $userRepository,
Application $application,
UserRepository $userRepository,
UserPassServiceInterface $userPassService
) {
parent::__construct($application);

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -33,7 +33,7 @@ use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\User\Ports\UserToUserGroupRepositoryInterface;
use SP\Domain\User\Ports\UserToUserGroupServiceInterface;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
use SP\Infrastructure\User\Repositories\UserToUserGroupRepository;
use SP\Infrastructure\User\Repositories\UserToUserGroupBaseRepository;
/**
* Class UserToUserGroupService
@@ -42,7 +42,7 @@ use SP\Infrastructure\User\Repositories\UserToUserGroupRepository;
*/
final class UserToUserGroupService extends Service implements UserToUserGroupServiceInterface
{
protected UserToUserGroupRepository $userToUserGroupRepository;
protected UserToUserGroupBaseRepository $userToUserGroupRepository;
public function __construct(Application $application, UserToUserGroupRepositoryInterface $userToUserGroupRepository)
{

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -36,7 +36,7 @@ use SP\Domain\Core\Context\ContextInterface;
use SP\Domain\Core\Events\EventDispatcherInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\DatabaseInterface;
use SP\Infrastructure\Database\QueryData;
@@ -49,7 +49,7 @@ use function SP\__u;
*
* @package Services
*/
final class Account extends Repository implements AccountRepository
final class Account extends BaseRepository implements AccountRepository
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -29,7 +29,7 @@ use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Ports\AccountFileRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -41,7 +41,7 @@ use function SP\__u;
*
* @package SP\Infrastructure\Account\Repositories
*/
final class AccountFile extends Repository implements AccountFileRepository
final class AccountFile extends BaseRepository implements AccountFileRepository
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -30,7 +30,7 @@ use SP\Domain\Account\Dtos\EncryptedPassword;
use SP\Domain\Account\Ports\AccountHistoryRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -42,7 +42,7 @@ use function SP\__u;
*
* @package Services
*/
final class AccountHistory extends Repository implements AccountHistoryRepository
final class AccountHistory extends BaseRepository implements AccountHistoryRepository
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -33,7 +33,7 @@ use SP\Domain\Account\Ports\AccountSearchConstants;
use SP\Domain\Account\Ports\AccountSearchRepository;
use SP\Domain\Core\Context\ContextInterface;
use SP\Domain\Core\Events\EventDispatcherInterface;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Database\DatabaseInterface;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -42,7 +42,7 @@ use SP\Util\Filter;
/**
* Class AccountSearchRepository
*/
final class AccountSearch extends Repository implements AccountSearchRepository
final class AccountSearch extends BaseRepository implements AccountSearchRepository
{
private readonly SelectInterface $query;
@@ -98,7 +98,7 @@ final class AccountSearch extends Repository implements AccountSearchRepository
/**
* Obtener las cuentas de una búsqueda.
*
* @param \SP\Domain\Account\Dtos\AccountSearchFilterDto $accountSearchFilter
* @param AccountSearchFilterDto $accountSearchFilter
*
* @return QueryResult
*/
@@ -124,7 +124,7 @@ final class AccountSearch extends Repository implements AccountSearchRepository
}
/**
* @param \SP\Domain\Account\Dtos\AccountSearchFilterDto $accountSearchFilter
* @param AccountSearchFilterDto $accountSearchFilter
* @return void
*/
private function filterByText(AccountSearchFilterDto $accountSearchFilter): void
@@ -149,7 +149,7 @@ final class AccountSearch extends Repository implements AccountSearchRepository
}
/**
* @param \SP\Domain\Account\Dtos\AccountSearchFilterDto $accountSearchFilter
* @param AccountSearchFilterDto $accountSearchFilter
* @return void
*/
private function filterByCategory(AccountSearchFilterDto $accountSearchFilter): void
@@ -166,7 +166,7 @@ final class AccountSearch extends Repository implements AccountSearchRepository
}
/**
* @param \SP\Domain\Account\Dtos\AccountSearchFilterDto $accountSearchFilter
* @param AccountSearchFilterDto $accountSearchFilter
* @return void
*/
private function filterByClient(AccountSearchFilterDto $accountSearchFilter): void
@@ -183,7 +183,7 @@ final class AccountSearch extends Repository implements AccountSearchRepository
}
/**
* @param \SP\Domain\Account\Dtos\AccountSearchFilterDto $accountSearchFilter
* @param AccountSearchFilterDto $accountSearchFilter
* @return void
*/
private function filterByFavorite(AccountSearchFilterDto $accountSearchFilter): void
@@ -202,7 +202,7 @@ final class AccountSearch extends Repository implements AccountSearchRepository
}
/**
* @param \SP\Domain\Account\Dtos\AccountSearchFilterDto $accountSearchFilter
* @param AccountSearchFilterDto $accountSearchFilter
* @return void
*/
private function filterByTags(AccountSearchFilterDto $accountSearchFilter): void

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -27,7 +27,7 @@ namespace SP\Infrastructure\Account\Repositories;
use SP\Domain\Account\Ports\AccountToFavoriteRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -38,7 +38,7 @@ use function SP\__u;
*
* @package SP\Infrastructure\Account\Repositories
*/
final class AccountToFavorite extends Repository implements AccountToFavoriteRepository
final class AccountToFavorite extends BaseRepository implements AccountToFavoriteRepository
{
/**
* Obtener un array con los Ids de cuentas favoritas

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -27,7 +27,7 @@ namespace SP\Infrastructure\Account\Repositories;
use SP\Domain\Account\Ports\AccountToTagRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -39,7 +39,7 @@ use function SP\__u;
*
* @package SP\Infrastructure\Account\Repositories
*/
final class AccountToTag extends Repository implements AccountToTagRepository
final class AccountToTag extends BaseRepository implements AccountToTagRepository
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -28,8 +28,8 @@ use SP\DataModel\ItemData;
use SP\Domain\Account\Ports\AccountToUserRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\Query;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -41,7 +41,7 @@ use function SP\__u;
*
* @package SP\Infrastructure\Account\Repositories
*/
final class AccountToUser extends Repository implements AccountToUserRepository
final class AccountToUser extends BaseRepository implements AccountToUserRepository
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -28,8 +28,8 @@ use SP\DataModel\ItemData;
use SP\Domain\Account\Ports\AccountToUserGroupRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\Query;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -41,7 +41,7 @@ use function SP\__u;
*
* @package SP\Infrastructure\Account\Repositories
*/
final class AccountToUserGroup extends Repository implements AccountToUserGroupRepository
final class AccountToUserGroup extends BaseRepository implements AccountToUserGroupRepository
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -30,8 +30,8 @@ use SP\Domain\Account\Ports\PublicLinkRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\DuplicatedItemException;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -43,7 +43,7 @@ use function SP\__u;
*
* @package SP\Infrastructure\Common\Repositories\PublicLink
*/
final class PublicLink extends Repository implements PublicLinkRepository
final class PublicLink extends BaseRepository implements PublicLinkRepository
{
use RepositoryItemTrait;

View File

@@ -30,8 +30,8 @@ use SP\Domain\Auth\Models\AuthToken as AuthTokenModel;
use SP\Domain\Auth\Ports\AuthTokenRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\DuplicatedItemException;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -43,7 +43,7 @@ use function SP\__u;
*
* @template T of AuthTokenModel
*/
final class AuthToken extends Repository implements AuthTokenRepository
final class AuthToken extends BaseRepository implements AuthTokenRepository
{
use RepositoryItemTrait;

View File

@@ -30,8 +30,8 @@ use SP\Domain\Category\Models\Category as CategoryModel;
use SP\Domain\Category\Ports\CategoryRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\DuplicatedItemException;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -43,7 +43,7 @@ use function SP\__u;
*
* @template T of CategoryModel
*/
final class Category extends Repository implements CategoryRepository
final class Category extends BaseRepository implements CategoryRepository
{
use RepositoryItemTrait;

View File

@@ -31,8 +31,8 @@ use SP\Domain\Client\Ports\ClientRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\DuplicatedItemException;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -44,7 +44,7 @@ use function SP\__u;
*
* @template T of ClientModel
*/
final class Client extends Repository implements ClientRepository
final class Client extends BaseRepository implements ClientRepository
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -29,7 +29,7 @@ use Closure;
use Exception;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Context\ContextInterface;
use SP\Domain\Core\Events\EventDispatcherInterface;
@@ -46,24 +46,21 @@ use function SP\logger;
*
* @package SP\Infrastructure\Common\Repositories
*/
abstract class Repository implements RepositoryInterface
abstract class BaseRepository implements Repository
{
public function __construct(
protected DatabaseInterface $db,
protected ContextInterface $context,
protected EventDispatcherInterface $eventDispatcher,
protected QueryFactory $queryFactory
protected readonly DatabaseInterface $db,
protected readonly ContextInterface $context,
protected readonly EventDispatcherInterface $eventDispatcher,
protected readonly QueryFactory $queryFactory
) {
if (method_exists($this, 'initialize')) {
$this->initialize();
}
}
/**
* Bubbles a Closure in a database transaction
*
* @param Closure $closure
* @param object $newThis
* @param object $newThis
*
* @return mixed
* @throws ServiceException
@@ -98,15 +95,15 @@ abstract class Repository implements RepositoryInterface
/**
* Run a SQL select query to get any data from any table
*
* @param array $columns
* @param string $from
* @param string|null $where
* @param array|null $bindValues
* @param array $columns
* @param string $from
* @param string|null $where
* @param array|null $bindValues
*
* @return QueryResult
*/
final public function getAny(
array $columns,
array $columns,
string $from,
?string $where = null,
?array $bindValues = null

View File

@@ -28,7 +28,7 @@ use SP\Domain\Config\Models\Config as ConfigModel;
use SP\Domain\Config\Ports\ConfigRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -37,7 +37,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @template T of ConfigModel
*/
final class Config extends Repository implements ConfigRepository
final class Config extends BaseRepository implements ConfigRepository
{
public const TABLE = 'Config';

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -29,8 +29,8 @@ use SP\DataModel\CustomFieldData;
use SP\DataModel\ItemSearchData;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\CustomField\Ports\CustomFieldRepositoryInterface;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Domain\CustomField\Ports\CustomFieldRepository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -40,7 +40,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Domain\Common\Services
*/
final class CustomFieldRepository extends Repository implements CustomFieldRepositoryInterface
final class CustomFieldBaseRepository extends BaseRepository implements CustomFieldRepository
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -30,9 +30,9 @@ use SP\DataModel\ItemSearchData;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\CustomField\Ports\CustomFieldDefRepositoryInterface;
use SP\Domain\CustomField\Ports\CustomFieldDefRepository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -42,7 +42,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\CustomField\Repositories
*/
final class CustomFieldDefRepository extends Repository implements CustomFieldDefRepositoryInterface
final class CustomFieldDefBaseRepository extends BaseRepository implements CustomFieldDefRepository
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -30,8 +30,8 @@ use SP\DataModel\ItemSearchData;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\CustomField\Ports\CustomFieldTypeRepositoryInterface;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Domain\CustomField\Ports\CustomFieldTypeRepository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -41,7 +41,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\CustomField\Repositories
*/
final class CustomFieldTypeRepository extends Repository implements CustomFieldTypeRepositoryInterface
final class CustomFieldTypeBaseRepository extends BaseRepository implements CustomFieldTypeRepository
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -27,11 +27,11 @@ namespace SP\Infrastructure\ItemPreset\Repositories;
use RuntimeException;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Models\ItemPreset;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\ItemPreset\Ports\ItemPresetRepositoryInterface;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Domain\ItemPreset\Ports\ItemPresetRepository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -41,7 +41,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Account\Repositories
*/
class ItemPresetRepository extends Repository implements RepositoryInterface, ItemPresetRepositoryInterface
class ItemPresetBaseRepository extends BaseRepository implements Repository, ItemPresetRepository
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -29,8 +29,8 @@ use SP\DataModel\ItemSearchData;
use SP\DataModel\NotificationData;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Notification\Ports\NotificationRepositoryInterface;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Domain\Notification\Ports\NotificationRepository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -41,7 +41,7 @@ use SP\Mvc\Model\QueryCondition;
*
* @package SP\Infrastructure\Notification\Repositories
*/
final class NotificationRepository extends Repository implements NotificationRepositoryInterface
final class NotificationBaseRepository extends BaseRepository implements NotificationRepository
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -30,8 +30,8 @@ use SP\DataModel\ItemSearchData;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\Plugin\Ports\PluginRepositoryInterface;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Domain\Plugin\Ports\PluginRepository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -41,7 +41,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Plugin\Repositories
*/
final class PluginRepository extends Repository implements PluginRepositoryInterface
final class PluginBaseRepository extends BaseRepository implements PluginRepository
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -27,7 +27,7 @@ namespace SP\Infrastructure\Plugin\Repositories;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Plugin\Ports\PluginDataRepositoryInterface;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -37,7 +37,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Plugin\Repositories
*/
final class PluginDataRepository extends Repository implements PluginDataRepositoryInterface
final class PluginDataBaseRepository extends BaseRepository implements PluginDataRepositoryInterface
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -29,7 +29,7 @@ use SP\DataModel\ItemSearchData;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Security\Ports\EventlogRepositoryInterface;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -38,7 +38,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Security\Repositories
*/
final class EventlogRepository extends Repository implements EventlogRepositoryInterface
final class EventlogBaseRepository extends BaseRepository implements EventlogRepositoryInterface
{
/**
* Clears the event log

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -30,7 +30,7 @@ use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Security\Ports\TrackRepositoryInterface;
use SP\Domain\Security\Services\TrackService;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -39,7 +39,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Security\Repositories
*/
final class TrackRepository extends Repository implements TrackRepositoryInterface
final class TrackBaseRepository extends BaseRepository implements TrackRepositoryInterface
{
/**
* @param TrackRequest $trackRequest

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -28,9 +28,9 @@ use SP\DataModel\ItemSearchData;
use SP\DataModel\TagData;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Tag\Ports\TagRepositoryInterface;
use SP\Domain\Tag\Ports\TagRepository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\DuplicatedItemException;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -40,7 +40,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Common\Repositories\Tag
*/
final class TagRepository extends Repository implements TagRepositoryInterface
final class TagBaseRepository extends BaseRepository implements TagRepository
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -31,10 +31,10 @@ use SP\DataModel\UserPreferencesData;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\User\Ports\UserRepositoryInterface;
use SP\Domain\User\Ports\UserRepository;
use SP\Domain\User\Services\UpdatePassRequest;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\DuplicatedItemException;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -44,7 +44,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\User\Repositories
*/
final class UserRepository extends Repository implements UserRepositoryInterface
final class UserBaseRepository extends BaseRepository implements UserRepository
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -29,9 +29,9 @@ use SP\DataModel\UserGroupData;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\User\Ports\UserGroupRepositoryInterface;
use SP\Domain\User\Ports\UserGroupRepository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\DuplicatedItemException;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -41,7 +41,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\User\Repositories
*/
final class UserGroupRepository extends Repository implements UserGroupRepositoryInterface
final class UserGroupBaseRepository extends BaseRepository implements UserGroupRepository
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -28,7 +28,7 @@ use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\User\Ports\UserPassRecoverRepositoryInterface;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -37,7 +37,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Common\Repositories\UserPassRecover
*/
final class UserPassRecoverRepository extends Repository implements UserPassRecoverRepositoryInterface
final class UserPassRecoverBaseRepository extends BaseRepository implements UserPassRecoverRepositoryInterface
{
/**
* Checks recovery limit attempts by user's id and time

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -28,9 +28,9 @@ use SP\DataModel\ItemSearchData;
use SP\DataModel\UserProfileData;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\User\Ports\UserProfileRepositoryInterface;
use SP\Domain\User\Ports\UserProfileRepository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\DuplicatedItemException;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -40,7 +40,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\User\Repositories
*/
final class UserProfileRepository extends Repository implements UserProfileRepositoryInterface
final class UserProfileBaseRepository extends BaseRepository implements UserProfileRepository
{
use RepositoryItemTrait;

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -28,7 +28,7 @@ use SP\DataModel\UserToUserGroupData;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\User\Ports\UserToUserGroupRepositoryInterface;
use SP\Infrastructure\Common\Repositories\Repository;
use SP\Infrastructure\Common\Repositories\BaseRepository;
use SP\Infrastructure\Common\Repositories\RepositoryItemTrait;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -38,7 +38,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\User\Repositories
*/
final class UserToUserGroupRepository extends Repository implements UserToUserGroupRepositoryInterface
final class UserToUserGroupBaseRepository extends BaseRepository implements UserToUserGroupRepositoryInterface
{
use RepositoryItemTrait;

View File

@@ -0,0 +1,239 @@
<?php
/*
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
* sysPass is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sysPass is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SPT\Domain\Crypt\Services;
use Dotenv\Repository\RepositoryInterface;
use Exception;
use PHPUnit\Framework\Constraint\Callback;
use PHPUnit\Framework\MockObject\MockObject;
use SP\Domain\Account\Ports\AccountCryptService;
use SP\Domain\Common\Ports\Repository;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Config\Ports\ConfigService;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Crypt\Services\MasterPass;
use SP\Domain\Crypt\Services\UpdateMasterPassRequest;
use SP\Domain\CustomField\Ports\CustomFieldCryptServiceInterface;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
use SPT\UnitaryTestCase;
/**
* Class MasterPassTest
*
* @group unitary
*/
class MasterPassTest extends UnitaryTestCase
{
private ConfigService|MockObject $configService;
private AccountCryptService|MockObject $accountCryptService;
private CustomFieldCryptServiceInterface|MockObject $customFieldCryptService;
private MockObject|RepositoryInterface $repository;
private MasterPass $masterPass;
public function testCheckUserUpdateMPassWithFutureTime()
{
$now = time();
$this->configService
->expects(self::once())
->method('getByParam')
->with('lastupdatempass')
->willReturn((string)$now);
$this->assertTrue($this->masterPass->checkUserUpdateMPass($now + 3600));
}
public function testCheckUserUpdateMPassWithPastTime()
{
$now = time();
$this->configService
->expects(self::once())
->method('getByParam')
->with('lastupdatempass')
->willReturn((string)$now);
$this->assertFalse($this->masterPass->checkUserUpdateMPass($now - 3600));
}
public function testCheckUserUpdateMPassWithEqualTime()
{
$now = time();
$this->configService
->expects(self::once())
->method('getByParam')
->with('lastupdatempass')
->willReturn((string)$now);
$this->assertTrue($this->masterPass->checkUserUpdateMPass($now));
}
public function testCheckUserUpdateMPassWithServiceError()
{
$this->configService
->expects(self::once())
->method('getByParam')
->with('lastupdatempass')
->willThrowException(ServiceException::error('test'));
$this->assertTrue($this->masterPass->checkUserUpdateMPass(time()));
}
public function testCheckUserUpdateMPassWithNoSuchItemError()
{
$this->configService
->expects(self::once())
->method('getByParam')
->with('lastupdatempass')
->willThrowException(NoSuchItemException::error('test'));
$this->assertTrue($this->masterPass->checkUserUpdateMPass(time()));
}
public function testCheckMasterPassword()
{
$password = self::$faker->sha1();
$hash = password_hash($password, PASSWORD_BCRYPT);
$this->configService
->expects(self::once())
->method('getByParam')
->with('masterPwd')
->willReturn($hash);
self::assertTrue($this->masterPass->checkMasterPassword($password));
}
public function testCheckMasterPasswordWithServiceError()
{
$password = self::$faker->sha1();
$this->configService
->expects(self::once())
->method('getByParam')
->with('masterPwd')
->willThrowException(ServiceException::error('test'));
self::assertFalse($this->masterPass->checkMasterPassword($password));
}
public function testCheckMasterPasswordWithNoSuchItemError()
{
$password = self::$faker->sha1();
$this->configService
->expects(self::once())
->method('getByParam')
->with('masterPwd')
->willThrowException(NoSuchItemException::error('test'));
self::assertFalse($this->masterPass->checkMasterPassword($password));
}
/**
* @throws Exception
*/
public function testChangeMasterPassword()
{
$hash = self::$faker->sha1();
$this->repository
->expects(self::once())
->method('transactionAware')
->with(
new Callback(static function (callable $callable) {
$callable();
return true;
})
);
$request = new UpdateMasterPassRequest('123', '456', $hash);
$this->accountCryptService
->expects(self::once())
->method('updateMasterPassword')
->with($request);
$this->accountCryptService
->expects(self::once())
->method('updateHistoryMasterPassword')
->with($request);
$this->customFieldCryptService
->expects(self::once())
->method('updateMasterPassword')
->with($request);
$this->configService
->expects(self::exactly(2))
->method('save')
->with(
...
self::withConsecutive(['masterPwd', $request->getHash()], ['lastupdatempass', self::anything()])
);
$this->masterPass->changeMasterPassword($request);
}
/**
* @throws ConstraintException
* @throws QueryException
*/
public function testUpdateConfig()
{
$hash = self::$faker->sha1();
$this->configService
->expects(self::exactly(2))
->method('save')
->with(
...
self::withConsecutive(['masterPwd', $hash], ['lastupdatempass', self::anything()])
);
$this->masterPass->updateConfig($hash);
}
protected function setUp(): void
{
parent::setUp();
$this->configService = $this->createMock(ConfigService::class);
$this->accountCryptService = $this->createMock(AccountCryptService::class);
$this->customFieldCryptService = $this->createMock(CustomFieldCryptServiceInterface::class);
$this->repository = $this->createMock(Repository::class);
$this->masterPass = new MasterPass(
$this->application,
$this->configService,
$this->accountCryptService,
$this->customFieldCryptService,
$this->repository
);
}
}