Skip to content

Commit 6a7158d

Browse files
authored
DRIVERS-2272 Fix errorContains in badQueries and types tests (#1177)
1 parent 3cb20c1 commit 6a7158d

File tree

6 files changed

+104
-24
lines changed

6 files changed

+104
-24
lines changed

source/client-side-encryption/etc/test-templates/badQueries.yml.template

+12-2
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,12 @@ tests:
476476
filter: { }
477477
update: { $set : { "encrypted_string": [1,2] }}
478478
result:
479-
errorContains: "Cannot encrypt element of type array"
479+
# DRIVERS-2272: The expected error message changed in mongocryptd 6.0. Before it was:
480+
# "Cannot encrypt element of type array because schema requires that type is one of: [ string ]"
481+
# After it is:
482+
# "Cannot encrypt element of type: array"
483+
# Only check for the common prefix.
484+
errorContains: "Cannot encrypt element of type"
480485
- description: "an insert with encrypted field on _id errors"
481486
clientOptions:
482487
autoEncryptOpts:
@@ -500,7 +505,12 @@ tests:
500505
arguments:
501506
document: { encrypted_string: [ "123", "456"] }
502507
result:
503-
errorContains: "Cannot encrypt element of type array"
508+
# DRIVERS-2272: The expected error message changed in mongocryptd 6.0. Before it was:
509+
# "Cannot encrypt element of type array because schema requires that type is one of: [ string ]"
510+
# After it is:
511+
# "Cannot encrypt element of type: array"
512+
# Only check for the common prefix.
513+
errorContains: "Cannot encrypt element of type"
504514
- description: "an insert with a Timestamp(0,0) value in the top-level fails"
505515
clientOptions:
506516
autoEncryptOpts:

source/client-side-encryption/etc/test-templates/types.yml.template

+36-6
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,12 @@ tests:
146146
arguments:
147147
document: &doc4 { _id: 1, encrypted_double: {"$numberDouble": "1.23"} }
148148
result:
149-
errorContains: "Cannot use deterministic encryption for element of type: double"
149+
# DRIVERS-2272: The expected error message changed in mongocryptd 6.0. Before it was:
150+
# "Cannot use deterministic encryption for element of type: double"
151+
# After it is:
152+
# "Cannot encrypt element of type: double"
153+
# Only check for the common suffix.
154+
errorContains: "element of type: double"
150155
- description: "type=decimal"
151156
clientOptions:
152157
autoEncryptOpts:
@@ -159,7 +164,12 @@ tests:
159164
arguments:
160165
document: &doc5 { _id: 1, encrypted_decimal: {"$numberDecimal": "1.23"} }
161166
result:
162-
errorContains: "Cannot use deterministic encryption for element of type: decimal"
167+
# DRIVERS-2272: The expected error message changed in mongocryptd 6.0. Before it was:
168+
# "Cannot use deterministic encryption for element of type: decimal"
169+
# After it is:
170+
# "Cannot encrypt element of type: decimal"
171+
# Only check for the common suffix.
172+
errorContains: "element of type: decimal"
163173
- description: "type=binData"
164174
clientOptions:
165175
autoEncryptOpts:
@@ -254,7 +264,12 @@ tests:
254264
arguments:
255265
document: &doc8 { _id: 1, encrypted_javascriptWithScope: {"$code": "var x = 1;", "$scope": {} } }
256266
result:
257-
errorContains: "Cannot use deterministic encryption for element of type: javascriptWithScope"
267+
# DRIVERS-2272: The expected error message changed in mongocryptd 6.0. Before it was:
268+
# "Cannot use deterministic encryption for element of type: javascriptWithScope"
269+
# After it is:
270+
# "Cannot encrypt element of type: javascriptWithScope"
271+
# Only check for the common suffix.
272+
errorContains: "element of type: javascriptWithScope"
258273
- description: "type=object"
259274
clientOptions:
260275
autoEncryptOpts:
@@ -267,7 +282,12 @@ tests:
267282
arguments:
268283
document: &doc9 { _id: 1, encrypted_object: {} }
269284
result:
270-
errorContains: "Cannot use deterministic encryption for element of type: object"
285+
# DRIVERS-2272: The expected error message changed in mongocryptd 6.0. Before it was:
286+
# "Cannot use deterministic encryption for element of type: object"
287+
# After it is:
288+
# "Cannot encrypt element of type: object"
289+
# Only check for the common suffix.
290+
errorContains: "element of type: object"
271291
- description: "type=timestamp"
272292
clientOptions:
273293
autoEncryptOpts:
@@ -442,7 +462,12 @@ tests:
442462
arguments:
443463
document: &doc17 { _id: 1, encrypted_array: [] }
444464
result:
445-
errorContains: "Cannot use deterministic encryption for element of type: array"
465+
# DRIVERS-2272: The expected error message changed in mongocryptd 6.0. Before it was:
466+
# "Cannot use deterministic encryption for element of type: array"
467+
# After it is:
468+
# "Cannot encrypt element of type: array"
469+
# Only check for the common suffix.
470+
errorContains: "element of type: array"
446471
- description: "type=bool"
447472
clientOptions:
448473
autoEncryptOpts:
@@ -455,7 +480,12 @@ tests:
455480
arguments:
456481
document: &doc18 { _id: 1, encrypted_bool: true }
457482
result:
458-
errorContains: "Cannot use deterministic encryption for element of type: bool"
483+
# DRIVERS-2272: The expected error message changed in mongocryptd 6.0. Before it was:
484+
# "Cannot use deterministic encryption for element of type: bool"
485+
# After it is:
486+
# "Cannot encrypt element of type: bool"
487+
# Only check for the common suffix.
488+
errorContains: "element of type: bool"
459489
- description: "type=null"
460490
clientOptions:
461491
autoEncryptOpts:

source/client-side-encryption/tests/badQueries.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@
13181318
}
13191319
},
13201320
"result": {
1321-
"errorContains": "Cannot encrypt element of type array"
1321+
"errorContains": "Cannot encrypt element of type"
13221322
}
13231323
}
13241324
]
@@ -1387,7 +1387,7 @@
13871387
}
13881388
},
13891389
"result": {
1390-
"errorContains": "Cannot encrypt element of type array"
1390+
"errorContains": "Cannot encrypt element of type"
13911391
}
13921392
}
13931393
]

