diff --git a/application/Espo/Tools/AppSecret/SecretProvider.php b/application/Espo/Tools/AppSecret/SecretProvider.php index 28b746b493..24c472859b 100644 --- a/application/Espo/Tools/AppSecret/SecretProvider.php +++ b/application/Espo/Tools/AppSecret/SecretProvider.php @@ -32,6 +32,8 @@ namespace Espo\Tools\AppSecret; use Espo\Core\Utils\Crypt; use Espo\Entities\AppSecret; use Espo\ORM\EntityManager; +use Espo\ORM\Query\Part\Condition; +use Espo\ORM\Query\Part\Expression; /** * @since 8.5.0 @@ -53,7 +55,12 @@ class SecretProvider { $secret = $this->entityManager ->getRDBRepositoryByClass(AppSecret::class) - ->where(['name' => $name]) + ->where( + Condition::equal( + Expression::binary(Expression::column('name')), + $name + ) + ) ->findOne(); if (!$secret) { diff --git a/tests/integration/Espo/Tools/AppSecret/SecretProviderTest.php b/tests/integration/Espo/Tools/AppSecret/SecretProviderTest.php new file mode 100644 index 0000000000..c0d999208a --- /dev/null +++ b/tests/integration/Espo/Tools/AppSecret/SecretProviderTest.php @@ -0,0 +1,63 @@ +. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU Affero General Public License version 3. + * + * In accordance with Section 7(b) of the GNU Affero General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. + ************************************************************************/ + +namespace tests\integration\Espo\Tools\AppSecret; + +use Espo\Core\Utils\Crypt; +use Espo\Entities\AppSecret; +use Espo\Tools\AppSecret\SecretProvider; +use tests\integration\Core\BaseTestCase; + +class SecretProviderTest extends BaseTestCase +{ + public function testGet(): void + { + $em = $this->getEntityManager(); + + $provider = $this->getInjectableFactory()->create(SecretProvider::class); + + $secret = $em->getRDBRepositoryByClass(AppSecret::class)->getNew(); + $crypt = $this->getInjectableFactory()->create(Crypt::class); + + $value = 'hello'; + + $secret + ->setName('test') + ->setSecretValue($crypt->encrypt($value)); + + $em->saveEntity($secret); + + $this->assertEquals( + $value, + $provider->get('test') + ); + + $this->assertNull($provider->get('Test')); + } +}