|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | 3 | const common = require('../common'); |
| 4 | +const fixtures = require('../common/fixtures'); |
4 | 5 |
|
5 | 6 | if (!common.hasCrypto) |
6 | 7 | common.skip('missing crypto'); |
7 | 8 |
|
8 | 9 | const assert = require('assert'); |
9 | 10 | const http2 = require('http2'); |
10 | 11 | const fs = require('fs'); |
11 | | -const path = require('path'); |
12 | 12 | const tls = require('tls'); |
13 | 13 |
|
14 | | -const ajs_data = fs.readFileSync(path.resolve(common.fixturesDir, 'a.js'), |
15 | | - 'utf8'); |
| 14 | +const ajs_data = fixtures.readSync('a.js', 'utf8'); |
16 | 15 |
|
17 | 16 | const { |
18 | 17 | HTTP2_HEADER_PATH, |
19 | 18 | HTTP2_HEADER_STATUS |
20 | 19 | } = http2.constants; |
21 | 20 |
|
22 | | -function loadKey(keyname) { |
23 | | - return fs.readFileSync( |
24 | | - path.join(common.fixturesDir, 'keys', keyname), 'binary'); |
25 | | -} |
26 | | - |
27 | | -const key = loadKey('agent8-key.pem'); |
28 | | -const cert = loadKey('agent8-cert.pem'); |
29 | | -const ca = loadKey('fake-startcom-root-cert.pem'); |
| 21 | +const key = fixtures.readKey('agent8-key.pem', 'binary'); |
| 22 | +const cert = fixtures.readKey('agent8-cert.pem', 'binary'); |
| 23 | +const ca = fixtures.readKey('fake-startcom-root-cert.pem', 'binary'); |
30 | 24 |
|
31 | 25 | const server = http2.createSecureServer({ key, cert }); |
32 | 26 |
|
33 | 27 | server.on('stream', (stream, headers) => { |
34 | 28 | const name = headers[HTTP2_HEADER_PATH].slice(1); |
35 | | - const file = path.resolve(common.fixturesDir, name); |
| 29 | + const file = fixtures.path(name); |
36 | 30 | fs.stat(file, (err, stat) => { |
37 | 31 | if (err != null || stat.isDirectory()) { |
38 | 32 | stream.respond({ [HTTP2_HEADER_STATUS]: 404 }); |
|
0 commit comments