Skip to content

Commit

Permalink
GODRIVER-2614 add prose test for not spawning mongocryptd with crypt …
Browse files Browse the repository at this point in the history
…shared library (mongodb#1127)
  • Loading branch information
kevinAlbs authored Nov 16, 2022
1 parent 2053ec7 commit 2f4c9b7
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions mongo/integration/client_side_encryption_prose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
setBypassAutoEncryption bool
bypassAutoEncryption bool
bypassQueryAnalysis bool
useSharedLib bool
}{
{
name: "mongocryptdBypassSpawn only",
Expand Down Expand Up @@ -1002,9 +1003,23 @@ func TestClientSideEncryptionProse(t *testing.T) {
mongocryptdOpts: mongocryptdBypassSpawnNotSet,
bypassQueryAnalysis: true,
},
{
name: "use shared library",
useSharedLib: true,
mongocryptdOpts: map[string]interface{}{
"mongocryptdURI": "mongodb://localhost:27021/db?serverSelectionTimeoutMS=1000",
"mongocryptdSpawnArgs": []string{"--pidfilepath=bypass-spawning-mongocryptd.pid", "--port=27021"},
"cryptSharedLibPath": os.Getenv("CRYPT_SHARED_LIB_PATH"),
"cryptSharedRequired": true,
},
},
}
for _, tc := range testCases {
mt.Run(tc.name, func(mt *mtest.T) {
if tc.useSharedLib && os.Getenv("CRYPT_SHARED_LIB_PATH") == "" {
mt.Skip("CRYPT_SHARED_LIB_PATH not set, skipping")
return
}
aeo := options.AutoEncryption().
SetKmsProviders(kmsProviders).
SetKeyVaultNamespace(kvNamespace).
Expand All @@ -1019,8 +1034,8 @@ func TestClientSideEncryptionProse(t *testing.T) {

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

// Check for mongocryptd server selection error if auto encryption was not bypassed.
if !(tc.setBypassAutoEncryption && tc.bypassAutoEncryption) && !tc.bypassQueryAnalysis {
// Check for mongocryptd server selection error if auto encryption needed mongocryptd.
if !(tc.setBypassAutoEncryption && tc.bypassAutoEncryption) && !tc.bypassQueryAnalysis && !tc.useSharedLib {
assert.NotNil(mt, err, "expected InsertOne error, got nil")
mcryptErr, ok := err.(mongo.MongocryptdError)
assert.True(mt, ok, "expected error type %T, got %v of type %T", mongo.MongocryptdError{}, err, err)
Expand All @@ -1029,7 +1044,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
return
}

// If auto encryption is bypassed, the command should succeed. Create a new client to connect to
// If mongocryptd was not needed, the command should succeed. Create a new client to connect to
// mongocryptd and verify it is not running.
assert.Nil(mt, err, "InsertOne error: %v", err)

Expand Down

0 comments on commit 2f4c9b7

Please sign in to comment.