@@ -2212,7 +2212,47 @@ func TestClientSideEncryptionProse(t *testing.T) {
22122212
22132213 precision := int32 (2 )
22142214
2215+ d128_0 , err := primitive .ParseDecimal128 ("0" )
2216+ assert .Nil (mt , err )
2217+ d128_6 , err := primitive .ParseDecimal128 ("6" )
2218+ assert .Nil (mt , err )
2219+ d128_30 , err := primitive .ParseDecimal128 ("30" )
2220+ assert .Nil (mt , err )
2221+ d128_200 , err := primitive .ParseDecimal128 ("200" )
2222+ assert .Nil (mt , err )
2223+ d128_201 , err := primitive .ParseDecimal128 ("201" )
2224+ assert .Nil (mt , err )
2225+
22152226 tests := []testcase {
2227+ {
2228+ typeStr : "DecimalNoPrecision" ,
2229+ field : "encryptedDecimalNoPrecision" ,
2230+ typeBson : bson .TypeDecimal128 ,
2231+ rangeOpts : options.RangeOptions {
2232+ Sparsity : 1 ,
2233+ },
2234+ zero : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_0 )},
2235+ six : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_6 )},
2236+ thirty : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_30 )},
2237+ twoHundred : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_200 )},
2238+ twoHundredOne : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_201 )},
2239+ },
2240+ {
2241+ typeStr : "DecimalPrecision" ,
2242+ field : "encryptedDecimalPrecision" ,
2243+ typeBson : bson .TypeDecimal128 ,
2244+ rangeOpts : options.RangeOptions {
2245+ Min : & bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_0 )},
2246+ Max : & bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_200 )},
2247+ Sparsity : 1 ,
2248+ Precision : & precision ,
2249+ },
2250+ zero : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_0 )},
2251+ six : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_6 )},
2252+ thirty : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_30 )},
2253+ twoHundred : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_200 )},
2254+ twoHundredOne : bson.RawValue {Type : bson .TypeDecimal128 , Value : bsoncore .AppendDecimal128 (nil , d128_201 )},
2255+ },
22162256 {
22172257 typeStr : "DoubleNoPrecision" ,
22182258 field : "encryptedDoubleNoPrecision" ,
@@ -2291,6 +2331,10 @@ func TestClientSideEncryptionProse(t *testing.T) {
22912331
22922332 for _ , test := range tests {
22932333 mt .Run (test .typeStr , func (mt * mtest.T ) {
2334+ if test .typeStr == "DecimalNoPrecision" && mtest .ClusterTopologyKind () != mtest .ReplicaSet {
2335+ mt .Skipf ("Skipping DecimalNoPrecision tests on a non ReplicaSet topology. DecimalNoPrecision queries are expected to take a long time and may exceed the default mongos timeout" )
2336+ }
2337+
22942338 // Test Setup ... begin
22952339 encryptedFields := readJSONFile (mt , fmt .Sprintf ("range-encryptedFields-%v.json" , test .typeStr ))
22962340 key1Document := readJSONFile (mt , "key1-document.json" )
@@ -2548,7 +2592,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
25482592 checkCursorResults (cursor , test .field , test .zero , test .six )
25492593 })
25502594
2551- if test .field != "encryptedDoubleNoPrecision" {
2595+ if test .field != "encryptedDoubleNoPrecision" && test . field != "encryptedDecimalNoPrecision" {
25522596 mt .Run ("Case 6: encrypting a document greater than the maximum errors" , func (mt * mtest.T ) {
25532597 encryptedClient , clientEncryption := testSetup ()
25542598 defer clientEncryption .Close (context .Background ())
@@ -2585,7 +2629,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
25852629 })
25862630 }
25872631
2588- if test .field != "encryptedDoubleNoPrecision" && test .field != "encryptedDoublePrecision" {
2632+ if test .field != "encryptedDoubleNoPrecision" && test .field != "encryptedDoublePrecision" && test . field != "encryptedDecimalNoPrecision" && test . field != "encryptedDecimalPrecision" {
25892633 mt .Run ("Case 8: setting precision errors if the type is not a double" , func (mt * mtest.T ) {
25902634 encryptedClient , clientEncryption := testSetup ()
25912635 defer clientEncryption .Close (context .Background ())
0 commit comments