test: http2 test coverage for assertValidPseudoHeader
PR-URL: https://github.com/nodejs/node/pull/15105 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
This commit is contained in:
parent
425ce52036
commit
2f9d9e5fe3
31
test/parallel/test-http2-util-assert-valid-pseudoheader.js
Normal file
31
test/parallel/test-http2-util-assert-valid-pseudoheader.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Flags: --expose-internals
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
|
||||||
|
// Tests the assertValidPseudoHeader function that is used within the
|
||||||
|
// mapToHeaders function. The assert function is not exported so we
|
||||||
|
// have to test it through mapToHeaders
|
||||||
|
|
||||||
|
const { mapToHeaders } = require('internal/http2/util');
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
function isNotError(val) {
|
||||||
|
assert(!(val instanceof Error));
|
||||||
|
}
|
||||||
|
|
||||||
|
function isError(val) {
|
||||||
|
common.expectsError({
|
||||||
|
code: 'ERR_HTTP2_INVALID_PSEUDOHEADER',
|
||||||
|
type: Error,
|
||||||
|
message: '":foo" is an invalid pseudoheader or is used incorrectly'
|
||||||
|
})(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
isNotError(mapToHeaders({ ':status': 'a' }));
|
||||||
|
isNotError(mapToHeaders({ ':path': 'a' }));
|
||||||
|
isNotError(mapToHeaders({ ':authority': 'a' }));
|
||||||
|
isNotError(mapToHeaders({ ':scheme': 'a' }));
|
||||||
|
isNotError(mapToHeaders({ ':method': 'a' }));
|
||||||
|
|
||||||
|
isError(mapToHeaders({ ':foo': 'a' }));
|
Loading…
x
Reference in New Issue
Block a user