Skip to content

Commit c7f3a17

Browse files
committed
WIP
1 parent 4beefe6 commit c7f3a17

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

mongo/integration/client_side_encryption_prose_test.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package integration
1111

1212
import (
13+
"bytes"
1314
"context"
1415
"crypto/tls"
1516
"encoding/base64"
@@ -24,6 +25,7 @@ import (
2425
"time"
2526

2627
"go.mongodb.org/mongo-driver/bson"
28+
"go.mongodb.org/mongo-driver/bson/bsonrw"
2729
"go.mongodb.org/mongo-driver/bson/bsontype"
2830
"go.mongodb.org/mongo-driver/bson/primitive"
2931
"go.mongodb.org/mongo-driver/event"
@@ -2147,12 +2149,14 @@ func TestClientSideEncryptionProse(t *testing.T) {
21472149
})
21482150

21492151
mt.RunOpts("18. Azure IMDS Credentials", noClientOpts, func(mt *mtest.T) {
2150-
buf := make([]byte, 0, 256)
2152+
buf := new(bytes.Buffer)
21512153
kmsProvidersMap := map[string]map[string]interface{}{
21522154
"azure": {},
21532155
}
2154-
p, err := bson.MarshalAppend(buf[:0], kmsProvidersMap)
2155-
assert.Nil(mt, err, "error in MarshalAppendWithRegistry: %v", err)
2156+
vw, err := bsonrw.NewBSONValueWriter(buf)
2157+
assert.Nil(mt, err, "error in NewBSONValueWriter: %v", err)
2158+
err = bson.NewEncoder(vw).Encode(kmsProvidersMap)
2159+
assert.Nil(mt, err, "error in Encode: %v", err)
21562160

21572161
getClient := func(header http.Header) *http.Client {
21582162
lt := &localTransport{
@@ -2167,7 +2171,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
21672171

21682172
mt.Run("Case 1: Success", func(mt *mtest.T) {
21692173
opts := &mongocryptopts.MongoCryptOptions{
2170-
KmsProviders: p,
2174+
KmsProviders: buf.Bytes(),
21712175
HTTPClient: getClient(nil),
21722176
}
21732177
crypt, err := mongocrypt.NewMongoCrypt(opts)
@@ -2182,7 +2186,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
21822186
header := make(http.Header)
21832187
header.Set("X-MongoDB-HTTP-TestParams", "case=empty-json")
21842188
opts := &mongocryptopts.MongoCryptOptions{
2185-
KmsProviders: p,
2189+
KmsProviders: buf.Bytes(),
21862190
HTTPClient: getClient(header),
21872191
}
21882192
crypt, err := mongocrypt.NewMongoCrypt(opts)
@@ -2194,7 +2198,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
21942198
header := make(http.Header)
21952199
header.Set("X-MongoDB-HTTP-TestParams", "case=bad-json")
21962200
opts := &mongocryptopts.MongoCryptOptions{
2197-
KmsProviders: p,
2201+
KmsProviders: buf.Bytes(),
21982202
HTTPClient: getClient(header),
21992203
}
22002204
crypt, err := mongocrypt.NewMongoCrypt(opts)
@@ -2206,7 +2210,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
22062210
header := make(http.Header)
22072211
header.Set("X-MongoDB-HTTP-TestParams", "case=404")
22082212
opts := &mongocryptopts.MongoCryptOptions{
2209-
KmsProviders: p,
2213+
KmsProviders: buf.Bytes(),
22102214
HTTPClient: getClient(header),
22112215
}
22122216
crypt, err := mongocrypt.NewMongoCrypt(opts)
@@ -2218,7 +2222,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
22182222
header := make(http.Header)
22192223
header.Set("X-MongoDB-HTTP-TestParams", "case=500")
22202224
opts := &mongocryptopts.MongoCryptOptions{
2221-
KmsProviders: p,
2225+
KmsProviders: buf.Bytes(),
22222226
HTTPClient: getClient(header),
22232227
}
22242228
crypt, err := mongocrypt.NewMongoCrypt(opts)
@@ -2230,7 +2234,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
22302234
header := make(http.Header)
22312235
header.Set("X-MongoDB-HTTP-TestParams", "case=slow")
22322236
opts := &mongocryptopts.MongoCryptOptions{
2233-
KmsProviders: p,
2237+
KmsProviders: buf.Bytes(),
22342238
HTTPClient: getClient(header),
22352239
}
22362240
crypt, err := mongocrypt.NewMongoCrypt(opts)

0 commit comments

Comments
 (0)