Skip to content

Commit

Permalink
test: remove error messages in crypto-binary test
Browse files Browse the repository at this point in the history
PR-URL: #15981
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
corvinrok authored and joyeecheung committed Oct 14, 2017
1 parent 4e835b3 commit 24d7294
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions test/parallel/test-crypto-binary-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,13 @@ if (!common.hasFipsCrypto) {
const a0 = crypto.createHash('md5').update('Test123').digest('latin1');
assert.strictEqual(
a0,
'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca\u00bd\u008c',
'Test MD5 as latin1'
'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca\u00bd\u008c'
);
}

assert.strictEqual(a1, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'Test SHA1');
assert.strictEqual(a1, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2');

assert.strictEqual(a2, '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=',
'Test SHA256 as base64');
assert.strictEqual(a2, '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=');

assert.strictEqual(
a3,
Expand All @@ -394,14 +392,13 @@ assert.strictEqual(

assert.deepStrictEqual(
a4,
Buffer.from('8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'hex'),
'Test SHA1'
Buffer.from('8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'hex')
);

// Test multiple updates to same hash
const h1 = crypto.createHash('sha1').update('Test123').digest('hex');
const h2 = crypto.createHash('sha1').update('Test').update('123').digest('hex');
assert.strictEqual(h1, h2, 'multipled updates');
assert.strictEqual(h1, h2);

// Test hashing for binary files
const fn = fixtures.path('sample.png');
Expand All @@ -413,8 +410,7 @@ fileStream.on('data', function(data) {
fileStream.on('close', common.mustCall(function() {
assert.strictEqual(
sha1Hash.digest('hex'),
'22723e553129a336ad96e10f6aecdf0f45e4149e',
'Test SHA1 of sample.png'
'22723e553129a336ad96e10f6aecdf0f45e4149e'
);
}));

Expand All @@ -431,7 +427,7 @@ const s1Verified = crypto.createVerify('SHA1')
.update('Test')
.update('123')
.verify(certPem, s1, 'base64');
assert.strictEqual(s1Verified, true, 'sign and verify (base 64)');
assert.strictEqual(s1Verified, true);

const s2 = crypto.createSign('SHA256')
.update('Test123')
Expand All @@ -440,7 +436,7 @@ const s2Verified = crypto.createVerify('SHA256')
.update('Test')
.update('123')
.verify(certPem, s2); // binary
assert.strictEqual(s2Verified, true, 'sign and verify (binary)');
assert.strictEqual(s2Verified, true);

const s3 = crypto.createSign('SHA1')
.update('Test123')
Expand All @@ -449,7 +445,7 @@ const s3Verified = crypto.createVerify('SHA1')
.update('Test')
.update('123')
.verify(certPem, s3);
assert.strictEqual(s3Verified, true, 'sign and verify (buffer)');
assert.strictEqual(s3Verified, true);


function testCipher1(key) {
Expand All @@ -467,7 +463,7 @@ function testCipher1(key) {
let txt = decipher.update(ciph, 'hex', 'utf8');
txt += decipher.final('utf8');

assert.strictEqual(txt, plaintext, 'encryption and decryption');
assert.strictEqual(txt, plaintext);
}


Expand All @@ -489,7 +485,7 @@ function testCipher2(key) {
let txt = decipher.update(ciph, 'base64', 'utf8');
txt += decipher.final('utf8');

assert.strictEqual(txt, plaintext, 'encryption and decryption with Base64');
assert.strictEqual(txt, plaintext);
}


Expand All @@ -507,8 +503,7 @@ function testCipher3(key, iv) {
let txt = decipher.update(ciph, 'hex', 'utf8');
txt += decipher.final('utf8');

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


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

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


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

assert.strictEqual(txt, plaintext,
'encryption and decryption with key');
assert.strictEqual(txt, plaintext);
}

if (!common.hasFipsCrypto) {
Expand Down

0 comments on commit 24d7294

Please sign in to comment.