-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
tls: throw an error on getLegacyCipher #14572
Changes from 1 commit
41ec32f
b450336
2d1d2a0
14a26f9
7f4d098
30f46c3
8a61f11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Per the latest round of feedback from julien. Fix a couple of typos, add some explanatory text, refactor the test case.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,7 @@ function doTest(checklist, additional_args, env) { | |
| }); | ||
| } | ||
|
|
||
| // test that the command line switchs takes precedence | ||
| // test that the command line switches takes precedence | ||
| // over the environment variables | ||
| function doTestPrecedence() { | ||
| // test that --cipher-list takes precedence over NODE_CIPHER_LIST | ||
|
|
@@ -64,6 +64,10 @@ function doTestPrecedence() { | |
|
|
||
|
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. Style: unnecessary blank line. |
||
|
|
||
| // test that --enable-legacy-cipher-list takes precence over both envars | ||
| // note: in this release, there's only one legal value for the legacy | ||
| // switch so this test is largely a non-op. When multiple values | ||
| // are supported, this test should be changed to test that the | ||
| // command line switch actually does override | ||
| doTest(V1038Ciphers, | ||
| ['--enable-legacy-cipher-list=v0.10.38'], | ||
| { | ||
|
|
@@ -88,7 +92,7 @@ function doTestPrecedence() { | |
| // test the right-most command line option takes precedence | ||
| doTest('XYZ', | ||
| [ | ||
| '--cipher-list=XYZ', | ||
| '--cipher-list=ABC', | ||
| '--enable-legacy-cipher-list=v0.10.38', | ||
| '--cipher-list=XYZ' | ||
| ]); | ||
|
|
@@ -155,6 +159,10 @@ var script = ( | |
| var tls = require('tls'); | ||
| var orig_createCredentials = require('crypto').createCredentials; | ||
| require('crypto').createCredentials = function(options) { | ||
|
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. Instead of monkey patching Since it's explicitly excluded from the ciphers list after node v0.10.38, the test could make sure that the client connection can only be established when passing I believe it would make the implementation of this test much simpler.
Member
Author
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. That's not quite what this is testing. This tests to make sure the default
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. OK, thank you for the clarification. I would suggest also asserting that the monkey-patched version of Also, do we really need to spawn a server to run that test? If I understand correctly,
Member
Author
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. I spawn the server purposefully to do a full roundtrip to make sure that the connection still works without those defaults being set on the client side. 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. @jasnell OK, I understand now. Generally, testing a single characteristic/behavior in a test helps make it clearer and avoid false negatives. In this case, the test doesn't make a difference between the child process writing to stderr because the client could not connect or because the If I understand correctly, I think splitting that in two different simpler tests would make the tests more reliable and easier to understand. |
||
| // since node was started with the --enable-legacy-cipher-list | ||
| // switch equal to v0.10.38, the options.ciphers should be | ||
| // undefined. If it's not undefined, we have a problem and | ||
| // the test fails | ||
| if (options.ciphers !== undefined) { | ||
| console.error(options.ciphers); | ||
| process.exit(1); | ||
|
|
@@ -172,7 +180,7 @@ var script = ( | |
|
|
||
| var test_count = 0; | ||
|
|
||
| function doDefaultCipherTest(additional_args, env, failexpected) { | ||
| function doDefaultCipherTest(additional_args, env, opts) { | ||
| var options = {}; | ||
| if (env) options.env = env; | ||
| var out = '', err = ''; | ||
|
|
@@ -187,7 +195,7 @@ function doDefaultCipherTest(additional_args, env, failexpected) { | |
| out += data; | ||
| }). | ||
| on('end', function() { | ||
| if (failexpected && err === '') { | ||
| if (opts.failExpected && err === '') { | ||
|
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. Why is this test done in the listener for the |
||
| // if we get here, there's a problem because the default cipher | ||
| // list was not set when it should have been | ||
| assert.fail('options.cipher list was not set'); | ||
|
|
@@ -199,7 +207,7 @@ function doDefaultCipherTest(additional_args, env, failexpected) { | |
| }). | ||
| on('end', function() { | ||
| if (err !== '') { | ||
| if (!failexpected) { | ||
| if (!opts.failExpected) { | ||
| assert.fail(err.substr(0,err.length-1)); | ||
| } | ||
| } | ||
|
|
@@ -219,11 +227,10 @@ server.listen(common.PORT, function() { | |
| doDefaultCipherTest(['--enable-legacy-cipher-list=v0.10.38']); | ||
| doDefaultCipherTest([], {'NODE_LEGACY_CIPHER_LIST': 'v0.10.38'}); | ||
| // this variant checks to ensure that the default cipher list IS set | ||
| var test_uses_default_cipher_list = true; | ||
| doDefaultCipherTest([], {}, test_uses_default_cipher_list); | ||
| doDefaultCipherTest([], {}, {failedExpected:true}); | ||
| // test that setting the cipher list explicitly to the v0.10.38 | ||
| // string without using the legacy cipher switch causes the | ||
| // default ciphers to be set. | ||
| doDefaultCipherTest(['--cipher-list=' + V1038Ciphers], {}, | ||
| test_uses_default_cipher_list); | ||
| {failedExpected:true}); | ||
| }); | ||
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.
Maybe add a comment to clarify why there's an exception for v0.10.38 here? Otherwise I'm concerned it's going to be difficult to understand a few months/years from now.