Skip to content

Commit 40b5f17

Browse files
GODRIVER-3402 Bump testdata/specifications from 5ef7b1b to 49ade88 (#2182)
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Preston Vasquez <[email protected]>
1 parent b79c3f6 commit 40b5f17

File tree

3 files changed

+61
-13
lines changed

3 files changed

+61
-13
lines changed

internal/integration/mtest/mongotest.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -816,18 +816,23 @@ func verifyRunOnBlockConstraint(rob RunOnBlock) error {
816816
return err
817817
}
818818

819-
if rob.CSFLE != nil {
820-
if *rob.CSFLE && !IsCSFLEEnabled() {
821-
return fmt.Errorf("runOnBlock requires CSFLE to be enabled. Build with the cse tag to enable")
822-
} else if !*rob.CSFLE && IsCSFLEEnabled() {
823-
return fmt.Errorf("runOnBlock requires CSFLE to be disabled. Build without the cse tag to disable")
824-
}
825-
if *rob.CSFLE {
826-
if err := verifyVersionConstraints("4.2", ""); err != nil {
827-
return err
828-
}
819+
// TODO(GODRIVER-3486): Once auto encryption is supported by the unified test
820+
// format,this check should be removed.
821+
if rob.CSFLEEnabled() && rob.CSFLE.Options != nil {
822+
return fmt.Errorf("Auto encryption required (GODRIVER-3486)")
823+
}
824+
825+
if rob.CSFLEEnabled() && !IsCSFLEEnabled() {
826+
return fmt.Errorf("runOnBlock requires CSFLE to be enabled. Build with the cse tag to enable")
827+
} else if !rob.CSFLEEnabled() && IsCSFLEEnabled() {
828+
return fmt.Errorf("runOnBlock requires CSFLE to be disabled. Build without the cse tag to disable")
829+
}
830+
if rob.CSFLEEnabled() {
831+
if err := verifyVersionConstraints("4.2", ""); err != nil {
832+
return err
829833
}
830834
}
835+
831836
return nil
832837
}
833838

internal/integration/mtest/options.go

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,45 @@ var (
4949
falseBool = false
5050
)
5151

52+
// CSFLEOptions holds configuration for Client-Side Field Level Encryption
53+
// (CSFLE).
54+
type CSFLEOptions struct{}
55+
56+
// CSFLE models the runOnRequirements.csfle field in Unified Test Format tests.
57+
//
58+
// The csfle field accepts either:
59+
// - a boolean: true enables CSFLE with no options; false disables CSFLE
60+
// (Options is nil).
61+
// - an object: Options is populated from the document and Boolean is set to
62+
// false.
63+
type CSFLE struct {
64+
Boolean bool
65+
Options *CSFLEOptions
66+
}
67+
68+
// UnmarshalBSON implements custom BSON unmarshalling for CSFLE, accepting
69+
// either a boolean or an embedded document. If a document is provided, Options
70+
// is set and Boolean is false. If a boolean is provided, Boolean is set and
71+
// Options is nil.
72+
func (csfle *CSFLE) UnmarshalBSON(data []byte) error {
73+
embRawValue := bson.RawValue{Type: bson.TypeEmbeddedDocument, Value: data}
74+
if err := embRawValue.Unmarshal(&csfle.Options); err == nil {
75+
csfle.Boolean = false
76+
77+
return nil
78+
}
79+
80+
rawValue := bson.RawValue{Type: bson.TypeBoolean, Value: data}
81+
if b, ok := rawValue.BooleanOK(); ok {
82+
csfle.Boolean = b
83+
csfle.Options = nil
84+
85+
return nil
86+
}
87+
88+
return fmt.Errorf("error unmarshalling CSFLE: %s", data)
89+
}
90+
5291
// RunOnBlock describes a constraint for a test.
5392
type RunOnBlock struct {
5493
MinServerVersion string `bson:"minServerVersion"`
@@ -58,7 +97,11 @@ type RunOnBlock struct {
5897
ServerParameters map[string]bson.RawValue `bson:"serverParameters"`
5998
Auth *bool `bson:"auth"`
6099
AuthEnabled *bool `bson:"authEnabled"`
61-
CSFLE *bool `bson:"csfle"`
100+
CSFLE *CSFLE `bson:"csfleConfiguration"`
101+
}
102+
103+
func (r *RunOnBlock) CSFLEEnabled() bool {
104+
return r.CSFLE != nil && (r.CSFLE.Boolean || r.CSFLE.Options != nil)
62105
}
63106

64107
// UnmarshalBSON implements custom BSON unmarshalling behavior for RunOnBlock because some test formats use the
@@ -73,7 +116,7 @@ func (r *RunOnBlock) UnmarshalBSON(data []byte) error {
73116
ServerParameters map[string]bson.RawValue `bson:"serverParameters"`
74117
Auth *bool `bson:"auth"`
75118
AuthEnabled *bool `bson:"authEnabled"`
76-
CSFLE *bool `bson:"csfle"`
119+
CSFLE *CSFLE `bson:"csfle"`
77120
Extra map[string]any `bson:",inline"`
78121
}
79122
if err := bson.Unmarshal(data, &temp); err != nil {

testdata/specifications

Submodule specifications updated 213 files

0 commit comments

Comments
 (0)