mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
test: remove error messages in crypto-binary test
PR-URL: https://github.com/nodejs/node/pull/15981 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
1 parent
086d8519a1
commit
f46e1187b3
1 file changed
+14
-21
@@ -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,
|
||||
@@ -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');
|
||||
@@ -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'
|
||||
);
|
||||
}));
|
||||
|
||||
@@ -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')
|
||||
@@ -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')
|
||||
@@ -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) {
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user