mirror of
https://github.com/nodejs/node.git
synced 2025-04-29 06:19:07 +00:00

Some checks failed
Coverage Linux (without intl) / coverage-linux-without-intl (push) Waiting to run
Coverage Linux / coverage-linux (push) Waiting to run
Coverage Windows / coverage-windows (push) Waiting to run
Test and upload documentation to artifacts / build-docs (push) Waiting to run
Linters / lint-addon-docs (push) Waiting to run
Linters / lint-cpp (push) Waiting to run
Linters / format-cpp (push) Waiting to run
Linters / lint-js-and-md (push) Waiting to run
Linters / lint-py (push) Waiting to run
Linters / lint-yaml (push) Waiting to run
Linters / lint-sh (push) Waiting to run
Linters / lint-codeowners (push) Waiting to run
Linters / lint-pr-url (push) Waiting to run
Linters / lint-readme (push) Waiting to run
Notify on Push / Notify on Force Push on `main` (push) Waiting to run
Notify on Push / Notify on Push on `main` that lacks metadata (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
V8 patch update / v8-update (push) Has been cancelled
OpenSSL update / openssl-update (push) Has been cancelled
Timezone update / timezone_update (push) Has been cancelled
This commit updates test/parallel/test-set-http-max-http-headers.js to use node:test. This test already implemented a test runner, so it makes sense to use the existing public API. PR-URL: https://github.com/nodejs/node/pull/56439 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com>
82 lines
2.4 KiB
JavaScript
82 lines
2.4 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { spawn } = require('child_process');
|
|
const path = require('path');
|
|
const { suite, test } = require('node:test');
|
|
const testName = path.join(__dirname, 'test-http-max-http-headers.js');
|
|
|
|
test(function(_, cb) {
|
|
console.log('running subtest expecting failure');
|
|
|
|
// Validate that the test fails if the max header size is too small.
|
|
const args = ['--expose-internals',
|
|
'--max-http-header-size=1024',
|
|
testName];
|
|
const cp = spawn(process.execPath, args, { stdio: 'inherit' });
|
|
|
|
cp.on('close', common.mustCall((code, signal) => {
|
|
assert.strictEqual(code, 1);
|
|
assert.strictEqual(signal, null);
|
|
cb();
|
|
}));
|
|
});
|
|
|
|
test(function(_, cb) {
|
|
console.log('running subtest expecting success');
|
|
|
|
const env = Object.assign({}, process.env, {
|
|
NODE_DEBUG: 'http'
|
|
});
|
|
|
|
// Validate that the test now passes if the same limit is large enough.
|
|
const args = ['--expose-internals',
|
|
'--max-http-header-size=1024',
|
|
testName,
|
|
'1024'];
|
|
const cp = spawn(process.execPath, args, {
|
|
env,
|
|
stdio: 'inherit'
|
|
});
|
|
|
|
cp.on('close', common.mustCall((code, signal) => {
|
|
assert.strictEqual(code, 0);
|
|
assert.strictEqual(signal, null);
|
|
cb();
|
|
}));
|
|
});
|
|
|
|
const skip = process.config.variables.node_without_node_options;
|
|
suite('same checks using NODE_OPTIONS if it is supported', { skip }, () => {
|
|
const env = Object.assign({}, process.env, {
|
|
NODE_OPTIONS: '--max-http-header-size=1024'
|
|
});
|
|
|
|
test(function(_, cb) {
|
|
console.log('running subtest expecting failure');
|
|
|
|
// Validate that the test fails if the max header size is too small.
|
|
const args = ['--expose-internals', testName];
|
|
const cp = spawn(process.execPath, args, { env, stdio: 'inherit' });
|
|
|
|
cp.on('close', common.mustCall((code, signal) => {
|
|
assert.strictEqual(code, 1);
|
|
assert.strictEqual(signal, null);
|
|
cb();
|
|
}));
|
|
});
|
|
|
|
test(function(_, cb) {
|
|
// Validate that the test now passes if the same limit is large enough.
|
|
const args = ['--expose-internals', testName, '1024'];
|
|
const cp = spawn(process.execPath, args, { env, stdio: 'inherit' });
|
|
|
|
cp.on('close', common.mustCall((code, signal) => {
|
|
assert.strictEqual(code, 0);
|
|
assert.strictEqual(signal, null);
|
|
cb();
|
|
}));
|
|
});
|
|
});
|