(secret, opts, error)
| 31 | }; |
| 32 | |
| 33 | function 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 | |
| 66 | test({ psk: USERS.UserA, identity: 'UserA' }); |
| 67 | test({ psk: USERS.UserA, identity: 'UserA' }, { maxVersion: 'TLSv1.2' }); |
no test coverage detected
searching dependent graphs…