chore(tests): UT for PluginData service

Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
Rubén D
2024-03-10 17:00:00 +01:00
parent 4d72408e90
commit dd21f9c29b
8 changed files with 413 additions and 47 deletions

View File

@@ -56,11 +56,13 @@ trait EncryptedModel
$data = $this->{$instance->getDataProperty()};
if ($data !== null) {
$key = $crypt->makeSecuredKey($password);
return $this->mutate([
$instance->getKeyProperty() => $crypt->makeSecuredKey($password),
$instance->getKeyProperty() => $key,
$instance->getDataProperty() => $crypt->encrypt(
$data,
$this->{$instance->getKeyProperty()},
$key,
$password
)
]);
@@ -88,12 +90,13 @@ trait EncryptedModel
$instance = $attribute->newInstance();
$data = $this->{$instance->getDataProperty()};
$key = $this->{$instance->getKeyProperty()};
if ($data !== null) {
if ($data !== null && $key !== null) {
return $this->mutate([
$instance->getDataProperty() => $crypt->decrypt(
$data,
$this->{$instance->getKeyProperty()},
$key,
$password
)
]);