source/client-side-encryption/tests/badQueries.yml

+12-2
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,12 @@ tests:
476476
filter: { }
477477
update: { $set : { "encrypted_string": [1,2] }}
478478
result:
479-
errorContains: "Cannot encrypt element of type array"
479+
# DRIVERS-2272: The expected error message changed in mongocryptd 6.0. Before it was:
480+
# "Cannot encrypt element of type array because schema requires that type is one of: [ string ]"
481+
# After it is:
482+
# "Cannot encrypt element of type: array"
483+
# Only check for the common prefix.
484+
errorContains: "Cannot encrypt element of type"
480485
- description: "an insert with encrypted field on _id errors"
481486
clientOptions:
482487
autoEncryptOpts:
@@ -500,7 +505,12 @@ tests:
500505
arguments:
501506
document: { encrypted_string: [ "123", "456"] }
502507
result:
503-
errorContains: "Cannot encrypt element of type array"
508+
# DRIVERS-2272: The expected error message changed in mongocryptd 6.0. Before it was:
509+
# "Cannot encrypt element of type array because schema requires that type is one of: [ string ]"
510+
# After it is:
511+
# "Cannot encrypt element of type: array"
512+
# Only check for the common prefix.
513+
errorContains: "Cannot encrypt element of type"
504514
- description: "an insert with a Timestamp(0,0) value in the top-level fails"
505515
clientOptions:
506516
autoEncryptOpts:

source/client-side-encryption/tests/types.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@
504504
}
505505
},
506506
"result": {
507-
"errorContains": "Cannot use deterministic encryption for element of type: double"
507+
"errorContains": "element of type: double"
508508
}
509509
}
510510
]
@@ -551,7 +551,7 @@
551551
}
552552
},
553553
"result": {
554-
"errorContains": "Cannot use deterministic encryption for element of type: decimal"
554+
"errorContains": "element of type: decimal"
555555
}
556556
}
557557
]
@@ -883,7 +883,7 @@
883883
}
884884
},
885885
"result": {
886-
"errorContains": "Cannot use deterministic encryption for element of type: javascriptWithScope"
886+
"errorContains": "element of type: javascriptWithScope"
887887
}
888888
}
889889
]
@@ -928,7 +928,7 @@
928928
}
929929
},
930930
"result": {
931-
"errorContains": "Cannot use deterministic encryption for element of type: object"
931+
"errorContains": "element of type: object"
932932
}
933933
}
934934
]
@@ -1547,7 +1547,7 @@
15471547
}
15481548
},
15491549
"result": {
1550-
"errorContains": "Cannot use deterministic encryption for element of type: array"
1550+
"errorContains": "element of type: array"
15511551
}
15521552
}
15531553
]
@@ -1592,7 +1592,7 @@
15921592
}
15931593
},
15941594
"result": {
1595-
"errorContains": "Cannot use deterministic encryption for element of type: bool"
1595+
"errorContains": "element of type: bool"
15961596
}
15971597
}
15981598
]

