-
-
Save kevinAlbs/198ec9c8784b7297a76d966f2ca785ec to your computer and use it in GitHub Desktop.
Reproduce the expected error from the badQueries test "an update that would produce an array on an encrypted field errors"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Q: What error does mongocryptd return when encrypting an array? | |
* A: See "Sample outputs" below. | |
* | |
* Run this script with: mongo --port 27020 run-badQuery.js | |
*/ | |
reply = db.runCommand({ | |
update: "coll", | |
updates: [ | |
{q: { }, u: { $set : { "encrypted_string": [1,2] }}} | |
], | |
jsonSchema: {'properties': {'encrypted_string': {'encrypt': {'keyId': [UUID()], 'bsonType': 'string', 'algorithm': 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic'}}}, 'bsonType': 'object'}, | |
isRemoteSchema: true | |
}) | |
printjson (reply) | |
/* | |
Sample outputs: | |
% mongo run-badQuery.js --port 27020 | |
MongoDB shell version v6.0.0-alpha-825-g57b670b | |
connecting to: mongodb://127.0.0.1:27020/?compressors=disabled&gssapiServiceName=mongodb | |
Implicit session: session { "id" : UUID("ddf804aa-5ee3-40cf-be44-7e936e63d27a") } | |
MongoDB server version: 6.0.0-alpha-825-g57b670b | |
{ | |
"ok" : 0, | |
"errmsg" : "Cannot encrypt element of type array because schema requires that type is one of: [ string ]", | |
"code" : 31118, | |
"codeName" : "Location31118" | |
} | |
% mongo run-badQuery.js --port 27020 | |
MongoDB shell version v6.0.0-alpha-1179-gdc27194 | |
connecting to: mongodb://127.0.0.1:27020/?compressors=disabled&gssapiServiceName=mongodb | |
Implicit session: session { "id" : UUID("ddf804aa-5ee3-40cf-be44-7e936e63d27a") } | |
MongoDB server version: 6.0.0-alpha-1179-gdc27194 | |
{ | |
"ok" : 0, | |
"errmsg" : "Cannot encrypt element of type: array", | |
"code" : 31041, | |
"codeName" : "Location31041" | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment