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: do not assume tls handshake order #25508

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
test: do not assume tls handshake order
Do not assume that server handshake event happens before client, it is
not guaranteed.
sam-github committed Feb 5, 2019
commit 78565d79dabd975b3eb4e7fa599ad99d06f2f0a4
17 changes: 10 additions & 7 deletions test/parallel/test-tls-alpn-server-client.js
Original file line number Diff line number Diff line change
@@ -23,9 +23,10 @@ function runTest(clientsOptions, serverOptions, cb) {
serverOptions.key = loadPEM('agent2-key');
serverOptions.cert = loadPEM('agent2-cert');
const results = [];
let index = 0;
let clientIndex = 0;
let serverIndex = 0;
const server = tls.createServer(serverOptions, function(c) {
results[index].server = { ALPN: c.alpnProtocol };
results[serverIndex++].server = { ALPN: c.alpnProtocol };
});

server.listen(0, serverIP, function() {
@@ -38,16 +39,18 @@ function runTest(clientsOptions, serverOptions, cb) {
opt.host = serverIP;
opt.rejectUnauthorized = false;

results[index] = {};
results[clientIndex] = {};
const client = tls.connect(opt, function() {
results[index].client = { ALPN: client.alpnProtocol };
client.destroy();
results[clientIndex].client = { ALPN: client.alpnProtocol };
client.end();
if (options.length) {
index++;
clientIndex++;
connectClient(options);
} else {
server.close();
cb(results);
server.on('close', () => {
cb(results);
});
}
});
}