Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: crypto-hmac test assert.equal -> assert.strictEqual #9958

Closed
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions test/parallel/test-crypto-hmac.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var h1 = crypto.createHmac('sha1', 'Node')
.update('some data')
.update('to hmac')
.digest('hex');
assert.equal(h1, '19fd6e1ba73d9ed2224dd5094a71babe85d9a892', 'test HMAC');
assert.strictEqual(h1, '19fd6e1ba73d9ed2224dd5094a71babe85d9a892', 'test HMAC');

// Test HMAC (Wikipedia Test Cases)
var wikipedia = [
Expand Down Expand Up @@ -67,9 +67,10 @@ for (let i = 0, l = wikipedia.length; i < l; i++) {
const result = crypto.createHmac(hash, wikipedia[i]['key'])
.update(wikipedia[i]['data'])
.digest('hex');
assert.equal(wikipedia[i]['hmac'][hash],
result,
'Test HMAC-' + hash + ': Test case ' + (i + 1) + ' wikipedia');
assert.strictEqual(wikipedia[i]['hmac'][hash],
result,
'Test HMAC-' + hash + ': Test case ' + (i + 1)
+ ' wikipedia');
Copy link
Member

@jasnell jasnell Dec 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may be able to avoid wrapping here by using a template literal:

`Test HMAC-${hash}: Test case ${i + 1} wikipedia`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasnell I updated this using template string

}
}

Expand Down Expand Up @@ -233,10 +234,11 @@ for (let i = 0, l = rfc4231.length; i < l; i++) {
result = result.substr(0, 32); // first 128 bits == 32 hex chars
strRes = strRes.substr(0, 32);
}
assert.equal(rfc4231[i]['hmac'][hash],
result,
'Test HMAC-' + hash + ': Test case ' + (i + 1) + ' rfc 4231');
assert.equal(strRes, result, 'Should get same result from stream');
assert.strictEqual(rfc4231[i]['hmac'][hash],
result,
'Test HMAC-' + hash + ': Test case ' + (i + 1)
+ ' rfc 4231');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto here...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasnell and this one too

assert.strictEqual(strRes, result, 'Should get same result from stream');
}
}

Expand Down