Browse Source

test: increase coverage for http2.connect

Added checks for connecting using https and an unsupported protocol.

PR-URL: https://github.com/nodejs/node/pull/14832
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
canary-base
Michael Albert 7 years ago
committed by Anna Henningsen
parent
commit
aa24777c44
No known key found for this signature in database GPG Key ID: D8B9F5AEAE84E4CF
  1. 30
      test/parallel/test-http2-connect.js

30
test/parallel/test-http2-connect.js

@ -1,14 +1,14 @@
// Flags: --expose-http2
'use strict';
const { mustCall, hasCrypto, skip } = require('../common');
const { mustCall, hasCrypto, skip, expectsError } = require('../common');
if (!hasCrypto)
skip('missing crypto');
const { doesNotThrow } = require('assert');
const { doesNotThrow, throws } = require('assert');
const { createServer, connect } = require('http2');
const server = createServer();
server.listen(0, mustCall(() => {
{
const server = createServer();
server.listen(0, mustCall(() => {
const authority = `http://localhost:${server.address().port}`;
const options = {};
const listener = () => mustCall();
@ -28,4 +28,22 @@ server.listen(0, mustCall(() => {
}
}));
}
}));
}));
}
// check for https as protocol
{
const authority = 'https://localhost';
doesNotThrow(() => connect(authority));
}
// check for error for an invalid protocol (not http or https)
{
const authority = 'ssh://localhost';
throws(() => {
connect(authority);
}, expectsError({
code: 'ERR_HTTP2_UNSUPPORTED_PROTOCOL',
type: Error
}));
}

Loading…
Cancel
Save