|
2 | 2 |
|
3 | 3 | // Test: ALPN mismatch causes connection failure. |
4 | 4 | // The server offers 'quic-test' but the client requests 'nonexistent'. |
5 | | -// The handshake should fail. |
| 5 | +// The handshake should fail with a `no_application_protocol` alert. |
| 6 | +// |
| 7 | +// The QUIC transport error code for a CRYPTO_ERROR carrying a TLS alert is |
| 8 | +// 0x100 | <tls_alert>. For `no_application_protocol` (alert 120 / 0x78) this |
| 9 | +// is 0x178 == 376. ERR_QUIC_TRANSPORT_ERROR formats the wire code into its |
| 10 | +// message as a bigint, so we match `376n` to assert the specific alert was |
| 11 | +// sent rather than some other handshake failure. |
6 | 12 |
|
7 | 13 | import { hasQuic, skip, mustCall } from '../common/index.mjs'; |
8 | 14 | import assert from 'node:assert'; |
9 | 15 |
|
10 | | -const { rejects, strictEqual } = assert; |
| 16 | +const { rejects, strictEqual, match } = assert; |
11 | 17 |
|
12 | 18 | if (!hasQuic) { |
13 | 19 | skip('QUIC is not enabled'); |
14 | 20 | } |
15 | 21 |
|
16 | 22 | const { listen, connect } = await import('../common/quic.mjs'); |
17 | 23 |
|
| 24 | +const expected = { |
| 25 | + code: 'ERR_QUIC_TRANSPORT_ERROR', |
| 26 | + message: /\b376n\b/, |
| 27 | +}; |
| 28 | + |
18 | 29 | const onerror = mustCall((err) => { |
19 | 30 | strictEqual(err.code, 'ERR_QUIC_TRANSPORT_ERROR'); |
| 31 | + match(err.message, /\b376n\b/); |
20 | 32 | }, 2); |
21 | 33 | const transportParams = { maxIdleTimeout: 1 }; |
22 | 34 |
|
23 | 35 | const serverEndpoint = await listen(mustCall(async (serverSession) => { |
24 | | - await rejects(serverSession.opened, { |
25 | |