mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
test: refactor test to use the fixtures module
PR-URL: https://github.com/nodejs/node/pull/15934 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
This commit is contained in:
1 parent
2bf182dc46
commit
96221c2471
1 file changed
+6
-12
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
if (!common.hasCrypto)
|
||||
common.skip('missing crypto');
|
||||
@@ -8,31 +9,24 @@ if (!common.hasCrypto)
|
||||
const assert = require('assert');
|
||||
const http2 = require('http2');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const tls = require('tls');
|
||||
|
||||
const ajs_data = fs.readFileSync(path.resolve(common.fixturesDir, 'a.js'),
|
||||
'utf8');
|
||||
const ajs_data = fixtures.readSync('a.js', 'utf8');
|
||||
|
||||
const {
|
||||
HTTP2_HEADER_PATH,
|
||||
HTTP2_HEADER_STATUS
|
||||
} = http2.constants;
|
||||
|
||||
function loadKey(keyname) {
|
||||
return fs.readFileSync(
|
||||
path.join(common.fixturesDir, 'keys', keyname), 'binary');
|
||||
}
|
||||
|
||||
const key = loadKey('agent8-key.pem');
|
||||
const cert = loadKey('agent8-cert.pem');
|
||||
const ca = loadKey('fake-startcom-root-cert.pem');
|
||||
const key = fixtures.readKey('agent8-key.pem', 'binary');
|
||||
const cert = fixtures.readKey('agent8-cert.pem', 'binary');
|
||||
const ca = fixtures.readKey('fake-startcom-root-cert.pem', 'binary');
|
||||
|
||||
const server = http2.createSecureServer({ key, cert });
|
||||
|
||||
server.on('stream', (stream, headers) => {
|
||||
const name = headers[HTTP2_HEADER_PATH].slice(1);
|
||||
const file = path.resolve(common.fixturesDir, name);
|
||||
const file = fixtures.path(name);
|
||||
fs.stat(file, (err, stat) => {
|
||||
if (err != null || stat.isDirectory()) {
|
||||
stream.respond({ [HTTP2_HEADER_STATUS]: 404 });
|
||||
|
||||
Reference in new issue
Block a user