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