Skip to content

Commit 4660022

Browse files
committed
update test case
1 parent a23e594 commit 4660022

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

internal/integration/client_side_encryption_prose_test.go

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,7 +3194,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
31943194
ceo := options.ClientEncryption().
31953195
SetKeyVaultNamespace("keyvault.datakeys").
31963196
SetKmsProviders(map[string]map[string]any{
3197-
"aws": map[string]any{},
3197+
"aws": nil,
31983198
}).
31993199
SetCredentialProviders(map[string]options.CredentialsProvider{
32003200
"aws": func(_ context.Context) (options.Credentials, error) {
@@ -3254,27 +3254,20 @@ func TestClientSideEncryptionProse(t *testing.T) {
32543254
keyVaultClient, err := mongo.Connect(opts)
32553255
assert.NoErrorf(mt, err, "error on Connect: %v", err)
32563256

3257+
var calledCount int
32573258
ceo := options.ClientEncryption().
32583259
SetKeyVaultNamespace("keyvault.datakeys").
32593260
SetKmsProviders(map[string]map[string]any{
3260-
"aws": {
3261-
"accessKeyId": awsAccessKeyID,
3262-
"secretAccessKey": awsSecretAccessKey,
3263-
},
3261+
"aws": nil,
32643262
}).
32653263
SetCredentialProviders(map[string]options.CredentialsProvider{
32663264
"aws": func(ctx context.Context) (options.Credentials, error) {
3267-
var cred options.Credentials
3268-
provider := credproviders.NewEnvProvider()
3269-
c, err := provider.Retrieve(ctx)
3270-
if err != nil {
3271-
return cred, err
3272-
}
3273-
cred.AccessKeyID = c.AccessKeyID
3274-
cred.SecretAccessKey = c.SecretAccessKey
3275-
cred.SessionToken = c.SessionToken
3276-
cred.ExpirationCallback = provider.IsExpired
3277-
return cred, nil
3265+
calledCount++
3266+
return options.Credentials{
3267+
AccessKeyID: awsAccessKeyID,
3268+
SecretAccessKey: awsSecretAccessKey,
3269+
ExpirationCallback: func() bool { return false },
3270+
}, nil
32783271
},
32793272
})
32803273
clientEncryption, err := mongo.NewClientEncryption(keyVaultClient, ceo)
@@ -3283,6 +3276,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
32833276
dkOpts := options.DataKey()
32843277
_, err = clientEncryption.CreateDataKey(context.Background(), "aws", dkOpts)
32853278
assert.NoErrorf(mt, err, "unexpected error %v", err)
3279+
assert.Equal(mt, 1, calledCount, "expected credential provider to be called once")
32863280
})
32873281
})
32883282
}

0 commit comments

Comments
 (0)