You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it('createDataKey() handles duplicate key errors on the keyvault collection',asyncfunction(){
1772
+
// 1. Use client_encryption to create a new local data key with a keyAltName "abc" and assert the operation does not fail.
1773
+
awaitclientEncryption.createDataKey('local',{
1774
+
keyAltNames: ['abc']
1775
+
});
1776
+
1777
+
// 2. Repeat Step 1 and assert the operation fails due to a duplicate key server error (error code 11000).
1778
+
constresultStep2=awaitclientEncryption
1779
+
.createDataKey('local',{
1780
+
keyAltNames: ['abc']
1781
+
})
1782
+
.catch(e=>e);
1783
+
expect(
1784
+
resultStep2,
1785
+
'Error in step 2) expected clientEncryption.createDataKey to throw duplicate key error but it did not'
1786
+
).to.be.instanceof(MongoServerError);
1787
+
expect(resultStep2).have.property('code',11000);
1788
+
1789
+
// 3. Use client_encryption to create a new local data key with a keyAltName "def" and assert the operation fails due to a duplicate key server error (error code 11000).
1790
+
constresultStep3=awaitclientEncryption
1791
+
.createDataKey('local',{
1792
+
keyAltNames: ['def']
1793
+
})
1794
+
.catch(e=>e);
1795
+
expect(
1796
+
resultStep3,
1797
+
'Error in step 3) expected clientEncryption.createDataKey to throw duplicate key error but it did not'
1798
+
).to.be.instanceof(MongoServerError);
1799
+
expect(resultStep3).have.property('code',11000);
1800
+
});
1801
+
});
1802
+
1803
+
context('Case 2',metadata,function(){
1804
+
it('addKeyAltName() handles duplicate key errors on the keyvault collection',asyncfunction(){
1805
+
// 1. Use client_encryption to create a new local data key and assert the operation does not fail.
// 4. Use client_encryption to add a keyAltName "def" to the key created in Step 1 and assert the operation fails due to a duplicate key server error (error code 11000).
// 5. Use client_encryption to add a keyAltName "def" to the existing key, assert the operation does not fail, and assert the returned key document contains the keyAltName "def" added during Setup.
0 commit comments