Skip to content

Commit de35a62

Browse files
authored
test(NODE-4260): add test for csfle bulk write error (#3305)
1 parent 7797b73 commit de35a62

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,57 @@ 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+
{},
64+
{
65+
autoEncryption: {
66+
keyVaultNamespace: 'test.keyvault',
67+
kmsProviders: {
68+
local: {
69+
key: 'A'.repeat(128)
70+
}
71+
},
72+
encryptedFieldsMap: {
73+
'test.coll': {
74+
fields: [
75+
{
76+
path: 'ssn',
77+
keyId: new BSON.UUID('23f786b4-1d39-4c36-ae88-70a663321ec9').toBinary(),
78+
bsonType: 'string'
79+
}
80+
]
81+
}
82+
}
83+
}
84+
}
85+
);
86+
});
87+
88+
afterEach(async function () {
89+
await client.close();
90+
});
91+
92+
it('bubbles up the mongocrypt error', async function () {
93+
try {
94+
await client
95+
.db('test')
96+
.collection('coll')
97+
.bulkWrite([{ insertOne: { ssn: 'foo' } }]);
98+
expect.fail('expected error to be thrown');
99+
} catch (error) {
100+
expect(error.message).to.equal('not all keys requested were satisfied');
101+
}
102+
});
103+
});
104+
});
105+
});
106+
56107
describe('BSON Options', function () {
57108
beforeEach(function () {
58109
this.client = this.configuration.newClient();

0 commit comments

Comments
 (0)