summaryrefslogtreecommitdiff
path: root/test/parallel/test-crypto-padding.js
diff options
context:
space:
mode:
authorJulian Duque <julianduquej@gmail.com>2016-12-01 10:21:00 -0600
committerRich Trott <rtrott@gmail.com>2016-12-04 15:42:17 -0800
commit72b1f79a64fcfe243e7d3b8600f9e10dc96c5694 (patch)
tree813884a686b0a0468db150098f4b63aac2de19f6 /test/parallel/test-crypto-padding.js
parent6d54c879d6a7e614142bcef351cd9bf7c838825d (diff)
downloadandroid-node-v8-72b1f79a64fcfe243e7d3b8600f9e10dc96c5694.tar.gz
android-node-v8-72b1f79a64fcfe243e7d3b8600f9e10dc96c5694.tar.bz2
android-node-v8-72b1f79a64fcfe243e7d3b8600f9e10dc96c5694.zip
test: improve test for crypto padding
Replace assert.equal with assert.strictEqual and use RegExp in assert.throws PR-URL: https://github.com/nodejs/node/pull/9906 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test/parallel/test-crypto-padding.js')
-rw-r--r--test/parallel/test-crypto-padding.js28
1 files changed, 17 insertions, 11 deletions
diff --git a/test/parallel/test-crypto-padding.js b/test/parallel/test-crypto-padding.js
index 7822df64d9..eeb41f278a 100644
--- a/test/parallel/test-crypto-padding.js
+++ b/test/parallel/test-crypto-padding.js
@@ -74,16 +74,18 @@ function dec(encd, pad) {
* Test encryption
*/
-assert.equal(enc(ODD_LENGTH_PLAIN, true), ODD_LENGTH_ENCRYPTED);
-assert.equal(enc(EVEN_LENGTH_PLAIN, true), EVEN_LENGTH_ENCRYPTED);
+assert.strictEqual(enc(ODD_LENGTH_PLAIN, true), ODD_LENGTH_ENCRYPTED);
+assert.strictEqual(enc(EVEN_LENGTH_PLAIN, true), EVEN_LENGTH_ENCRYPTED);
assert.throws(function() {
// input must have block length %
enc(ODD_LENGTH_PLAIN, false);
-});
+}, /data not multiple of block length/);
assert.doesNotThrow(function() {
- assert.equal(enc(EVEN_LENGTH_PLAIN, false), EVEN_LENGTH_ENCRYPTED_NOPAD);
+ assert.strictEqual(
+ enc(EVEN_LENGTH_PLAIN, false), EVEN_LENGTH_ENCRYPTED_NOPAD
+ );
});
@@ -91,21 +93,25 @@ assert.doesNotThrow(function() {
* Test decryption
*/
-assert.equal(dec(ODD_LENGTH_ENCRYPTED, true), ODD_LENGTH_PLAIN);
-assert.equal(dec(EVEN_LENGTH_ENCRYPTED, true), EVEN_LENGTH_PLAIN);
+assert.strictEqual(dec(ODD_LENGTH_ENCRYPTED, true), ODD_LENGTH_PLAIN);
+assert.strictEqual(dec(EVEN_LENGTH_ENCRYPTED, true), EVEN_LENGTH_PLAIN);
assert.doesNotThrow(function() {
// returns including original padding
- assert.equal(dec(ODD_LENGTH_ENCRYPTED, false).length, 32);
- assert.equal(dec(EVEN_LENGTH_ENCRYPTED, false).length, 48);
+ assert.strictEqual(dec(ODD_LENGTH_ENCRYPTED, false).length, 32);
+ assert.strictEqual(dec(EVEN_LENGTH_ENCRYPTED, false).length, 48);
});
assert.throws(function() {
// must have at least 1 byte of padding (PKCS):
- assert.equal(dec(EVEN_LENGTH_ENCRYPTED_NOPAD, true), EVEN_LENGTH_PLAIN);
-});
+ assert.strictEqual(
+ dec(EVEN_LENGTH_ENCRYPTED_NOPAD, true), EVEN_LENGTH_PLAIN
+ );
+}, /bad decrypt/);
assert.doesNotThrow(function() {
// no-pad encrypted string should return the same:
- assert.equal(dec(EVEN_LENGTH_ENCRYPTED_NOPAD, false), EVEN_LENGTH_PLAIN);
+ assert.strictEqual(
+ dec(EVEN_LENGTH_ENCRYPTED_NOPAD, false), EVEN_LENGTH_PLAIN
+ );
});