Merge pull request #9841 from ArnabChatterjee20k/dat-532

added checking for encrypt and plan allowing encryption of string att…
This commit is contained in:
Jake Barnby
2025-05-23 23:54:18 +12:00
parent 1a2a725cb0
commit d27dba05d2
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -1347,7 +1347,11 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/string
->inject('dbForProject')
->inject('queueForDatabase')
->inject('queueForEvents')
->action(function (string $databaseId, string $collectionId, string $key, ?int $size, ?bool $required, ?string $default, bool $array, bool $encrypt, Response $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents) {
->inject('plan')
->action(function (string $databaseId, string $collectionId, string $key, ?int $size, ?bool $required, ?string $default, bool $array, bool $encrypt, Response $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, array $plan) {
if ($encrypt && !empty($plan) && !($plan['databasesAllowEncrypt'] ?? false)) {
throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Encrypted string attributes are not available on your plan. Please upgrade to create encrypted string attributes.');
}
// Ensure attribute default is within required size
$validator = new Text($size, 0);
if (!is_null($default) && !$validator->isValid($default)) {
@@ -695,7 +695,7 @@ class DatabasesCustomServerTest extends Scope
'key' => 'lastName',
'size' => 256,
'required' => true,
'encrypt' => true,
'encrypt' => true
]);
$this->assertTrue($lastName['body']['encrypt']);
sleep(1);