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-rsa-dsa #10681

Closed
wants to merge 1 commit into from

Conversation

edsadr
Copy link
Member

@edsadr edsadr commented Jan 8, 2017

  • use const and let instead of var
  • use assert.strictEqual instead of assert.equal
  • use arrow functions
  • swap assertions arguments to match the standard
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. dont-land-on-v7.x labels Jan 8, 2017
@mscdex mscdex added crypto Issues and PRs related to the crypto subsystem. and removed dont-land-on-v7.x labels Jan 8, 2017
@Trott
Copy link
Member

Trott commented Jan 8, 2017

There are five instances of assert.throws() that get just one argument (the function containing code to run). While you're in there improving the test, it would be great if you could add a second argument containing a RegExp that matches the resulting error message.

assert.ok(rsaSign);
assert.ok(rsaVerify);

const expectingSig =
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you name this expectedSignature?

@edsadr
Copy link
Member Author

edsadr commented Jan 9, 2017

@Trott , @cjihrig , did as suggested

key: rsaKeyPem,
padding: padding
}, encryptedBuffer);
assert.equal(input, decryptedBuffer.toString());
assert.strictEqual(decryptedBuffer.toString(), input.toString());
Copy link
Member

Choose a reason for hiding this comment

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

Nit: isn't it better to compare the two buffers directly instead of their string representation?

assert.deepStrictEqual(decryptedBuffer, input);

or

assert(decryptedBuffer.equals(input));

common.fixturesDir + '/test_dsa_privkey_encrypted.pem', 'ascii');

const decryptError = new RegExp('^Error: error:06065064:digital envelope ' +
'routines:EVP_DecryptFinal_ex:bad decrypt$');
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I think should be shifted to the left by 2 spaces.

* use const and let instead of var
* use assert.strictEqual or assert.strictDeepEqual instead of assert.equal
* use arrow functions
* swap assertions arguments to match the standard
* validate the error for assert.throws
@edsadr
Copy link
Member Author

edsadr commented Jan 9, 2017

@lpinca , did as suggested

@lpinca
Copy link
Member

lpinca commented Jan 9, 2017

@lpinca
Copy link
Member

lpinca commented Jan 10, 2017

Landed in 85a9034.

@lpinca lpinca closed this Jan 10, 2017
lpinca pushed a commit that referenced this pull request Jan 10, 2017
* use const and let instead of var
* use assert.strictEqual or assert.strictDeepEqual instead of assert.equal
* use arrow functions
* swap assertions arguments to match the standard
* validate the error for assert.throws

PR-URL: #10681
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 18, 2017
* use const and let instead of var
* use assert.strictEqual or assert.strictDeepEqual instead of assert.equal
* use arrow functions
* swap assertions arguments to match the standard
* validate the error for assert.throws

PR-URL: nodejs#10681
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 23, 2017
* use const and let instead of var
* use assert.strictEqual or assert.strictDeepEqual instead of assert.equal
* use arrow functions
* swap assertions arguments to match the standard
* validate the error for assert.throws

PR-URL: nodejs#10681
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
targos pushed a commit that referenced this pull request Jan 28, 2017
* use const and let instead of var
* use assert.strictEqual or assert.strictDeepEqual instead of assert.equal
* use arrow functions
* swap assertions arguments to match the standard
* validate the error for assert.throws

PR-URL: #10681
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
@italoacasas italoacasas mentioned this pull request Jan 29, 2017
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 30, 2017
* use const and let instead of var
* use assert.strictEqual or assert.strictDeepEqual instead of assert.equal
* use arrow functions
* swap assertions arguments to match the standard
* validate the error for assert.throws

PR-URL: nodejs#10681
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 30, 2017
* use const and let instead of var
* use assert.strictEqual or assert.strictDeepEqual instead of assert.equal
* use arrow functions
* swap assertions arguments to match the standard
* validate the error for assert.throws

PR-URL: nodejs#10681
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
@jasnell
Copy link
Member

jasnell commented Mar 8, 2017

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

gibfahn pushed a commit that referenced this pull request Jun 19, 2017
* use const and let instead of var
* use assert.strictEqual or assert.strictDeepEqual instead of assert.equal
* use arrow functions
* swap assertions arguments to match the standard
* validate the error for assert.throws

PR-URL: #10681
Backport-PR-URL: #13785
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
gibfahn pushed a commit that referenced this pull request Jun 20, 2017
* use const and let instead of var
* use assert.strictEqual or assert.strictDeepEqual instead of assert.equal
* use arrow functions
* swap assertions arguments to match the standard
* validate the error for assert.throws

PR-URL: #10681
Backport-PR-URL: #13785
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jul 11, 2017
* use const and let instead of var
* use assert.strictEqual or assert.strictDeepEqual instead of assert.equal
* use arrow functions
* swap assertions arguments to match the standard
* validate the error for assert.throws

PR-URL: #10681
Backport-PR-URL: #13785
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
@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
* use const and let instead of var
* use assert.strictEqual or assert.strictDeepEqual instead of assert.equal
* use arrow functions
* swap assertions arguments to match the standard
* validate the error for assert.throws

PR-URL: nodejs/node#10681
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
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.

8 participants