|
9 | 9 | } = require('../common');
|
10 | 10 | if (!hasCrypto)
|
11 | 11 | skip('missing crypto');
|
| 12 | +const fixtures = require('../common/fixtures'); |
12 | 13 | const assert = require('assert');
|
13 |
| -const { createServer, connect } = require('http2'); |
| 14 | +const { createServer, createSecureServer, connect } = require('http2'); |
14 | 15 | const { connect: netConnect } = require('net');
|
| 16 | +const { connect: tlsConnect } = require('tls'); |
15 | 17 |
|
16 | 18 | // Check for session connect callback and event
|
17 | 19 | {
|
@@ -70,6 +72,36 @@ const { connect: netConnect } = require('net');
|
70 | 72 | connect(authority).on('error', () => {});
|
71 | 73 | }
|
72 | 74 |
|
| 75 | +// Check for session connect callback on already connected TLS socket |
| 76 | +{ |
| 77 | + const serverOptions = { |
| 78 | + key: fixtures.readKey('agent1-key.pem'), |
| 79 | + cert: fixtures.readKey('agent1-cert.pem') |
| 80 | + }; |
| 81 | + const server = createSecureServer(serverOptions); |
| 82 | + server.listen(0, mustCall(() => { |
| 83 | + const { port } = server.address(); |
| 84 | + |
| 85 | + const onSocketConnect = () => { |
| 86 | + const authority = `https://localhost:${port}`; |
| 87 | + const createConnection = mustCall(() => socket); |
| 88 | + const options = { createConnection }; |
| 89 | + connect(authority, options, mustCall(onSessionConnect)); |
| 90 | + }; |
| 91 | + |
| 92 | + const onSessionConnect = (session) => { |
| 93 | + session.close(); |
| 94 | + server.close(); |
| 95 | + }; |
| 96 | + |
| 97 | + const clientOptions = { |
| 98 | + port, |
| 99 | + rejectUnauthorized: false |
| 100 | + }; |
| 101 | + const socket = tlsConnect(clientOptions, mustCall(onSocketConnect)); |
| 102 | + })); |
| 103 | +} |
| 104 | + |
73 | 105 | // Check for error for init settings error
|
74 | 106 | {
|
75 | 107 | createServer(function() {
|
|
0 commit comments