@@ -42,6 +42,11 @@ describe('14. Decryption Events', metadata, function () {
42
42
setupClient = this . configuration . newClient ( ) ;
43
43
// Drop and create the collection ``db.decryption_events``.
44
44
const db = setupClient . db ( 'db' ) ;
45
+ await setupClient
46
+ . db ( 'db' )
47
+ . collection ( 'decryption_events' )
48
+ . deleteMany ( { } )
49
+ . catch ( ( ) => null ) ;
45
50
await db . dropCollection ( 'decryption_events' ) . catch ( ( ) => null ) ;
46
51
await db . createCollection ( 'decryption_events' ) ;
47
52
// Create a ClientEncryption object named ``clientEncryption`` with these options:
@@ -110,6 +115,11 @@ describe('14. Decryption Events', metadata, function () {
110
115
afterEach ( async function ( ) {
111
116
aggregateSucceeded = undefined ;
112
117
aggregateFailed = undefined ;
118
+ await setupClient
119
+ . db ( 'db' )
120
+ . collection ( 'decryption_events' )
121
+ . deleteMany ( { } )
122
+ . catch ( ( ) => null ) ;
113
123
await setupClient . close ( ) ;
114
124
await encryptedClient . close ( ) ;
115
125
} ) ;
@@ -216,7 +226,15 @@ describe('14. Decryption Events', metadata, function () {
216
226
// to contain BSON binary for the field
217
227
// ``cursor.firstBatch.encrypted``.
218
228
const collection = encryptedClient . db ( 'db' ) . collection ( 'decryption_events' ) ;
219
- await collection . insertOne ( { encrypted : malformedCiphertext } ) ;
229
+ await collection . insertOne (
230
+ { encrypted : malformedCiphertext } ,
231
+ { writeConcern : { w : 'majority' } }
232
+ ) ;
233
+
234
+ /// Verify the malformedCiphertext was inserted with a plain client
235
+ const docs = await setupClient . db ( 'db' ) . collection ( 'decryption_events' ) . find ( { } ) . toArray ( ) ;
236
+ expect ( docs ) . to . have . lengthOf ( 1 ) ;
237
+ expect ( docs ) . to . have . deep . nested . property ( '[0].encrypted' , malformedCiphertext ) ;
220
238
221
239
const error = await collection
222
240
. aggregate ( [ ] )
0 commit comments