-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
test-tls-check-server-identity var->const, assert, string template #9986
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
test: update test-tls-check-server-identity.js
Changed var to const, assert.equal to assert.strictEqual, and used a template string for error output.
- Loading branch information
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,16 @@ | ||
| 'use strict'; | ||
| var common = require('../common'); | ||
| var assert = require('assert'); | ||
| var util = require('util'); | ||
| const common = require('../common'); | ||
| const assert = require('assert'); | ||
| const util = require('util'); | ||
|
|
||
| if (!common.hasCrypto) { | ||
| common.skip('missing crypto'); | ||
| return; | ||
| } | ||
| var tls = require('tls'); | ||
| const tls = require('tls'); | ||
|
|
||
|
|
||
| var tests = [ | ||
| const tests = [ | ||
| // False-y values. | ||
| { | ||
| host: false, | ||
|
|
@@ -253,9 +253,9 @@ var tests = [ | |
| ]; | ||
|
|
||
| tests.forEach(function(test, i) { | ||
| var err = tls.checkServerIdentity(test.host, test.cert); | ||
| assert.equal(err && err.reason, | ||
| test.error, | ||
| 'Test#' + i + ' failed: ' + util.inspect(test) + '\n' + | ||
| test.error + ' != ' + (err && err.reason)); | ||
| const err = tls.checkServerIdentity(test.host, test.cert); | ||
| assert.strictEqual(err && err.reason, | ||
| test.error, | ||
| `Test# ${i} failed: ${util.inspect(test)} \n | ||
| ${test.error} != ${(err && err.reason)}`); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please avoid multi-line template literals, especially given that the additional whitespace will be included in the string. `Test# ${i} failed: ${util.inspect(test)} \n` +
`${test.error} != ${(err && err.reason)}`); |
||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
please move the assert and util requires after the hasCrypto check
Uh oh!
There was an error while loading. Please reload this page.
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.
I tried removing the block
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
but module common is not used "error 'common' is assigned a value but never used no-unused-vars".
Then when I remove the require for common I get "error Mandatory module "common" must be loaded required-modules"
The util requires in used in the string template, can't remove that.
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.
@koxauvin Please don't remove the
hasCryptocheck. It is needed for this test. But please move the assignments toassertandutilto be after that block.