Skip to content

Commit ad9c732

Browse files
Merge branch 'master' into GODRIVER-3434
2 parents 05e9a7e + 7ea8947 commit ad9c732

File tree

96 files changed

+308
-50
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+308
-50
lines changed

internal/integration/client_side_encryption_prose_test.go

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,10 @@ func TestClientSideEncryptionProse(t *testing.T) {
14441444
if os.Getenv("KMS_MOCK_SERVERS_RUNNING") == "" {
14451445
mt.Skipf("Skipping test as KMS_MOCK_SERVERS_RUNNING is not set")
14461446
}
1447+
if tlsCAFileKMIP == "" || tlsClientCertificateKeyFileKMIP == "" {
1448+
mt.Fatal("Env vars CSFLE_TLS_CA_FILE and CSFLE_TLS_CLIENT_CERT_FILE must be set")
1449+
}
1450+
14471451
validKmsProviders := map[string]map[string]interface{}{
14481452
"aws": {
14491453
"accessKeyId": awsAccessKeyID,
@@ -1513,50 +1517,50 @@ func TestClientSideEncryptionProse(t *testing.T) {
15131517
SetKeyVaultNamespace(kvNamespace)
15141518

15151519
// make TLS opts containing client certificate and CA file
1516-
tlsConfig := make(map[string]*tls.Config)
1517-
if tlsCAFileKMIP != "" && tlsClientCertificateKeyFileKMIP != "" {
1518-
clientAndCATlsMap := map[string]interface{}{
1519-
"tlsCertificateKeyFile": tlsClientCertificateKeyFileKMIP,
1520-
"tlsCAFile": tlsCAFileKMIP,
1521-
}
1522-
certConfig, err := options.BuildTLSConfig(clientAndCATlsMap)
1523-
assert.Nil(mt, err, "BuildTLSConfig error: %v", err)
1524-
tlsConfig["aws"] = certConfig
1525-
tlsConfig["azure"] = certConfig
1526-
tlsConfig["gcp"] = certConfig
1527-
tlsConfig["kmip"] = certConfig
1528-
}
1520+
clientAndCATLSConfig, err := options.BuildTLSConfig(map[string]interface{}{
1521+
"tlsCertificateKeyFile": tlsClientCertificateKeyFileKMIP,
1522+
"tlsCAFile": tlsCAFileKMIP,
1523+
})
1524+
assert.Nil(mt, err, "BuildTLSConfig error: %v", err)
15291525

15301526
// create valid Client Encryption options and set valid TLS options
15311527
validClientEncryptionOptionsWithTLS := options.ClientEncryption().
15321528
SetKmsProviders(validKmsProviders).
15331529
SetKeyVaultNamespace(kvNamespace).
1534-
SetTLSConfig(tlsConfig)
1530+
SetTLSConfig(map[string]*tls.Config{
1531+
"aws": clientAndCATLSConfig,
1532+
"azure": clientAndCATLSConfig,
1533+
"gcp": clientAndCATLSConfig,
1534+
"kmip": clientAndCATLSConfig,
1535+
})
15351536

15361537
// make TLS opts containing only CA file
1537-
if tlsCAFileKMIP != "" {
1538-
caTlsMap := map[string]interface{}{
1539-
"tlsCAFile": tlsCAFileKMIP,
1540-
}
1541-
certConfig, err := options.BuildTLSConfig(caTlsMap)
1542-
assert.Nil(mt, err, "BuildTLSConfig error: %v", err)
1543-
tlsConfig["aws"] = certConfig
1544-
tlsConfig["azure"] = certConfig
1545-
tlsConfig["gcp"] = certConfig
1546-
tlsConfig["kmip"] = certConfig
1547-
}
1538+
caTLSConfig, err := options.BuildTLSConfig(map[string]interface{}{
1539+
"tlsCAFile": tlsCAFileKMIP,
1540+
})
1541+
assert.Nil(mt, err, "BuildTLSConfig error: %v", err)
15481542

15491543
// create invalid Client Encryption options with expired credentials
15501544
expiredClientEncryptionOptions := options.ClientEncryption().
15511545
SetKmsProviders(expiredKmsProviders).
15521546
SetKeyVaultNamespace(kvNamespace).
1553-
SetTLSConfig(tlsConfig)
1547+
SetTLSConfig(map[string]*tls.Config{
1548+
"aws": caTLSConfig,
1549+
"azure": caTLSConfig,
1550+
"gcp": caTLSConfig,
1551+
"kmip": caTLSConfig,
1552+
})
15541553

15551554
// create invalid Client Encryption options with invalid hostnames
15561555
invalidHostnameClientEncryptionOptions := options.ClientEncryption().
15571556
SetKmsProviders(invalidKmsProviders).
15581557
SetKeyVaultNamespace(kvNamespace).
1559-
SetTLSConfig(tlsConfig)
1558+
SetTLSConfig(map[string]*tls.Config{
1559+
"aws": caTLSConfig,
1560+
"azure": caTLSConfig,
1561+
"gcp": caTLSConfig,
1562+
"kmip": caTLSConfig,
1563+
})
15601564

15611565
awsMasterKeyNoClientCert := map[string]interface{}{
15621566
"region": "us-east-1",
@@ -1622,7 +1626,8 @@ func TestClientSideEncryptionProse(t *testing.T) {
16221626

16231627
possibleErrors := []string{
16241628
"x509: certificate signed by unknown authority", // Windows
1625-
"x509: “valid.testing.golang.invalid” certificate is not trusted", // MacOS
1629+
"x509: “valid.testing.golang.invalid” certificate is not trusted", // macOS
1630+
"x509: “server” certificate is not standards compliant", // macOS
16261631
"x509: certificate is not authorized to sign other certificates", // All others
16271632
}
16281633

internal/integration/collection_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,7 @@ func TestCollection(t *testing.T) {
11651165
SetHint(indexName).
11661166
SetMax(bson.D{{"x", int32(5)}}).
11671167
SetMin(bson.D{{"x", int32(0)}}).
1168+
SetOplogReplay(false).
11681169
SetProjection(bson.D{{"x", int32(1)}}).
11691170
SetReturnKey(false).
11701171
SetShowRecordID(false).
@@ -1186,6 +1187,7 @@ func TestCollection(t *testing.T) {
11861187
AppendString("hint", indexName).
11871188
StartDocument("max").AppendInt32("x", 5).FinishDocument().
11881189
StartDocument("min").AppendInt32("x", 0).FinishDocument().
1190+
AppendBoolean("oplogReplay", false).
11891191
StartDocument("projection").AppendInt32("x", 1).FinishDocument().
11901192
AppendBoolean("returnKey", false).
11911193
AppendBoolean("showRecordId", false).

internal/integration/unified/collection_operation_execution.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,8 @@ func createFindCursor(ctx context.Context, operation *operation) (*cursorResult,
14711471
opts.SetMin(val.Document())
14721472
case "noCursorTimeout":
14731473
opts.SetNoCursorTimeout(val.Boolean())
1474+
case "oplogReplay":
1475+
opts.SetOplogReplay(val.Boolean())
14741476
case "projection":
14751477
opts.SetProjection(val.Document())
14761478
case "returnKey":

internal/integration/unified/unified_spec_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var (
2525
"command-monitoring/logging",
2626
"connection-monitoring-and-pooling/logging",
2727
"sessions",
28+
"retryable-reads/unified",
2829
"retryable-writes/unified",
2930
"client-side-encryption/unified",
3031
"client-side-operations-timeout",

internal/integration/unified_spec_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ const dataPath string = "../../testdata/"
178178
var directories = []string{
179179
"transactions/legacy",
180180
"convenient-transactions",
181-
"retryable-reads",
181+
"retryable-reads/legacy",
182182
"read-write-concern/operation",
183183
"server-discovery-and-monitoring/integration",
184184
"atlas-data-lake-testing",

mongo/collection.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,9 @@ func (coll *Collection) find(
14651465
if args.NoCursorTimeout != nil {
14661466
op.NoCursorTimeout(*args.NoCursorTimeout)
14671467
}
1468+
if args.OplogReplay != nil {
1469+
op.OplogReplay(*args.OplogReplay)
1470+
}
14681471
if args.Projection != nil {
14691472
proj, err := marshal(args.Projection, coll.bsonOpts, coll.registry)
14701473
if err != nil {
@@ -1518,6 +1521,7 @@ func newFindArgsFromFindOneArgs(args *options.FindOneOptions) *options.FindOptio
15181521
v.Hint = args.Hint
15191522
v.Max = args.Max
15201523
v.Min = args.Min
1524+
v.OplogReplay = args.OplogReplay
15211525
v.Projection = args.Projection
15221526
v.ReturnKey = args.ReturnKey
15231527
v.ShowRecordID = args.ShowRecordID

mongo/options/autoencryptionoptions.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,9 @@ func (a *AutoEncryptionOptionsBuilder) SetExtraOptions(extraOpts map[string]inte
184184
// to the KMS provider.
185185
//
186186
// This should only be used to set custom TLS configurations. By default, the connection will use an empty tls.Config{} with MinVersion set to tls.VersionTLS12.
187-
func (a *AutoEncryptionOptionsBuilder) SetTLSConfig(tlsOpts map[string]*tls.Config) *AutoEncryptionOptionsBuilder {
187+
func (a *AutoEncryptionOptionsBuilder) SetTLSConfig(cfg map[string]*tls.Config) *AutoEncryptionOptionsBuilder {
188188
a.Opts = append(a.Opts, func(args *AutoEncryptionOptions) error {
189-
tlsConfigs := make(map[string]*tls.Config)
190-
for provider, config := range tlsOpts {
191-
// use TLS min version 1.2 to enforce more secure hash algorithms and advanced cipher suites
192-
if config.MinVersion == 0 {
193-
config.MinVersion = tls.VersionTLS12
194-
}
195-
tlsConfigs[provider] = config
196-
}
197-
args.TLSConfig = tlsConfigs
189+
args.TLSConfig = cfg
198190

199191
return nil
200192
})

mongo/options/clientencryptionoptions.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,13 @@ func (c *ClientEncryptionOptionsBuilder) SetKmsProviders(providers map[string]ma
7070
// to the KMS provider.
7171
//
7272
// This should only be used to set custom TLS configurations. By default, the connection will use an empty tls.Config{} with MinVersion set to tls.VersionTLS12.
73-
func (c *ClientEncryptionOptionsBuilder) SetTLSConfig(tlsOpts map[string]*tls.Config) *ClientEncryptionOptionsBuilder {
73+
func (c *ClientEncryptionOptionsBuilder) SetTLSConfig(cfg map[string]*tls.Config) *ClientEncryptionOptionsBuilder {
7474
c.Opts = append(c.Opts, func(opts *ClientEncryptionOptions) error {
75-
tlsConfigs := make(map[string]*tls.Config)
76-
for provider, config := range tlsOpts {
77-
// use TLS min version 1.2 to enforce more secure hash algorithms and advanced cipher suites
78-
if config.MinVersion == 0 {
79-
config.MinVersion = tls.VersionTLS12
80-
}
81-
tlsConfigs[provider] = config
82-
}
83-
opts.TLSConfig = tlsConfigs
75+
opts.TLSConfig = cfg
76+
8477
return nil
8578
})
79+
8680
return c
8781
}
8882

mongo/options/findoptions.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type FindOptions struct {
2222
Max interface{}
2323
MaxAwaitTime *time.Duration
2424
Min interface{}
25+
OplogReplay *bool
2526
Projection interface{}
2627
ReturnKey *bool
2728
ShowRecordID *bool
@@ -200,6 +201,19 @@ func (f *FindOptionsBuilder) SetNoCursorTimeout(b bool) *FindOptionsBuilder {
200201
return f
201202
}
202203

204+
// SetOplogReplay sets the value for the OplogReplay field. OplogReplay is for internal
205+
// replication use only and should not be set.
206+
//
207+
// Deprecated: This option has been deprecated in MongoDB version 4.4 and will be ignored by
208+
// the server if it is set.
209+
func (f *FindOptionsBuilder) SetOplogReplay(b bool) *FindOptionsBuilder {
210+
f.Opts = append(f.Opts, func(opts *FindOptions) error {
211+
opts.OplogReplay = &b
212+
return nil
213+
})
214+
return f
215+
}
216+
203217
// SetProjection sets the value for the Projection field. Projection is a document describing
204218
// which fields will be included in the documents returned by the Find operation. The
205219
// default value is nil, which means all fields will be included.
@@ -265,6 +279,7 @@ type FindOneOptions struct {
265279
Hint interface{}
266280
Max interface{}
267281
Min interface{}
282+
OplogReplay *bool
268283
Projection interface{}
269284
ReturnKey *bool
270285
ShowRecordID *bool
@@ -354,6 +369,19 @@ func (f *FindOneOptionsBuilder) SetMin(min interface{}) *FindOneOptionsBuilder {
354369
return f
355370
}
356371

372+
// SetOplogReplay sets the value for the OplogReplay field. OplogReplay is for internal
373+
// replication use only and should not be set.
374+
//
375+
// Deprecated: This option has been deprecated in MongoDB version 4.4 and will be ignored by
376+
// the server if it is set.
377+
func (f *FindOneOptionsBuilder) SetOplogReplay(b bool) *FindOneOptionsBuilder {
378+
f.Opts = append(f.Opts, func(opts *FindOneOptions) error {
379+
opts.OplogReplay = &b
380+
return nil
381+
})
382+
return f
383+
}
384+
357385
// SetProjection sets the value for the Projection field. Sets a document describing which fields
358386
// will be included in the document returned by the operation. The default value is nil, which
359387
// means all fields will be included.

0 commit comments

Comments
 (0)