source/client-side-encryption/tests/types.yml

+36-6
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,12 @@ tests:
146146
arguments:
147147
document: &doc4 { _id: 1, encrypted_double: {"$numberDouble": "1.23"} }
148148
result:
149-
errorContains: "Cannot use deterministic encryption for element of type: double"
149+
# DRIVERS-2272: The expected error message changed in mongocryptd 6.0. Before it was:
150+
# "Cannot use deterministic encryption for element of type: double"
151+
# After it is:
152+
# "Cannot encrypt element of type: double"
153+
# Only check for the common suffix.
154+
errorContains: "element of type: double"
150155
- description: "type=decimal"
151156
clientOptions:
152157
autoEncryptOpts:
@@ -159,7 +164,12 @@ tests:
159164
arguments:
160165
document: &doc5 { _id: 1, encrypted_decimal: {"$numberDecimal": "1.23"} }
161166
result:
162-
errorContains: "Cannot use deterministic encryption for element of type: decimal"
167+
# DRIVERS-2272: The expected error message changed in mongocryptd 6.0. Before it was:
168+
# "Cannot use deterministic encryption for element of type: decimal"
169+
# After it is:
170+
# "Cannot encrypt element of type: decimal"
171+
# Only check for the common suffix.
172+
errorContains: "element of type: decimal"
163173
- description: "type=binData"
164174
clientOptions:
165175
autoEncryptOpts:
@@ -254,7 +264,12 @@ tests:
254264
arguments:
255265
document: &doc8 { _id: 1, encrypted_javascriptWithScope: {"$code": "var x = 1;", "$scope": {} } }
256266
result:
257-
errorContains: "Cannot use deterministic encryption for element of type: javascriptWithScope"
267+
# DRIVERS-2272: The expected error message changed in mongocryptd 6.0. Before it was:
268+
# "Cannot use deterministic encryption for element of type: javascriptWithScope"
269+
# After it is:
270+
# "Cannot encrypt element of type: javascriptWithScope"
271+
# Only check for the common suffix.
272+
errorContains: "element of type: javascriptWithScope"
258273
- description: "type=object"
259274
clientOptions:
260275
autoEncryptOpts:
@@ -267,7 +282,12 @@ tests:
267282
arguments:
268283
document: &doc9 { _id: 1, encrypted_object: {} }
269284
result:
270-
errorContains: "Cannot use deterministic encryption for element of type: object"
285+
# DRIVERS-2272: The expected error message changed in mongocryptd 6.0. Before it was:
286+
# "Cannot use deterministic encryption for element of type: object"
287+
# After it is:
288+
# "Cannot encrypt element of type: object"
289+
# Only check for the common suffix.
290+
errorContains: "element of type: object"
271291
- description: "type=timestamp"
272292
clientOptions:
273293
autoEncryptOpts:
@@ -442,7 +462,12 @@ tests:
442462
arguments:
443463
document: &doc17 { _id: 1, encrypted_array: [] }
444464
result:
445-
errorContains: "Cannot use deterministic encryption for element of type: array"
465+
# DRIVERS-2272: The expected error message changed in mongocryptd 6.0. Before it was:
466+
# "Cannot use deterministic encryption for element of type: array"
467+
# After it is:
468+
# "Cannot encrypt element of type: array"
469+
# Only check for the common suffix.
470+
errorContains: "element of type: array"
446471
- description: "type=bool"
447472
clientOptions:
448473
autoEncryptOpts:
@@ -455,7 +480,12 @@ tests:
455480
arguments:
456481
document: &doc18 { _id: 1, encrypted_bool: true }
457482
result:
458-
errorContains: "Cannot use deterministic encryption for element of type: bool"
483+
# DRIVERS-2272: The expected error message changed in mongocryptd 6.0. Before it was:
484+
# "Cannot use deterministic encryption for element of type: bool"
485+
# After it is:
486+
# "Cannot encrypt element of type: bool"
487+
# Only check for the common suffix.
488+
errorContains: "element of type: bool"
459489
- description: "type=null"
460490
clientOptions:
461491
autoEncryptOpts:

0 commit comments

Comments
 (0)