FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Enhance crypto/sig.js coverage by Leko · Pull Request #17426 · nodejs/node · GitHub

/ node Public

Enhance crypto/sig.js coverage - #17426

Closed
Leko wants to merge 9 commits into
nodejs:masterfrom
Leko:enhance_crypto_sig_coverage
Closed

Enhance crypto/sig.js coverage#17426
Leko wants to merge 9 commits into
nodejs:masterfrom
Leko:enhance_crypto_sig_coverage

Conversation

Leko commented Dec 2, 2017
edited
Loading

Copy link
Copy Markdown
Contributor

I added these case:

  1. Call Sign without new
  2. Call Verify without new
  3. Call Verify#verify with options.padding !== options.padding >> 0
  4. Call Verify#verify with options.saltLength !== options.saltLength >> 0

Current coverage: https://coverage.nodejs.org/coverage-06e1b0386196f8f8/root/internal/crypto/sig.js.html

After this PR: crypto/sig.js become 100% covered even in branch coverage.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

test

nodejs-github-bot added the test Issues and PRs related to the tests. label Dec 2, 2017
{
const Verify = crypto.Verify;
const instance = Verify('SHA256');
assert.ok(instance instanceof Verify, 'call sign constructor without new');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

sign -> verify

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ah, I made a mistake.
Thank you for your review.

mscdex added the crypto Issues and PRs related to the crypto subsystem. label Dec 2, 2017

apapirovski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM but the assert message should be adjusted, IMHO.

{
const Sign = crypto.Sign;
const instance = Sign('SHA256');
assert.ok(instance instanceof Sign, 'call sign constructor without new');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The message here seems to be more of a description of the test than communicate what was expected. Maybe something like "expected Sign to return a new instance when called without new keyword"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you for review.
I got it. I'll revise error message.

{
const Verify = crypto.Verify;
const instance = Verify('SHA256');
assert.ok(instance instanceof Verify, 'call verify constructor without new');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Same as above.

const Sign = crypto.Sign;
const instance = Sign('SHA256');
assert.ok(instance instanceof Sign, 'Sign is expected to return a new \
instance when called without `new` keyword');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Sorry, two more things:

  1. assert instead of assert.ok
  2. We usually try to break strings using + and line them up beneath each other, so something like this:
assert(instance instanceof Sign, 'Sign is expected to return a new instance ' +
                                 'when called without `new` keyword');

Same below. Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I don't mind.

assert instead of assert.ok

What difference between assert.ok and assert ?
I think assert() is better because there are fewer characters, right ?

apapirovski Dec 2, 2017
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

assert.ok is just an alias for assert (or, well, the other way around...). Not better but I think in general we try to use assert.

The practical difference in this case is it lets us fit that first line instead of having to split everything significantly more awkwardly. :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for your detailed information.
I understood that assert was better.

Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor

Landed in 0ab98f1

apapirovski closed this Dec 8, 2017
apapirovski pushed a commit that referenced this pull request Dec 8, 2017
- Call Sign without new
- Call Verify without new
- Call Verify#verify with options.padding !== options.padding >> 0
- Call Verify#verify with options.saltLength !== options.saltLength >> 0

PR-URL: #17426
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Leko deleted the enhance_crypto_sig_coverage branch December 8, 2017 13:54
MylesBorins pushed a commit that referenced this pull request Dec 12, 2017
- Call Sign without new
- Call Verify without new
- Call Verify#verify with options.padding !== options.padding >> 0
- Call Verify#verify with options.saltLength !== options.saltLength >> 0

PR-URL: #17426
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
MylesBorins pushed a commit that referenced this pull request Dec 12, 2017
- Call Sign without new
- Call Verify without new
- Call Verify#verify with options.padding !== options.padding >> 0
- Call Verify#verify with options.saltLength !== options.saltLength >> 0

PR-URL: #17426
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
MylesBorins mentioned this pull request Dec 12, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

crypto Issues and PRs related to the crypto subsystem. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants


Back | FazBrowse Home | New Git URL