Skip to content

Commit c0dba0f

Browse files
jasnellMylesBorins
authored andcommitted
test: http2 test coverage for assertValidPseudoHeader
PR-URL: #15105 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]>
1 parent 837c29c commit c0dba0f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Flags: --expose-internals
2+
'use strict';
3+
4+
const common = require('../common');
5+
6+
// Tests the assertValidPseudoHeader function that is used within the
7+
// mapToHeaders function. The assert function is not exported so we
8+
// have to test it through mapToHeaders
9+
10+
const { mapToHeaders } = require('internal/http2/util');
11+
const assert = require('assert');
12+
13+
function isNotError(val) {
14+
assert(!(val instanceof Error));
15+
}
16+
17+
function isError(val) {
18+
common.expectsError({
19+
code: 'ERR_HTTP2_INVALID_PSEUDOHEADER',
20+
type: Error,
21+
message: '":foo" is an invalid pseudoheader or is used incorrectly'
22+
})(val);
23+
}
24+
25+
isNotError(mapToHeaders({ ':status': 'a' }));
26+
isNotError(mapToHeaders({ ':path': 'a' }));
27+
isNotError(mapToHeaders({ ':authority': 'a' }));
28+
isNotError(mapToHeaders({ ':scheme': 'a' }));
29+
isNotError(mapToHeaders({ ':method': 'a' }));
30+
31+
isError(mapToHeaders({ ':foo': 'a' }));

0 commit comments

Comments
 (0)