Skip to content

Commit

Permalink
test: change crypto decipheriv assertion messages
Browse files Browse the repository at this point in the history
Includes problematic key and iv values into the assertion message

PR-URL: #16007
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
  • Loading branch information
stropitek authored and MylesBorins committed Nov 28, 2017
1 parent 541866e commit d591750
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/parallel/test-crypto-cipheriv-decipheriv.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ function testCipher1(key, iv) {
let txt = decipher.update(ciph, 'hex', 'utf8');
txt += decipher.final('utf8');

assert.strictEqual(txt, plaintext, 'encryption/decryption with key and iv');
assert.strictEqual(txt, plaintext,
`encryption/decryption with key ${key} and iv ${iv}`);

// streaming cipher interface
// NB: In real life, it's not guaranteed that you can get all of it
Expand All @@ -34,7 +35,8 @@ function testCipher1(key, iv) {
dStream.end(ciph);
txt = dStream.read().toString('utf8');

assert.strictEqual(txt, plaintext, 'streaming cipher iv');
assert.strictEqual(txt, plaintext,
`streaming cipher with key ${key} and iv ${iv}`);
}


Expand All @@ -52,7 +54,8 @@ function testCipher2(key, iv) {
let txt = decipher.update(ciph, 'buffer', 'utf8');
txt += decipher.final('utf8');

assert.strictEqual(txt, plaintext, 'encryption/decryption with key and iv');
assert.strictEqual(txt, plaintext,
`encryption/decryption with key ${key} and iv ${iv}`);
}


Expand All @@ -71,7 +74,8 @@ function testCipher3(key, iv) {
let deciph = decipher.update(ciph, 'buffer');
deciph = Buffer.concat([deciph, decipher.final()]);

assert(deciph.equals(plaintext), 'encryption/decryption with key and iv');
assert(deciph.equals(plaintext),
`encryption/decryption with key ${key} and iv ${iv}`);
}

testCipher1('0123456789abcd0123456789', '12345678');
Expand Down

0 comments on commit d591750

Please sign in to comment.