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: improve the code in test-crypto-dh #10734

Closed
wants to merge 1 commit into from

Conversation

edsadr
Copy link
Member

@edsadr edsadr commented Jan 11, 2017

  • validate the errors for some assert.throws
  • use arrow functions
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 nodejs-github-bot added test Issues and PRs related to the tests. lts-watch-v6.x labels Jan 11, 2017
@mscdex mscdex added the crypto Issues and PRs related to the crypto subsystem. label Jan 11, 2017

// Run this one twice to make sure that the dh3 clears its error properly
{
const c = crypto.createDecipheriv('aes-128-ecb', crypto.randomBytes(16), '');
assert.throws(function() { c.final('utf8'); }, /wrong final block length/);
assert.throws(() => { c.final('utf8'); }, /wrong final block length/);
Copy link
Member

@lpinca lpinca Jan 11, 2017

Choose a reason for hiding this comment

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

Nit: can the regex be updated to include ^ and $ anchors?


let modp2Secret = modp2.computeSecret(exmodp2.getPublicKey()).toString('hex');
const exmodp2Secret = exmodp2.computeSecret(modp2.getPublicKey())
.toString('hex');
Copy link
Contributor

Choose a reason for hiding this comment

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

This line should be indented more.

@edsadr
Copy link
Member Author

edsadr commented Jan 12, 2017

@cjihrig, @lpinca did the changes, please check

@cjihrig
Copy link
Contributor

cjihrig commented Jan 12, 2017

This has conflicts that need to be resolved.

@edsadr
Copy link
Member Author

edsadr commented Jan 12, 2017

@cjihrig solved those conflicts

@@ -258,10 +270,10 @@ ecdh5.setPrivateKey(cafebabeKey, 'hex');
'0000000000000000000000000000000000000000000000000000000000000000',
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141',
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF',
].forEach(function(element, index, object) {
assert.throws(function() {
].forEach((element, index, object) => {

Choose a reason for hiding this comment

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

index and object are not used; they were excluded in #10753 (didn't realize this PR existed). Can you remove?

Copy link
Member Author

@edsadr edsadr Jan 12, 2017

Choose a reason for hiding this comment

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

sure thing @fluxsauce, I am changing this now

* validate the errors for all assert.throws
* use arrow functions
@@ -56,21 +59,29 @@ const secret3 = dh3.computeSecret(key2, 'hex', 'base64');

assert.strictEqual(secret1, secret3);

const wrongBlockLength =
new RegExp('^Error: error:0606506D:digital envelope' +
Copy link
Member

Choose a reason for hiding this comment

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

Nit: this indentation looks a bit weird, why 4 spaces?

Copy link
Member

Choose a reason for hiding this comment

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

See discussion here. I thought it was 4 spaces (otherwise two would get confused with indentation), but I'm not sure what the consensus is.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm ok, thanks @gibfahn.

Copy link
Member Author

@edsadr edsadr Jan 12, 2017

Choose a reason for hiding this comment

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

@lpinca, looks like we really need this code style defined, the linter is not effective enough to solve these questions and the answer differs among collaborators

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I agree.

@lpinca
Copy link
Member

lpinca commented Jan 12, 2017

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

jasnell pushed a commit that referenced this pull request Jan 13, 2017
* validate the errors for all assert.throws
* use arrow functions

PR-URL: #10734
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@jasnell
Copy link
Member

jasnell commented Jan 13, 2017

Landed in 5520e40

@jasnell jasnell closed this Jan 13, 2017
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 18, 2017
* validate the errors for all assert.throws
* use arrow functions

PR-URL: nodejs#10734
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
targos pushed a commit that referenced this pull request Jan 28, 2017
* validate the errors for all assert.throws
* use arrow functions

PR-URL: #10734
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@italoacasas italoacasas mentioned this pull request Jan 29, 2017
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 30, 2017
* validate the errors for all assert.throws
* use arrow functions

PR-URL: nodejs#10734
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 30, 2017
* validate the errors for all assert.throws
* use arrow functions

PR-URL: nodejs#10734
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@jasnell
Copy link
Member

jasnell commented Mar 8, 2017

This will need backport PRs in order to land in v6 or v4

gibfahn pushed a commit that referenced this pull request Jun 19, 2017
* validate the errors for all assert.throws
* use arrow functions

PR-URL: #10734
Backport-PR-URL: #13785
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
gibfahn pushed a commit that referenced this pull request Jun 20, 2017
* validate the errors for all assert.throws
* use arrow functions

PR-URL: #10734
Backport-PR-URL: #13785
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
MylesBorins pushed a commit that referenced this pull request Jul 11, 2017
* validate the errors for all assert.throws
* use arrow functions

PR-URL: #10734
Backport-PR-URL: #13785
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@MylesBorins MylesBorins mentioned this pull request Jul 18, 2017
abhishekumar-tyagi pushed a commit to abhishekumar-tyagi/node that referenced this pull request May 5, 2024
* validate the errors for all assert.throws
* use arrow functions

PR-URL: nodejs/node#10734
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
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.

9 participants