Skip to content

Commit

Permalink
test/crypto: use assert.throw() instead of hand-rolling (#1412)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn authored Feb 20, 2025
1 parent ac74cc5 commit 3922f07
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions test/unit/util/crypto.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const assert = require('node:assert/strict');
const { KeyObject } = require('node:crypto');
const appRoot = require('app-root-path');
const { readFileSync } = require('fs');
Expand Down Expand Up @@ -294,14 +295,10 @@ describe('util/crypto', () => {
const aesKey = getSubmissionKey(priv, encAesKey);
const ivs = getSubmissionIvs(instanceId, aesKey);

let thrown = false;
try { // i know about should.throws but i can't get it to assert the specific error type.
getSubmissionCleartext(aesKey, ivs(1), unpaddedCiphertext);
} catch (ex) {
ex.message.should.equal('Could not perform decryption. Double check your passphrase and your data and try again.');
thrown = true;
}
thrown.should.equal(true);
assert.throws(
() => getSubmissionCleartext(aesKey, ivs(1), unpaddedCiphertext),
{ message: 'Could not perform decryption. Double check your passphrase and your data and try again.' },
);
});
});
});
Expand Down

0 comments on commit 3922f07

Please sign in to comment.