@@ -118,6 +118,8 @@ class ClientSideEncryptionSpecTest extends FunctionalTestCase
118
118
'fle2v2-Compact: Compact works ' => 'Failing due to bug in libmongocrypt (LIBMONGOCRYPT-699) ' ,
119
119
];
120
120
121
+ private static string $ specDir = __DIR__ . '/../specifications/source/client-side-encryption ' ;
122
+
121
123
public function setUp (): void
122
124
{
123
125
parent ::setUp ();
@@ -222,7 +224,7 @@ public static function provideTests()
222
224
{
223
225
$ testArgs = [];
224
226
225
- foreach (glob (__DIR__ . '/client-side-encryption/ tests/*.json ' ) as $ filename ) {
227
+ foreach (glob (self :: $ specDir . '/tests/legacy /*.json ' ) as $ filename ) {
226
228
$ group = basename ($ filename , '.json ' );
227
229
228
230
/* Some tests need to differentiate int32 and int64 BSON types.
@@ -421,7 +423,7 @@ public function testExternalKeyVault($withExternalKeyVault): void
421
423
$ client ->selectCollection ('db ' , 'coll ' )->drop ();
422
424
423
425
self ::insertKeyVaultData ($ client , [
424
- $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption /external/external-key.json ' )),
426
+ $ this ->decodeJson (file_get_contents (self :: $ specDir . '/external/external-key.json ' )),
425
427
]);
426
428
427
429
$ encryptionOpts = [
@@ -437,7 +439,7 @@ public function testExternalKeyVault($withExternalKeyVault): void
437
439
438
440
$ autoEncryptionOpts = $ encryptionOpts + [
439
441
'schemaMap ' => [
440
- 'db.coll ' => $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption /external/external-schema.json ' )),
442
+ 'db.coll ' => $ this ->decodeJson (file_get_contents (self :: $ specDir . '/external/external-schema.json ' )),
441
443
],
442
444
];
443
445
@@ -567,10 +569,10 @@ public function testBSONSizeLimitsAndBatchSplitting(Closure $test): void
567
569
$ client = static ::createTestClient ();
568
570
569
571
$ client ->selectCollection ('db ' , 'coll ' )->drop ();
570
- $ client ->selectDatabase ('db ' )->createCollection ('coll ' , ['validator ' => ['$jsonSchema ' => $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption /limits/limits-schema.json ' ))]]);
572
+ $ client ->selectDatabase ('db ' )->createCollection ('coll ' , ['validator ' => ['$jsonSchema ' => $ this ->decodeJson (file_get_contents (self :: $ specDir . '/limits/limits-schema.json ' ))]]);
571
573
572
574
self ::insertKeyVaultData ($ client , [
573
- $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption /limits/limits-key.json ' )),
575
+ $ this ->decodeJson (file_get_contents (self :: $ specDir . '/limits/limits-key.json ' )),
574
576
]);
575
577
576
578
$ autoEncryptionOpts = [
@@ -585,7 +587,7 @@ public function testBSONSizeLimitsAndBatchSplitting(Closure $test): void
585
587
586
588
$ collection = $ clientEncrypted ->selectCollection ('db ' , 'coll ' );
587
589
588
- $ document = json_decode (file_get_contents (__DIR__ . '/client-side-encryption /limits/limits-doc.json ' ), true , 512 , JSON_THROW_ON_ERROR );
590
+ $ document = json_decode (file_get_contents (self :: $ specDir . '/limits/limits-doc.json ' ), true , 512 , JSON_THROW_ON_ERROR );
589
591
590
592
$ test ($ this , $ collection , $ document );
591
593
}
@@ -634,18 +636,18 @@ public function testCorpus($schemaMap = true): void
634
636
$ client = static ::createTestClient ();
635
637
$ client ->selectDatabase ('db ' )->dropCollection ('coll ' );
636
638
637
- $ schema = $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption /corpus/corpus-schema.json ' ));
639
+ $ schema = $ this ->decodeJson (file_get_contents (self :: $ specDir . '/corpus/corpus-schema.json ' ));
638
640
639
641
if (! $ schemaMap ) {
640
642
$ client ->selectDatabase ('db ' )->createCollection ('coll ' , ['validator ' => ['$jsonSchema ' => $ schema ]]);
641
643
}
642
644
643
645
self ::insertKeyVaultData ($ client , [
644
- $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption /corpus/corpus-key-local.json ' )),
645
- $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption /corpus/corpus-key-aws.json ' )),
646
- $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption /corpus/corpus-key-azure.json ' )),
647
- $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption /corpus/corpus-key-gcp.json ' )),
648
- $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption /corpus/corpus-key-kmip.json ' )),
646
+ $ this ->decodeJson (file_get_contents (self :: $ specDir . '/corpus/corpus-key-local.json ' )),
647
+ $ this ->decodeJson (file_get_contents (self :: $ specDir . '/corpus/corpus-key-aws.json ' )),
648
+ $ this ->decodeJson (file_get_contents (self :: $ specDir . '/corpus/corpus-key-azure.json ' )),
649
+ $ this ->decodeJson (file_get_contents (self :: $ specDir . '/corpus/corpus-key-gcp.json ' )),
650
+ $ this ->decodeJson (file_get_contents (self :: $ specDir . '/corpus/corpus-key-kmip.json ' )),
649
651
]);
650
652
651
653
$ encryptionOpts = [
@@ -670,7 +672,7 @@ public function testCorpus($schemaMap = true): void
670
672
];
671
673
}
672
674
673
- $ corpus = (array ) $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption /corpus/corpus.json ' ));
675
+ $ corpus = (array ) $ this ->decodeJson (file_get_contents (self :: $ specDir . '/corpus/corpus.json ' ));
674
676
$ corpusCopied = [];
675
677
676
678
$ clientEncrypted = static ::createTestClient (null , [], ['autoEncryption ' => $ autoEncryptionOpts ]);
@@ -701,7 +703,7 @@ public function testCorpus($schemaMap = true): void
701
703
702
704
$ this ->assertDocumentsMatch ($ corpus , $ corpusDecrypted );
703
705
704
- $ corpusEncryptedExpected = (array ) $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption /corpus/corpus-encrypted.json ' ));
706
+ $ corpusEncryptedExpected = (array ) $ this ->decodeJson (file_get_contents (self :: $ specDir . '/corpus/corpus-encrypted.json ' ));
705
707
$ corpusEncryptedActual = $ client ->selectCollection ('db ' , 'coll ' )->findOne (['_id ' => 'client_side_encryption_corpus ' ], ['typeMap ' => ['root ' => 'array ' , 'document ' => stdClass::class, 'array ' => 'array ' ]]);
706
708
707
709
foreach ($ corpusEncryptedExpected as $ fieldName => $ expectedData ) {
@@ -913,7 +915,7 @@ public function testBypassSpawningMongocryptdViaLoadingSharedLibrary(): void
913
915
'local ' => ['key ' => new Binary (base64_decode (self ::LOCAL_MASTERKEY ))],
914
916
],
915
917
'schemaMap ' => [
916
- 'db.coll ' => $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption /external/external-schema.json ' )),
918
+ 'db.coll ' => $ this ->decodeJson (file_get_contents (self :: $ specDir . '/external/external-schema.json ' )),
917
919
],
918
920
'extraOptions ' => [
919
921
'mongocryptdBypassSpawn ' => true ,
@@ -955,7 +957,7 @@ public function testBypassSpawningMongocryptdViaBypassSpawn(): void
955
957
'local ' => ['key ' => new Binary (base64_decode (self ::LOCAL_MASTERKEY ))],
956
958
],
957
959
'schemaMap ' => [
958
- 'db.coll ' => $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption /external/external-schema.json ' )),
960
+ 'db.coll ' => $ this ->decodeJson (file_get_contents (self :: $ specDir . '/external/external-schema.json ' )),
959
961
],
960
962
'extraOptions ' => [
961
963
'mongocryptdBypassSpawn ' => true ,
@@ -1335,8 +1337,8 @@ public function testExplicitEncryption(Closure $test): void
1335
1337
$ this ->skipIfServerVersion ('< ' , '7.0.0 ' , 'Explicit encryption tests require MongoDB 7.0 or later ' );
1336
1338
1337
1339
// Test setup
1338
- $ encryptedFields = $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption /etc/data/encryptedFields.json ' ));
1339
- $ key1Document = $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption /etc/data/keys/key1-document.json ' ));
1340
+ $ encryptedFields = $ this ->decodeJson (file_get_contents (self :: $ specDir . '/etc/data/encryptedFields.json ' ));
1341
+ $ key1Document = $ this ->decodeJson (file_get_contents (self :: $ specDir . '/etc/data/keys/key1-document.json ' ));
1340
1342
$ key1Id = $ key1Document ->_id ;
1341
1343
1342
1344
$ client = static ::createTestClient ();
0 commit comments