Skip to content

Commit 8ca7d56

Browse files
Trotttargos
authored andcommitted
test: fix pummel/test-tls-session-timeout
The test does not work with TLS 1.3 nor should it. Force TLS version 1.2. While at it, some refactoring: * refresh the tmp directory in case it doesn't exist! * add an assert.strictEqual() check on the client return `code` value which must be zero * use arrow functions for callbacks * add trailing commas for multiline arrays/objects Fixes: #26839 PR-URL: #26865 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 41bd7a6 commit 8ca7d56

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

test/pummel/test-tls-session-timeout.js

+14-11
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ if (!common.hasCrypto)
2929
common.skip('missing crypto');
3030

3131
const tmpdir = require('../common/tmpdir');
32+
tmpdir.refresh();
3233

3334
doTest();
3435

@@ -56,7 +57,8 @@ function doTest() {
5657
key: key,
5758
cert: cert,
5859
ca: [cert],
59-
sessionTimeout: SESSION_TIMEOUT
60+
sessionTimeout: SESSION_TIMEOUT,
61+
maxVersion: 'TLSv1.2',
6062
};
6163

6264
// We need to store a sample session ticket in the fixtures directory because
@@ -79,17 +81,17 @@ function doTest() {
7981
's_client',
8082
'-connect', `localhost:${common.PORT}`,
8183
'-sess_in', sessionFileName,
82-
'-sess_out', sessionFileName
84+
'-sess_out', sessionFileName,
8385
];
8486
const client = spawn(common.opensslCli, flags, {
8587
stdio: ['ignore', 'pipe', 'ignore']
8688
});
8789

8890
let clientOutput = '';
89-
client.stdout.on('data', function(data) {
91+
client.stdout.on('data', (data) => {
9092
clientOutput += data.toString();
9193
});
92-
client.on('exit', function(code) {
94+
client.on('exit', (code) => {
9395
let connectionType;
9496
const grepConnectionType = (line) => {
9597
const matches = line.match(/(New|Reused), /);
@@ -102,25 +104,26 @@ function doTest() {
102104
if (!lines.some(grepConnectionType)) {
103105
throw new Error('unexpected output from openssl client');
104106
}
107+
assert.strictEqual(code, 0);
105108
cb(connectionType);
106109
});
107110
}
108111

109-
const server = tls.createServer(options, function(cleartext) {
110-
cleartext.on('error', function(er) {
112+
const server = tls.createServer(options, (cleartext) => {
113+
cleartext.on('error', (er) => {
111114
if (er.code !== 'ECONNRESET')
112115
throw er;
113116
});
114117
cleartext.end();
115118
});
116119

117-
server.listen(common.PORT, function() {
118-
Client(function(connectionType) {
120+
server.listen(common.PORT, () => {
121+
Client((connectionType) => {
119122
assert.strictEqual(connectionType, 'New');
120-
Client(function(connectionType) {
123+
Client((connectionType) => {
121124
assert.strictEqual(connectionType, 'Reused');
122-
setTimeout(function() {
123-
Client(function(connectionType) {
125+
setTimeout(() => {
126+
Client((connectionType) => {
124127
assert.strictEqual(connectionType, 'New');
125128
server.close();
126129
});

0 commit comments

Comments
 (0)