@@ -873,7 +873,35 @@ public function testBypassSpawningMongocryptdViaBypassAutoEncryption(): void
873873
874874 $ clientEncrypted = static ::createTestClient (null , [], ['autoEncryption ' => $ autoEncryptionOpts ]);
875875
876- $ clientEncrypted ->selectCollection ('db ' , 'coll ' )->insertOne (['encrypted ' => 'test ' ]);
876+ $ clientEncrypted ->selectCollection ('db ' , 'coll ' )->insertOne (['unencrypted ' => 'test ' ]);
877+
878+ $ clientMongocryptd = static ::createTestClient ('mongodb://localhost:27021 ' );
879+
880+ $ this ->expectException (ConnectionTimeoutException::class);
881+ $ clientMongocryptd ->selectDatabase ('db ' )->command (['ping ' => 1 ]);
882+ }
883+
884+ /**
885+ * Prose test 8: Bypass spawning mongocryptd (via bypassQueryAnalysis)
886+ *
887+ * @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#via-bypassqueryanalysis
888+ */
889+ public function testBypassSpawningMongocryptdViaBypassQueryAnalysis (): void
890+ {
891+ $ autoEncryptionOpts = [
892+ 'keyVaultNamespace ' => 'keyvault.datakeys ' ,
893+ 'kmsProviders ' => [
894+ 'local ' => ['key ' => new Binary (base64_decode (self ::LOCAL_MASTERKEY ), 0 )],
895+ ],
896+ 'bypassQueryAnalysis ' => true ,
897+ 'extraOptions ' => [
898+ 'mongocryptdSpawnArgs ' => ['--pidfilepath=bypass-spawning-mongocryptd.pid ' , '--port=27021 ' ],
899+ ],
900+ ];
901+
902+ $ clientEncrypted = static ::createTestClient (null , [], ['autoEncryption ' => $ autoEncryptionOpts ]);
903+
904+ $ clientEncrypted ->selectCollection ('db ' , 'coll ' )->insertOne (['unencrypted ' => 'test ' ]);
877905
878906 $ clientMongocryptd = static ::createTestClient ('mongodb://localhost:27021 ' );
879907
0 commit comments