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

Function test

test/parallel/test-tls-psk-circuit.js:33–64  ·  view source on GitHub ↗
(secret, opts, error)

Source from the content-addressed store, hash-verified

31};
32
33function test(secret, opts, error) {
34 const cb = !error ?
35 common.mustCall((c) => { c.pipe(c); }) :
36 common.mustNotCall();
37 const server = tls.createServer(serverOptions, cb);
38 server.listen(0, common.mustCall(() => {
39 const options = {
40 port: server.address().port,
41 ciphers: CIPHERS,
42 checkServerIdentity: () => {},
43 pskCallback: common.mustCall(() => secret),
44 ...opts,
45 };
46
47 if (!error) {
48 const client = tls.connect(options, common.mustCall(() => {
49 client.end(TEST_DATA);
50
51 client.on('data', common.mustCall((data) => {
52 assert.strictEqual(data.toString(), TEST_DATA);
53 }));
54 client.on('close', common.mustCall(() => server.close()));
55 }));
56 } else {
57 const client = tls.connect(options, common.mustNotCall());
58 client.on('error', common.mustCall((err) => {
59 assert.strictEqual(err.code, error);
60 server.close();
61 }));
62 }
63 }));
64}
65
66test({ psk: USERS.UserA, identity: 'UserA' });
67test({ psk: USERS.UserA, identity: 'UserA' }, { maxVersion: 'TLSv1.2' });

Callers 1

Calls 7

listenMethod · 0.80
addressMethod · 0.65
connectMethod · 0.65
closeMethod · 0.65
endMethod · 0.45
onMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…