-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Conversation
|
||
// 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/); |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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.
This has conflicts that need to be resolved. |
@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) => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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' + |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm ok, thanks @gibfahn.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* 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>
Landed in 5520e40 |
* 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>
* 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>
* 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>
* 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>
This will need backport PRs in order to land in v6 or v4 |
* 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>
* 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>
* 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>
* 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>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test