Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions test/parallel/test-http2-getpackedsettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ assert.doesNotThrow(() => http2.getPackedSettings({ enablePush: false }));
assert.deepStrictEqual(packed, check);
}

// check for not passing settings
{
const packed = http2.getPackedSettings();
assert.strictEqual(packed.length, 0);
}

{
const packed = Buffer.from([
0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0x00, 0x03, 0x00, 0x00,
Expand Down Expand Up @@ -118,6 +124,33 @@ assert.doesNotThrow(() => http2.getPackedSettings({ enablePush: false }));
assert.strictEqual(settings.enablePush, true);
}

//check for what happens if passing {validate: true} and no errors happen
{
const packed = Buffer.from([
0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0x00, 0x03, 0x00, 0x00,
0x00, 0xc8, 0x00, 0x05, 0x00, 0x00, 0x4e, 0x20, 0x00, 0x04,
0x00, 0x00, 0x00, 0x64, 0x00, 0x06, 0x00, 0x00, 0x00, 0x64,
0x00, 0x02, 0x00, 0x00, 0x00, 0x01]);

assert.doesNotThrow(() => {
http2.getUnpackedSettings(packed, { validate: true });
});
}

// check for maxFrameSize failing the max number
{
const packed = Buffer.from([0x00, 0x05, 0x01, 0x00, 0x00, 0x00]);

assert.throws(() => {
http2.getUnpackedSettings(packed, { validate: true });
}, common.expectsError({
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
type: RangeError,
message: 'Invalid value for setting "maxFrameSize": 16777216'
}));
}

// check for maxConcurrentStreams failing the max number
{
const packed = Buffer.from([0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xFF]);

Expand Down