Skip to content

Commit 96849e3

Browse files
committed
Fix test
1 parent 9b30ccb commit 96849e3

File tree

2 files changed

+55
-41
lines changed

2 files changed

+55
-41
lines changed

src/Command/DumpEncryptedFieldsMapCommand.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6161
$dumper = new Dumper();
6262

6363
foreach ($this->documentManagers as $name => $documentManager) {
64-
assert($documentManager instanceof DocumentManager);
65-
6664
$encryptedFieldsMap = [];
6765
foreach ($documentManager->getMetadataFactory()->getAllMetadata() as $metadata) {
6866
$database = $documentManager->getDocumentDatabase($metadata->getName());

tests/DependencyInjection/ConfigurationTest.php

Lines changed: 55 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ public static function provideNormalizeOptions(): Generator
572572
],
573573
];
574574

575-
// Encrypted Field Map normalization from XML tags
575+
// Encrypted Field Map can be a JSON string in a <![CDATA[...]]>
576576
yield [
577577
[
578578
'connection' => [
@@ -581,38 +581,40 @@ public static function provideNormalizeOptions(): Generator
581581
'id' => 'foo',
582582
'autoEncryption' => [
583583
'kmsProvider' => ['type' => 'local', 'key' => '1234567890123456789012345678901234567890123456789012345678901234'],
584-
'encryptedFieldsMap' => [
585-
'encryptedFields' => [
586-
[
587-
'name' => 'encrypted.patients',
588-
'field' => [
589-
[
590-
'path' => 'patientRecord.ssn',
591-
'bsonType' => 'string',
592-
'queries' => ['queryType' => 'equality'],
593-
],
594-
[
595-
'path' => 'patientRecord.billing',
596-
'bsonType' => 'object',
597-
],
598-
[
599-
'path' => 'patientRecord.billingAmount',
600-
'bsonType' => 'int',
601-
'queries' => ['queryType' => 'range', 'min' => 100, 'max' => 2000, 'sparsity' => 1, 'trimFactor' => 4],
602-
],
603-
],
604-
],
605-
[
606-
'name' => 'encrypted.users',
607-
'field' =>
608-
[
609-
'path' => 'email',
610-
'bsonType' => 'string',
611-
'queries' => ['queryType' => 'equality'],
612-
],
613-
],
584+
'encryptedFieldsMap' => <<<'JSON'
585+
{
586+
"encrypted.patients": [
587+
{
588+
"keyId": { "$binary": { "base64": "GH25/XvYSaCgTUQLAo1hQw==", "subType": "04" } },
589+
"path": "pathologies",
590+
"bsonType": "array"
591+
},
592+
{
593+
"keyId": { "$binary": { "base64": "krVWyFlNTUOaGFMfk+s7UA==", "subType": "04" } },
594+
"path": "patientRecord.billing",
595+
"bsonType": "object"
596+
},
597+
{
598+
"keyId": { "$binary": { "base64": "X1ZaSI1GSAKnZ+sPGcmYBA==", "subType": "04" } },
599+
"path": "patientRecord.billingAmount",
600+
"bsonType": "int",
601+
"queries": { "queryType": "range", "contention": 8, "min": 100, "max": 2000, "sparsity": 1, "trimFactor": 4 }
602+
}
614603
],
615-
],
604+
"encrypted.client": [
605+
{
606+
"keyId": { "$binary": { "base64": "I0Aw18vnRGWzVS1t3uejpQ==", "subType": "04" } },
607+
"path": "name",
608+
"bsonType": "string"
609+
},
610+
{
611+
"keyId": { "$binary": { "base64": "XSPRK3vaTLmMZr9IEj/qwQ==", "subType": "04" } },
612+
"path": "clientCards",
613+
"bsonType": "array"
614+
}
615+
]
616+
}
617+
JSON,
616618
],
617619
],
618620
],
@@ -626,25 +628,39 @@ public static function provideNormalizeOptions(): Generator
626628
'encryptedFieldsMap' => [
627629
'encrypted.patients' => [
628630
[
629-
'path' => 'patientRecord.ssn',
630-
'bsonType' => 'string',
631-
'queries' => ['queryType' => 'equality'],
631+
'keyId' => ['$binary' => ['base64' => 'GH25/XvYSaCgTUQLAo1hQw==', 'subType' => '04']],
632+
'path' => 'pathologies',
633+
'bsonType' => 'array',
632634
],
633635
[
636+
'keyId' => ['$binary' => ['base64' => 'krVWyFlNTUOaGFMfk+s7UA==', 'subType' => '04']],
634637
'path' => 'patientRecord.billing',
635638
'bsonType' => 'object',
636639
],
637640
[
641+
'keyId' => ['$binary' => ['base64' => 'X1ZaSI1GSAKnZ+sPGcmYBA==', 'subType' => '04']],
638642
'path' => 'patientRecord.billingAmount',
639643
'bsonType' => 'int',
640-
'queries' => ['queryType' => 'range', 'min' => 100, 'max' => 2000, 'sparsity' => 1, 'trimFactor' => 4],
644+
'queries' => [
645+
'queryType' => 'range',
646+
'contention' => 8,
647+
'min' => 100,
648+
'max' => 2000,
649+
'sparsity' => 1,
650+
'trimFactor' => 4,
651+
],
641652
],
642653
],
643-
'encrypted.users' => [
654+
'encrypted.client' => [
644655
[
645-
'path' => 'email',
656+
'keyId' => ['$binary' => ['base64' => 'I0Aw18vnRGWzVS1t3uejpQ==', 'subType' => '04']],
657+
'path' => 'name',
646658
'bsonType' => 'string',
647-
'queries' => ['queryType' => 'equality'],
659+
],
660+
[
661+
'keyId' => ['$binary' => ['base64' => 'XSPRK3vaTLmMZr9IEj/qwQ==', 'subType' => '04']],
662+
'path' => 'clientCards',
663+
'bsonType' => 'array',
648664
],
649665
],
650666
],

0 commit comments

Comments
 (0)