Skip to content

Commit

Permalink
auto encryption cache test
Browse files Browse the repository at this point in the history
  • Loading branch information
adriandole committed Nov 12, 2024
1 parent 54eff94 commit ec411e3
Show file tree
Hide file tree
Showing 3 changed files with 406 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
runOn:
- minServerVersion: "4.1.10"
database_name: &database_name "default"
collection_name: &collection_name "default"

data: []
json_schema: {{schema()}}
key_vault_data: [{{key()}}]

tests:
- description: "Insert with deterministic encryption, then find it"
clientOptions:
autoEncryptOpts:
kmsProviders:
aws: {} # Credentials filled in from environment.
keyExpirationMS: 1
operations:
- name: insertOne
arguments:
document: &doc0 { _id: 1, encrypted_string: "string0" }
- name: wait
object: testRunner
arguments:
ms: 2
- name: find
arguments:
filter: { _id: 1 }
result: [*doc0]
expectations:
# Auto encryption will request the collection info.
- command_started_event:
command:
listCollections: 1
filter:
name: *collection_name
command_name: listCollections
# Then key is fetched from the key vault.
- command_started_event:
command:
find: datakeys
filter: {"$or": [{"_id": {"$in": [ {{key()["_id"]}} ] }}, {"keyAltNames": {"$in": []}}]}
$db: keyvault
readConcern: { level: "majority" }
command_name: find
- command_started_event:
command:
insert: *collection_name
documents:
- &doc0_encrypted { _id: 1, encrypted_string: {{ciphertext("string0", field="encrypted_string")}} }
ordered: true
command_name: insert
- command_started_event:
command:
find: *collection_name
filter: { _id: 1 }
command_name: find
- command_started_event:
command:
find: datakeys
filter: {"$or": [{"_id": {"$in": [ {{key()["_id"]}} ] }}, {"keyAltNames": {"$in": []}}]}
$db: keyvault
readConcern: { level: "majority" }
command_name: find
outcome:
collection:
# Outcome is checked using a separate MongoClient without auto encryption.
data:
- *doc0_encrypted
270 changes: 270 additions & 0 deletions source/client-side-encryption/tests/legacy/keyCache.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ec411e3

Please sign in to comment.