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 <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
corvinrok authored and MylesBorins committed Nov 28, 2017
1 parent 086d851 commit f46e118
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 @@ -351,15 +351,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 @@ -373,14 +371,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 @@ -392,8 +389,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 @@ -410,7 +406,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 @@ -419,7 +415,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 @@ -428,7 +424,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 @@ -446,7 +442,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 @@ -468,7 +464,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 @@ -486,8 +482,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 @@ -505,8 +500,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 @@ -524,8 +518,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 f46e118

Please sign in to comment.