@@ -974,6 +974,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
974
974
setBypassAutoEncryption bool
975
975
bypassAutoEncryption bool
976
976
bypassQueryAnalysis bool
977
+ useSharedLib bool
977
978
}{
978
979
{
979
980
name : "mongocryptdBypassSpawn only" ,
@@ -1002,9 +1003,23 @@ func TestClientSideEncryptionProse(t *testing.T) {
1002
1003
mongocryptdOpts : mongocryptdBypassSpawnNotSet ,
1003
1004
bypassQueryAnalysis : true ,
1004
1005
},
1006
+ {
1007
+ name : "use shared library" ,
1008
+ useSharedLib : true ,
1009
+ mongocryptdOpts : map [string ]interface {}{
1010
+ "mongocryptdURI" : "mongodb://localhost:27021/db?serverSelectionTimeoutMS=1000" ,
1011
+ "mongocryptdSpawnArgs" : []string {"--pidfilepath=bypass-spawning-mongocryptd.pid" , "--port=27021" },
1012
+ "cryptSharedLibPath" : os .Getenv ("CRYPT_SHARED_LIB_PATH" ),
1013
+ "cryptSharedRequired" : true ,
1014
+ },
1015
+ },
1005
1016
}
1006
1017
for _ , tc := range testCases {
1007
1018
mt .Run (tc .name , func (mt * mtest.T ) {
1019
+ if tc .useSharedLib && os .Getenv ("CRYPT_SHARED_LIB_PATH" ) == "" {
1020
+ mt .Skip ("CRYPT_SHARED_LIB_PATH not set, skipping" )
1021
+ return
1022
+ }
1008
1023
aeo := options .AutoEncryption ().
1009
1024
SetKmsProviders (kmsProviders ).
1010
1025
SetKeyVaultNamespace (kvNamespace ).
@@ -1019,8 +1034,8 @@ func TestClientSideEncryptionProse(t *testing.T) {
1019
1034
1020
1035
_ , err := cpt .cseColl .InsertOne (context .Background (), bson.D {{"unencrypted" , "test" }})
1021
1036
1022
- // Check for mongocryptd server selection error if auto encryption was not bypassed .
1023
- if ! (tc .setBypassAutoEncryption && tc .bypassAutoEncryption ) && ! tc .bypassQueryAnalysis {
1037
+ // Check for mongocryptd server selection error if auto encryption needed mongocryptd .
1038
+ if ! (tc .setBypassAutoEncryption && tc .bypassAutoEncryption ) && ! tc .bypassQueryAnalysis && ! tc . useSharedLib {
1024
1039
assert .NotNil (mt , err , "expected InsertOne error, got nil" )
1025
1040
mcryptErr , ok := err .(mongo.MongocryptdError )
1026
1041
assert .True (mt , ok , "expected error type %T, got %v of type %T" , mongo.MongocryptdError {}, err , err )
@@ -1029,7 +1044,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
1029
1044
return
1030
1045
}
1031
1046
1032
- // If auto encryption is bypassed , the command should succeed. Create a new client to connect to
1047
+ // If mongocryptd was not needed , the command should succeed. Create a new client to connect to
1033
1048
// mongocryptd and verify it is not running.
1034
1049
assert .Nil (mt , err , "InsertOne error: %v" , err )
1035
1050
0 commit comments