◐ Shell
clean mode source ↗

test: show more information in test-http2-debug upon failure · nodejs/node@23474cb

11

'use strict';

2+23

const common = require('../common');

34

if (!common.hasCrypto)

45

common.skip('missing crypto');

56

const assert = require('assert');

6-

const child_process = require('child_process');

7+

const { spawnSyncAndAssert } = require('../common/child_process');

78

const path = require('path');

899-

process.env.NODE_DEBUG_NATIVE = 'http2';

10-

process.env.NODE_DEBUG = 'http2';

11-

const { stdout, stderr } = child_process.spawnSync(process.execPath, [

10+

spawnSyncAndAssert(process.execPath, [

1211

path.resolve(__dirname, 'test-http2-ping.js'),

13-

], { encoding: 'utf8' });

14-15-

assert(stderr.match(/Setting the NODE_DEBUG environment variable to 'http2' can expose sensitive data \(such as passwords, tokens and authentication headers\) in the resulting log\.\r?\n/),

16-

stderr);

17-

assert(stderr.match(/Http2Session client \(\d+\) handling data frame for stream \d+\r?\n/),

18-

stderr);

19-

assert(stderr.match(/HttpStream \d+ \(\d+\) \[Http2Session client \(\d+\)\] reading starting\r?\n/),

20-

stderr);

21-

assert(stderr.match(/HttpStream \d+ \(\d+\) \[Http2Session client \(\d+\)\] closed with code 0\r?\n/),

22-

stderr);

23-

assert(stderr.match(/HttpStream \d+ \(\d+\) \[Http2Session server \(\d+\)\] closed with code 0\r?\n/),

24-

stderr);

25-

assert(stderr.match(/HttpStream \d+ \(\d+\) \[Http2Session server \(\d+\)\] tearing down stream\r?\n/),

26-

stderr);

27-

assert.strictEqual(stdout.trim(), '');

12+

], {

13+

env: {

14+

...process.env,

15+

NODE_DEBUG: 'http2',

16+

NODE_DEBUG_NATIVE: 'http2',

17+

},

18+

}, {

19+

trim: true,

20+

stderr(output) {

21+

assert.match(output,

22+

/Setting the NODE_DEBUG environment variable to 'http2' can expose sensitive data/);

23+

assert.match(output, /\(such as passwords, tokens and authentication headers\) in the resulting log\.\r?\n/);

24+

assert.match(output, /Http2Session client \(\d+\) handling data frame for stream \d+\r?\n/);

25+

assert.match(output, /HttpStream \d+ \(\d+\) \[Http2Session client \(\d+\)\] reading starting\r?\n/);

26+

assert.match(output, /HttpStream \d+ \(\d+\) \[Http2Session client \(\d+\)\] closed with code 0\r?\n/);

27+

assert.match(output, /HttpStream \d+ \(\d+\) \[Http2Session server \(\d+\)\] closed with code 0\r?\n/);

28+

assert.match(output, /HttpStream \d+ \(\d+\) \[Http2Session server \(\d+\)\] tearing down stream\r?\n/);

29+

},

30+

stdout: ''

31+

});