Skip to content

Commit 2f4c9b7

Browse files
authored
GODRIVER-2614 add prose test for not spawning mongocryptd with crypt shared library (#1127)
1 parent 2053ec7 commit 2f4c9b7

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

mongo/integration/client_side_encryption_prose_test.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
974974
setBypassAutoEncryption bool
975975
bypassAutoEncryption bool
976976
bypassQueryAnalysis bool
977+
useSharedLib bool
977978
}{
978979
{
979980
name: "mongocryptdBypassSpawn only",
@@ -1002,9 +1003,23 @@ func TestClientSideEncryptionProse(t *testing.T) {
10021003
mongocryptdOpts: mongocryptdBypassSpawnNotSet,
10031004
bypassQueryAnalysis: true,
10041005
},
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+
},
10051016
}
10061017
for _, tc := range testCases {
10071018
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+
}
10081023
aeo := options.AutoEncryption().
10091024
SetKmsProviders(kmsProviders).
10101025
SetKeyVaultNamespace(kvNamespace).
@@ -1019,8 +1034,8 @@ func TestClientSideEncryptionProse(t *testing.T) {
10191034

10201035
_, err := cpt.cseColl.InsertOne(context.Background(), bson.D{{"unencrypted", "test"}})
10211036

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 {
10241039
assert.NotNil(mt, err, "expected InsertOne error, got nil")
10251040
mcryptErr, ok := err.(mongo.MongocryptdError)
10261041
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) {
10291044
return
10301045
}
10311046

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
10331048
// mongocryptd and verify it is not running.
10341049
assert.Nil(mt, err, "InsertOne error: %v", err)
10351050

0 commit comments

Comments
 (0)