Skip to content

Commit 3ba3d1d

Browse files
committed
test(NODE-4294): add test for csfle bulk write error
1 parent c4e173c commit 3ba3d1d

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/integration/client-side-encryption/driver.test.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,49 @@ describe('Client Side Encryption Functional', function () {
5353
}
5454
});
5555

56+
describe('Collection', function () {
57+
describe('#bulkWrite()', function () {
58+
context('when encryption errors', function () {
59+
let client;
60+
61+
beforeEach(function () {
62+
client = this.configuration.newClient({}, {
63+
autoEncryption: {
64+
keyVaultNamespace: 'test.keyvault',
65+
kmsProviders: {
66+
local: {
67+
key: 'A'.repeat(128)
68+
}
69+
},
70+
encryptedFieldsMap: {
71+
'test.coll': {
72+
fields: [{
73+
path: 'ssn',
74+
keyId: new BSON.UUID('23f786b4-1d39-4c36-ae88-70a663321ec9').toBinary(),
75+
bsonType: 'string'
76+
}]
77+
}
78+
}
79+
}
80+
});
81+
});
82+
83+
afterEach(async function () {
84+
await client?.close();
85+
});
86+
87+
it('bubbles up the mongocrypt error', async function () {
88+
try {
89+
await client.db('test').collection('coll').bulkWrite([{insertOne: { ssn: 'foo' }}]);
90+
expect.fail('expected error to be thrown');
91+
} catch (error) {
92+
expect(error.message).to.equal('not all keys requested were satisfied');
93+
}
94+
});
95+
});
96+
});
97+
});
98+
5699
describe('BSON Options', function () {
57100
beforeEach(function () {
58101
this.client = this.configuration.newClient();

0 commit comments

Comments
 (0)