@@ -118,6 +118,8 @@ class ClientSideEncryptionSpecTest extends FunctionalTestCase
118118 'fle2v2-Compact: Compact works ' => 'Failing due to bug in libmongocrypt (LIBMONGOCRYPT-699) ' ,
119119 ];
120120
121+ private static string $ specDir = __DIR__ . '/../specifications/source/client-side-encryption ' ;
122+
121123 public function setUp (): void
122124 {
123125 parent ::setUp ();
@@ -222,7 +224,7 @@ public static function provideTests()
222224 {
223225 $ testArgs = [];
224226
225- foreach (glob (__DIR__ . '/client-side-encryption/ tests/*.json ' ) as $ filename ) {
227+ foreach (glob (self :: $ specDir . '/tests/legacy /*.json ' ) as $ filename ) {
226228 $ group = basename ($ filename , '.json ' );
227229
228230 /* Some tests need to differentiate int32 and int64 BSON types.
@@ -421,7 +423,7 @@ public function testExternalKeyVault($withExternalKeyVault): void
421423 $ client ->selectCollection ('db ' , 'coll ' )->drop ();
422424
423425 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 ' )),
425427 ]);
426428
427429 $ encryptionOpts = [
@@ -437,7 +439,7 @@ public function testExternalKeyVault($withExternalKeyVault): void
437439
438440 $ autoEncryptionOpts = $ encryptionOpts + [
439441 '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 ' )),
441443 ],
442444 ];
443445
@@ -567,10 +569,10 @@ public function testBSONSizeLimitsAndBatchSplitting(Closure $test): void
567569 $ client = static ::createTestClient ();
568570
569571 $ 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 ' ))]]);
571573
572574 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 ' )),
574576 ]);
575577
576578 $ autoEncryptionOpts = [
@@ -585,7 +587,7 @@ public function testBSONSizeLimitsAndBatchSplitting(Closure $test): void
585587
586588 $ collection = $ clientEncrypted ->selectCollection ('db ' , 'coll ' );
587589
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 );
589591
590592 $ test ($ this , $ collection , $ document );
591593 }
@@ -634,18 +636,18 @@ public function testCorpus($schemaMap = true): void
634636 $ client = static ::createTestClient ();
635637 $ client ->selectDatabase ('db ' )->dropCollection ('coll ' );
636638
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 ' ));
638640
639641 if (! $ schemaMap ) {
640642 $ client ->selectDatabase ('db ' )->createCollection ('coll ' , ['validator ' => ['$jsonSchema ' => $ schema ]]);
641643 }
642644
643645 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 ' )),
649651 ]);
650652
651653 $ encryptionOpts = [
@@ -670,7 +672,7 @@ public function testCorpus($schemaMap = true): void
670672 ];
671673 }
672674
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 ' ));
674676 $ corpusCopied = [];
675677
676678 $ clientEncrypted = static ::createTestClient (null , [], ['autoEncryption ' => $ autoEncryptionOpts ]);
@@ -701,7 +703,7 @@ public function testCorpus($schemaMap = true): void
701703
702704 $ this ->assertDocumentsMatch ($ corpus , $ corpusDecrypted );
703705
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 ' ));
705707 $ corpusEncryptedActual = $ client ->selectCollection ('db ' , 'coll ' )->findOne (['_id ' => 'client_side_encryption_corpus ' ], ['typeMap ' => ['root ' => 'array ' , 'document ' => stdClass::class, 'array ' => 'array ' ]]);
706708
707709 foreach ($ corpusEncryptedExpected as $ fieldName => $ expectedData ) {
@@ -913,7 +915,7 @@ public function testBypassSpawningMongocryptdViaLoadingSharedLibrary(): void
913915 'local ' => ['key ' => new Binary (base64_decode (self ::LOCAL_MASTERKEY ))],
914916 ],
915917 '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 ' )),
917919 ],
918920 'extraOptions ' => [
919921 'mongocryptdBypassSpawn ' => true ,
@@ -955,7 +957,7 @@ public function testBypassSpawningMongocryptdViaBypassSpawn(): void
955957 'local ' => ['key ' => new Binary (base64_decode (self ::LOCAL_MASTERKEY ))],
956958 ],
957959 '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 ' )),
959961 ],
960962 'extraOptions ' => [
961963 'mongocryptdBypassSpawn ' => true ,
@@ -1335,8 +1337,8 @@ public function testExplicitEncryption(Closure $test): void
13351337 $ this ->skipIfServerVersion ('< ' , '7.0.0 ' , 'Explicit encryption tests require MongoDB 7.0 or later ' );
13361338
13371339 // 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 ' ));
13401342 $ key1Id = $ key1Document ->_id ;
13411343
13421344 $ client = static ::createTestClient ();
0 commit comments