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: test hmac binding robustness #10923

Merged
merged 1 commit into from
Jan 23, 2017
Merged
Changes from all 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
8 changes: 8 additions & 0 deletions test/parallel/test-crypto-hmac.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ if (!common.hasCrypto) {
}
const crypto = require('crypto');

// Test for binding layer robustness
{
const binding = process.binding('crypto');
const h = new binding.Hmac();
// Fail to init the Hmac with an algorithm.
Copy link
Member

@Trott Trott Jan 20, 2017

Choose a reason for hiding this comment

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

Nit: It took me a little bit to realize this comment was saying "We fail to init the Hmac with an algorithm, so an attempt to update should throw." I read it as "We're going to fail (that is: throw) when we try to init the Hmac with an algorithm" and I was all like, "What? I do not understand this test. There's no algorithm specified at all!"

Maybe expand the comment a bit to something like: "Hmac.update() should throw if Hmac has not been initialized with an algorithm" or something like that?

assert.throws(() => h.update('hello'), /^TypeError: HmacUpdate fail$/);
}

// Test HMAC
const h1 = crypto.createHmac('sha1', 'Node')
.update('some data')
Expand Down