MCPcopy Index your code
hub / github.com/nodejs/node / test

Function test

test/parallel/test-tls-socket-default-options.js:37–68  ·  view source on GitHub ↗
(client, callback)

Source from the content-addressed store, hash-verified

35 });
36
37function test(client, callback) {
38 callback = common.mustCall(callback);
39 connect({
40 server: {
41 key: keys.agent1.key,
42 cert: keys.agent1.cert,
43 },
44 }, common.mustCall(function(err, pair, cleanup) {
45 assert.strictEqual(err.code, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE');
46 let recv = '';
47 pair.server.server.once('secureConnection', common.mustCall((conn) => {
48 conn.on('data', (data) => recv += data);
49 conn.on('end', common.mustCall(() => {
50 // Server sees nothing wrong with connection, even though the client's
51 // authentication of the server cert failed.
52 assert.strictEqual(recv, 'hello');
53 cleanup();
54 }));
55 }));
56
57 // `new TLSSocket` doesn't support the 'secureConnect' event on client side,
58 // and doesn't error if authentication failed. Caller must explicitly check
59 // for failure.
60 (new tls.TLSSocket(null, client)).connect(pair.server.server.address().port)
61 .on('connect', common.mustCall(function() {
62 this.end('hello');
63 }))
64 .on('secure', common.mustCall(function() {
65 callback(this.ssl.verifyError());
66 }));
67 }));
68}

Calls 8

connectFunction · 0.70
cleanupFunction · 0.70
callbackFunction · 0.70
connectMethod · 0.65
addressMethod · 0.65
onceMethod · 0.45
onMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…