test: check for tls renegotiation errors
Check that the return value and callback error for tls.renegotiate() does not indicate a failure. Also, remove unnecessary line wrapping and indentation. PR-URL: https://github.com/nodejs/node/pull/25437 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
7f913293c1
commit
641b0135cf
@ -12,7 +12,7 @@ const tls = require('tls');
|
|||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fixtures.readKey('agent1-key.pem'),
|
key: fixtures.readKey('agent1-key.pem'),
|
||||||
cert: fixtures.readKey('agent1-cert.pem')
|
cert: fixtures.readKey('agent1-cert.pem'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = tls.Server(options, common.mustCall((socket) => {
|
const server = tls.Server(options, common.mustCall((socket) => {
|
||||||
@ -45,28 +45,26 @@ server.listen(0, common.mustCall(() => {
|
|||||||
rejectUnauthorized: false,
|
rejectUnauthorized: false,
|
||||||
port
|
port
|
||||||
};
|
};
|
||||||
const client =
|
const client = tls.connect(options, common.mustCall(() => {
|
||||||
tls.connect(options, common.mustCall(() => {
|
client.write('');
|
||||||
client.write('');
|
// Negotiation is still permitted for this first
|
||||||
// Negotiation is still permitted for this first
|
// attempt. This should succeed.
|
||||||
// attempt. This should succeed.
|
let ok = client.renegotiate(options, common.mustCall((err) => {
|
||||||
client.renegotiate(
|
assert.ifError(err);
|
||||||
{ rejectUnauthorized: false },
|
// Once renegotiation completes, we write some
|
||||||
common.mustCall(() => {
|
// data to the socket, which triggers the on
|
||||||
// Once renegotiation completes, we write some
|
// data event on the server. After that data
|
||||||
// data to the socket, which triggers the on
|
// is received, disableRenegotiation is called.
|
||||||
// data event on the server. After that data
|
client.write('data', common.mustCall(() => {
|
||||||
// is received, disableRenegotiation is called.
|
client.write('');
|
||||||
client.write('data', common.mustCall(() => {
|
// This second renegotiation attempt should fail
|
||||||
client.write('');
|
// and the callback should never be invoked. The
|
||||||
// This second renegotiation attempt should fail
|
// server will simply drop the connection after
|
||||||
// and the callback should never be invoked. The
|
// emitting the error.
|
||||||
// server will simply drop the connection after
|
ok = client.renegotiate(options, common.mustNotCall());
|
||||||
// emitting the error.
|
assert.strictEqual(ok, true);
|
||||||
client.renegotiate(
|
}));
|
||||||
{ rejectUnauthorized: false },
|
|
||||||
common.mustNotCall());
|
|
||||||
}));
|
|
||||||
}));
|
|
||||||
}));
|
}));
|
||||||
|
assert.strictEqual(ok, true);
|
||||||
|
}));
|
||||||
}));
|
}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user