(url: string)
| 136 | } |
| 137 | |
| 138 | function expectRejected(url: string): Promise<void> { |
| 139 | return new Promise((resolve, reject) => { |
| 140 | const ws = new WebSocket(url); |
| 141 | const t = setTimeout( |
| 142 | () => done(new Error('connection was not rejected within timeout')), |
| 143 | 1500, |
| 144 | ); |
| 145 | const done = (err?: Error): void => { |
| 146 | clearTimeout(t); |
| 147 | ws.removeAllListeners(); |
| 148 | try { |
| 149 | ws.terminate(); |
| 150 | } catch { |
| 151 | // ignore |
| 152 | } |
| 153 | if (err === undefined) { |
| 154 | resolve(); |
| 155 | } else { |
| 156 | reject(err); |
| 157 | } |
| 158 | }; |
| 159 | ws.once('open', () => done(new Error('connection unexpectedly opened'))); |
| 160 | ws.once('error', () => done()); |
| 161 | ws.once('close', () => done()); |
| 162 | }); |
| 163 | } |
| 164 | |
| 165 | describe('production auth wiring (M5.1)', () => { |
| 166 | it.skipIf(process.platform === 'win32')('writes a 0600 token file at boot and keeps it on close (persistent)', async () => { |
no test coverage detected