Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTrivikram Kamat <trivikr.dev@gmail.com>2017-10-16 08:20:44 +0300
committerMyles Borins <mylesborins@google.com>2017-10-24 00:51:51 +0300
commit65c5d0e27ac147d5fff9842d41efbaed5c384b96 (patch)
treefc08b7046cd21879c094aa5ce72da4b6ed6d13dc /test
parent6ad5b90730392ee1acd2d2891ff412677c662c34 (diff)
test: consolidate http2 tests in one file
PR-URL: https://github.com/nodejs/node/pull/15624 Refs: https://github.com/nodejs/node/issues/14985 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-http2-server-destroy-before-additional.js40
-rw-r--r--test/parallel/test-http2-server-destroy-before-priority.js41
-rw-r--r--test/parallel/test-http2-server-destroy-before-push.js40
-rw-r--r--test/parallel/test-http2-server-destroy-before-respond.js40
-rw-r--r--test/parallel/test-http2-server-destroy-before-rst.js41
-rw-r--r--test/parallel/test-http2-server-destroy-before-shutdown.js31
-rw-r--r--test/parallel/test-http2-server-destroy-before-state.js37
-rw-r--r--test/parallel/test-http2-server-destroy-before-write.js40
-rw-r--r--test/parallel/test-http2-server-stream-session-destroy.js47
9 files changed, 47 insertions, 310 deletions
diff --git a/test/parallel/test-http2-server-destroy-before-additional.js b/test/parallel/test-http2-server-destroy-before-additional.js
deleted file mode 100644
index d3edd559d9e..00000000000
--- a/test/parallel/test-http2-server-destroy-before-additional.js
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-'use strict';
-
-const common = require('../common');
-if (!common.hasCrypto)
- common.skip('missing crypto');
-const assert = require('assert');
-const h2 = require('http2');
-
-const server = h2.createServer();
-
-// we use the lower-level API here
-server.on('stream', common.mustCall(onStream));
-
-function onStream(stream, headers, flags) {
- stream.session.destroy();
- assert.throws(() => stream.additionalHeaders({}),
- common.expectsError({
- code: 'ERR_HTTP2_INVALID_STREAM',
- message: /^The stream has been destroyed$/
- }));
-}
-
-server.listen(0);
-
-server.on('listening', common.mustCall(() => {
-
- const client = h2.connect(`http://localhost:${server.address().port}`);
-
- const req = client.request({ ':path': '/' });
-
- req.on('response', common.mustNotCall());
- req.resume();
- req.on('end', common.mustCall(() => {
- server.close();
- client.destroy();
- }));
- req.end();
-
-}));
diff --git a/test/parallel/test-http2-server-destroy-before-priority.js b/test/parallel/test-http2-server-destroy-before-priority.js
deleted file mode 100644
index c0d6e01135a..00000000000
--- a/test/parallel/test-http2-server-destroy-before-priority.js
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-'use strict';
-
-const common = require('../common');
-if (!common.hasCrypto)
- common.skip('missing crypto');
-const assert = require('assert');
-const http2 = require('http2');
-
-const server = http2.createServer();
-
-// Test that ERR_HTTP2_INVALID_STREAM is thrown when a stream is destroyed
-// before calling stream.priority
-server.on('stream', common.mustCall(onStream));
-
-function onStream(stream, headers, flags) {
- stream.session.destroy();
- assert.throws(() => stream.priority(),
- common.expectsError({
- code: 'ERR_HTTP2_INVALID_STREAM',
- message: /^The stream has been destroyed$/
- }));
-}
-
-server.listen(0);
-
-server.on('listening', common.mustCall(() => {
-
- const client = http2.connect(`http://localhost:${server.address().port}`);
-
- const req = client.request({ ':path': '/' });
-
- req.on('response', common.mustNotCall());
- req.resume();
- req.on('end', common.mustCall(() => {
- server.close();
- client.destroy();
- }));
- req.end();
-
-}));
diff --git a/test/parallel/test-http2-server-destroy-before-push.js b/test/parallel/test-http2-server-destroy-before-push.js
deleted file mode 100644
index 02e0fa01bd0..00000000000
--- a/test/parallel/test-http2-server-destroy-before-push.js
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-'use strict';
-
-const common = require('../common');
-if (!common.hasCrypto)
- common.skip('missing crypto');
-const assert = require('assert');
-const h2 = require('http2');
-
-const server = h2.createServer();
-
-// we use the lower-level API here
-server.on('stream', common.mustCall(onStream));
-
-function onStream(stream, headers, flags) {
- stream.session.destroy();
- assert.throws(() => stream.pushStream({}, common.mustNotCall()),
- common.expectsError({
- code: 'ERR_HTTP2_INVALID_STREAM',
- message: /^The stream has been destroyed$/
- }));
-}
-
-server.listen(0);
-
-server.on('listening', common.mustCall(() => {
-
- const client = h2.connect(`http://localhost:${server.address().port}`);
-
- const req = client.request({ ':path': '/' });
-
- req.on('response', common.mustNotCall());
- req.resume();
- req.on('end', common.mustCall(() => {
- server.close();
- client.destroy();
- }));
- req.end();
-
-}));
diff --git a/test/parallel/test-http2-server-destroy-before-respond.js b/test/parallel/test-http2-server-destroy-before-respond.js
deleted file mode 100644
index 584d98a30ee..00000000000
--- a/test/parallel/test-http2-server-destroy-before-respond.js
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-'use strict';
-
-const common = require('../common');
-if (!common.hasCrypto)
- common.skip('missing crypto');
-const assert = require('assert');
-const h2 = require('http2');
-
-const server = h2.createServer();
-
-// we use the lower-level API here
-server.on('stream', common.mustCall(onStream));
-
-function onStream(stream, headers, flags) {
- stream.session.destroy();
- assert.throws(() => stream.respond({}),
- common.expectsError({
- code: 'ERR_HTTP2_INVALID_STREAM',
- message: /^The stream has been destroyed$/
- }));
-}
-
-server.listen(0);
-
-server.on('listening', common.mustCall(() => {
-
- const client = h2.connect(`http://localhost:${server.address().port}`);
-
- const req = client.request({ ':path': '/' });
-
- req.on('response', common.mustNotCall());
- req.resume();
- req.on('end', common.mustCall(() => {
- server.close();
- client.destroy();
- }));
- req.end();
-
-}));
diff --git a/test/parallel/test-http2-server-destroy-before-rst.js b/test/parallel/test-http2-server-destroy-before-rst.js
deleted file mode 100644
index 7630ba38741..00000000000
--- a/test/parallel/test-http2-server-destroy-before-rst.js
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-'use strict';
-
-const common = require('../common');
-if (!common.hasCrypto)
- common.skip('missing crypto');
-const assert = require('assert');
-const http2 = require('http2');
-
-const server = http2.createServer();
-
-// Test that ERR_HTTP2_INVALID_STREAM is thrown when a stream is destroyed
-// before calling stream.rstStream
-server.on('stream', common.mustCall(onStream));
-
-function onStream(stream, headers, flags) {
- stream.session.destroy();
- assert.throws(() => stream.rstStream(),
- common.expectsError({
- code: 'ERR_HTTP2_INVALID_STREAM',
- message: /^The stream has been destroyed$/
- }));
-}
-
-server.listen(0);
-
-server.on('listening', common.mustCall(() => {
-
- const client = http2.connect(`http://localhost:${server.address().port}`);
-
- const req = client.request({ ':path': '/' });
-
- req.on('response', common.mustNotCall());
- req.resume();
- req.on('end', common.mustCall(() => {
- server.close();
- client.destroy();
- }));
- req.end();
-
-}));
diff --git a/test/parallel/test-http2-server-destroy-before-shutdown.js b/test/parallel/test-http2-server-destroy-before-shutdown.js
deleted file mode 100644
index 87bf2438c12..00000000000
--- a/test/parallel/test-http2-server-destroy-before-shutdown.js
+++ /dev/null
@@ -1,31 +0,0 @@
-// Flags: --expose-http2
-'use strict';
-
-const common = require('../common');
-if (!common.hasCrypto)
- common.skip('missing crypto');
-const http2 = require('http2');
-
-const server = http2.createServer();
-
-// Test that ERR_HTTP2_INVALID_SESSION is thrown when a stream is destroyed
-// before calling stream.session.shutdown
-server.on('stream', common.mustCall((stream) => {
- stream.session.destroy();
- common.expectsError(
- () => stream.session.shutdown(),
- {
- type: Error,
- code: 'ERR_HTTP2_INVALID_SESSION',
- message: 'The session has been destroyed'
- }
- );
-}));
-
-server.listen(0, common.mustCall(() => {
- const client = http2.connect(`http://localhost:${server.address().port}`);
-
- const req = client.request();
- req.resume();
- req.on('end', common.mustCall(() => server.close()));
-}));
diff --git a/test/parallel/test-http2-server-destroy-before-state.js b/test/parallel/test-http2-server-destroy-before-state.js
deleted file mode 100644
index f3392d5e074..00000000000
--- a/test/parallel/test-http2-server-destroy-before-state.js
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-'use strict';
-
-const common = require('../common');
-if (!common.hasCrypto)
- common.skip('missing crypto');
-const assert = require('assert');
-const http2 = require('http2');
-
-const server = http2.createServer();
-
-// Test that stream.state getter returns and empty object
-// if the stream session has been destroyed
-server.on('stream', common.mustCall(onStream));
-
-function onStream(stream, headers, flags) {
- stream.session.destroy();
- assert.deepStrictEqual(Object.create(null), stream.state);
-}
-
-server.listen(0);
-
-server.on('listening', common.mustCall(() => {
-
- const client = http2.connect(`http://localhost:${server.address().port}`);
-
- const req = client.request({ ':path': '/' });
-
- req.on('response', common.mustNotCall());
- req.resume();
- req.on('end', common.mustCall(() => {
- server.close();
- client.destroy();
- }));
- req.end();
-
-}));
diff --git a/test/parallel/test-http2-server-destroy-before-write.js b/test/parallel/test-http2-server-destroy-before-write.js
deleted file mode 100644
index f23f9d31c8f..00000000000
--- a/test/parallel/test-http2-server-destroy-before-write.js
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-'use strict';
-
-const common = require('../common');
-if (!common.hasCrypto)
- common.skip('missing crypto');
-const assert = require('assert');
-const h2 = require('http2');
-
-const server = h2.createServer();
-
-// we use the lower-level API here
-server.on('stream', common.mustCall(onStream));
-
-function onStream(stream, headers, flags) {
- stream.session.destroy();
- assert.throws(() => stream.write('data'),
- common.expectsError({
- code: 'ERR_HTTP2_INVALID_STREAM',
- type: Error
- }));
-}
-
-server.listen(0);
-
-server.on('listening', common.mustCall(() => {
-
- const client = h2.connect(`http://localhost:${server.address().port}`);
-
- const req = client.request({ ':path': '/' });
-
- req.on('response', common.mustNotCall());
- req.resume();
- req.on('end', common.mustCall(() => {
- server.close();
- client.destroy();
- }));
- req.end();
-
-}));
diff --git a/test/parallel/test-http2-server-stream-session-destroy.js b/test/parallel/test-http2-server-stream-session-destroy.js
new file mode 100644
index 00000000000..2426216580b
--- /dev/null
+++ b/test/parallel/test-http2-server-stream-session-destroy.js
@@ -0,0 +1,47 @@
+'use strict';
+
+const common = require('../common');
+if (!common.hasCrypto)
+ common.skip('missing crypto');
+const assert = require('assert');
+const h2 = require('http2');
+
+const server = h2.createServer();
+
+server.on(
+ 'stream',
+ common.mustCall((stream) => {
+ const errorObj = {
+ type: Error,
+ code: 'ERR_HTTP2_INVALID_STREAM',
+ message: 'The stream has been destroyed'
+ };
+ stream.session.destroy();
+
+ // Test that stream.state getter returns an empty object
+ // when the stream session has been destroyed
+ assert.deepStrictEqual(Object.create(null), stream.state);
+
+ // Test that ERR_HTTP2_INVALID_STREAM is thrown while calling
+ // stream operations after the stream session has been destroyed
+ common.expectsError(() => stream.additionalHeaders(), errorObj);
+ common.expectsError(() => stream.priority(), errorObj);
+ common.expectsError(
+ () => stream.pushStream({}, common.mustNotCall()),
+ errorObj
+ );
+ common.expectsError(() => stream.respond(), errorObj);
+ common.expectsError(() => stream.rstStream(), errorObj);
+ common.expectsError(() => stream.write('data'), errorObj);
+ })
+);
+
+server.listen(
+ 0,
+ common.mustCall(() => {
+ const client = h2.connect(`http://localhost:${server.address().port}`);
+ const req = client.request();
+ req.resume();
+ req.on('end', common.mustCall(() => server.close()));
+ })
+);