@@ -1029,6 +1029,44 @@ static function (self $test, ClientEncryption $clientEncryption, ClientEncryptio
1029
1029
];
1030
1030
}
1031
1031
1032
+ /**
1033
+ * Prose test 8: Bypass Spawning mongocryptd (via loading shared library)
1034
+ *
1035
+ * @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/#via-loading-shared-library
1036
+ */
1037
+ public function testBypassSpawningMongocryptdViaLoadingSharedLibrary (): void
1038
+ {
1039
+ if (! static ::isCryptSharedLibAvailable ()) {
1040
+ $ this ->markTestSkipped ('Bypass spawning of mongocryptd cannot be tested when crypt_shared is not available ' );
1041
+ }
1042
+
1043
+ $ autoEncryptionOpts = [
1044
+ 'keyVaultNamespace ' => 'keyvault.datakeys ' ,
1045
+ 'kmsProviders ' => [
1046
+ 'local ' => ['key ' => new Binary (base64_decode (self ::LOCAL_MASTERKEY ), 0 )],
1047
+ ],
1048
+ 'schemaMap ' => [
1049
+ 'db.coll ' => $ this ->decodeJson (file_get_contents (__DIR__ . '/client-side-encryption/external/external-schema.json ' )),
1050
+ ],
1051
+ 'extraOptions ' => [
1052
+ 'mongocryptdBypassSpawn ' => true ,
1053
+ 'mongocryptdURI ' => 'mongodb://localhost:27021/?serverSelectionTimeoutMS=1000 ' ,
1054
+ 'mongocryptdSpawnArgs ' => ['--pidfilepath=bypass-spawning-mongocryptd.pid ' , '--port=27021 ' ],
1055
+ 'cryptSharedLibRequired ' => true ,
1056
+ ],
1057
+ ];
1058
+
1059
+ $ clientEncrypted = static ::createTestClient (null , [], ['autoEncryption ' => $ autoEncryptionOpts ]);
1060
+
1061
+ $ clientEncrypted ->selectCollection ('db ' , 'coll ' )->insertOne (['unencrypted ' => 'test ' ]);
1062
+
1063
+ $ clientMongocryptd = static ::createTestClient ('mongodb://localhost:27021/?serverSelectionTimeoutMS=1000 ' );
1064
+
1065
+ $ this ->expectException (ConnectionTimeoutException::class);
1066
+ $ this ->expectExceptionMessageMatches ('#(No suitable servers found)|(No servers yet eligible for rescan)# ' );
1067
+ $ clientMongocryptd ->getManager ()->selectServer ();
1068
+ }
1069
+
1032
1070
/**
1033
1071
* Prose test 8: Bypass Spawning mongocryptd (via mongocryptdBypassSpawn)
1034
1072
*
@@ -1054,7 +1092,7 @@ public function testBypassSpawningMongocryptdViaBypassSpawn(): void
1054
1092
],
1055
1093
'extraOptions ' => [
1056
1094
'mongocryptdBypassSpawn ' => true ,
1057
- 'mongocryptdURI ' => 'mongodb://localhost:27021/db ?serverSelectionTimeoutMS=1000 ' ,
1095
+ 'mongocryptdURI ' => 'mongodb://localhost:27021/?serverSelectionTimeoutMS=1000 ' ,
1058
1096
'mongocryptdSpawnArgs ' => ['--pidfilepath=bypass-spawning-mongocryptd.pid ' , '--port=27021 ' ],
1059
1097
],
1060
1098
];
@@ -1100,10 +1138,11 @@ public function testBypassSpawningMongocryptdViaBypassAutoEncryption(): void
1100
1138
1101
1139
$ clientEncrypted ->selectCollection ('db ' , 'coll ' )->insertOne (['unencrypted ' => 'test ' ]);
1102
1140
1103
- $ clientMongocryptd = static ::createTestClient ('mongodb://localhost:27021 ' );
1141
+ $ clientMongocryptd = static ::createTestClient ('mongodb://localhost:27021/?serverSelectionTimeoutMS=1000 ' );
1104
1142
1105
1143
$ this ->expectException (ConnectionTimeoutException::class);
1106
- $ clientMongocryptd ->selectDatabase ('db ' )->command (['ping ' => 1 ]);
1144
+ $ this ->expectExceptionMessageMatches ('#(No suitable servers found)|(No servers yet eligible for rescan)# ' );
1145
+ $ clientMongocryptd ->getManager ()->selectServer ();
1107
1146
}
1108
1147
1109
1148
/**
@@ -1133,10 +1172,11 @@ public function testBypassSpawningMongocryptdViaBypassQueryAnalysis(): void
1133
1172
1134
1173
$ clientEncrypted ->selectCollection ('db ' , 'coll ' )->insertOne (['unencrypted ' => 'test ' ]);
1135
1174
1136
- $ clientMongocryptd = static ::createTestClient ('mongodb://localhost:27021 ' );
1175
+ $ clientMongocryptd = static ::createTestClient ('mongodb://localhost:27021/?serverSelectionTimeoutMS=1000 ' );
1137
1176
1138
1177
$ this ->expectException (ConnectionTimeoutException::class);
1139
- $ clientMongocryptd ->selectDatabase ('db ' )->command (['ping ' => 1 ]);
1178
+ $ this ->expectExceptionMessageMatches ('#(No suitable servers found)|(No servers yet eligible for rescan)# ' );
1179
+ $ clientMongocryptd ->getManager ()->selectServer ();
1140
1180
}
1141
1181
1142
1182
/**
0 commit comments