From 1c4c68b58d8a4798d2f0d28d6582ec7cfcbb9292 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 12 Oct 2021 06:56:20 +0530 Subject: [PATCH 01/17] feat: add support for the `server` options --- lib/Server.js | 89 +++++++++---- lib/options.json | 341 ++++++++++++++++++++++++++--------------------- 2 files changed, 250 insertions(+), 180 deletions(-) diff --git a/lib/Server.js b/lib/Server.js index 4a0af3b3f1..ddaf88c7b8 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -155,7 +155,7 @@ class Server { if (typeof this.options.client.webSocketURL.protocol !== "undefined") { protocol = this.options.client.webSocketURL.protocol; } else { - protocol = this.options.https ? "wss:" : "ws:"; + protocol = this.options.server.type === "http" ? "ws:" : "wss:"; } searchParams.set("protocol", protocol); @@ -520,23 +520,58 @@ class Server { ? options.hot : true; - // if the user enables http2, we can safely enable https - if ((options.http2 && !options.https) || options.https === true) { - options.https = { - requestCert: false, - }; + // normalize the `server` option + const defaultServerType = "http"; + const defaultServerOptions = { requestCert: false }; + + switch (typeof options.server) { + case "string": + options.server = { + type: options.server, + }; + if (options.server.type !== "http") { + options.server.options = defaultServerOptions; + } + break; + case "object": + if (typeof options.https === "object") { + options.server.options = { + ...options.https, + ...options.server.options, + }; + } + break; + default: + options.server = {}; + if (options.http2) { + options.server = { + type: "spdy", + options: defaultServerOptions, + }; + } else if (options.https) { + options.server = { + type: "https", + options: + typeof options.https === "object" + ? options.https + : defaultServerOptions, + }; + } else { + options.server.type = defaultServerType; + } } - // https option - if (options.https) { + // server options + if (options.server.options) { + const { server } = options; // TODO remove the `cacert` option in favor `ca` in the next major release for (const property of ["cacert", "ca", "cert", "crl", "key", "pfx"]) { - if (typeof options.https[property] === "undefined") { + if (typeof server.options[property] === "undefined") { // eslint-disable-next-line no-continue continue; } - const value = options.https[property]; + const value = server.options[property]; const readFile = (item) => { if ( Buffer.isBuffer(item) || @@ -559,14 +594,14 @@ class Server { } }; - options.https[property] = Array.isArray(value) + server.options[property] = Array.isArray(value) ? value.map((item) => readFile(item)) : readFile(value); } let fakeCert; - if (!options.https.key || !options.https.cert) { + if (!server.options.key || !server.options.cert) { const certificateDir = Server.findCacheDir(); const certificatePath = path.join(certificateDir, "server.pem"); let certificateExists; @@ -681,20 +716,20 @@ class Server { this.logger.info(`SSL certificate: ${certificatePath}`); } - if (options.https.cacert) { - if (options.https.ca) { + if (server.options.cacert) { + if (options.server.options.ca) { this.logger.warn( - "Do not specify 'https.ca' and 'https.cacert' options together, the 'https.ca' option will be used." + "Do not specify 'ca' and 'cacert' options together, the 'ca' option will be used." ); } else { - options.https.ca = options.https.cacert; + server.options.ca = options.server.options.cacert; } - delete options.https.cacert; + delete server.options.cacert; } - options.https.key = options.https.key || fakeCert; - options.https.cert = options.https.cert || fakeCert; + server.options.key = server.options.key || fakeCert; + server.options.cert = server.options.cert || fakeCert; } if (typeof options.ipc === "boolean") { @@ -1559,12 +1594,12 @@ class Server { } createServer() { - if (this.options.https) { - if (this.options.http2) { + if (this.options.server) { + if (this.options.server.type === "spdy") { // TODO: we need to replace spdy with http2 which is an internal module this.server = require("spdy").createServer( { - ...this.options.https, + ...this.options.server.options, spdy: { protocols: ["h2", "http/1.1"], }, @@ -1574,7 +1609,7 @@ class Server { } else { const https = require("https"); - this.server = https.createServer(this.options.https, this.app); + this.server = https.createServer(this.options.server.options, this.app); } } else { const http = require("http"); @@ -1696,7 +1731,7 @@ class Server { bonjour.publish({ name: `Webpack Dev Server ${os.hostname()}:${this.options.port}`, port: this.options.port, - type: this.options.https ? "https" : "http", + type: this.options.server.type === "http" ? "http" : "https", subtypes: ["webpack"], ...this.options.bonjour, }); @@ -1747,7 +1782,7 @@ class Server { if (this.options.ipc) { this.logger.info(`Project is running at: "${this.server.address()}"`); } else { - const protocol = this.options.https ? "https" : "http"; + const protocol = this.options.server.type === "http" ? "http" : "https"; const { address, port } = this.server.address(); const prettyPrintURL = (newHostname) => url.format({ protocol, hostname: newHostname, port, pathname: "/" }); @@ -1866,7 +1901,9 @@ class Server { if (this.options.bonjour) { const bonjourProtocol = - this.options.bonjour.type || this.options.https ? "https" : "http"; + this.options.bonjour.type || this.options.server.type === "http" + ? "http" + : "https"; this.logger.info( `Broadcasting "${bonjourProtocol}" with subtype of "webpack" via ZeroConf DNS (Bonjour)` diff --git a/lib/options.json b/lib/options.json index 875e828e82..72028c7acd 100644 --- a/lib/options.json +++ b/lib/options.json @@ -216,174 +216,177 @@ "type": "boolean" }, { - "type": "object", - "additionalProperties": true, - "properties": { - "passphrase": { - "type": "string", - "description": "Passphrase for a pfx file." + "$ref": "#/definitions/HTTPSObject" + } + ], + "description": "Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP).", + "link": "https://webpack.js.org/configuration/dev-server/#devserverhttps" + }, + "HTTPSObject": { + "type": "object", + "additionalProperties": true, + "properties": { + "passphrase": { + "type": "string", + "description": "Passphrase for a pfx file." + }, + "requestCert": { + "type": "boolean", + "description": "Request for an SSL certificate." + }, + "ca": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] + } }, - "requestCert": { - "type": "boolean", - "description": "Request for an SSL certificate." + { + "type": "string" }, - "ca": { - "anyOf": [ - { - "type": "array", - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" - } - ] + { + "instanceof": "Buffer" + } + ], + "description": "Path to an SSL CA certificate or content of an SSL CA certificate." + }, + "cacert": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" } - }, - { - "type": "string" - }, - { - "instanceof": "Buffer" - } - ], - "description": "Path to an SSL CA certificate or content of an SSL CA certificate." + ] + } }, - "cacert": { - "anyOf": [ - { - "type": "array", - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" - } - ] - } - }, - { - "type": "string" - }, - { - "instanceof": "Buffer" - } - ], - "description": "Path to an SSL CA certificate or content of an SSL CA certificate." + { + "type": "string" }, - "cert": { - "anyOf": [ - { - "type": "array", - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" - } - ] + { + "instanceof": "Buffer" + } + ], + "description": "Path to an SSL CA certificate or content of an SSL CA certificate." + }, + "cert": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" } - }, - { - "type": "string" - }, - { - "instanceof": "Buffer" - } - ], - "description": "Path to an SSL certificate or content of an SSL certificate." + ] + } }, - "crl": { - "anyOf": [ - { - "type": "array", - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" - } - ] + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ], + "description": "Path to an SSL certificate or content of an SSL certificate." + }, + "crl": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" } - }, - { - "type": "string" - }, - { - "instanceof": "Buffer" - } - ], - "description": "Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists)." + ] + } }, - "key": { - "anyOf": [ - { - "type": "array", - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" - }, - { - "type": "object", - "additionalProperties": true - } - ] + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ], + "description": "Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists)." + }, + "key": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + }, + { + "type": "object", + "additionalProperties": true } - }, - { - "type": "string" - }, - { - "instanceof": "Buffer" - } - ], - "description": "Path to an SSL key or content of an SSL key." + ] + } }, - "pfx": { - "anyOf": [ - { - "type": "array", - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" - }, - { - "type": "object", - "additionalProperties": true - } - ] + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ], + "description": "Path to an SSL key or content of an SSL key." + }, + "pfx": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + }, + { + "type": "object", + "additionalProperties": true } - }, - { - "type": "string" - }, - { - "instanceof": "Buffer" - } - ], - "description": "Path to an SSL pfx file or content of an SSL pfx file." + ] + } + }, + { + "type": "string" + }, + { + "instanceof": "Buffer" } - } + ], + "description": "Path to an SSL pfx file or content of an SSL pfx file." } - ], - "description": "Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP).", - "link": "https://webpack.js.org/configuration/dev-server/#devserverhttps" + } }, "HeaderObject": { "type": "object", @@ -631,6 +634,33 @@ "description": "Allows to proxy requests, can be useful when you have a separate API backend development server and you want to send API requests on the same domain.", "link": "https://webpack.js.org/configuration/dev-server/#devserverproxy" }, + "Server": { + "anyOf": [ + { + "$ref": "#/definitions/ServerType" + }, + { + "$ref": "#/definitions/ServerObject" + } + ], + "link": "", + "description": "" + }, + "ServerType": { + "enum": ["http", "https", "spdy"] + }, + "ServerObject": { + "type": "object", + "properties": { + "type": { + "$ref": "#/definitions/ServerType" + }, + "options": { + "$ref": "#/definitions/HTTPSObject" + } + }, + "additionalProperties": false + }, "SetupExitSignals": { "type": "boolean", "description": "Allows to close dev server and exit the process on SIGINT and SIGTERM signals (enabled by default for CLI).", @@ -915,6 +945,9 @@ "proxy": { "$ref": "#/definitions/Proxy" }, + "server": { + "$ref": "#/definitions/Server" + }, "setupExitSignals": { "$ref": "#/definitions/SetupExitSignals" }, From c698cff164b1f9163bd89dde35cb9e646c24debd Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 12 Oct 2021 07:42:55 +0530 Subject: [PATCH 02/17] feat: cli options for `server` --- README.md | 24 ++ bin/cli-flags.js | 229 ++++++++++++++++++ lib/options.json | 4 +- .../__snapshots__/basic.test.js.snap.webpack4 | 17 ++ .../__snapshots__/basic.test.js.snap.webpack5 | 17 ++ 5 files changed, 289 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ebfa2e5c26..2baf9647d2 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,30 @@ Options: --open-target-reset Clear all items provided in 'open.target' configuration. Opens specified page in browser. --open-app-name-reset Clear all items provided in 'open.app.name' configuration. Open specified browser. --port Allows to specify a port to use. + --server Allows to set server and options (by default 'http'). + --server-type Allows to set server and options (by default 'http'). + --server-options-passphrase Passphrase for a pfx file. + --server-options-request-cert Request for an SSL certificate. + --no-server-options-request-cert Negative 'server-options-request-cert' option. + --server-options-ca Path to an SSL CA certificate or content of an SSL CA certificate. + --server-options-ca-reset Clear all items provided in 'server.options.ca' configuration. Path to an SSL CA certificate or content + of an SSL CA certificate. + --server-options-cacert Path to an SSL CA certificate or content of an SSL CA certificate. + --server-options-cacert-reset Clear all items provided in 'server.options.cacert' configuration. Path to an SSL CA certificate or + content of an SSL CA certificate. + --server-options-cert Path to an SSL certificate or content of an SSL certificate. + --server-options-cert-reset Clear all items provided in 'server.options.cert' configuration. Path to an SSL certificate or content + of an SSL certificate. + --server-options-crl Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate + Revocation Lists). + --server-options-crl-reset Clear all items provided in 'server.options.crl' configuration. Path to PEM formatted CRLs (Certificate + Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). + --server-options-key Path to an SSL key or content of an SSL key. + --server-options-key-reset Clear all items provided in 'server.options.key' configuration. Path to an SSL key or content of an SSL + key. + --server-options-pfx Path to an SSL pfx file or content of an SSL pfx file. + --server-options-pfx-reset Clear all items provided in 'server.options.pfx' configuration. Path to an SSL pfx file or content of + an SSL pfx file. --static [value...] Allows to configure options for serving static files from directory (by default 'public' directory). --no-static Negative 'static' option. --static-directory Directory for static contents. diff --git a/bin/cli-flags.js b/bin/cli-flags.js index bbef95350b..329f2098bc 100644 --- a/bin/cli-flags.js +++ b/bin/cli-flags.js @@ -852,6 +852,235 @@ module.exports = { simpleType: "string", multiple: false, }, + server: { + configs: [ + { + description: "Allows to set server and options (by default 'http').", + multiple: false, + path: "server", + type: "enum", + values: ["http", "https", "spdy"], + }, + ], + description: "Allows to set server and options (by default 'http').", + multiple: false, + simpleType: "string", + }, + "server-options-ca": { + configs: [ + { + description: + "Path to an SSL CA certificate or content of an SSL CA certificate.", + multiple: true, + path: "server.options.ca[]", + type: "string", + }, + ], + description: + "Path to an SSL CA certificate or content of an SSL CA certificate.", + multiple: true, + simpleType: "string", + }, + "server-options-ca-reset": { + configs: [ + { + description: + "Clear all items provided in 'server.options.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate.", + multiple: false, + path: "server.options.ca", + type: "reset", + }, + ], + description: + "Clear all items provided in 'server.options.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate.", + multiple: false, + simpleType: "boolean", + }, + "server-options-cacert": { + configs: [ + { + description: + "Path to an SSL CA certificate or content of an SSL CA certificate.", + multiple: true, + path: "server.options.cacert[]", + type: "string", + }, + ], + description: + "Path to an SSL CA certificate or content of an SSL CA certificate.", + multiple: true, + simpleType: "string", + }, + "server-options-cacert-reset": { + configs: [ + { + description: + "Clear all items provided in 'server.options.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate.", + multiple: false, + path: "server.options.cacert", + type: "reset", + }, + ], + description: + "Clear all items provided in 'server.options.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate.", + multiple: false, + simpleType: "boolean", + }, + "server-options-cert": { + configs: [ + { + description: + "Path to an SSL certificate or content of an SSL certificate.", + multiple: true, + path: "server.options.cert[]", + type: "string", + }, + ], + description: "Path to an SSL certificate or content of an SSL certificate.", + multiple: true, + simpleType: "string", + }, + "server-options-cert-reset": { + configs: [ + { + description: + "Clear all items provided in 'server.options.cert' configuration. Path to an SSL certificate or content of an SSL certificate.", + multiple: false, + path: "server.options.cert", + type: "reset", + }, + ], + description: + "Clear all items provided in 'server.options.cert' configuration. Path to an SSL certificate or content of an SSL certificate.", + multiple: false, + simpleType: "boolean", + }, + "server-options-crl": { + configs: [ + { + description: + "Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).", + multiple: true, + path: "server.options.crl[]", + type: "string", + }, + ], + description: + "Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).", + multiple: true, + simpleType: "string", + }, + "server-options-crl-reset": { + configs: [ + { + description: + "Clear all items provided in 'server.options.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).", + multiple: false, + path: "server.options.crl", + type: "reset", + }, + ], + description: + "Clear all items provided in 'server.options.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).", + multiple: false, + simpleType: "boolean", + }, + "server-options-key": { + configs: [ + { + description: "Path to an SSL key or content of an SSL key.", + multiple: true, + path: "server.options.key[]", + type: "string", + }, + ], + description: "Path to an SSL key or content of an SSL key.", + multiple: true, + simpleType: "string", + }, + "server-options-key-reset": { + configs: [ + { + description: + "Clear all items provided in 'server.options.key' configuration. Path to an SSL key or content of an SSL key.", + multiple: false, + path: "server.options.key", + type: "reset", + }, + ], + description: + "Clear all items provided in 'server.options.key' configuration. Path to an SSL key or content of an SSL key.", + multiple: false, + simpleType: "boolean", + }, + "server-options-passphrase": { + configs: [ + { + description: "Passphrase for a pfx file.", + multiple: false, + path: "server.options.passphrase", + type: "string", + }, + ], + description: "Passphrase for a pfx file.", + multiple: false, + simpleType: "string", + }, + "server-options-pfx": { + configs: [ + { + description: "Path to an SSL pfx file or content of an SSL pfx file.", + multiple: true, + path: "server.options.pfx[]", + type: "string", + }, + ], + description: "Path to an SSL pfx file or content of an SSL pfx file.", + multiple: true, + simpleType: "string", + }, + "server-options-pfx-reset": { + configs: [ + { + description: + "Clear all items provided in 'server.options.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file.", + multiple: false, + path: "server.options.pfx", + type: "reset", + }, + ], + description: + "Clear all items provided in 'server.options.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file.", + multiple: false, + simpleType: "boolean", + }, + "server-options-request-cert": { + configs: [ + { + description: "Request for an SSL certificate.", + multiple: false, + path: "server.options.requestCert", + type: "boolean", + }, + ], + description: "Request for an SSL certificate.", + multiple: false, + simpleType: "boolean", + }, + "server-type": { + configs: [ + { + description: "Allows to set server and options (by default 'http').", + multiple: false, + path: "server.type", + type: "enum", + values: ["http", "https", "spdy"], + }, + ], + description: "Allows to set server and options (by default 'http').", + multiple: false, + simpleType: "string", + }, static: { configs: [ { diff --git a/lib/options.json b/lib/options.json index 72028c7acd..04ea997210 100644 --- a/lib/options.json +++ b/lib/options.json @@ -643,8 +643,8 @@ "$ref": "#/definitions/ServerObject" } ], - "link": "", - "description": "" + "link": "https://webpack.js.org/configuration/dev-server/#devserverserver", + "description": "Allows to set server and options (by default 'http')." }, "ServerType": { "enum": ["http", "https", "spdy"] diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack4 b/test/cli/__snapshots__/basic.test.js.snap.webpack4 index e0df6aac4f..a921b0ec49 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack4 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack4 @@ -120,6 +120,23 @@ Options: --open-target-reset Clear all items provided in 'open.target' configuration. Opens specified page in browser. --open-app-name-reset Clear all items provided in 'open.app.name' configuration. Open specified browser. --port Allows to specify a port to use. + --server Allows to set server and options (by default 'http'). + --server-type Allows to set server and options (by default 'http'). + --server-options-passphrase Passphrase for a pfx file. + --server-options-request-cert Request for an SSL certificate. + --no-server-options-request-cert Negative 'server-options-request-cert' option. + --server-options-ca Path to an SSL CA certificate or content of an SSL CA certificate. + --server-options-ca-reset Clear all items provided in 'server.options.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. + --server-options-cacert Path to an SSL CA certificate or content of an SSL CA certificate. + --server-options-cacert-reset Clear all items provided in 'server.options.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. + --server-options-cert Path to an SSL certificate or content of an SSL certificate. + --server-options-cert-reset Clear all items provided in 'server.options.cert' configuration. Path to an SSL certificate or content of an SSL certificate. + --server-options-crl Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). + --server-options-crl-reset Clear all items provided in 'server.options.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). + --server-options-key Path to an SSL key or content of an SSL key. + --server-options-key-reset Clear all items provided in 'server.options.key' configuration. Path to an SSL key or content of an SSL key. + --server-options-pfx Path to an SSL pfx file or content of an SSL pfx file. + --server-options-pfx-reset Clear all items provided in 'server.options.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. --static [value...] Allows to configure options for serving static files from directory (by default 'public' directory). --no-static Negative 'static' option. --static-directory Directory for static contents. diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack5 b/test/cli/__snapshots__/basic.test.js.snap.webpack5 index bc996eea90..1a5705792a 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack5 @@ -119,6 +119,23 @@ Options: --open-target-reset Clear all items provided in 'open.target' configuration. Opens specified page in browser. --open-app-name-reset Clear all items provided in 'open.app.name' configuration. Open specified browser. --port Allows to specify a port to use. + --server Allows to set server and options (by default 'http'). + --server-type Allows to set server and options (by default 'http'). + --server-options-passphrase Passphrase for a pfx file. + --server-options-request-cert Request for an SSL certificate. + --no-server-options-request-cert Negative 'server-options-request-cert' option. + --server-options-ca Path to an SSL CA certificate or content of an SSL CA certificate. + --server-options-ca-reset Clear all items provided in 'server.options.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. + --server-options-cacert Path to an SSL CA certificate or content of an SSL CA certificate. + --server-options-cacert-reset Clear all items provided in 'server.options.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. + --server-options-cert Path to an SSL certificate or content of an SSL certificate. + --server-options-cert-reset Clear all items provided in 'server.options.cert' configuration. Path to an SSL certificate or content of an SSL certificate. + --server-options-crl Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). + --server-options-crl-reset Clear all items provided in 'server.options.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). + --server-options-key Path to an SSL key or content of an SSL key. + --server-options-key-reset Clear all items provided in 'server.options.key' configuration. Path to an SSL key or content of an SSL key. + --server-options-pfx Path to an SSL pfx file or content of an SSL pfx file. + --server-options-pfx-reset Clear all items provided in 'server.options.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. --static [value...] Allows to configure options for serving static files from directory (by default 'public' directory). --no-static Negative 'static' option. --static-directory Directory for static contents. From 9484260408b3ac8e54014ee7211b02a428e8e0e0 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 12 Oct 2021 07:58:58 +0530 Subject: [PATCH 03/17] test: add validation tests --- .../validate-options.test.js.snap.webpack4 | 118 ++++++++++++++++++ .../validate-options.test.js.snap.webpack5 | 118 ++++++++++++++++++ test/validate-options.test.js | 74 +++++++++++ 3 files changed, 310 insertions(+) diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack4 b/test/__snapshots__/validate-options.test.js.snap.webpack4 index 26874115f1..1dc4bab2de 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack4 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack4 @@ -608,6 +608,124 @@ exports[`options validate should throw an error on the "proxy" option with 'fals [object { … } | function, ...]" `; +exports[`options validate should throw an error on the "server" option with '{"type":"https","additional":"test"}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server has an unknown property 'additional'. These properties are valid: + object { type?, options? }" +`; + +exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"ca":true}}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + -> Allows to set server and options (by default 'http'). + -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver + Details: + * options.server.options.ca should be one of these: + [string | Buffer, ...] | string | Buffer + -> Path to an SSL CA certificate or content of an SSL CA certificate. + Details: + * options.server.options.ca should be an array: + [string | Buffer, ...] + * options.server.options.ca should be a string. + * options.server.options.ca should be an instance of Buffer." +`; + +exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"cert":true}}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + -> Allows to set server and options (by default 'http'). + -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver + Details: + * options.server.options.cert should be one of these: + [string | Buffer, ...] | string | Buffer + -> Path to an SSL certificate or content of an SSL certificate. + Details: + * options.server.options.cert should be an array: + [string | Buffer, ...] + * options.server.options.cert should be a string. + * options.server.options.cert should be an instance of Buffer." +`; + +exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"key":10}}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + -> Allows to set server and options (by default 'http'). + -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver + Details: + * options.server.options.key should be one of these: + [string | Buffer | object { … }, ...] | string | Buffer + -> Path to an SSL key or content of an SSL key. + Details: + * options.server.options.key should be an array: + [string | Buffer | object { … }, ...] + * options.server.options.key should be a string. + * options.server.options.key should be an instance of Buffer." +`; + +exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"passphrase":false}}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server.options.passphrase should be a string. + -> Passphrase for a pfx file." +`; + +exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"pfx":10}}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + -> Allows to set server and options (by default 'http'). + -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver + Details: + * options.server.options.pfx should be one of these: + [string | Buffer | object { … }, ...] | string | Buffer + -> Path to an SSL pfx file or content of an SSL pfx file. + Details: + * options.server.options.pfx should be an array: + [string | Buffer | object { … }, ...] + * options.server.options.pfx should be a string. + * options.server.options.pfx should be an instance of Buffer." +`; + +exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"requestCert":"false"}}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server.options.requestCert should be a boolean. + -> Request for an SSL certificate." +`; + +exports[`options validate should throw an error on the "server" option with '{"type":"invalid"}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server.type should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\"" +`; + +exports[`options validate should throw an error on the "server" option with 'http2' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + -> Allows to set server and options (by default 'http'). + -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver + Details: + * options.server should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\" + * options.server should be an object: + object { type?, options? }" +`; + +exports[`options validate should throw an error on the "server" option with 'invalid' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + -> Allows to set server and options (by default 'http'). + -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver + Details: + * options.server should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\" + * options.server should be an object: + object { type?, options? }" +`; + exports[`options validate should throw an error on the "static" option with '' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.static should be a non-empty string." diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack5 b/test/__snapshots__/validate-options.test.js.snap.webpack5 index 26874115f1..1dc4bab2de 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack5 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack5 @@ -608,6 +608,124 @@ exports[`options validate should throw an error on the "proxy" option with 'fals [object { … } | function, ...]" `; +exports[`options validate should throw an error on the "server" option with '{"type":"https","additional":"test"}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server has an unknown property 'additional'. These properties are valid: + object { type?, options? }" +`; + +exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"ca":true}}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + -> Allows to set server and options (by default 'http'). + -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver + Details: + * options.server.options.ca should be one of these: + [string | Buffer, ...] | string | Buffer + -> Path to an SSL CA certificate or content of an SSL CA certificate. + Details: + * options.server.options.ca should be an array: + [string | Buffer, ...] + * options.server.options.ca should be a string. + * options.server.options.ca should be an instance of Buffer." +`; + +exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"cert":true}}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + -> Allows to set server and options (by default 'http'). + -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver + Details: + * options.server.options.cert should be one of these: + [string | Buffer, ...] | string | Buffer + -> Path to an SSL certificate or content of an SSL certificate. + Details: + * options.server.options.cert should be an array: + [string | Buffer, ...] + * options.server.options.cert should be a string. + * options.server.options.cert should be an instance of Buffer." +`; + +exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"key":10}}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + -> Allows to set server and options (by default 'http'). + -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver + Details: + * options.server.options.key should be one of these: + [string | Buffer | object { … }, ...] | string | Buffer + -> Path to an SSL key or content of an SSL key. + Details: + * options.server.options.key should be an array: + [string | Buffer | object { … }, ...] + * options.server.options.key should be a string. + * options.server.options.key should be an instance of Buffer." +`; + +exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"passphrase":false}}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server.options.passphrase should be a string. + -> Passphrase for a pfx file." +`; + +exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"pfx":10}}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + -> Allows to set server and options (by default 'http'). + -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver + Details: + * options.server.options.pfx should be one of these: + [string | Buffer | object { … }, ...] | string | Buffer + -> Path to an SSL pfx file or content of an SSL pfx file. + Details: + * options.server.options.pfx should be an array: + [string | Buffer | object { … }, ...] + * options.server.options.pfx should be a string. + * options.server.options.pfx should be an instance of Buffer." +`; + +exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"requestCert":"false"}}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server.options.requestCert should be a boolean. + -> Request for an SSL certificate." +`; + +exports[`options validate should throw an error on the "server" option with '{"type":"invalid"}' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server.type should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\"" +`; + +exports[`options validate should throw an error on the "server" option with 'http2' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + -> Allows to set server and options (by default 'http'). + -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver + Details: + * options.server should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\" + * options.server should be an object: + object { type?, options? }" +`; + +exports[`options validate should throw an error on the "server" option with 'invalid' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.server should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + -> Allows to set server and options (by default 'http'). + -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver + Details: + * options.server should be one of these: + \\"http\\" | \\"https\\" | \\"spdy\\" + * options.server should be an object: + object { type?, options? }" +`; + exports[`options validate should throw an error on the "static" option with '' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.static should be a non-empty string." diff --git a/test/validate-options.test.js b/test/validate-options.test.js index bb319acef6..e7038948a4 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -388,6 +388,80 @@ const tests = { ], failure: [() => {}, false], }, + server: { + success: [ + "http", + "https", + "spdy", + { + type: "http", + }, + { + type: "https", + }, + { + type: "spdy", + }, + { + type: "https", + options: { + ca: path.join(httpsCertificateDirectory, "ca.pem"), + key: path.join(httpsCertificateDirectory, "server.key"), + pfx: path.join(httpsCertificateDirectory, "server.pfx"), + cert: path.join(httpsCertificateDirectory, "server.crt"), + requestCert: true, + passphrase: "webpack-dev-server", + }, + }, + ], + failure: [ + "http2", + "invalid", + { + type: "invalid", + }, + { + type: "https", + additional: "test", + }, + { + type: "https", + options: { + key: 10, + }, + }, + { + type: "https", + options: { + cert: true, + }, + }, + { + type: "https", + options: { + ca: true, + }, + }, + { + type: "https", + options: { + pfx: 10, + }, + }, + { + type: "https", + options: { + passphrase: false, + }, + }, + { + type: "https", + options: { + requestCert: "false", + }, + }, + ], + }, static: { success: [ "path", From ad332b6eb1579a79d99992aad622ff31de9bcea8 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 15 Oct 2021 16:27:13 +0530 Subject: [PATCH 04/17] refactor: code --- lib/Server.js | 63 +++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/lib/Server.js b/lib/Server.js index ddaf88c7b8..b4b2e31aa1 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -525,23 +525,7 @@ class Server { const defaultServerOptions = { requestCert: false }; switch (typeof options.server) { - case "string": - options.server = { - type: options.server, - }; - if (options.server.type !== "http") { - options.server.options = defaultServerOptions; - } - break; - case "object": - if (typeof options.https === "object") { - options.server.options = { - ...options.https, - ...options.server.options, - }; - } - break; - default: + case "undefined": options.server = {}; if (options.http2) { options.server = { @@ -559,6 +543,28 @@ class Server { } else { options.server.type = defaultServerType; } + break; + case "string": + options.server = { + type: options.server, + }; + if (options.server.type !== "http") { + options.server.options = defaultServerOptions; + } + break; + case "object": + if (typeof options.https === "object") { + options.server.options = { + ...options.https, + ...options.server.options, + }; + } + break; + default: + options.server = { + type: defaultServerType, + options: defaultServerOptions, + }; } // server options @@ -1594,9 +1600,14 @@ class Server { } createServer() { - if (this.options.server) { - if (this.options.server.type === "spdy") { - // TODO: we need to replace spdy with http2 which is an internal module + switch (this.options.server.type) { + case "https": + this.server = require("https").createServer( + this.options.server.options, + this.app + ); + break; + case "spdy": this.server = require("spdy").createServer( { ...this.options.server.options, @@ -1606,15 +1617,9 @@ class Server { }, this.app ); - } else { - const https = require("https"); - - this.server = https.createServer(this.options.server.options, this.app); - } - } else { - const http = require("http"); - - this.server = http.createServer(this.app); + break; + default: + this.server = require("http").createServer(this.app); } this.server.on("connection", (socket) => { From 126c113d76b35cef2ee4336faf0d79e380f1977d Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 15 Oct 2021 17:20:12 +0530 Subject: [PATCH 05/17] refactor: cli options --- README.md | 42 +- bin/cli-flags.js | 65 ++- lib/options.json | 479 ++++++++++++------ .../__snapshots__/basic.test.js.snap.webpack4 | 26 +- .../__snapshots__/basic.test.js.snap.webpack5 | 28 +- 5 files changed, 413 insertions(+), 227 deletions(-) diff --git a/README.md b/README.md index 2baf9647d2..af2eafba6d 100644 --- a/README.md +++ b/README.md @@ -121,21 +121,35 @@ Options: --no-http2 Does not serve over HTTP/2 using SPDY. --https Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). --no-https Disallows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). - --https-passphrase Passphrase for a pfx file. - --https-request-cert Request for an SSL certificate. - --no-https-request-cert Does not request for an SSL certificate. - --https-ca Path to an SSL CA certificate or content of an SSL CA certificate. - --https-ca-reset Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. - --https-cacert Path to an SSL CA certificate or content of an SSL CA certificate. - --https-cacert-reset Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. - --https-key Path to an SSL key or content of an SSL key. - --https-key-reset Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key. - --https-pfx Path to an SSL pfx file or content of an SSL pfx file. + --https-passphrase Passphrase for a pfx file. Deprecated, it will be removed in favor of the `server.options.passphrase` option. + --https-request-cert Request for an SSL certificate. Deprecated, it will be removed in favor of the `server.options.requestCert` + option. + --no-https-request-cert Negative 'https-request-cert' option. + --https-ca Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the + `server.options.ca` option. + --https-ca-reset Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA + certificate. Deprecated, it will be removed in favor of the `server.options.ca` option. + --https-cacert Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the + `server.options.cacert` option. + --https-cacert-reset Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA + certificate. Deprecated, it will be removed in favor of the `server.options.cacert` option. + --https-cert Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the + `server.options.cert` option. + --https-cert-reset Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL + certificate. Deprecated, it will be removed in favor of the `server.options.cert` option. + --https-crl Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate + Revocation Lists). Deprecated, it will be removed in favor of the `server.options.crl` option. + --https-crl-reset Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) + or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the + `server.options.crl` option. + --https-key Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the `server.options.key` + option. + --https-key-reset Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key. Deprecated, + it will be removed in favor of the `server.options.key` option. + --https-pfx Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the + `server.options.pfx` option. --https-pfx-reset Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. - --https-cert Path to an SSL certificate or content of an SSL certificate. - --https-cert-reset Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate. - --https-crl Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). - --https-crl-reset Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). + Deprecated, it will be removed in favor of the `server.options.pfx` option. --ipc [value] Listen to a unix socket. --live-reload Enables reload/refresh the page(s) when file changes are detected (enabled by default). --no-live-reload Disables reload/refresh the page(s) when file changes are detected (enabled by default) diff --git a/bin/cli-flags.js b/bin/cli-flags.js index 329f2098bc..9e71ca3bbd 100644 --- a/bin/cli-flags.js +++ b/bin/cli-flags.js @@ -455,11 +455,13 @@ module.exports = { { type: "string", multiple: false, - description: "Passphrase for a pfx file.", + description: + "Passphrase for a pfx file. Deprecated, it will be removed in favor of the `server.options.passphrase` option.", path: "https.passphrase", }, ], - description: "Passphrase for a pfx file.", + description: + "Passphrase for a pfx file. Deprecated, it will be removed in favor of the `server.options.passphrase` option.", simpleType: "string", multiple: false, }, @@ -468,11 +470,13 @@ module.exports = { { type: "boolean", multiple: false, - description: "Request for an SSL certificate.", + description: + "Request for an SSL certificate. Deprecated, it will be removed in favor of the `server.options.requestCert` option.", path: "https.requestCert", }, ], - description: "Request for an SSL certificate.", + description: + "Request for an SSL certificate. Deprecated, it will be removed in favor of the `server.options.requestCert` option.", negatedDescription: "Does not request for an SSL certificate.", simpleType: "boolean", multiple: false, @@ -483,12 +487,12 @@ module.exports = { type: "string", multiple: true, description: - "Path to an SSL CA certificate or content of an SSL CA certificate.", + "Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.ca` option.", path: "https.ca[]", }, ], description: - "Path to an SSL CA certificate or content of an SSL CA certificate.", + "Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.ca` option.", simpleType: "string", multiple: true, }, @@ -496,14 +500,14 @@ module.exports = { configs: [ { description: - "Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate.", + "Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.ca` option.", multiple: false, path: "https.ca", type: "reset", }, ], description: - "Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate.", + "Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.ca` option.", multiple: false, simpleType: "boolean", }, @@ -513,12 +517,12 @@ module.exports = { type: "string", multiple: true, description: - "Path to an SSL CA certificate or content of an SSL CA certificate.", + "Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.cacert` option.", path: "https.cacert[]", }, ], description: - "Path to an SSL CA certificate or content of an SSL CA certificate.", + "Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.cacert` option.", simpleType: "string", multiple: true, }, @@ -526,14 +530,14 @@ module.exports = { configs: [ { description: - "Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate.", + "Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.cacert` option.", multiple: false, path: "https.cacert", type: "reset", }, ], description: - "Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate.", + "Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.cacert` option.", multiple: false, simpleType: "boolean", }, @@ -542,11 +546,13 @@ module.exports = { { type: "string", multiple: true, - description: "Path to an SSL key or content of an SSL key.", + description: + "Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the `server.options.key` option.", path: "https.key[]", }, ], - description: "Path to an SSL key or content of an SSL key.", + description: + "Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the `server.options.key` option.", simpleType: "string", multiple: true, }, @@ -554,14 +560,14 @@ module.exports = { configs: [ { description: - "Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key.", + "Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the `server.options.key` option.", multiple: false, path: "https.key", type: "reset", }, ], description: - "Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key.", + "Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the `server.options.key` option.", multiple: false, simpleType: "boolean", }, @@ -570,11 +576,13 @@ module.exports = { { type: "string", multiple: true, - description: "Path to an SSL pfx file or content of an SSL pfx file.", + description: + "Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the `server.options.pfx` option.", path: "https.pfx[]", }, ], - description: "Path to an SSL pfx file or content of an SSL pfx file.", + description: + "Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the `server.options.pfx` option.", simpleType: "string", multiple: true, }, @@ -582,14 +590,14 @@ module.exports = { configs: [ { description: - "Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file.", + "Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the `server.options.pfx` option.", multiple: false, path: "https.pfx", type: "reset", }, ], description: - "Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file.", + "Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the `server.options.pfx` option.", multiple: false, simpleType: "boolean", }, @@ -599,11 +607,12 @@ module.exports = { type: "string", multiple: true, description: - "Path to an SSL certificate or content of an SSL certificate.", + "Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the `server.options.cert` option.", path: "https.cert[]", }, ], - description: "Path to an SSL certificate or content of an SSL certificate.", + description: + "Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the `server.options.cert` option.", simpleType: "string", multiple: true, }, @@ -611,14 +620,14 @@ module.exports = { configs: [ { description: - "Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate.", + "Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the `server.options.cert` option.", multiple: false, path: "https.cert", type: "reset", }, ], description: - "Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate.", + "Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the `server.options.cert` option.", multiple: false, simpleType: "boolean", }, @@ -626,14 +635,14 @@ module.exports = { configs: [ { description: - "Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).", + "Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the `server.options.crl` option.", multiple: true, path: "https.crl[]", type: "string", }, ], description: - "Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).", + "Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the `server.options.crl` option.", multiple: true, simpleType: "string", }, @@ -641,14 +650,14 @@ module.exports = { configs: [ { description: - "Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).", + "Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the `server.options.crl` option.", multiple: false, path: "https.crl", type: "reset", }, ], description: - "Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).", + "Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the `server.options.crl` option.", multiple: false, simpleType: "boolean", }, diff --git a/lib/options.json b/lib/options.json index 04ea997210..0947c09227 100644 --- a/lib/options.json +++ b/lib/options.json @@ -216,177 +216,174 @@ "type": "boolean" }, { - "$ref": "#/definitions/HTTPSObject" - } - ], - "description": "Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP).", - "link": "https://webpack.js.org/configuration/dev-server/#devserverhttps" - }, - "HTTPSObject": { - "type": "object", - "additionalProperties": true, - "properties": { - "passphrase": { - "type": "string", - "description": "Passphrase for a pfx file." - }, - "requestCert": { - "type": "boolean", - "description": "Request for an SSL certificate." - }, - "ca": { - "anyOf": [ - { - "type": "array", - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" - } - ] - } + "type": "object", + "additionalProperties": true, + "properties": { + "passphrase": { + "type": "string", + "description": "Passphrase for a pfx file. Deprecated, it will be removed in favor of the `server.options.passphrase` option." }, - { - "type": "string" + "requestCert": { + "type": "boolean", + "description": "Request for an SSL certificate. Deprecated, it will be removed in favor of the `server.options.requestCert` option." }, - { - "instanceof": "Buffer" - } - ], - "description": "Path to an SSL CA certificate or content of an SSL CA certificate." - }, - "cacert": { - "anyOf": [ - { - "type": "array", - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" + "ca": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] } - ] - } - }, - { - "type": "string" + }, + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ], + "description": "Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.ca` option." }, - { - "instanceof": "Buffer" - } - ], - "description": "Path to an SSL CA certificate or content of an SSL CA certificate." - }, - "cert": { - "anyOf": [ - { - "type": "array", - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" + "cacert": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] } - ] - } - }, - { - "type": "string" + }, + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ], + "description": "Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.cacert` option." }, - { - "instanceof": "Buffer" - } - ], - "description": "Path to an SSL certificate or content of an SSL certificate." - }, - "crl": { - "anyOf": [ - { - "type": "array", - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" + "cert": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] } - ] - } - }, - { - "type": "string" + }, + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ], + "description": "Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the `server.options.cert` option." }, - { - "instanceof": "Buffer" - } - ], - "description": "Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists)." - }, - "key": { - "anyOf": [ - { - "type": "array", - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" - }, - { - "type": "object", - "additionalProperties": true + "crl": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] } - ] - } - }, - { - "type": "string" + }, + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ], + "description": "Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the `server.options.crl` option." }, - { - "instanceof": "Buffer" - } - ], - "description": "Path to an SSL key or content of an SSL key." - }, - "pfx": { - "anyOf": [ - { - "type": "array", - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" - }, - { - "type": "object", - "additionalProperties": true + "key": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + }, + { + "type": "object", + "additionalProperties": true + } + ] } - ] - } - }, - { - "type": "string" + }, + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ], + "description": "Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the `server.options.key` option." }, - { - "instanceof": "Buffer" + "pfx": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + }, + { + "type": "object", + "additionalProperties": true + } + ] + } + }, + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ], + "description": "Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the `server.options.pfx` option." } - ], - "description": "Path to an SSL pfx file or content of an SSL pfx file." + } } - } + ], + "description": "Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP).", + "link": "https://webpack.js.org/configuration/dev-server/#devserverhttps" }, "HeaderObject": { "type": "object", @@ -656,11 +653,177 @@ "$ref": "#/definitions/ServerType" }, "options": { - "$ref": "#/definitions/HTTPSObject" + "$ref": "#/definitions/ServerOptions" } }, "additionalProperties": false }, + "ServerOptions": { + "type": "object", + "additionalProperties": true, + "properties": { + "passphrase": { + "type": "string", + "description": "Passphrase for a pfx file." + }, + "requestCert": { + "type": "boolean", + "description": "Request for an SSL certificate." + }, + "ca": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] + } + }, + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ], + "description": "Path to an SSL CA certificate or content of an SSL CA certificate." + }, + "cacert": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] + } + }, + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ], + "description": "Path to an SSL CA certificate or content of an SSL CA certificate." + }, + "cert": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] + } + }, + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ], + "description": "Path to an SSL certificate or content of an SSL certificate." + }, + "crl": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] + } + }, + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ], + "description": "Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists)." + }, + "key": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + }, + { + "type": "object", + "additionalProperties": true + } + ] + } + }, + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ], + "description": "Path to an SSL key or content of an SSL key." + }, + "pfx": { + "anyOf": [ + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + }, + { + "type": "object", + "additionalProperties": true + } + ] + } + }, + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ], + "description": "Path to an SSL pfx file or content of an SSL pfx file." + } + } + }, "SetupExitSignals": { "type": "boolean", "description": "Allows to close dev server and exit the process on SIGINT and SIGTERM signals (enabled by default for CLI).", diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack4 b/test/cli/__snapshots__/basic.test.js.snap.webpack4 index a921b0ec49..13eccd0d9a 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack4 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack4 @@ -92,20 +92,20 @@ Options: --https Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). --no-https Disallows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). --https-passphrase Passphrase for a pfx file. - --https-request-cert Request for an SSL certificate. + --https-request-cert Request for an SSL certificate. Deprecated, it will be removed in favor of the `server.options.requestCert` option. --no-https-request-cert Does not request for an SSL certificate. - --https-ca Path to an SSL CA certificate or content of an SSL CA certificate. - --https-ca-reset Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. - --https-cacert Path to an SSL CA certificate or content of an SSL CA certificate. - --https-cacert-reset Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. - --https-key Path to an SSL key or content of an SSL key. - --https-key-reset Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key. - --https-pfx Path to an SSL pfx file or content of an SSL pfx file. - --https-pfx-reset Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. - --https-cert Path to an SSL certificate or content of an SSL certificate. - --https-cert-reset Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate. - --https-crl Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). - --https-crl-reset Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). + --https-ca Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.ca` option. + --https-ca-reset Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.ca` option. + --https-cacert Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.cacert` option. + --https-cacert-reset Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.cacert` option. + --https-key Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the `server.options.key` option. + --https-key-reset Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the `server.options.key` option. + --https-pfx Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the `server.options.pfx` option. + --https-pfx-reset Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the `server.options.pfx` option. + --https-cert Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the `server.options.cert` option. + --https-cert-reset Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the `server.options.cert` option. + --https-crl Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the `server.options.crl` option. + --https-crl-reset Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the `server.options.crl` option. --ipc [value] Listen to a unix socket. --live-reload Enables reload/refresh the page(s) when file changes are detected (enabled by default). --no-live-reload Disables reload/refresh the page(s) when file changes are detected (enabled by default) diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack5 b/test/cli/__snapshots__/basic.test.js.snap.webpack5 index 1a5705792a..c3e5fd7b74 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack5 @@ -90,21 +90,21 @@ Options: --no-http2 Negative 'http2' option. --https Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). --no-https Negative 'https' option. - --https-passphrase Passphrase for a pfx file. - --https-request-cert Request for an SSL certificate. + --https-passphrase Passphrase for a pfx file. Deprecated, it will be removed in favor of the `server.options.passphrase` option. + --https-request-cert Request for an SSL certificate. Deprecated, it will be removed in favor of the `server.options.requestCert` option. --no-https-request-cert Negative 'https-request-cert' option. - --https-ca Path to an SSL CA certificate or content of an SSL CA certificate. - --https-ca-reset Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. - --https-cacert Path to an SSL CA certificate or content of an SSL CA certificate. - --https-cacert-reset Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. - --https-cert Path to an SSL certificate or content of an SSL certificate. - --https-cert-reset Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate. - --https-crl Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). - --https-crl-reset Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). - --https-key Path to an SSL key or content of an SSL key. - --https-key-reset Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key. - --https-pfx Path to an SSL pfx file or content of an SSL pfx file. - --https-pfx-reset Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. + --https-ca Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.ca` option. + --https-ca-reset Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.ca` option. + --https-cacert Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.cacert` option. + --https-cacert-reset Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.cacert` option. + --https-cert Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the `server.options.cert` option. + --https-cert-reset Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the `server.options.cert` option. + --https-crl Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the `server.options.crl` option. + --https-crl-reset Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the `server.options.crl` option. + --https-key Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the `server.options.key` option. + --https-key-reset Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the `server.options.key` option. + --https-pfx Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the `server.options.pfx` option. + --https-pfx-reset Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the `server.options.pfx` option. --ipc [value] Listen to a unix socket. --live-reload Enables reload/refresh the page(s) when file changes are detected (enabled by default). --no-live-reload Negative 'live-reload' option. From 68b676ee14c0858f3e2b888f6c345669806afe91 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 15 Oct 2021 17:20:53 +0530 Subject: [PATCH 06/17] test: udpate snapshots --- .../validate-options.test.js.snap.webpack4 | 12 ++++++------ .../validate-options.test.js.snap.webpack5 | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack4 b/test/__snapshots__/validate-options.test.js.snap.webpack4 index 1dc4bab2de..8670894205 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack4 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack4 @@ -371,7 +371,7 @@ exports[`options validate should throw an error on the "https" option with '{"ca Details: * options.https.cacert should be one of these: [string | Buffer, ...] | string | Buffer - -> Path to an SSL CA certificate or content of an SSL CA certificate. + -> Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the \`server.options.cacert\` option. Details: * options.https.cacert should be an array: [string | Buffer, ...] @@ -388,7 +388,7 @@ exports[`options validate should throw an error on the "https" option with '{"ce Details: * options.https.cert should be one of these: [string | Buffer, ...] | string | Buffer - -> Path to an SSL certificate or content of an SSL certificate. + -> Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the \`server.options.cert\` option. Details: * options.https.cert should be an array: [string | Buffer, ...] @@ -405,7 +405,7 @@ exports[`options validate should throw an error on the "https" option with '{"ke Details: * options.https.key should be one of these: [string | Buffer | object { … }, ...] | string | Buffer - -> Path to an SSL key or content of an SSL key. + -> Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the \`server.options.key\` option. Details: * options.https.key should be an array: [string | Buffer | object { … }, ...] @@ -416,7 +416,7 @@ exports[`options validate should throw an error on the "https" option with '{"ke exports[`options validate should throw an error on the "https" option with '{"passphrase":false}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.https.passphrase should be a string. - -> Passphrase for a pfx file." + -> Passphrase for a pfx file. Deprecated, it will be removed in favor of the \`server.options.passphrase\` option." `; exports[`options validate should throw an error on the "https" option with '{"pfx":10}' value 1`] = ` @@ -428,7 +428,7 @@ exports[`options validate should throw an error on the "https" option with '{"pf Details: * options.https.pfx should be one of these: [string | Buffer | object { … }, ...] | string | Buffer - -> Path to an SSL pfx file or content of an SSL pfx file. + -> Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the \`server.options.pfx\` option. Details: * options.https.pfx should be an array: [string | Buffer | object { … }, ...] @@ -439,7 +439,7 @@ exports[`options validate should throw an error on the "https" option with '{"pf exports[`options validate should throw an error on the "https" option with '{"requestCert":"test"}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.https.requestCert should be a boolean. - -> Request for an SSL certificate." + -> Request for an SSL certificate. Deprecated, it will be removed in favor of the \`server.options.requestCert\` option." `; exports[`options validate should throw an error on the "ipc" option with '{}' value 1`] = ` diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack5 b/test/__snapshots__/validate-options.test.js.snap.webpack5 index 1dc4bab2de..8670894205 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack5 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack5 @@ -371,7 +371,7 @@ exports[`options validate should throw an error on the "https" option with '{"ca Details: * options.https.cacert should be one of these: [string | Buffer, ...] | string | Buffer - -> Path to an SSL CA certificate or content of an SSL CA certificate. + -> Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the \`server.options.cacert\` option. Details: * options.https.cacert should be an array: [string | Buffer, ...] @@ -388,7 +388,7 @@ exports[`options validate should throw an error on the "https" option with '{"ce Details: * options.https.cert should be one of these: [string | Buffer, ...] | string | Buffer - -> Path to an SSL certificate or content of an SSL certificate. + -> Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the \`server.options.cert\` option. Details: * options.https.cert should be an array: [string | Buffer, ...] @@ -405,7 +405,7 @@ exports[`options validate should throw an error on the "https" option with '{"ke Details: * options.https.key should be one of these: [string | Buffer | object { … }, ...] | string | Buffer - -> Path to an SSL key or content of an SSL key. + -> Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the \`server.options.key\` option. Details: * options.https.key should be an array: [string | Buffer | object { … }, ...] @@ -416,7 +416,7 @@ exports[`options validate should throw an error on the "https" option with '{"ke exports[`options validate should throw an error on the "https" option with '{"passphrase":false}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.https.passphrase should be a string. - -> Passphrase for a pfx file." + -> Passphrase for a pfx file. Deprecated, it will be removed in favor of the \`server.options.passphrase\` option." `; exports[`options validate should throw an error on the "https" option with '{"pfx":10}' value 1`] = ` @@ -428,7 +428,7 @@ exports[`options validate should throw an error on the "https" option with '{"pf Details: * options.https.pfx should be one of these: [string | Buffer | object { … }, ...] | string | Buffer - -> Path to an SSL pfx file or content of an SSL pfx file. + -> Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the \`server.options.pfx\` option. Details: * options.https.pfx should be an array: [string | Buffer | object { … }, ...] @@ -439,7 +439,7 @@ exports[`options validate should throw an error on the "https" option with '{"pf exports[`options validate should throw an error on the "https" option with '{"requestCert":"test"}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.https.requestCert should be a boolean. - -> Request for an SSL certificate." + -> Request for an SSL certificate. Deprecated, it will be removed in favor of the \`server.options.requestCert\` option." `; exports[`options validate should throw an error on the "ipc" option with '{}' value 1`] = ` From b66e2617f728984dae930a975bffec92578b7f08 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 15 Oct 2021 17:46:04 +0530 Subject: [PATCH 07/17] test: fixes --- README.md | 1 - lib/options.json | 5 +- .../__snapshots__/basic.test.js.snap.webpack4 | 1 - .../__snapshots__/basic.test.js.snap.webpack5 | 1 - .../https-option.test.js.snap.webpack4 | 2 +- .../https-option.test.js.snap.webpack5 | 2 +- .../Server.test.js.snap.webpack4 | 147 ++++++++++++++++++ .../Server.test.js.snap.webpack5 | 147 ++++++++++++++++++ 8 files changed, 300 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index af2eafba6d..34cb922191 100644 --- a/README.md +++ b/README.md @@ -164,7 +164,6 @@ Options: --open-target-reset Clear all items provided in 'open.target' configuration. Opens specified page in browser. --open-app-name-reset Clear all items provided in 'open.app.name' configuration. Open specified browser. --port Allows to specify a port to use. - --server Allows to set server and options (by default 'http'). --server-type Allows to set server and options (by default 'http'). --server-options-passphrase Passphrase for a pfx file. --server-options-request-cert Request for an SSL certificate. diff --git a/lib/options.json b/lib/options.json index 0947c09227..e70fbe5f8e 100644 --- a/lib/options.json +++ b/lib/options.json @@ -634,7 +634,10 @@ "Server": { "anyOf": [ { - "$ref": "#/definitions/ServerType" + "enum": ["http", "https", "spdy"], + "cli": { + "exclude": true + } }, { "$ref": "#/definitions/ServerObject" diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack4 b/test/cli/__snapshots__/basic.test.js.snap.webpack4 index 13eccd0d9a..1daf09caaf 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack4 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack4 @@ -120,7 +120,6 @@ Options: --open-target-reset Clear all items provided in 'open.target' configuration. Opens specified page in browser. --open-app-name-reset Clear all items provided in 'open.app.name' configuration. Open specified browser. --port Allows to specify a port to use. - --server Allows to set server and options (by default 'http'). --server-type Allows to set server and options (by default 'http'). --server-options-passphrase Passphrase for a pfx file. --server-options-request-cert Request for an SSL certificate. diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack5 b/test/cli/__snapshots__/basic.test.js.snap.webpack5 index c3e5fd7b74..f94be94da6 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack5 @@ -119,7 +119,6 @@ Options: --open-target-reset Clear all items provided in 'open.target' configuration. Opens specified page in browser. --open-app-name-reset Clear all items provided in 'open.app.name' configuration. Open specified browser. --port Allows to specify a port to use. - --server Allows to set server and options (by default 'http'). --server-type Allows to set server and options (by default 'http'). --server-options-passphrase Passphrase for a pfx file. --server-options-request-cert Request for an SSL certificate. diff --git a/test/cli/__snapshots__/https-option.test.js.snap.webpack4 b/test/cli/__snapshots__/https-option.test.js.snap.webpack4 index c00c673304..e4e06f2fdb 100644 --- a/test/cli/__snapshots__/https-option.test.js.snap.webpack4 +++ b/test/cli/__snapshots__/https-option.test.js.snap.webpack4 @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`"https" CLI option should warn using "--https-cacert" and "--https-ca" together 1`] = ` -" [webpack-dev-server] Do not specify 'https.ca' and 'https.cacert' options together, the 'https.ca' option will be used. +" [webpack-dev-server] Do not specify 'ca' and 'cacert' options together, the 'ca' option will be used. [webpack-dev-server] Project is running at: [webpack-dev-server] Loopback: https://localhost:/ [webpack-dev-server] On Your Network (IPv4): https://:/ diff --git a/test/cli/__snapshots__/https-option.test.js.snap.webpack5 b/test/cli/__snapshots__/https-option.test.js.snap.webpack5 index c00c673304..e4e06f2fdb 100644 --- a/test/cli/__snapshots__/https-option.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/https-option.test.js.snap.webpack5 @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`"https" CLI option should warn using "--https-cacert" and "--https-ca" together 1`] = ` -" [webpack-dev-server] Do not specify 'https.ca' and 'https.cacert' options together, the 'https.ca' option will be used. +" [webpack-dev-server] Do not specify 'ca' and 'cacert' options together, the 'ca' option will be used. [webpack-dev-server] Project is running at: [webpack-dev-server] Loopback: https://localhost:/ [webpack-dev-server] On Your Network (IPv4): https://:/ diff --git a/test/server/__snapshots__/Server.test.js.snap.webpack4 b/test/server/__snapshots__/Server.test.js.snap.webpack4 index 2d257aa5ef..a3e872e20b 100644 --- a/test/server/__snapshots__/Server.test.js.snap.webpack4 +++ b/test/server/__snapshots__/Server.test.js.snap.webpack4 @@ -75,6 +75,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -118,6 +121,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -162,6 +168,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -208,6 +217,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -254,6 +266,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -299,6 +314,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -344,6 +362,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -388,6 +409,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -432,6 +456,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -476,6 +503,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -522,6 +552,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -568,6 +601,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -613,6 +649,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -656,6 +695,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -699,6 +741,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -742,6 +787,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -785,6 +833,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -828,6 +879,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -871,6 +925,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -914,6 +971,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -957,6 +1017,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1000,6 +1063,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1043,6 +1109,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1086,6 +1155,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1129,6 +1201,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1172,6 +1247,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1215,6 +1293,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1258,6 +1339,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1303,6 +1387,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1348,6 +1435,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1393,6 +1483,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1438,6 +1531,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1492,6 +1588,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1546,6 +1645,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1600,6 +1702,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1643,6 +1748,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": false, "watchFiles": Array [], @@ -1674,6 +1782,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1717,6 +1828,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1760,6 +1874,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1803,6 +1920,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1847,6 +1967,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1890,6 +2013,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1931,6 +2057,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1974,6 +2103,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -2019,6 +2151,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -2062,6 +2197,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -2108,6 +2246,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -2151,6 +2292,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -2194,6 +2338,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { diff --git a/test/server/__snapshots__/Server.test.js.snap.webpack5 b/test/server/__snapshots__/Server.test.js.snap.webpack5 index 2d257aa5ef..a3e872e20b 100644 --- a/test/server/__snapshots__/Server.test.js.snap.webpack5 +++ b/test/server/__snapshots__/Server.test.js.snap.webpack5 @@ -75,6 +75,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -118,6 +121,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -162,6 +168,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -208,6 +217,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -254,6 +266,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -299,6 +314,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -344,6 +362,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -388,6 +409,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -432,6 +456,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -476,6 +503,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -522,6 +552,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -568,6 +601,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -613,6 +649,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -656,6 +695,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -699,6 +741,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -742,6 +787,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -785,6 +833,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -828,6 +879,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -871,6 +925,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -914,6 +971,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -957,6 +1017,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1000,6 +1063,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1043,6 +1109,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1086,6 +1155,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1129,6 +1201,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1172,6 +1247,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1215,6 +1293,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1258,6 +1339,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1303,6 +1387,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1348,6 +1435,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1393,6 +1483,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1438,6 +1531,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1492,6 +1588,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1546,6 +1645,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1600,6 +1702,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1643,6 +1748,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": false, "watchFiles": Array [], @@ -1674,6 +1782,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1717,6 +1828,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1760,6 +1874,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1803,6 +1920,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1847,6 +1967,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1890,6 +2013,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1931,6 +2057,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -1974,6 +2103,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -2019,6 +2151,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -2062,6 +2197,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -2108,6 +2246,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -2151,6 +2292,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { @@ -2194,6 +2338,9 @@ Object { "magicHtml": true, "open": Array [], "port": "", + "server": Object { + "type": "http", + }, "setupExitSignals": true, "static": Array [ Object { From e7c38b3fb9e4d2ac39ceb032ac51ee5cbda9f5ea Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 16 Oct 2021 00:38:43 +0000 Subject: [PATCH 08/17] test: update snapshots --- bin/cli-flags.js | 14 ---------- .../__snapshots__/basic.test.js.snap.webpack5 | 28 +++++++++---------- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/bin/cli-flags.js b/bin/cli-flags.js index 9e71ca3bbd..da2c2bf227 100644 --- a/bin/cli-flags.js +++ b/bin/cli-flags.js @@ -861,20 +861,6 @@ module.exports = { simpleType: "string", multiple: false, }, - server: { - configs: [ - { - description: "Allows to set server and options (by default 'http').", - multiple: false, - path: "server", - type: "enum", - values: ["http", "https", "spdy"], - }, - ], - description: "Allows to set server and options (by default 'http').", - multiple: false, - simpleType: "string", - }, "server-options-ca": { configs: [ { diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack5 b/test/cli/__snapshots__/basic.test.js.snap.webpack5 index f94be94da6..db8a66fbee 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack5 @@ -90,21 +90,21 @@ Options: --no-http2 Negative 'http2' option. --https Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). --no-https Negative 'https' option. - --https-passphrase Passphrase for a pfx file. Deprecated, it will be removed in favor of the `server.options.passphrase` option. - --https-request-cert Request for an SSL certificate. Deprecated, it will be removed in favor of the `server.options.requestCert` option. + --https-passphrase Passphrase for a pfx file. Deprecated, it will be removed in favor of the \`server.options.passphrase\` option. + --https-request-cert Request for an SSL certificate. Deprecated, it will be removed in favor of the \`server.options.requestCert\` option. --no-https-request-cert Negative 'https-request-cert' option. - --https-ca Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.ca` option. - --https-ca-reset Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.ca` option. - --https-cacert Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.cacert` option. - --https-cacert-reset Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.cacert` option. - --https-cert Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the `server.options.cert` option. - --https-cert-reset Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the `server.options.cert` option. - --https-crl Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the `server.options.crl` option. - --https-crl-reset Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the `server.options.crl` option. - --https-key Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the `server.options.key` option. - --https-key-reset Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the `server.options.key` option. - --https-pfx Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the `server.options.pfx` option. - --https-pfx-reset Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the `server.options.pfx` option. + --https-ca Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the \`server.options.ca\` option. + --https-ca-reset Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the \`server.options.ca\` option. + --https-cacert Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the \`server.options.cacert\` option. + --https-cacert-reset Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the \`server.options.cacert\` option. + --https-cert Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the \`server.options.cert\` option. + --https-cert-reset Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the \`server.options.cert\` option. + --https-crl Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the \`server.options.crl\` option. + --https-crl-reset Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the \`server.options.crl\` option. + --https-key Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the \`server.options.key\` option. + --https-key-reset Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the \`server.options.key\` option. + --https-pfx Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the \`server.options.pfx\` option. + --https-pfx-reset Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the \`server.options.pfx\` option. --ipc [value] Listen to a unix socket. --live-reload Enables reload/refresh the page(s) when file changes are detected (enabled by default). --no-live-reload Negative 'live-reload' option. From 72e43111d6e670f9978e7d436406f75021a3f75c Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 16 Oct 2021 00:40:07 +0000 Subject: [PATCH 09/17] test: update snapshots --- .../__snapshots__/basic.test.js.snap.webpack4 | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack4 b/test/cli/__snapshots__/basic.test.js.snap.webpack4 index 1daf09caaf..447853a050 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack4 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack4 @@ -91,21 +91,21 @@ Options: --no-http2 Does not serve over HTTP/2 using SPDY. --https Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). --no-https Disallows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). - --https-passphrase Passphrase for a pfx file. - --https-request-cert Request for an SSL certificate. Deprecated, it will be removed in favor of the `server.options.requestCert` option. + --https-passphrase Passphrase for a pfx file. Deprecated, it will be removed in favor of the \`server.options.passphrase\` option. + --https-request-cert Request for an SSL certificate. Deprecated, it will be removed in favor of the \`server.options.requestCert\` option. --no-https-request-cert Does not request for an SSL certificate. - --https-ca Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.ca` option. - --https-ca-reset Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.ca` option. - --https-cacert Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.cacert` option. - --https-cacert-reset Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the `server.options.cacert` option. - --https-key Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the `server.options.key` option. - --https-key-reset Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the `server.options.key` option. - --https-pfx Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the `server.options.pfx` option. - --https-pfx-reset Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the `server.options.pfx` option. - --https-cert Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the `server.options.cert` option. - --https-cert-reset Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the `server.options.cert` option. - --https-crl Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the `server.options.crl` option. - --https-crl-reset Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the `server.options.crl` option. + --https-ca Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the \`server.options.ca\` option. + --https-ca-reset Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the \`server.options.ca\` option. + --https-cacert Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the \`server.options.cacert\` option. + --https-cacert-reset Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, it will be removed in favor of the \`server.options.cacert\` option. + --https-key Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the \`server.options.key\` option. + --https-key-reset Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key. Deprecated, it will be removed in favor of the \`server.options.key\` option. + --https-pfx Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the \`server.options.pfx\` option. + --https-pfx-reset Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. Deprecated, it will be removed in favor of the \`server.options.pfx\` option. + --https-cert Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the \`server.options.cert\` option. + --https-cert-reset Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate. Deprecated, it will be removed in favor of the \`server.options.cert\` option. + --https-crl Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the \`server.options.crl\` option. + --https-crl-reset Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, it will be removed in favor of the \`server.options.crl\` option. --ipc [value] Listen to a unix socket. --live-reload Enables reload/refresh the page(s) when file changes are detected (enabled by default). --no-live-reload Disables reload/refresh the page(s) when file changes are detected (enabled by default) @@ -120,10 +120,6 @@ Options: --open-target-reset Clear all items provided in 'open.target' configuration. Opens specified page in browser. --open-app-name-reset Clear all items provided in 'open.app.name' configuration. Open specified browser. --port Allows to specify a port to use. - --server-type Allows to set server and options (by default 'http'). - --server-options-passphrase Passphrase for a pfx file. - --server-options-request-cert Request for an SSL certificate. - --no-server-options-request-cert Negative 'server-options-request-cert' option. --server-options-ca Path to an SSL CA certificate or content of an SSL CA certificate. --server-options-ca-reset Clear all items provided in 'server.options.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. --server-options-cacert Path to an SSL CA certificate or content of an SSL CA certificate. @@ -134,8 +130,12 @@ Options: --server-options-crl-reset Clear all items provided in 'server.options.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). --server-options-key Path to an SSL key or content of an SSL key. --server-options-key-reset Clear all items provided in 'server.options.key' configuration. Path to an SSL key or content of an SSL key. + --server-options-passphrase Passphrase for a pfx file. --server-options-pfx Path to an SSL pfx file or content of an SSL pfx file. --server-options-pfx-reset Clear all items provided in 'server.options.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. + --server-options-request-cert Request for an SSL certificate. + --no-server-options-request-cert Negative 'server-options-request-cert' option. + --server-type Allows to set server and options (by default 'http'). --static [value...] Allows to configure options for serving static files from directory (by default 'public' directory). --no-static Negative 'static' option. --static-directory Directory for static contents. From 4703dce2bb430deafa52863f3486e2102b18c971 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 16 Oct 2021 08:52:33 +0530 Subject: [PATCH 10/17] test: add cli options test --- lib/Server.js | 9 + .../server-option.test.js.snap.webpack4 | 56 +++++ .../server-option.test.js.snap.webpack5 | 56 +++++ test/cli/server-option.test.js | 232 ++++++++++++++++++ 4 files changed, 353 insertions(+) create mode 100644 test/cli/__snapshots__/server-option.test.js.snap.webpack4 create mode 100644 test/cli/__snapshots__/server-option.test.js.snap.webpack5 create mode 100644 test/cli/server-option.test.js diff --git a/lib/Server.js b/lib/Server.js index b4b2e31aa1..5adf06c9c2 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -555,9 +555,15 @@ class Server { case "object": if (typeof options.https === "object") { options.server.options = { + ...defaultServerOptions, ...options.https, ...options.server.options, }; + } else { + options.server.options = { + ...defaultServerOptions, + ...options.server.options, + }; } break; default: @@ -738,6 +744,9 @@ class Server { server.options.cert = server.options.cert || fakeCert; } + console.log(options.server); + + process.exit(0); if (typeof options.ipc === "boolean") { const isWindows = process.platform === "win32"; const pipePrefix = isWindows ? "\\\\.\\pipe\\" : os.tmpdir(); diff --git a/test/cli/__snapshots__/server-option.test.js.snap.webpack4 b/test/cli/__snapshots__/server-option.test.js.snap.webpack4 new file mode 100644 index 0000000000..fcfc60a5a3 --- /dev/null +++ b/test/cli/__snapshots__/server-option.test.js.snap.webpack4 @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`"server" CLI options should warn using "--server-options-cacert" and "--server-options-ca" together 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Do not specify 'ca' and 'cacert' options together, the 'ca' option will be used." +`; + +exports[`"server" CLI options should work using "--no-server-options-request-cert" 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +`; + +exports[`"server" CLI options should work using "--server-options-key --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert --server-options-ca " 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ +" +`; + +exports[`"server" CLI options should work using "--server-options-key --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert --server-options-cacert " 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ +" +`; + +exports[`"server" CLI options should work using "--server-options-key --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert " 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ +" +`; + +exports[`"server" CLI options should work using "--server-options-key-reset --server-options-key --server-options-pfx-reset --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert-reset --server-options-cert --server-options-ca-reset --server-options-ca " 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ +" +`; + +exports[`"server" CLI options should work using "--server-options-request-cert" 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +`; + +exports[`"server" CLI options should work using "--server-type http" 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +`; + +exports[`"server" CLI options should work using "--server-type https" 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +`; + +exports[`"server" CLI options should work using "--server-type spdy" 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +`; diff --git a/test/cli/__snapshots__/server-option.test.js.snap.webpack5 b/test/cli/__snapshots__/server-option.test.js.snap.webpack5 new file mode 100644 index 0000000000..fcfc60a5a3 --- /dev/null +++ b/test/cli/__snapshots__/server-option.test.js.snap.webpack5 @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`"server" CLI options should warn using "--server-options-cacert" and "--server-options-ca" together 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Do not specify 'ca' and 'cacert' options together, the 'ca' option will be used." +`; + +exports[`"server" CLI options should work using "--no-server-options-request-cert" 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +`; + +exports[`"server" CLI options should work using "--server-options-key --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert --server-options-ca " 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ +" +`; + +exports[`"server" CLI options should work using "--server-options-key --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert --server-options-cacert " 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ +" +`; + +exports[`"server" CLI options should work using "--server-options-key --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert " 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ +" +`; + +exports[`"server" CLI options should work using "--server-options-key-reset --server-options-key --server-options-pfx-reset --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert-reset --server-options-cert --server-options-ca-reset --server-options-ca " 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ +" +`; + +exports[`"server" CLI options should work using "--server-options-request-cert" 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +`; + +exports[`"server" CLI options should work using "--server-type http" 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +`; + +exports[`"server" CLI options should work using "--server-type https" 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +`; + +exports[`"server" CLI options should work using "--server-type spdy" 1`] = ` +" [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +`; diff --git a/test/cli/server-option.test.js b/test/cli/server-option.test.js new file mode 100644 index 0000000000..6b34d0e0dd --- /dev/null +++ b/test/cli/server-option.test.js @@ -0,0 +1,232 @@ +"use strict"; + +const path = require("path"); +const del = require("del"); +const Server = require("../../lib/Server"); +const { testBin, normalizeStderr } = require("../helpers/test-bin"); +const port = require("../ports-map")["cli-https"]; + +const httpsCertificateDirectory = path.resolve( + __dirname, + "../fixtures/https-certificate" +); + +const defaultCertificateDir = Server.findCacheDir(); + +describe('"server" CLI options', () => { + beforeEach(async () => { + await del([defaultCertificateDir]); + }); + + it('should work using "--server-type http"', async () => { + const { exitCode, stderr } = await testBin([ + "--port", + port, + "--server-type", + "http", + ]); + + expect(exitCode).toEqual(0); + expect( + normalizeStderr(stderr, { ipv6: true, https: false }) + ).toMatchSnapshot(); + }); + + it('should work using "--server-type https"', async () => { + const { exitCode, stderr } = await testBin([ + "--port", + port, + "--server-type", + "https", + ]); + + expect(exitCode).toEqual(0); + expect( + normalizeStderr(stderr, { ipv6: true, https: true }) + ).toMatchSnapshot(); + }); + + it('should work using "--server-type spdy"', async () => { + const { exitCode, stderr } = await testBin([ + "--port", + port, + "--server-type", + "spdy", + ]); + + expect(exitCode).toEqual(0); + expect( + normalizeStderr(stderr, { ipv6: true, https: true }) + ).toMatchSnapshot(); + }); + + it('should work using "--server-options-key --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert --server-options-cacert "', async () => { + const pfxFile = path.join(httpsCertificateDirectory, "server.pfx"); + const key = path.join(httpsCertificateDirectory, "server.key"); + const cert = path.join(httpsCertificateDirectory, "server.crt"); + const cacert = path.join(httpsCertificateDirectory, "ca.pem"); + const passphrase = "webpack-dev-server"; + + const { exitCode, stderr } = await testBin([ + "--port", + port, + "--server-options-key", + key, + "--server-options-pfx", + pfxFile, + "--server-options-passphrase", + passphrase, + "--server-options-cert", + cert, + "--server-options-cacert", + cacert, + ]); + + expect(exitCode).toEqual(0); + expect( + normalizeStderr(stderr, { ipv6: true, https: true }) + ).toMatchSnapshot(); + }); + + it('should work using "--server-options-key --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert --server-options-ca "', async () => { + const pfxFile = path.join(httpsCertificateDirectory, "server.pfx"); + const key = path.join(httpsCertificateDirectory, "server.key"); + const cert = path.join(httpsCertificateDirectory, "server.crt"); + const ca = path.join(httpsCertificateDirectory, "ca.pem"); + const passphrase = "webpack-dev-server"; + + const { exitCode, stderr } = await testBin([ + "--port", + port, + "--server-options-key", + key, + "--server-options-pfx", + pfxFile, + "--server-options-passphrase", + passphrase, + "--server-options-cert", + cert, + "--server-options-ca", + ca, + ]); + + expect(exitCode).toEqual(0); + expect( + normalizeStderr(stderr, { ipv6: true, https: true }) + ).toMatchSnapshot(); + }); + + it('should work using "--server-options-key-reset --server-options-key --server-options-pfx-reset --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert-reset --server-options-cert --server-options-ca-reset --server-options-ca "', async () => { + const pfxFile = path.join(httpsCertificateDirectory, "server.pfx"); + const key = path.join(httpsCertificateDirectory, "server.key"); + const cert = path.join(httpsCertificateDirectory, "server.crt"); + const ca = path.join(httpsCertificateDirectory, "ca.pem"); + const passphrase = "webpack-dev-server"; + + const { exitCode, stderr } = await testBin([ + "--port", + port, + "--server-options-key-reset", + "--server-options-key", + key, + "--server-options-pfx-reset", + "--server-options-pfx", + pfxFile, + "--server-options-passphrase", + passphrase, + "--server-options-cert-reset", + "--server-options-cert", + cert, + "--server-options-ca-reset", + "--server-options-ca", + ca, + ]); + + expect(exitCode).toEqual(0); + expect( + normalizeStderr(stderr, { ipv6: true, https: true }) + ).toMatchSnapshot(); + }); + + it('should warn using "--server-options-cacert" and "--server-options-ca" together', async () => { + const pfxFile = path.join(httpsCertificateDirectory, "server.pfx"); + const key = path.join(httpsCertificateDirectory, "server.key"); + const cert = path.join(httpsCertificateDirectory, "server.crt"); + const cacert = path.join(httpsCertificateDirectory, "ca.pem"); + const passphrase = "webpack-dev-server"; + + const { exitCode, stderr } = await testBin([ + "--port", + port, + "--server-options-key", + key, + "--server-options-pfx", + pfxFile, + "--server-options-passphrase", + passphrase, + "--server-options-cert", + cert, + "--server-options-cacert", + cacert, + "--server-options-ca", + cacert, + ]); + + expect(exitCode).toEqual(0); + expect( + normalizeStderr(stderr, { ipv6: true, https: true }) + ).toMatchSnapshot(); + }); + + // For https://github.com/webpack/webpack-dev-server/issues/3306 + it('should work using "--server-options-key --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert "', async () => { + const pfxFile = path.join(httpsCertificateDirectory, "server.pfx"); + const key = path.join(httpsCertificateDirectory, "server.key"); + const cert = path.join(httpsCertificateDirectory, "server.crt"); + const passphrase = "webpack-dev-server"; + + const { exitCode, stderr } = await testBin([ + "--port", + port, + "--server-options-key", + key, + "--server-options-pfx", + pfxFile, + "--server-options-passphrase", + passphrase, + "--server-options-cert", + cert, + ]); + + expect(exitCode).toEqual(0); + expect( + normalizeStderr(stderr, { ipv6: true, https: true }) + ).toMatchSnapshot(); + }); + + it('should work using "--server-options-request-cert"', async () => { + const { exitCode, stderr } = await testBin([ + "--port", + port, + "--server-options-request-cert", + ]); + + expect(exitCode).toEqual(0); + expect( + normalizeStderr(stderr, { ipv6: true, https: true }) + ).toMatchSnapshot(); + }); + + it('should work using "--no-server-options-request-cert"', async () => { + const { exitCode, stderr } = await testBin([ + "--port", + port, + "--no-server-options-request-cert", + ]); + + expect(exitCode).toEqual(0); + expect( + normalizeStderr(stderr, { ipv6: true, https: true }) + ).toMatchSnapshot(); + }); +}); From 43ec0888996590b3791180c676ac020d23318127 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 16 Oct 2021 10:33:47 +0530 Subject: [PATCH 11/17] test: add e2e tests for server option --- lib/Server.js | 3 - test/cli/server-option.test.js | 2 +- .../server.test.js.snap.webpack4 | 628 +++++++ .../server.test.js.snap.webpack5 | 628 +++++++ test/e2e/server.test.js | 1477 +++++++++++++++++ test/ports-map.js | 2 + 6 files changed, 2736 insertions(+), 4 deletions(-) create mode 100644 test/e2e/__snapshots__/server.test.js.snap.webpack4 create mode 100644 test/e2e/__snapshots__/server.test.js.snap.webpack5 create mode 100644 test/e2e/server.test.js diff --git a/lib/Server.js b/lib/Server.js index 5adf06c9c2..408682e391 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -744,9 +744,6 @@ class Server { server.options.cert = server.options.cert || fakeCert; } - console.log(options.server); - - process.exit(0); if (typeof options.ipc === "boolean") { const isWindows = process.platform === "win32"; const pipePrefix = isWindows ? "\\\\.\\pipe\\" : os.tmpdir(); diff --git a/test/cli/server-option.test.js b/test/cli/server-option.test.js index 6b34d0e0dd..3119a21f5a 100644 --- a/test/cli/server-option.test.js +++ b/test/cli/server-option.test.js @@ -4,7 +4,7 @@ const path = require("path"); const del = require("del"); const Server = require("../../lib/Server"); const { testBin, normalizeStderr } = require("../helpers/test-bin"); -const port = require("../ports-map")["cli-https"]; +const port = require("../ports-map")["cli-server"]; const httpsCertificateDirectory = path.resolve( __dirname, diff --git a/test/e2e/__snapshots__/server.test.js.snap.webpack4 b/test/e2e/__snapshots__/server.test.js.snap.webpack4 new file mode 100644 index 0000000000..c025840a38 --- /dev/null +++ b/test/e2e/__snapshots__/server.test.js.snap.webpack4 @@ -0,0 +1,628 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`server option as an object and allow to pass more options should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object and allow to pass more options should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "", + "cert": "", + "key": "", + "minVersion": "TLSv1.1", + "passphrase": "webpack-dev-server", + "pfx": "", + "requestCert": false, +} +`; + +exports[`server option as an object and allow to pass more options should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object and allow to pass more options should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object and allow to pass more options should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": Array [ + "", + ], + "cert": Array [ + "", + ], + "key": Array [ + "", + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + "", + ], + "requestCert": false, +} +`; + +exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": Array [ + "", + ], + "cert": Array [ + "", + ], + "key": Array [ + "", + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + "", + ], + "requestCert": false, +} +`; + +exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": Array [ + "-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kv +C/hf5Ei1J6qruJs3Xqg86Nl4+ed4ynUajAkRRibhp0P1SG1tgPssIK6iC7g8heYu +Dy9WkFuMie0513zjSn6bMEAK5TegxYAWCbaCZX/Fw9bDniabL/zuOv4sf8J4EPhs +EENnH6sUE9HxPUgQmNt1Tbd0j1Cd5PXrSTLyfVPRh0m9QhXTUHuxsse8XSn9U2sw +duxJTWRINmhffYn+O7kbJGI77xYr8u58Rsf3HCMI8DTKZNvQLChvvtLJ9ckyu7Q+ +T8emgklStASm3V2UtnriaK/IQEhgSdxqVRib3QIDAQABAoIBAGqWKPE1QnT3T+3J +G+ITz9P0dDFbvWltlTZmeSJh/s2q+WZloUNtBxdmwbqT/1QecnkyGgyzVCjvSKsu +CgVjWNVAhysgtNtxRT4BVflffBXLVH2qsBjpsLRGU6EcMXuPGTiEp3YRHNuO6Aj8 +oP8fEsCGPc9DlJMGgxQRAKlrVF8TN/0j6Qk+YpS4MZ0YFQfBY+WdKu04Z8TVTplQ +tTkiGpBI+Oj85jF59aQiizglJgADkAZ6zmbrctm/G9jPxh7JLS2cKI0ECZgK5yAc +pk10E1YWhoCksjr9arxy6fS9TiX9P15vv06k+s7c4c5X7XDm3X0GWeSbqBMJb8q7 +BhZQNzECgYEA4kAtymDBvFYiZFq7+lzQBR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g1svd1KP2206/Bh3gfZbgTsQg4YogXgjf0Uzuvw18btgTtLVpVyeuqz +TU3eeF30cwKBgQCN6lvOmapsDEs+T3uhqx4AUH53qp63PmjOSUAnANJGmsq6ROZV +HmHAy6nn9Qpf85BRHCXhZWiMoIhvc3As/EINNtWxS6hC/q6jqp4SvcD50cVFBroY +/16iWGXZCX+37A+DSOfTWgSDPEFcKRx41UOpStHbITgVgEPieo/NWxlHmQKBgQDX +JOLs2RB6V0ilnpnjdPXzvncD9fHgmwvJap24BPeZX3HtXViqD76oZsu1mNCg9EW3 +zk3pnEyyoDlvSIreZerVq4kN3HWsCVP3Pqr0kz9g0CRtmy8RWr28hjHDfXD3xPUZ +iGnMEz7IOHOKv722/liFAprV1cNaLUmFbDNg3jmlaQKBgQDG5WwngPhOHmjTnSml +amfEz9a4yEhQqpqgVNW5wwoXOf6DbjL2m/maJh01giThj7inMcbpkZlIclxD0Eu6 +Lof+ctCeqSAJvaVPmd+nv8Yp26zsF1yM8ax9xXjrIvv9fSbycNveGTDCsNNTiYoW +QyvMqmN1kGy20SZbQDD/fLfqBQ== +-----END PRIVATE KEY----- +", + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + "", + ], + "requestCert": false, +} +`; + +exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "", + "cert": "", + "key": "", + "passphrase": "webpack-dev-server", + "pfx": "", + "requestCert": false, +} +`; + +exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "", + "cert": "", + "key": Array [ + Object { + "pem": "", + }, + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + Object { + "buf": "", + }, + ], + "requestCert": false, +} +`; + +exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "", + "cert": "", + "key": "", + "passphrase": "webpack-dev-server", + "pfx": "", + "requestCert": false, +} +`; + +exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDsk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Kv722/liFAprV1cNaLUmFbDNg3jmlaQKBgQDG5WwngPhOHmjTnSml +amfEz9a4yEhQqpqgVNW5wwoXOf6DbjL2m/maJh01giThj7inMcbpkZlIclxD0Eu6 +Lof+ctCeqSAJvaVPmd+nv8Yp26zsF1yM8ax9xXjrIvv9fSbycNveGTDCsNNTiYoW +QyvMqmN1kGy20SZbQDD/fLfqBQ== +-----END PRIVATE KEY----- +", + "passphrase": "webpack-dev-server", + "pfx": "", + "requestCert": false, +} +`; + +exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kv +C/hf5Ei1J6qruJs3Xqg86Nl4+ed4ynUajAkRRibhp0P1SG1tgPssIK6iC7g8heYu +Dy9WkFuMie0513zjSn6bMEAK5TegxYAWCbaCZX/Fw9bDniabL/zuOv4sf8J4EPhs +EENnH6sUE9HxPUgQmNt1Tbd0j1Cd5PXrSTLyfVPRh0m9QhXTUHuxsse8XSn9U2sw +duxJTWRINmhffYn+O7kbJGI77xYr8u58Rsf3HCMI8DTKZNvQLChvvtLJ9ckyu7Q+ +T8emgklStASm3V2UtnriaK/IQEhgSdxqVRib3QIDAQABAoIBAGqWKPE1QnT3T+3J +G+ITz9P0dDFbvWltlTZmeSJh/s2q+WZloUNtBxdmwbqT/1QecnkyGgyzVCjvSKsu +CgVjWNVAhysgtNtxRT4BVflffBXL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EoAjVEKrtirGWJ66YfQ9KSJ7Zttrd1Y1V1OLtq3z4YMH39wdQ8rOD+yR8mWV +6Tnsxma6yJXAH8uan8iVbxjIZKF1hnvNCxUoxYmWOmTLcEQMzmxvTzAiR+s6R6Uj +9LgGqppt30nM4wnOhOJU6UxqbwKBgQDdy03KidbPZuycJSy1C9AIt0jlrxDsYm+U +fZrB6mHEZcgoZS5GbLKinQCdGcgERa05BXvJmNbfZtT5a37YEnbjsTImIhDiBP5P +nW36/9a3Vg1svd1KP2206/Bh3gfZbgTsQg4YogXgjf0Uzuvw18btgTtLVpVyeuqz +TU3eeF30cwKBgQCN6lvOmapsDEs+T3uhqx4AUH53qp63PmjOSUAnANJGmsq6ROZV +HmHAy6nn9Qpf85BRHCXhZWiMoIhvc3As/EINNtWxS6hC/q6jqp4SvcD50cVFBroY +/16iWGXZCX+37A+DSOfTWgSDPEFcKRx41UOpStHbITgVgEPieo/NWxlHmQKBgQDX +JOLs2RB6V0ilnpnjdPXzvncD9fHgmwvJap24BPeZX3HtXViqD76oZsu1mNCg9EW3 +zk3pnEyyoDlvSIreZerVq4kN3HWsCVP3Pqr0kz9g0CRtmy8RWr28hjHDfXD3xPUZ +iGnMEz7IOHOKv722/liFAprV1cNaLUmFbDNg3jmlaQKBgQDG5WwngPhOHmjTnSml +amfEz9a4yEhQqpqgVNW5wwoXOf6DbjL2m/maJh01giThj7inMcbpkZlIclxD0Eu6 +Lof+ctCeqSAJvaVPmd+nv8Yp26zsF1yM8ax9xXjrIvv9fSbycNveGTDCsNNTiYoW +QyvMqmN1kGy20SZbQDD/fLfqBQ== +-----END PRIVATE KEY----- +", + }, + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + Object { + "buf": "", + }, + ], + "requestCert": false, +} +`; + +exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "", + "cert": "", + "key": "", + "passphrase": "webpack-dev-server", + "pfx": "", + "requestCert": false, +} +`; + +exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "", + "cert": "", + "key": "", + "passphrase": "webpack-dev-server", + "pfx": "", + "requestCert": false, +} +`; + +exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as string http should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as string http should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as string http should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as string http should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as string https should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as string https should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as string https should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as string https should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as string spdy should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as string spdy should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as string spdy should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as string spdy should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option server options should be prioritized over https options should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option server options should be prioritized over https options should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": Array [ + "", + ], + "cert": Array [ + "", + ], + "key": Array [ + "", + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + "", + ], + "requestCert": false, +} +`; + +exports[`server option server options should be prioritized over https options should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option server options should be prioritized over https options should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option server options should be prioritized over https options should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option should support the "requestCert" option should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option should support the "requestCert" option should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option should support the "requestCert" option should pass options to the 'https.createServer' method: https options 1`] = ` +Object { + "cert": "", + "key": "", + "passphrase": "webpack-dev-server", + "pfx": "", + "requestCert": true, +} +`; + +exports[`server option spdy server with options should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option spdy server with options should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": Array [ + "", + ], + "cert": Array [ + "", + ], + "key": Array [ + "", + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + "", + ], + "requestCert": false, + "spdy": Object { + "protocols": Array [ + "h2", + "http/1.1", + ], + }, +} +`; + +exports[`server option spdy server with options should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option spdy server with options should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option spdy server with options should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; diff --git a/test/e2e/__snapshots__/server.test.js.snap.webpack5 b/test/e2e/__snapshots__/server.test.js.snap.webpack5 new file mode 100644 index 0000000000..c025840a38 --- /dev/null +++ b/test/e2e/__snapshots__/server.test.js.snap.webpack5 @@ -0,0 +1,628 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`server option as an object and allow to pass more options should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object and allow to pass more options should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "", + "cert": "", + "key": "", + "minVersion": "TLSv1.1", + "passphrase": "webpack-dev-server", + "pfx": "", + "requestCert": false, +} +`; + +exports[`server option as an object and allow to pass more options should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object and allow to pass more options should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object and allow to pass more options should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": Array [ + "", + ], + "cert": Array [ + "", + ], + "key": Array [ + "", + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + "", + ], + "requestCert": false, +} +`; + +exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": Array [ + "", + ], + "cert": Array [ + "", + ], + "key": Array [ + "", + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + "", + ], + "requestCert": false, +} +`; + +exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": Array [ + "-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kv +C/hf5Ei1J6qruJs3Xqg86Nl4+ed4ynUajAkRRibhp0P1SG1tgPssIK6iC7g8heYu +Dy9WkFuMie0513zjSn6bMEAK5TegxYAWCbaCZX/Fw9bDniabL/zuOv4sf8J4EPhs +EENnH6sUE9HxPUgQmNt1Tbd0j1Cd5PXrSTLyfVPRh0m9QhXTUHuxsse8XSn9U2sw +duxJTWRINmhffYn+O7kbJGI77xYr8u58Rsf3HCMI8DTKZNvQLChvvtLJ9ckyu7Q+ +T8emgklStASm3V2UtnriaK/IQEhgSdxqVRib3QIDAQABAoIBAGqWKPE1QnT3T+3J +G+ITz9P0dDFbvWltlTZmeSJh/s2q+WZloUNtBxdmwbqT/1QecnkyGgyzVCjvSKsu +CgVjWNVAhysgtNtxRT4BVflffBXLVH2qsBjpsLRGU6EcMXuPGTiEp3YRHNuO6Aj8 +oP8fEsCGPc9DlJMGgxQRAKlrVF8TN/0j6Qk+YpS4MZ0YFQfBY+WdKu04Z8TVTplQ +tTkiGpBI+Oj85jF59aQiizglJgADkAZ6zmbrctm/G9jPxh7JLS2cKI0ECZgK5yAc +pk10E1YWhoCksjr9arxy6fS9TiX9P15vv06k+s7c4c5X7XDm3X0GWeSbqBMJb8q7 +BhZQ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a37YEnbjsTImIhDiBP5P +nW36/9a3Vg1svd1KP2206/Bh3gfZbgTsQg4YogXgjf0Uzuvw18btgTtLVpVyeuqz +TU3eeF30cwKBgQCN6lvOmapsDEs+T3uhqx4AUH53qp63PmjOSUAnANJGmsq6ROZV +HmHAy6nn9Qpf85BRHCXhZWiMoIhvc3As/EINNtWxS6hC/q6jqp4SvcD50cVFBroY +/16iWGXZCX+37A+DSOfTWgSDPEFcKRx41UOpStHbITgVgEPieo/NWxlHmQKBgQDX +JOLs2RB6V0ilnpnjdPXzvncD9fHgmwvJap24BPeZX3HtXViqD76oZsu1mNCg9EW3 +zk3pnEyyoDlvSIreZerVq4kN3HWsCVP3Pqr0kz9g0CRtmy8RWr28hjHDfXD3xPUZ +iGnMEz7IOHOKv722/liFAprV1cNaLUmFbDNg3jmlaQKBgQDG5WwngPhOHmjTnSml +amfEz9a4yEhQqpqgVNW5wwoXOf6DbjL2m/maJh01giThj7inMcbpkZlIclxD0Eu6 +Lof+ctCeqSAJvaVPmd+nv8Yp26zsF1yM8ax9xXjrIvv9fSbycNveGTDCsNNTiYoW +QyvMqmN1kGy20SZbQDD/fLfqBQ== +-----END PRIVATE KEY----- +", + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + "", + ], + "requestCert": false, +} +`; + +exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "", + "cert": "", + "key": "", + "passphrase": "webpack-dev-server", + "pfx": "", + "requestCert": false, +} +`; + +exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "", + "cert": "", + "key": Array [ + Object { + "pem": "", + }, + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + Object { + "buf": "", + }, + ], + "requestCert": false, +} +`; + +exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "", + "cert": "", + "key": "", + "passphrase": "webpack-dev-server", + "pfx": "", + "requestCert": false, +} +`; + +exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEAxAUVL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Wr28hjHDfXD3xPUZ +iGnMEz7IOHOKv722/liFAprV1cNaLUmFbDNg3jmlaQKBgQDG5WwngPhOHmjTnSml +amfEz9a4yEhQqpqgVNW5wwoXOf6DbjL2m/maJh01giThj7inMcbpkZlIclxD0Eu6 +Lof+ctCeqSAJvaVPmd+nv8Yp26zsF1yM8ax9xXjrIvv9fSbycNveGTDCsNNTiYoW +QyvMqmN1kGy20SZbQDD/fLfqBQ== +-----END PRIVATE KEY----- +", + "passphrase": "webpack-dev-server", + "pfx": "", + "requestCert": false, +} +`; + +exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kv +C/hf5Ei1J6qruJs3Xqg86Nl4+ed4ynUajAkRRibhp0P1SG1tgPssIK6iC7g8heYu +Dy9WkFuMie0513zjSn6bMEAK5TegxYAWCbaCZX/Fw9bDniabL/zuOv4sf8J4EPhs +EENnH6sUE9HxPUgQmNt1Tbd0j1Cd5PXrSTLyfVPRh0m9QhXTUHuxsse8XSn9U2sw +duxJTWRINmhffYn+O7kbJGI77xYr8u58Rsf3HCMI8DTKZNvQLChvvtLJ9ckyu7Q+ +T8emgklStASm3V2UtnriaK/IQEhgSdxqVRib3QIDAQABAoIBAGqWKPE1QnT3T+3J +G+ITz9P0dDFbvWltlTZmeSJh/s2q+WZloUNtBxdmwbqT/1QecnkyGgyzVCjvSK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KBgQDiQC3KYMG8ViJkWrv6 +XNAFEoAjVEKrtirGWJ66YfQ9KSJ7Zttrd1Y1V1OLtq3z4YMH39wdQ8rOD+yR8mWV +6Tnsxma6yJXAH8uan8iVbxjIZKF1hnvNCxUoxYmWOmTLcEQMzmxvTzAiR+s6R6Uj +9LgGqppt30nM4wnOhOJU6UxqbwKBgQDdy03KidbPZuycJSy1C9AIt0jlrxDsYm+U +fZrB6mHEZcgoZS5GbLKinQCdGcgERa05BXvJmNbfZtT5a37YEnbjsTImIhDiBP5P +nW36/9a3Vg1svd1KP2206/Bh3gfZbgTsQg4YogXgjf0Uzuvw18btgTtLVpVyeuqz +TU3eeF30cwKBgQCN6lvOmapsDEs+T3uhqx4AUH53qp63PmjOSUAnANJGmsq6ROZV +HmHAy6nn9Qpf85BRHCXhZWiMoIhvc3As/EINNtWxS6hC/q6jqp4SvcD50cVFBroY +/16iWGXZCX+37A+DSOfTWgSDPEFcKRx41UOpStHbITgVgEPieo/NWxlHmQKBgQDX +JOLs2RB6V0ilnpnjdPXzvncD9fHgmwvJap24BPeZX3HtXViqD76oZsu1mNCg9EW3 +zk3pnEyyoDlvSIreZerVq4kN3HWsCVP3Pqr0kz9g0CRtmy8RWr28hjHDfXD3xPUZ +iGnMEz7IOHOKv722/liFAprV1cNaLUmFbDNg3jmlaQKBgQDG5WwngPhOHmjTnSml +amfEz9a4yEhQqpqgVNW5wwoXOf6DbjL2m/maJh01giThj7inMcbpkZlIclxD0Eu6 +Lof+ctCeqSAJvaVPmd+nv8Yp26zsF1yM8ax9xXjrIvv9fSbycNveGTDCsNNTiYoW +QyvMqmN1kGy20SZbQDD/fLfqBQ== +-----END PRIVATE KEY----- +", + }, + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + Object { + "buf": "", + }, + ], + "requestCert": false, +} +`; + +exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "", + "cert": "", + "key": "", + "passphrase": "webpack-dev-server", + "pfx": "", + "requestCert": false, +} +`; + +exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "", + "cert": "", + "key": "", + "passphrase": "webpack-dev-server", + "pfx": "", + "requestCert": false, +} +`; + +exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as string http should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as string http should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as string http should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as string http should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as string https should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as string https should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as string https should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as string https should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as string spdy should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as string spdy should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as string spdy should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as string spdy should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option server options should be prioritized over https options should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option server options should be prioritized over https options should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": Array [ + "", + ], + "cert": Array [ + "", + ], + "key": Array [ + "", + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + "", + ], + "requestCert": false, +} +`; + +exports[`server option server options should be prioritized over https options should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option server options should be prioritized over https options should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option server options should be prioritized over https options should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option should support the "requestCert" option should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option should support the "requestCert" option should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option should support the "requestCert" option should pass options to the 'https.createServer' method: https options 1`] = ` +Object { + "cert": "", + "key": "", + "passphrase": "webpack-dev-server", + "pfx": "", + "requestCert": true, +} +`; + +exports[`server option spdy server with options should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option spdy server with options should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": Array [ + "", + ], + "cert": Array [ + "", + ], + "key": Array [ + "", + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + "", + ], + "requestCert": false, + "spdy": Object { + "protocols": Array [ + "h2", + "http/1.1", + ], + }, +} +`; + +exports[`server option spdy server with options should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option spdy server with options should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option spdy server with options should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; diff --git a/test/e2e/server.test.js b/test/e2e/server.test.js new file mode 100644 index 0000000000..d1bf6c45e0 --- /dev/null +++ b/test/e2e/server.test.js @@ -0,0 +1,1477 @@ +"use strict"; + +const https = require("https"); +const path = require("path"); +const fs = require("graceful-fs"); +const request = require("supertest"); +const spdy = require("spdy"); +const webpack = require("webpack"); +const Server = require("../../lib/Server"); +const config = require("../fixtures/static-config/webpack.config"); +const runBrowser = require("../helpers/run-browser"); +const { skipTestOnWindows } = require("../helpers/conditional-test"); +const normalizeOptions = require("../helpers/normalize-options"); +const port = require("../ports-map")["server-option"]; + +const httpsCertificateDirectory = path.resolve( + __dirname, + "../fixtures/https-certificate" +); + +const staticDirectory = path.resolve( + __dirname, + "../fixtures/static-config/public" +); + +describe("server option", () => { + describe("as string", () => { + let compiler; + let server; + let page; + let browser; + let pageErrors; + let consoleMessages; + + describe("http", () => { + beforeEach(async () => { + compiler = webpack(config); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: "http", + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`http://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + const HTTPVersion = await page.evaluate( + () => performance.getEntries()[0].nextHopProtocol + ); + + expect(HTTPVersion).not.toEqual("h2"); + + expect(response.status()).toMatchSnapshot("response status"); + + expect(await response.text()).toMatchSnapshot("response text"); + + expect( + consoleMessages.map((message) => message.text()) + ).toMatchSnapshot("console messages"); + + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + + describe("https", () => { + beforeEach(async () => { + compiler = webpack(config); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: "https", + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + const HTTPVersion = await page.evaluate( + () => performance.getEntries()[0].nextHopProtocol + ); + + expect(HTTPVersion).not.toEqual("h2"); + + expect(response.status()).toMatchSnapshot("response status"); + + expect(await response.text()).toMatchSnapshot("response text"); + + expect( + consoleMessages.map((message) => message.text()) + ).toMatchSnapshot("console messages"); + + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + + describe("spdy", () => { + beforeEach(async () => { + compiler = webpack(config); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: "spdy", + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + const HTTPVersion = await page.evaluate( + () => performance.getEntries()[0].nextHopProtocol + ); + + expect(HTTPVersion).toEqual("h2"); + + expect(response.status()).toMatchSnapshot("response status"); + + expect(await response.text()).toMatchSnapshot("response text"); + + expect( + consoleMessages.map((message) => message.text()) + ).toMatchSnapshot("console messages"); + + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + }); + + describe("as an object when ca, pfx, key and cert are buffer", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + ca: fs.readFileSync( + path.join(httpsCertificateDirectory, "ca.pem") + ), + pfx: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + key: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ), + cert: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ), + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + + describe("as an object when ca, pfx, key and cert are array of buffers", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + ca: [ + fs.readFileSync(path.join(httpsCertificateDirectory, "ca.pem")), + ], + pfx: [ + fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + ], + key: [ + fs.readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ), + ], + cert: [ + fs.readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ), + ], + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + + describe("as an object when ca, pfx, key and cert are strings", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + ca: fs + .readFileSync(path.join(httpsCertificateDirectory, "ca.pem")) + .toString(), + // TODO + // pfx can't be string because it is binary format + pfx: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + key: fs + .readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ) + .toString(), + cert: fs + .readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ) + .toString(), + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + + describe("as an object when ca, pfx, key and cert are array of strings", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + ca: [ + fs + .readFileSync(path.join(httpsCertificateDirectory, "ca.pem")) + .toString(), + ], + // pfx can't be string because it is binary format + pfx: [ + fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + ], + key: [ + fs + .readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ) + .toString(), + ], + cert: [ + fs + .readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ) + .toString(), + ], + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + + describe("as an object when ca, pfx, key and cert are paths to files", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + ca: path.join(httpsCertificateDirectory, "ca.pem"), + pfx: path.join(httpsCertificateDirectory, "server.pfx"), + key: path.join(httpsCertificateDirectory, "server.key"), + cert: path.join(httpsCertificateDirectory, "server.crt"), + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + + describe("as an object when ca, pfx, key and cert are array of paths to files", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + ca: [path.join(httpsCertificateDirectory, "ca.pem")], + pfx: [path.join(httpsCertificateDirectory, "server.pfx")], + key: [path.join(httpsCertificateDirectory, "server.key")], + cert: [path.join(httpsCertificateDirectory, "server.crt")], + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + + describe("as an object when ca, pfx, key and cert are symlinks", () => { + if (skipTestOnWindows("Symlinks are not supported on Windows")) { + return; + } + + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + ca: path.join(httpsCertificateDirectory, "ca-symlink.pem"), + pfx: path.join(httpsCertificateDirectory, "server-symlink.pfx"), + key: path.join(httpsCertificateDirectory, "server-symlink.key"), + cert: path.join(httpsCertificateDirectory, "server-symlink.crt"), + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + expect(response.status()).toEqual(200); + expect(await response.text()).toContain("Heyo"); + expect(consoleMessages.map((message) => message.text())).toEqual([]); + expect(pageErrors).toEqual([]); + }); + }); + + describe("as an object when cacert, pfx, key and cert are buffer", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + cacert: fs.readFileSync( + path.join(httpsCertificateDirectory, "ca.pem") + ), + pfx: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + key: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ), + cert: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ), + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + + describe("as an object when cacert and ca, pfx, key and cert are buffer", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + ca: fs.readFileSync( + path.join(httpsCertificateDirectory, "ca.pem") + ), + cacert: fs.readFileSync( + path.join(httpsCertificateDirectory, "ca.pem") + ), + pfx: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + key: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ), + cert: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ), + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + + describe("as an object when ca, pfx, key and cert are buffer, key and pfx are objects", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + ca: fs.readFileSync( + path.join(httpsCertificateDirectory, "ca.pem") + ), + pfx: [ + { + buf: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + }, + ], + key: [ + { + pem: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ), + }, + ], + cert: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ), + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + + describe("as an object when ca, pfx, key and cert are strings, key and pfx are objects", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + ca: fs + .readFileSync(path.join(httpsCertificateDirectory, "ca.pem")) + .toString(), + pfx: [ + { + // pfx can't be string because it is binary format + buf: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + }, + ], + key: [ + { + pem: fs + .readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ) + .toString(), + }, + ], + cert: fs + .readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ) + .toString(), + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + + describe("as an object and allow to pass more options", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + minVersion: "TLSv1.1", + ca: fs.readFileSync( + path.join(httpsCertificateDirectory, "ca.pem") + ), + pfx: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + key: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ), + cert: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ), + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + + // puppeteer having issues accepting SSL here, + // throwing error net::ERR_BAD_SSL_CLIENT_AUTH_CERT, + // hence testing with supertest + describe('should support the "requestCert" option', () => { + let compiler; + let server; + let createServerSpy; + let req; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + requestCert: true, + pfx: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + key: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ), + cert: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ), + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + req = request(server.app); + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await server.stop(); + }); + + it("should pass options to the 'https.createServer' method", async () => { + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + }); + + it("should handle GET request to index route (/)", async () => { + const response = await req.get("/"); + + expect(response.status).toMatchSnapshot("response status"); + expect(response.text).toMatchSnapshot("response text"); + }); + }); + + describe("server options should be prioritized over https options", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + https: { + requestCert: true, + ca: fs + .readFileSync(path.join(httpsCertificateDirectory, "ca.pem")) + .toString(), + // TODO + // pfx can't be string because it is binary format + pfx: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + key: fs + .readFileSync(path.join(httpsCertificateDirectory, "server.key")) + .toString(), + cert: fs + .readFileSync(path.join(httpsCertificateDirectory, "server.crt")) + .toString(), + passphrase: "webpack-dev-server", + }, + server: { + type: "https", + options: { + requestCert: false, + ca: [path.join(httpsCertificateDirectory, "ca.pem")], + pfx: [path.join(httpsCertificateDirectory, "server.pfx")], + key: [path.join(httpsCertificateDirectory, "server.key")], + cert: [path.join(httpsCertificateDirectory, "server.crt")], + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + + describe("spdy server with options", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(spdy, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "spdy", + options: { + requestCert: false, + ca: [path.join(httpsCertificateDirectory, "ca.pem")], + pfx: [path.join(httpsCertificateDirectory, "server.pfx")], + key: [path.join(httpsCertificateDirectory, "server.key")], + cert: [path.join(httpsCertificateDirectory, "server.crt")], + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + const HTTPVersion = await page.evaluate( + () => performance.getEntries()[0].nextHopProtocol + ); + + expect(HTTPVersion).toEqual("h2"); + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); +}); diff --git a/test/ports-map.js b/test/ports-map.js index f2bc714e5a..231f7f6640 100644 --- a/test/ports-map.js +++ b/test/ports-map.js @@ -75,6 +75,8 @@ const listOfTests = { port: 1, "web-socket-server-test": 1, "client-reconnect-option": 1, + "cli-server": 1, + "server-option": 1, }; let startPort = 8089; From 57e581f4765eecbd045ecf03d91953a1d2cd8bab Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 18 Oct 2021 02:01:23 +0000 Subject: [PATCH 12/17] test: update snapshots --- .../server-option.test.js.snap.webpack4 | 86 +++++++++++++------ 1 file changed, 61 insertions(+), 25 deletions(-) diff --git a/test/cli/__snapshots__/server-option.test.js.snap.webpack4 b/test/cli/__snapshots__/server-option.test.js.snap.webpack4 index fcfc60a5a3..037ab60bd4 100644 --- a/test/cli/__snapshots__/server-option.test.js.snap.webpack4 +++ b/test/cli/__snapshots__/server-option.test.js.snap.webpack4 @@ -1,56 +1,92 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`"server" CLI options should warn using "--server-options-cacert" and "--server-options-ca" together 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ - [webpack-dev-server] Do not specify 'ca' and 'cacert' options together, the 'ca' option will be used." +" [webpack-dev-server] Do not specify 'ca' and 'cacert' options together, the 'ca' option will be used. + [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--no-server-options-request-cert" 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ - [webpack-dev-server] Generating SSL certificate... - [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +" [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem + [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--server-options-key --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert --server-options-ca " 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ -" +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--server-options-key --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert --server-options-cacert " 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ -" +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--server-options-key --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert " 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ -" +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--server-options-key-reset --server-options-key --server-options-pfx-reset --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert-reset --server-options-cert --server-options-ca-reset --server-options-ca " 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ -" +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--server-options-request-cert" 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ - [webpack-dev-server] Generating SSL certificate... - [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +" [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem + [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--server-type http" 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): http://[]:/ - [webpack-dev-server] Generating SSL certificate... - [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +" [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem + [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--server-type https" 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ - [webpack-dev-server] Generating SSL certificate... - [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +" [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem + [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--server-type spdy" 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ - [webpack-dev-server] Generating SSL certificate... - [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +" [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem + [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; From de0af2a0a750ec3f9db62e39a8873635911355ea Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 18 Oct 2021 02:03:19 +0000 Subject: [PATCH 13/17] test: update snapshots --- .../server-option.test.js.snap.webpack5 | 86 +++++++++++++------ 1 file changed, 61 insertions(+), 25 deletions(-) diff --git a/test/cli/__snapshots__/server-option.test.js.snap.webpack5 b/test/cli/__snapshots__/server-option.test.js.snap.webpack5 index fcfc60a5a3..037ab60bd4 100644 --- a/test/cli/__snapshots__/server-option.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/server-option.test.js.snap.webpack5 @@ -1,56 +1,92 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`"server" CLI options should warn using "--server-options-cacert" and "--server-options-ca" together 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ - [webpack-dev-server] Do not specify 'ca' and 'cacert' options together, the 'ca' option will be used." +" [webpack-dev-server] Do not specify 'ca' and 'cacert' options together, the 'ca' option will be used. + [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--no-server-options-request-cert" 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ - [webpack-dev-server] Generating SSL certificate... - [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +" [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem + [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--server-options-key --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert --server-options-ca " 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ -" +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--server-options-key --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert --server-options-cacert " 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ -" +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--server-options-key --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert " 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ -" +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--server-options-key-reset --server-options-key --server-options-pfx-reset --server-options-pfx --server-options-passphrase webpack-dev-server --server-options-cert-reset --server-options-cert --server-options-ca-reset --server-options-ca " 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ -" +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--server-options-request-cert" 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ - [webpack-dev-server] Generating SSL certificate... - [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +" [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem + [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--server-type http" 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): http://[]:/ - [webpack-dev-server] Generating SSL certificate... - [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +" [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem + [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--server-type https" 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ - [webpack-dev-server] Generating SSL certificate... - [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +" [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem + [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; exports[`"server" CLI options should work using "--server-type spdy" 1`] = ` -" [webpack-dev-server] On Your Network (IPv6): https://[]:/ - [webpack-dev-server] Generating SSL certificate... - [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem" +" [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem + [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: https://localhost:/ + [webpack-dev-server] On Your Network (IPv4): https://:/ + [webpack-dev-server] On Your Network (IPv6): https://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" `; From e57c3493c579a5fd2c2dc5e045701a7cc93ec7a3 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Wed, 27 Oct 2021 18:34:07 +0300 Subject: [PATCH 14/17] refactor: code --- lib/Server.js | 133 +- lib/options.json | 21 +- .../validate-options.test.js.snap.webpack4 | 40 +- .../validate-options.test.js.snap.webpack5 | 40 +- .../server.test.js.snap.webpack4 | 214 +- .../server.test.js.snap.webpack5 | 214 +- test/e2e/server.test.js | 2176 +++++++++-------- test/validate-options.test.js | 5 - 8 files changed, 1461 insertions(+), 1382 deletions(-) diff --git a/lib/Server.js b/lib/Server.js index 408682e391..d996b6441a 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -520,70 +520,51 @@ class Server { ? options.hot : true; - // normalize the `server` option - const defaultServerType = "http"; - const defaultServerOptions = { requestCert: false }; - - switch (typeof options.server) { - case "undefined": - options.server = {}; - if (options.http2) { - options.server = { - type: "spdy", - options: defaultServerOptions, - }; - } else if (options.https) { - options.server = { - type: "https", - options: - typeof options.https === "object" - ? options.https - : defaultServerOptions, - }; - } else { - options.server.type = defaultServerType; - } - break; - case "string": - options.server = { - type: options.server, - }; - if (options.server.type !== "http") { - options.server.options = defaultServerOptions; - } - break; - case "object": - if (typeof options.https === "object") { - options.server.options = { - ...defaultServerOptions, - ...options.https, - ...options.server.options, - }; - } else { - options.server.options = { - ...defaultServerOptions, - ...options.server.options, - }; - } - break; - default: - options.server = { - type: defaultServerType, - options: defaultServerOptions, - }; + const isHTTPs = Boolean(options.https); + const isSPDY = Boolean(options.http2); + + options.server = { + type: + // eslint-disable-next-line no-nested-ternary + typeof options.server === "string" + ? options.server + : // eslint-disable-next-line no-nested-ternary + typeof (options.server || {}).type === "string" + ? options.server.type + : // eslint-disable-next-line no-nested-ternary + isSPDY + ? "spdy" + : isHTTPs + ? "https" + : "http", + options: { + ...options.https, + ...(options.server || {}).options, + }, + }; + + if ( + options.server.type === "spdy" && + typeof options.server.options.spdy === "undefined" + ) { + options.server.options.spdy = { + protocols: ["h2", "http/1.1"], + }; } - // server options - if (options.server.options) { - const { server } = options; + if (options.server.type === "https" || options.server.type === "spdy") { + if (typeof options.server.options.requestCert === "undefined") { + options.server.options.requestCert = false; + } + // TODO remove the `cacert` option in favor `ca` in the next major release for (const property of ["cacert", "ca", "cert", "crl", "key", "pfx"]) { - if (typeof server.options[property] === "undefined") { + if (typeof options.server.options[property] === "undefined") { // eslint-disable-next-line no-continue continue; } - const value = server.options[property]; + const value = options.server.options[property]; const readFile = (item) => { if ( Buffer.isBuffer(item) || @@ -606,14 +587,14 @@ class Server { } }; - server.options[property] = Array.isArray(value) + options.server.options[property] = Array.isArray(value) ? value.map((item) => readFile(item)) : readFile(value); } let fakeCert; - if (!server.options.key || !server.options.cert) { + if (!options.server.options.key || !options.server.options.cert) { const certificateDir = Server.findCacheDir(); const certificatePath = path.join(certificateDir, "server.pem"); let certificateExists; @@ -728,20 +709,20 @@ class Server { this.logger.info(`SSL certificate: ${certificatePath}`); } - if (server.options.cacert) { + if (options.server.options.cacert) { if (options.server.options.ca) { this.logger.warn( "Do not specify 'ca' and 'cacert' options together, the 'ca' option will be used." ); } else { - server.options.ca = options.server.options.cacert; + options.server.options.ca = options.server.options.cacert; } - delete server.options.cacert; + delete options.server.options.cacert; } - server.options.key = server.options.key || fakeCert; - server.options.cert = server.options.cert || fakeCert; + options.server.options.key = options.server.options.key || fakeCert; + options.server.options.cert = options.server.options.cert || fakeCert; } if (typeof options.ipc === "boolean") { @@ -1606,27 +1587,11 @@ class Server { } createServer() { - switch (this.options.server.type) { - case "https": - this.server = require("https").createServer( - this.options.server.options, - this.app - ); - break; - case "spdy": - this.server = require("spdy").createServer( - { - ...this.options.server.options, - spdy: { - protocols: ["h2", "http/1.1"], - }, - }, - this.app - ); - break; - default: - this.server = require("http").createServer(this.app); - } + // eslint-disable-next-line import/no-dynamic-require + this.server = require(this.options.server.type).createServer( + this.options.server.options, + this.app + ); this.server.on("connection", (socket) => { // Add socket to list diff --git a/lib/options.json b/lib/options.json index e70fbe5f8e..dd6d7f5e8c 100644 --- a/lib/options.json +++ b/lib/options.json @@ -634,10 +634,10 @@ "Server": { "anyOf": [ { - "enum": ["http", "https", "spdy"], - "cli": { - "exclude": true - } + "$ref": "#/definitions/ServerEnum" + }, + { + "$ref": "#/definitions/ServerString" }, { "$ref": "#/definitions/ServerObject" @@ -649,6 +649,19 @@ "ServerType": { "enum": ["http", "https", "spdy"] }, + "ServerEnum": { + "enum": ["http", "https", "spdy"], + "cli": { + "exclude": true + } + }, + "ServerString": { + "type": "string", + "minLength": 1, + "cli": { + "exclude": true + } + }, "ServerObject": { "type": "object", "properties": { diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack4 b/test/__snapshots__/validate-options.test.js.snap.webpack4 index 8670894205..646e103f06 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack4 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack4 @@ -617,7 +617,7 @@ exports[`options validate should throw an error on the "server" option with '{"t exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"ca":true}}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.server should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + \\"http\\" | \\"https\\" | \\"spdy\\" | non-empty string | object { type?, options? } -> Allows to set server and options (by default 'http'). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver Details: @@ -634,7 +634,7 @@ exports[`options validate should throw an error on the "server" option with '{"t exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"cert":true}}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.server should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + \\"http\\" | \\"https\\" | \\"spdy\\" | non-empty string | object { type?, options? } -> Allows to set server and options (by default 'http'). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver Details: @@ -651,7 +651,7 @@ exports[`options validate should throw an error on the "server" option with '{"t exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"key":10}}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.server should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + \\"http\\" | \\"https\\" | \\"spdy\\" | non-empty string | object { type?, options? } -> Allows to set server and options (by default 'http'). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver Details: @@ -674,7 +674,7 @@ exports[`options validate should throw an error on the "server" option with '{"t exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"pfx":10}}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.server should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + \\"http\\" | \\"https\\" | \\"spdy\\" | non-empty string | object { type?, options? } -> Allows to set server and options (by default 'http'). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver Details: @@ -694,38 +694,6 @@ exports[`options validate should throw an error on the "server" option with '{"t -> Request for an SSL certificate." `; -exports[`options validate should throw an error on the "server" option with '{"type":"invalid"}' value 1`] = ` -"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - - options.server.type should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\"" -`; - -exports[`options validate should throw an error on the "server" option with 'http2' value 1`] = ` -"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - - options.server should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } - -> Allows to set server and options (by default 'http'). - -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver - Details: - * options.server should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\" - * options.server should be an object: - object { type?, options? }" -`; - -exports[`options validate should throw an error on the "server" option with 'invalid' value 1`] = ` -"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - - options.server should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } - -> Allows to set server and options (by default 'http'). - -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver - Details: - * options.server should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\" - * options.server should be an object: - object { type?, options? }" -`; - exports[`options validate should throw an error on the "static" option with '' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.static should be a non-empty string." diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack5 b/test/__snapshots__/validate-options.test.js.snap.webpack5 index 8670894205..646e103f06 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack5 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack5 @@ -617,7 +617,7 @@ exports[`options validate should throw an error on the "server" option with '{"t exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"ca":true}}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.server should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + \\"http\\" | \\"https\\" | \\"spdy\\" | non-empty string | object { type?, options? } -> Allows to set server and options (by default 'http'). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver Details: @@ -634,7 +634,7 @@ exports[`options validate should throw an error on the "server" option with '{"t exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"cert":true}}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.server should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + \\"http\\" | \\"https\\" | \\"spdy\\" | non-empty string | object { type?, options? } -> Allows to set server and options (by default 'http'). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver Details: @@ -651,7 +651,7 @@ exports[`options validate should throw an error on the "server" option with '{"t exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"key":10}}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.server should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + \\"http\\" | \\"https\\" | \\"spdy\\" | non-empty string | object { type?, options? } -> Allows to set server and options (by default 'http'). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver Details: @@ -674,7 +674,7 @@ exports[`options validate should throw an error on the "server" option with '{"t exports[`options validate should throw an error on the "server" option with '{"type":"https","options":{"pfx":10}}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.server should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } + \\"http\\" | \\"https\\" | \\"spdy\\" | non-empty string | object { type?, options? } -> Allows to set server and options (by default 'http'). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver Details: @@ -694,38 +694,6 @@ exports[`options validate should throw an error on the "server" option with '{"t -> Request for an SSL certificate." `; -exports[`options validate should throw an error on the "server" option with '{"type":"invalid"}' value 1`] = ` -"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - - options.server.type should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\"" -`; - -exports[`options validate should throw an error on the "server" option with 'http2' value 1`] = ` -"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - - options.server should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } - -> Allows to set server and options (by default 'http'). - -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver - Details: - * options.server should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\" - * options.server should be an object: - object { type?, options? }" -`; - -exports[`options validate should throw an error on the "server" option with 'invalid' value 1`] = ` -"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - - options.server should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\" | object { type?, options? } - -> Allows to set server and options (by default 'http'). - -> Read more at https://webpack.js.org/configuration/dev-server/#devserverserver - Details: - * options.server should be one of these: - \\"http\\" | \\"https\\" | \\"spdy\\" - * options.server should be an object: - object { type?, options? }" -`; - exports[`options validate should throw an error on the "static" option with '' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.static should be a non-empty string." diff --git a/test/e2e/__snapshots__/server.test.js.snap.webpack4 b/test/e2e/__snapshots__/server.test.js.snap.webpack4 index c025840a38..ad324c4391 100644 --- a/test/e2e/__snapshots__/server.test.js.snap.webpack4 +++ b/test/e2e/__snapshots__/server.test.js.snap.webpack4 @@ -1,8 +1,8 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`server option as an object and allow to pass more options should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object allow to pass more options should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object and allow to pass more options should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object allow to pass more options should handle GET request to index route (/): https options 1`] = ` Object { "ca": "", "cert": "", @@ -14,18 +14,18 @@ Object { } `; -exports[`server option as an object and allow to pass more options should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object allow to pass more options should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object and allow to pass more options should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object allow to pass more options should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object and allow to pass more options should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object allow to pass more options should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are array of buffers should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object ca, pfx, key and cert are array of buffers should handle GET request to index route (/): https options 1`] = ` Object { "ca": Array [ "", @@ -44,18 +44,18 @@ Object { } `; -exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are array of buffers should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object ca, pfx, key and cert are array of buffers should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object ca, pfx, key and cert are array of buffers should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): https options 1`] = ` Object { "ca": Array [ "", @@ -74,18 +74,18 @@ Object { } `; -exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are array of strings should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object ca, pfx, key and cert are array of strings should handle GET request to index route (/): https options 1`] = ` Object { "ca": Array [ "-----BEGIN RSA PRIVATE KEY----- @@ -180,18 +180,18 @@ QyvMqmN1kGy20SZbQDD/fLfqBQ== } `; -exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are array of strings should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object ca, pfx, key and cert are array of strings should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object ca, pfx, key and cert are array of strings should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` Object { "ca": "", "cert": "", @@ -202,18 +202,18 @@ Object { } `; -exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): https options 1`] = ` Object { "ca": "", "cert": "", @@ -232,18 +232,18 @@ Object { } `; -exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are paths to files should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object ca, pfx, key and cert are paths to files should handle GET request to index route (/): https options 1`] = ` Object { "ca": "", "cert": "", @@ -254,18 +254,18 @@ Object { } `; -exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are paths to files should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object ca, pfx, key and cert are paths to files should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object ca, pfx, key and cert are paths to files should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are strings should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object ca, pfx, key and cert are strings should handle GET request to index route (/): https options 1`] = ` Object { "ca": "-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kv @@ -352,18 +352,18 @@ QyvMqmN1kGy20SZbQDD/fLfqBQ== } `; -exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are strings should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object ca, pfx, key and cert are strings should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object ca, pfx, key and cert are strings should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): https options 1`] = ` Object { "ca": "-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kv @@ -458,18 +458,18 @@ QyvMqmN1kGy20SZbQDD/fLfqBQ== } `; -exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` Object { "ca": "", "cert": "", @@ -480,18 +480,18 @@ Object { } `; -exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object cacert, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object cacert, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` Object { "ca": "", "cert": "", @@ -502,51 +502,48 @@ Object { } `; -exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object cacert, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object cacert, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object cacert, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as string http should handle GET request to index route (/): console messages 1`] = `Array []`; - -exports[`server option as string http should handle GET request to index route (/): page errors 1`] = `Array []`; - -exports[`server option as string http should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object options should be prioritized over http2 options should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as string http should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" +exports[`server option as object options should be prioritized over http2 options should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": Array [ + "", + ], + "cert": Array [ + "", + ], + "key": Array [ + "", + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + "", + ], + "requestCert": false, +} `; -exports[`server option as string https should handle GET request to index route (/): console messages 1`] = `Array []`; - -exports[`server option as string https should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object options should be prioritized over http2 options should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as string https should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object options should be prioritized over http2 options should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as string https should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object options should be prioritized over http2 options should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as string spdy should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object options should be prioritized over https options should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as string spdy should handle GET request to index route (/): page errors 1`] = `Array []`; - -exports[`server option as string spdy should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as string spdy should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - -exports[`server option server options should be prioritized over https options should handle GET request to index route (/): console messages 1`] = `Array []`; - -exports[`server option server options should be prioritized over https options should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object options should be prioritized over https options should handle GET request to index route (/): https options 1`] = ` Object { "ca": Array [ "", @@ -565,23 +562,23 @@ Object { } `; -exports[`server option server options should be prioritized over https options should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object options should be prioritized over https options should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option server options should be prioritized over https options should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object options should be prioritized over https options should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option server options should be prioritized over https options should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object options should be prioritized over https options should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option should support the "requestCert" option should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object should support the "requestCert" option should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option should support the "requestCert" option should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object should support the "requestCert" option should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option should support the "requestCert" option should pass options to the 'https.createServer' method: https options 1`] = ` +exports[`server option as object should support the "requestCert" option should pass options to the 'https.createServer' method: https options 1`] = ` Object { "cert": "", "key": "", @@ -591,9 +588,9 @@ Object { } `; -exports[`server option spdy server with options should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object spdy server with options should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option spdy server with options should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object spdy server with options should handle GET request to index route (/): https options 1`] = ` Object { "ca": Array [ "", @@ -618,11 +615,44 @@ Object { } `; -exports[`server option spdy server with options should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object spdy server with options should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as object spdy server with options should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as object spdy server with options should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as string http should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as string http should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as string http should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as string http should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as string https should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as string https should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as string https should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as string https should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as string spdy should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option spdy server with options should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as string spdy should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as string spdy should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option spdy server with options should handle GET request to index route (/): response text 1`] = ` +exports[`server option as string spdy should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; diff --git a/test/e2e/__snapshots__/server.test.js.snap.webpack5 b/test/e2e/__snapshots__/server.test.js.snap.webpack5 index c025840a38..ad324c4391 100644 --- a/test/e2e/__snapshots__/server.test.js.snap.webpack5 +++ b/test/e2e/__snapshots__/server.test.js.snap.webpack5 @@ -1,8 +1,8 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`server option as an object and allow to pass more options should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object allow to pass more options should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object and allow to pass more options should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object allow to pass more options should handle GET request to index route (/): https options 1`] = ` Object { "ca": "", "cert": "", @@ -14,18 +14,18 @@ Object { } `; -exports[`server option as an object and allow to pass more options should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object allow to pass more options should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object and allow to pass more options should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object allow to pass more options should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object and allow to pass more options should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object allow to pass more options should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are array of buffers should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object ca, pfx, key and cert are array of buffers should handle GET request to index route (/): https options 1`] = ` Object { "ca": Array [ "", @@ -44,18 +44,18 @@ Object { } `; -exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are array of buffers should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object ca, pfx, key and cert are array of buffers should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when ca, pfx, key and cert are array of buffers should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object ca, pfx, key and cert are array of buffers should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): https options 1`] = ` Object { "ca": Array [ "", @@ -74,18 +74,18 @@ Object { } `; -exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are array of strings should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object ca, pfx, key and cert are array of strings should handle GET request to index route (/): https options 1`] = ` Object { "ca": Array [ "-----BEGIN RSA PRIVATE KEY----- @@ -180,18 +180,18 @@ QyvMqmN1kGy20SZbQDD/fLfqBQ== } `; -exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are array of strings should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object ca, pfx, key and cert are array of strings should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when ca, pfx, key and cert are array of strings should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object ca, pfx, key and cert are array of strings should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` Object { "ca": "", "cert": "", @@ -202,18 +202,18 @@ Object { } `; -exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): https options 1`] = ` Object { "ca": "", "cert": "", @@ -232,18 +232,18 @@ Object { } `; -exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are paths to files should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object ca, pfx, key and cert are paths to files should handle GET request to index route (/): https options 1`] = ` Object { "ca": "", "cert": "", @@ -254,18 +254,18 @@ Object { } `; -exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are paths to files should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object ca, pfx, key and cert are paths to files should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object ca, pfx, key and cert are paths to files should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are strings should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object ca, pfx, key and cert are strings should handle GET request to index route (/): https options 1`] = ` Object { "ca": "-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kv @@ -352,18 +352,18 @@ QyvMqmN1kGy20SZbQDD/fLfqBQ== } `; -exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are strings should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object ca, pfx, key and cert are strings should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object ca, pfx, key and cert are strings should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): https options 1`] = ` Object { "ca": "-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kv @@ -458,18 +458,18 @@ QyvMqmN1kGy20SZbQDD/fLfqBQ== } `; -exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` Object { "ca": "", "cert": "", @@ -480,18 +480,18 @@ Object { } `; -exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object cacert, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object cacert, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` Object { "ca": "", "cert": "", @@ -502,51 +502,48 @@ Object { } `; -exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object cacert, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object cacert, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object cacert, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as string http should handle GET request to index route (/): console messages 1`] = `Array []`; - -exports[`server option as string http should handle GET request to index route (/): page errors 1`] = `Array []`; - -exports[`server option as string http should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object options should be prioritized over http2 options should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as string http should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" +exports[`server option as object options should be prioritized over http2 options should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": Array [ + "", + ], + "cert": Array [ + "", + ], + "key": Array [ + "", + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + "", + ], + "requestCert": false, +} `; -exports[`server option as string https should handle GET request to index route (/): console messages 1`] = `Array []`; - -exports[`server option as string https should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object options should be prioritized over http2 options should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option as string https should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object options should be prioritized over http2 options should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option as string https should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object options should be prioritized over http2 options should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option as string spdy should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object options should be prioritized over https options should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option as string spdy should handle GET request to index route (/): page errors 1`] = `Array []`; - -exports[`server option as string spdy should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as string spdy should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - -exports[`server option server options should be prioritized over https options should handle GET request to index route (/): console messages 1`] = `Array []`; - -exports[`server option server options should be prioritized over https options should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object options should be prioritized over https options should handle GET request to index route (/): https options 1`] = ` Object { "ca": Array [ "", @@ -565,23 +562,23 @@ Object { } `; -exports[`server option server options should be prioritized over https options should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object options should be prioritized over https options should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`server option server options should be prioritized over https options should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object options should be prioritized over https options should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option server options should be prioritized over https options should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object options should be prioritized over https options should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option should support the "requestCert" option should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as object should support the "requestCert" option should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option should support the "requestCert" option should handle GET request to index route (/): response text 1`] = ` +exports[`server option as object should support the "requestCert" option should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`server option should support the "requestCert" option should pass options to the 'https.createServer' method: https options 1`] = ` +exports[`server option as object should support the "requestCert" option should pass options to the 'https.createServer' method: https options 1`] = ` Object { "cert": "", "key": "", @@ -591,9 +588,9 @@ Object { } `; -exports[`server option spdy server with options should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`server option as object spdy server with options should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option spdy server with options should handle GET request to index route (/): https options 1`] = ` +exports[`server option as object spdy server with options should handle GET request to index route (/): https options 1`] = ` Object { "ca": Array [ "", @@ -618,11 +615,44 @@ Object { } `; -exports[`server option spdy server with options should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`server option as object spdy server with options should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as object spdy server with options should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as object spdy server with options should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as string http should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as string http should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as string http should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as string http should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as string https should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`server option as string https should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as string https should handle GET request to index route (/): response status 1`] = `200`; + +exports[`server option as string https should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`server option as string spdy should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`server option spdy server with options should handle GET request to index route (/): response status 1`] = `200`; +exports[`server option as string spdy should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`server option as string spdy should handle GET request to index route (/): response status 1`] = `200`; -exports[`server option spdy server with options should handle GET request to index route (/): response text 1`] = ` +exports[`server option as string spdy should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; diff --git a/test/e2e/server.test.js b/test/e2e/server.test.js index d1bf6c45e0..29c470b14f 100644 --- a/test/e2e/server.test.js +++ b/test/e2e/server.test.js @@ -213,890 +213,1134 @@ describe("server option", () => { }); }); - describe("as an object when ca, pfx, key and cert are buffer", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; + describe("as object", () => { + describe("ca, pfx, key and cert are buffer", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; - beforeEach(async () => { - compiler = webpack(config); + beforeEach(async () => { + compiler = webpack(config); - createServerSpy = jest.spyOn(https, "createServer"); + createServerSpy = jest.spyOn(https, "createServer"); - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - server: { - type: "https", - options: { - ca: fs.readFileSync( - path.join(httpsCertificateDirectory, "ca.pem") - ), - pfx: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.pfx") - ), - key: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.key") - ), - cert: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.crt") - ), - passphrase: "webpack-dev-server", + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, }, - }, - port, - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - createServerSpy.mockRestore(); - - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", (message) => { - consoleMessages.push(message); - }) - .on("pageerror", (error) => { - pageErrors.push(error); - }); - - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0", - }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("as an object when ca, pfx, key and cert are array of buffers", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - createServerSpy = jest.spyOn(https, "createServer"); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - server: { - type: "https", - options: { - ca: [ - fs.readFileSync(path.join(httpsCertificateDirectory, "ca.pem")), - ], - pfx: [ - fs.readFileSync( + server: { + type: "https", + options: { + ca: fs.readFileSync( + path.join(httpsCertificateDirectory, "ca.pem") + ), + pfx: fs.readFileSync( path.join(httpsCertificateDirectory, "server.pfx") ), - ], - key: [ - fs.readFileSync( + key: fs.readFileSync( path.join(httpsCertificateDirectory, "server.key") ), - ], - cert: [ - fs.readFileSync( + cert: fs.readFileSync( path.join(httpsCertificateDirectory, "server.crt") ), - ], - passphrase: "webpack-dev-server", + passphrase: "webpack-dev-server", + }, }, + port, }, - port, - }, - compiler - ); + compiler + ); - await server.start(); + await server.start(); - ({ page, browser } = await runBrowser()); + ({ page, browser } = await runBrowser()); - pageErrors = []; - consoleMessages = []; - }); + pageErrors = []; + consoleMessages = []; + }); - afterEach(async () => { - createServerSpy.mockRestore(); + afterEach(async () => { + createServerSpy.mockRestore(); - await browser.close(); - await server.stop(); - }); + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); - it("should handle GET request to index route (/)", async () => { - page - .on("console", (message) => { - consoleMessages.push(message); - }) - .on("pageerror", (error) => { - pageErrors.push(error); + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0", + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect( + consoleMessages.map((message) => message.text()) + ).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); }); - }); - describe("as an object when ca, pfx, key and cert are strings", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; + describe("ca, pfx, key and cert are array of buffers", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; - beforeEach(async () => { - compiler = webpack(config); + beforeEach(async () => { + compiler = webpack(config); - createServerSpy = jest.spyOn(https, "createServer"); + createServerSpy = jest.spyOn(https, "createServer"); - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - server: { - type: "https", - options: { - ca: fs - .readFileSync(path.join(httpsCertificateDirectory, "ca.pem")) - .toString(), - // TODO - // pfx can't be string because it is binary format - pfx: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.pfx") - ), - key: fs - .readFileSync( - path.join(httpsCertificateDirectory, "server.key") - ) - .toString(), - cert: fs - .readFileSync( - path.join(httpsCertificateDirectory, "server.crt") - ) - .toString(), - passphrase: "webpack-dev-server", + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + ca: [ + fs.readFileSync( + path.join(httpsCertificateDirectory, "ca.pem") + ), + ], + pfx: [ + fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + ], + key: [ + fs.readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ), + ], + cert: [ + fs.readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ), + ], + passphrase: "webpack-dev-server", + }, }, + port, }, - port, - }, - compiler - ); + compiler + ); + + await server.start(); - await server.start(); + ({ page, browser } = await runBrowser()); - ({ page, browser } = await runBrowser()); + pageErrors = []; + consoleMessages = []; + }); - pageErrors = []; - consoleMessages = []; - }); + afterEach(async () => { + createServerSpy.mockRestore(); - afterEach(async () => { - createServerSpy.mockRestore(); + await browser.close(); + await server.stop(); + }); - await browser.close(); - await server.stop(); - }); + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); - it("should handle GET request to index route (/)", async () => { - page - .on("console", (message) => { - consoleMessages.push(message); - }) - .on("pageerror", (error) => { - pageErrors.push(error); + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0", + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect( + consoleMessages.map((message) => message.text()) + ).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); }); - }); - describe("as an object when ca, pfx, key and cert are array of strings", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; + describe("ca, pfx, key and cert are strings", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; - beforeEach(async () => { - compiler = webpack(config); + beforeEach(async () => { + compiler = webpack(config); - createServerSpy = jest.spyOn(https, "createServer"); + createServerSpy = jest.spyOn(https, "createServer"); - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - server: { - type: "https", - options: { - ca: [ - fs + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + ca: fs .readFileSync(path.join(httpsCertificateDirectory, "ca.pem")) .toString(), - ], - // pfx can't be string because it is binary format - pfx: [ - fs.readFileSync( + // TODO + // pfx can't be string because it is binary format + pfx: fs.readFileSync( path.join(httpsCertificateDirectory, "server.pfx") ), - ], - key: [ - fs + key: fs .readFileSync( path.join(httpsCertificateDirectory, "server.key") ) .toString(), - ], - cert: [ - fs + cert: fs .readFileSync( path.join(httpsCertificateDirectory, "server.crt") ) .toString(), - ], - passphrase: "webpack-dev-server", + passphrase: "webpack-dev-server", + }, }, + port, }, - port, - }, - compiler - ); + compiler + ); - await server.start(); + await server.start(); - ({ page, browser } = await runBrowser()); + ({ page, browser } = await runBrowser()); - pageErrors = []; - consoleMessages = []; - }); + pageErrors = []; + consoleMessages = []; + }); - afterEach(async () => { - createServerSpy.mockRestore(); + afterEach(async () => { + createServerSpy.mockRestore(); - await browser.close(); - await server.stop(); - }); + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); - it("should handle GET request to index route (/)", async () => { - page - .on("console", (message) => { - consoleMessages.push(message); - }) - .on("pageerror", (error) => { - pageErrors.push(error); + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0", + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect( + consoleMessages.map((message) => message.text()) + ).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); }); - }); - describe("as an object when ca, pfx, key and cert are paths to files", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; + describe("ca, pfx, key and cert are array of strings", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; - beforeEach(async () => { - compiler = webpack(config); + beforeEach(async () => { + compiler = webpack(config); - createServerSpy = jest.spyOn(https, "createServer"); + createServerSpy = jest.spyOn(https, "createServer"); - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - server: { - type: "https", - options: { - ca: path.join(httpsCertificateDirectory, "ca.pem"), - pfx: path.join(httpsCertificateDirectory, "server.pfx"), - key: path.join(httpsCertificateDirectory, "server.key"), - cert: path.join(httpsCertificateDirectory, "server.crt"), - passphrase: "webpack-dev-server", + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, }, + server: { + type: "https", + options: { + ca: [ + fs + .readFileSync( + path.join(httpsCertificateDirectory, "ca.pem") + ) + .toString(), + ], + // pfx can't be string because it is binary format + pfx: [ + fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + ], + key: [ + fs + .readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ) + .toString(), + ], + cert: [ + fs + .readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ) + .toString(), + ], + passphrase: "webpack-dev-server", + }, + }, + port, }, - port, - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); + compiler + ); - pageErrors = []; - consoleMessages = []; - }); + await server.start(); - afterEach(async () => { - createServerSpy.mockRestore(); + ({ page, browser } = await runBrowser()); - await browser.close(); - await server.stop(); - }); + pageErrors = []; + consoleMessages = []; + }); - it("should handle GET request to index route (/)", async () => { - page - .on("console", (message) => { - consoleMessages.push(message); - }) - .on("pageerror", (error) => { - pageErrors.push(error); - }); + afterEach(async () => { + createServerSpy.mockRestore(); - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0", + await browser.close(); + await server.stop(); }); - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("as an object when ca, pfx, key and cert are array of paths to files", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect( + consoleMessages.map((message) => message.text()) + ).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); - beforeEach(async () => { - compiler = webpack(config); + describe("ca, pfx, key and cert are paths to files", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; - createServerSpy = jest.spyOn(https, "createServer"); + beforeEach(async () => { + compiler = webpack(config); - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - server: { - type: "https", - options: { - ca: [path.join(httpsCertificateDirectory, "ca.pem")], - pfx: [path.join(httpsCertificateDirectory, "server.pfx")], - key: [path.join(httpsCertificateDirectory, "server.key")], - cert: [path.join(httpsCertificateDirectory, "server.crt")], - passphrase: "webpack-dev-server", + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, }, + server: { + type: "https", + options: { + ca: path.join(httpsCertificateDirectory, "ca.pem"), + pfx: path.join(httpsCertificateDirectory, "server.pfx"), + key: path.join(httpsCertificateDirectory, "server.key"), + cert: path.join(httpsCertificateDirectory, "server.crt"), + passphrase: "webpack-dev-server", + }, + }, + port, }, - port, - }, - compiler - ); + compiler + ); - await server.start(); + await server.start(); - ({ page, browser } = await runBrowser()); + ({ page, browser } = await runBrowser()); - pageErrors = []; - consoleMessages = []; - }); + pageErrors = []; + consoleMessages = []; + }); - afterEach(async () => { - createServerSpy.mockRestore(); + afterEach(async () => { + createServerSpy.mockRestore(); - await browser.close(); - await server.stop(); - }); + await browser.close(); + await server.stop(); + }); - it("should handle GET request to index route (/)", async () => { - page - .on("console", (message) => { - consoleMessages.push(message); - }) - .on("pageerror", (error) => { - pageErrors.push(error); + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0", + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect( + consoleMessages.map((message) => message.text()) + ).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + + describe("ca, pfx, key and cert are array of paths to files", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + ca: [path.join(httpsCertificateDirectory, "ca.pem")], + pfx: [path.join(httpsCertificateDirectory, "server.pfx")], + key: [path.join(httpsCertificateDirectory, "server.key")], + cert: [path.join(httpsCertificateDirectory, "server.crt")], + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); }); - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect( + consoleMessages.map((message) => message.text()) + ).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); + }); }); - }); - describe("as an object when ca, pfx, key and cert are symlinks", () => { - if (skipTestOnWindows("Symlinks are not supported on Windows")) { - return; - } + describe("ca, pfx, key and cert are symlinks", () => { + if (skipTestOnWindows("Symlinks are not supported on Windows")) { + return; + } - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; - beforeEach(async () => { - compiler = webpack(config); + beforeEach(async () => { + compiler = webpack(config); - createServerSpy = jest.spyOn(https, "createServer"); + createServerSpy = jest.spyOn(https, "createServer"); - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - server: { - type: "https", - options: { - ca: path.join(httpsCertificateDirectory, "ca-symlink.pem"), - pfx: path.join(httpsCertificateDirectory, "server-symlink.pfx"), - key: path.join(httpsCertificateDirectory, "server-symlink.key"), - cert: path.join(httpsCertificateDirectory, "server-symlink.crt"), - passphrase: "webpack-dev-server", + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, }, + server: { + type: "https", + options: { + ca: path.join(httpsCertificateDirectory, "ca-symlink.pem"), + pfx: path.join(httpsCertificateDirectory, "server-symlink.pfx"), + key: path.join(httpsCertificateDirectory, "server-symlink.key"), + cert: path.join( + httpsCertificateDirectory, + "server-symlink.crt" + ), + passphrase: "webpack-dev-server", + }, + }, + port, }, - port, - }, - compiler - ); + compiler + ); - await server.start(); + await server.start(); - ({ page, browser } = await runBrowser()); + ({ page, browser } = await runBrowser()); - pageErrors = []; - consoleMessages = []; - }); + pageErrors = []; + consoleMessages = []; + }); - afterEach(async () => { - createServerSpy.mockRestore(); + afterEach(async () => { + createServerSpy.mockRestore(); - await browser.close(); - await server.stop(); - }); + await browser.close(); + await server.stop(); + }); - it("should handle GET request to index route (/)", async () => { - page - .on("console", (message) => { - consoleMessages.push(message); - }) - .on("pageerror", (error) => { - pageErrors.push(error); + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0", + expect(response.status()).toEqual(200); + expect(await response.text()).toContain("Heyo"); + expect(consoleMessages.map((message) => message.text())).toEqual([]); + expect(pageErrors).toEqual([]); }); - - expect(response.status()).toEqual(200); - expect(await response.text()).toContain("Heyo"); - expect(consoleMessages.map((message) => message.text())).toEqual([]); - expect(pageErrors).toEqual([]); }); - }); - describe("as an object when cacert, pfx, key and cert are buffer", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; + describe("cacert, pfx, key and cert are buffer", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; - beforeEach(async () => { - compiler = webpack(config); + beforeEach(async () => { + compiler = webpack(config); - createServerSpy = jest.spyOn(https, "createServer"); + createServerSpy = jest.spyOn(https, "createServer"); - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - server: { - type: "https", - options: { - cacert: fs.readFileSync( - path.join(httpsCertificateDirectory, "ca.pem") - ), - pfx: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.pfx") - ), - key: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.key") - ), - cert: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.crt") - ), - passphrase: "webpack-dev-server", + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + cacert: fs.readFileSync( + path.join(httpsCertificateDirectory, "ca.pem") + ), + pfx: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + key: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ), + cert: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ), + passphrase: "webpack-dev-server", + }, }, + port, }, - port, - }, - compiler - ); + compiler + ); - await server.start(); + await server.start(); - ({ page, browser } = await runBrowser()); + ({ page, browser } = await runBrowser()); - pageErrors = []; - consoleMessages = []; - }); + pageErrors = []; + consoleMessages = []; + }); - afterEach(async () => { - createServerSpy.mockRestore(); + afterEach(async () => { + createServerSpy.mockRestore(); - await browser.close(); - await server.stop(); - }); + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); - it("should handle GET request to index route (/)", async () => { - page - .on("console", (message) => { - consoleMessages.push(message); - }) - .on("pageerror", (error) => { - pageErrors.push(error); + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0", + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect( + consoleMessages.map((message) => message.text()) + ).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); }); - }); - describe("as an object when cacert and ca, pfx, key and cert are buffer", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; + describe("cacert and ca, pfx, key and cert are buffer", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; - beforeEach(async () => { - compiler = webpack(config); + beforeEach(async () => { + compiler = webpack(config); - createServerSpy = jest.spyOn(https, "createServer"); + createServerSpy = jest.spyOn(https, "createServer"); - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - server: { - type: "https", - options: { - ca: fs.readFileSync( - path.join(httpsCertificateDirectory, "ca.pem") - ), - cacert: fs.readFileSync( - path.join(httpsCertificateDirectory, "ca.pem") - ), - pfx: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.pfx") - ), - key: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.key") - ), - cert: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.crt") - ), - passphrase: "webpack-dev-server", + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + ca: fs.readFileSync( + path.join(httpsCertificateDirectory, "ca.pem") + ), + cacert: fs.readFileSync( + path.join(httpsCertificateDirectory, "ca.pem") + ), + pfx: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + key: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ), + cert: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ), + passphrase: "webpack-dev-server", + }, }, + port, }, - port, - }, - compiler - ); + compiler + ); - await server.start(); + await server.start(); - ({ page, browser } = await runBrowser()); + ({ page, browser } = await runBrowser()); - pageErrors = []; - consoleMessages = []; - }); + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); - afterEach(async () => { - createServerSpy.mockRestore(); + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); - await browser.close(); - await server.stop(); + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect( + consoleMessages.map((message) => message.text()) + ).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); + }); }); - it("should handle GET request to index route (/)", async () => { - page - .on("console", (message) => { - consoleMessages.push(message); - }) - .on("pageerror", (error) => { - pageErrors.push(error); + describe("ca, pfx, key and cert are buffer, key and pfx are objects", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + ca: fs.readFileSync( + path.join(httpsCertificateDirectory, "ca.pem") + ), + pfx: [ + { + buf: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + }, + ], + key: [ + { + pem: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ), + }, + ], + cert: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ), + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0", + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect( + consoleMessages.map((message) => message.text()) + ).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + + describe("ca, pfx, key and cert are strings, key and pfx are objects", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + ca: fs + .readFileSync(path.join(httpsCertificateDirectory, "ca.pem")) + .toString(), + pfx: [ + { + // pfx can't be string because it is binary format + buf: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + }, + ], + key: [ + { + pem: fs + .readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ) + .toString(), + }, + ], + cert: fs + .readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ) + .toString(), + passphrase: "webpack-dev-server", + }, + }, + port, + }, + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); }); - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect( + consoleMessages.map((message) => message.text()) + ).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); + }); }); - }); - describe("as an object when ca, pfx, key and cert are buffer, key and pfx are objects", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; + describe("allow to pass more options", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; - beforeEach(async () => { - compiler = webpack(config); + beforeEach(async () => { + compiler = webpack(config); - createServerSpy = jest.spyOn(https, "createServer"); + createServerSpy = jest.spyOn(https, "createServer"); - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + minVersion: "TLSv1.1", + ca: fs.readFileSync( + path.join(httpsCertificateDirectory, "ca.pem") + ), + pfx: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + key: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ), + cert: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ), + passphrase: "webpack-dev-server", + }, + }, + port, }, - server: { - type: "https", - options: { - ca: fs.readFileSync( - path.join(httpsCertificateDirectory, "ca.pem") - ), - pfx: [ - { - buf: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.pfx") - ), - }, - ], - key: [ - { - pem: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.key") - ), - }, - ], - cert: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.crt") - ), - passphrase: "webpack-dev-server", + compiler + ); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + createServerSpy.mockRestore(); + + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", + }); + + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect( + consoleMessages.map((message) => message.text()) + ).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); + }); + }); + + // puppeteer having issues accepting SSL here, throwing error net::ERR_BAD_SSL_CLIENT_AUTH_CERT, hence testing with supertest + describe('should support the "requestCert" option', () => { + let compiler; + let server; + let createServerSpy; + let req; + + beforeEach(async () => { + compiler = webpack(config); + + createServerSpy = jest.spyOn(https, "createServer"); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "https", + options: { + requestCert: true, + pfx: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + key: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ), + cert: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ), + passphrase: "webpack-dev-server", + }, }, + port, }, - port, - }, - compiler - ); + compiler + ); - await server.start(); + await server.start(); - ({ page, browser } = await runBrowser()); + req = request(server.app); + }); - pageErrors = []; - consoleMessages = []; - }); + afterEach(async () => { + createServerSpy.mockRestore(); - afterEach(async () => { - createServerSpy.mockRestore(); + await server.stop(); + }); - await browser.close(); - await server.stop(); - }); + it("should pass options to the 'https.createServer' method", async () => { + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + }); - it("should handle GET request to index route (/)", async () => { - page - .on("console", (message) => { - consoleMessages.push(message); - }) - .on("pageerror", (error) => { - pageErrors.push(error); - }); + it("should handle GET request to index route (/)", async () => { + const response = await req.get("/"); - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0", + expect(response.status).toMatchSnapshot("response status"); + expect(response.text).toMatchSnapshot("response text"); }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); }); - }); - describe("as an object when ca, pfx, key and cert are strings, key and pfx are objects", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; + describe("options should be prioritized over https options", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; - beforeEach(async () => { - compiler = webpack(config); + beforeEach(async () => { + compiler = webpack(config); - createServerSpy = jest.spyOn(https, "createServer"); + createServerSpy = jest.spyOn(https, "createServer"); - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - server: { - type: "https", - options: { + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + https: { + requestCert: true, ca: fs .readFileSync(path.join(httpsCertificateDirectory, "ca.pem")) .toString(), - pfx: [ - { - // pfx can't be string because it is binary format - buf: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.pfx") - ), - }, - ], - key: [ - { - pem: fs - .readFileSync( - path.join(httpsCertificateDirectory, "server.key") - ) - .toString(), - }, - ], + // TODO + // pfx can't be string because it is binary format + pfx: fs.readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + key: fs + .readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ) + .toString(), cert: fs .readFileSync( path.join(httpsCertificateDirectory, "server.crt") @@ -1104,374 +1348,240 @@ describe("server option", () => { .toString(), passphrase: "webpack-dev-server", }, + server: { + type: "https", + options: { + requestCert: false, + ca: [path.join(httpsCertificateDirectory, "ca.pem")], + pfx: [path.join(httpsCertificateDirectory, "server.pfx")], + key: [path.join(httpsCertificateDirectory, "server.key")], + cert: [path.join(httpsCertificateDirectory, "server.crt")], + passphrase: "webpack-dev-server", + }, + }, + port, }, - port, - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - createServerSpy.mockRestore(); + compiler + ); - await browser.close(); - await server.stop(); - }); + await server.start(); - it("should handle GET request to index route (/)", async () => { - page - .on("console", (message) => { - consoleMessages.push(message); - }) - .on("pageerror", (error) => { - pageErrors.push(error); - }); + ({ page, browser } = await runBrowser()); - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0", + pageErrors = []; + consoleMessages = []; }); - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("as an object and allow to pass more options", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - createServerSpy = jest.spyOn(https, "createServer"); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - server: { - type: "https", - options: { - minVersion: "TLSv1.1", - ca: fs.readFileSync( - path.join(httpsCertificateDirectory, "ca.pem") - ), - pfx: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.pfx") - ), - key: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.key") - ), - cert: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.crt") - ), - passphrase: "webpack-dev-server", - }, - }, - port, - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); + afterEach(async () => { + createServerSpy.mockRestore(); - afterEach(async () => { - createServerSpy.mockRestore(); + await browser.close(); + await server.stop(); + }); - await browser.close(); - await server.stop(); - }); + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); - it("should handle GET request to index route (/)", async () => { - page - .on("console", (message) => { - consoleMessages.push(message); - }) - .on("pageerror", (error) => { - pageErrors.push(error); + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0", + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect( + consoleMessages.map((message) => message.text()) + ).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); }); - }); - // puppeteer having issues accepting SSL here, - // throwing error net::ERR_BAD_SSL_CLIENT_AUTH_CERT, - // hence testing with supertest - describe('should support the "requestCert" option', () => { - let compiler; - let server; - let createServerSpy; - let req; + describe("options should be prioritized over http2 options", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; - beforeEach(async () => { - compiler = webpack(config); + beforeEach(async () => { + compiler = webpack(config); - createServerSpy = jest.spyOn(https, "createServer"); + createServerSpy = jest.spyOn(https, "createServer"); - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - server: { - type: "https", - options: { + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + https: { requestCert: true, + ca: fs + .readFileSync(path.join(httpsCertificateDirectory, "ca.pem")) + .toString(), + // TODO + // pfx can't be string because it is binary format pfx: fs.readFileSync( path.join(httpsCertificateDirectory, "server.pfx") ), - key: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.key") - ), - cert: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.crt") - ), + key: fs + .readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ) + .toString(), + cert: fs + .readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ) + .toString(), passphrase: "webpack-dev-server", }, - }, - port, - }, - compiler - ); - - await server.start(); - - req = request(server.app); - }); - - afterEach(async () => { - createServerSpy.mockRestore(); - - await server.stop(); - }); - - it("should pass options to the 'https.createServer' method", async () => { - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - }); - - it("should handle GET request to index route (/)", async () => { - const response = await req.get("/"); - - expect(response.status).toMatchSnapshot("response status"); - expect(response.text).toMatchSnapshot("response text"); - }); - }); - - describe("server options should be prioritized over https options", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - createServerSpy = jest.spyOn(https, "createServer"); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - https: { - requestCert: true, - ca: fs - .readFileSync(path.join(httpsCertificateDirectory, "ca.pem")) - .toString(), - // TODO - // pfx can't be string because it is binary format - pfx: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.pfx") - ), - key: fs - .readFileSync(path.join(httpsCertificateDirectory, "server.key")) - .toString(), - cert: fs - .readFileSync(path.join(httpsCertificateDirectory, "server.crt")) - .toString(), - passphrase: "webpack-dev-server", - }, - server: { - type: "https", - options: { - requestCert: false, - ca: [path.join(httpsCertificateDirectory, "ca.pem")], - pfx: [path.join(httpsCertificateDirectory, "server.pfx")], - key: [path.join(httpsCertificateDirectory, "server.key")], - cert: [path.join(httpsCertificateDirectory, "server.crt")], - passphrase: "webpack-dev-server", + http2: true, + server: { + type: "https", + options: { + requestCert: false, + ca: [path.join(httpsCertificateDirectory, "ca.pem")], + pfx: [path.join(httpsCertificateDirectory, "server.pfx")], + key: [path.join(httpsCertificateDirectory, "server.key")], + cert: [path.join(httpsCertificateDirectory, "server.crt")], + passphrase: "webpack-dev-server", + }, }, + port, }, - port, - }, - compiler - ); + compiler + ); - await server.start(); + await server.start(); - ({ page, browser } = await runBrowser()); + ({ page, browser } = await runBrowser()); - pageErrors = []; - consoleMessages = []; - }); + pageErrors = []; + consoleMessages = []; + }); - afterEach(async () => { - createServerSpy.mockRestore(); + afterEach(async () => { + createServerSpy.mockRestore(); - await browser.close(); - await server.stop(); - }); + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); - it("should handle GET request to index route (/)", async () => { - page - .on("console", (message) => { - consoleMessages.push(message); - }) - .on("pageerror", (error) => { - pageErrors.push(error); + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0", + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect( + consoleMessages.map((message) => message.text()) + ).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); }); - }); - describe("spdy server with options", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; + describe("spdy server with options", () => { + let compiler; + let server; + let createServerSpy; + let page; + let browser; + let pageErrors; + let consoleMessages; - beforeEach(async () => { - compiler = webpack(config); + beforeEach(async () => { + compiler = webpack(config); - createServerSpy = jest.spyOn(spdy, "createServer"); + createServerSpy = jest.spyOn(spdy, "createServer"); - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - server: { - type: "spdy", - options: { - requestCert: false, - ca: [path.join(httpsCertificateDirectory, "ca.pem")], - pfx: [path.join(httpsCertificateDirectory, "server.pfx")], - key: [path.join(httpsCertificateDirectory, "server.key")], - cert: [path.join(httpsCertificateDirectory, "server.crt")], - passphrase: "webpack-dev-server", + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + server: { + type: "spdy", + options: { + requestCert: false, + ca: [path.join(httpsCertificateDirectory, "ca.pem")], + pfx: [path.join(httpsCertificateDirectory, "server.pfx")], + key: [path.join(httpsCertificateDirectory, "server.key")], + cert: [path.join(httpsCertificateDirectory, "server.crt")], + passphrase: "webpack-dev-server", + }, }, + port, }, - port, - }, - compiler - ); + compiler + ); - await server.start(); + await server.start(); - ({ page, browser } = await runBrowser()); + ({ page, browser } = await runBrowser()); - pageErrors = []; - consoleMessages = []; - }); + pageErrors = []; + consoleMessages = []; + }); - afterEach(async () => { - createServerSpy.mockRestore(); + afterEach(async () => { + createServerSpy.mockRestore(); - await browser.close(); - await server.stop(); - }); + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to index route (/)", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); - it("should handle GET request to index route (/)", async () => { - page - .on("console", (message) => { - consoleMessages.push(message); - }) - .on("pageerror", (error) => { - pageErrors.push(error); + const response = await page.goto(`https://127.0.0.1:${port}/`, { + waitUntil: "networkidle0", }); - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0", - }); + const HTTPVersion = await page.evaluate( + () => performance.getEntries()[0].nextHopProtocol + ); - const HTTPVersion = await page.evaluate( - () => performance.getEntries()[0].nextHopProtocol - ); - - expect(HTTPVersion).toEqual("h2"); - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); + expect(HTTPVersion).toEqual("h2"); + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + expect(response.status()).toMatchSnapshot("response status"); + expect(await response.text()).toMatchSnapshot("response text"); + expect( + consoleMessages.map((message) => message.text()) + ).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); + }); }); }); }); diff --git a/test/validate-options.test.js b/test/validate-options.test.js index e7038948a4..fbd4fd805e 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -415,11 +415,6 @@ const tests = { }, ], failure: [ - "http2", - "invalid", - { - type: "invalid", - }, { type: "https", additional: "test", From c23987f5c5e85bba80d63e14c6ff9e5223594d3d Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Wed, 27 Oct 2021 18:49:09 +0300 Subject: [PATCH 15/17] test: fix --- .../Server.test.js.snap.webpack4 | 49 +++++++++++++++++++ .../Server.test.js.snap.webpack5 | 49 +++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/test/server/__snapshots__/Server.test.js.snap.webpack4 b/test/server/__snapshots__/Server.test.js.snap.webpack4 index a3e872e20b..d394c36fa9 100644 --- a/test/server/__snapshots__/Server.test.js.snap.webpack4 +++ b/test/server/__snapshots__/Server.test.js.snap.webpack4 @@ -76,6 +76,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -122,6 +123,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -169,6 +171,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -218,6 +221,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -267,6 +271,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -315,6 +320,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -363,6 +369,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -410,6 +417,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -457,6 +465,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -504,6 +513,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -553,6 +563,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -602,6 +613,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -650,6 +662,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -696,6 +709,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -742,6 +756,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -788,6 +803,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -834,6 +850,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -880,6 +897,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -926,6 +944,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -972,6 +991,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1018,6 +1038,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1064,6 +1085,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1110,6 +1132,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1156,6 +1179,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1202,6 +1226,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1248,6 +1273,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1294,6 +1320,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1340,6 +1367,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1388,6 +1416,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1436,6 +1465,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1484,6 +1514,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1532,6 +1563,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1589,6 +1621,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1646,6 +1679,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1703,6 +1737,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1749,6 +1784,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1783,6 +1819,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1829,6 +1866,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1875,6 +1913,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1921,6 +1960,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1968,6 +2008,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -2014,6 +2055,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -2058,6 +2100,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -2104,6 +2147,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -2152,6 +2196,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -2198,6 +2243,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -2247,6 +2293,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -2293,6 +2340,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -2339,6 +2387,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, diff --git a/test/server/__snapshots__/Server.test.js.snap.webpack5 b/test/server/__snapshots__/Server.test.js.snap.webpack5 index a3e872e20b..d394c36fa9 100644 --- a/test/server/__snapshots__/Server.test.js.snap.webpack5 +++ b/test/server/__snapshots__/Server.test.js.snap.webpack5 @@ -76,6 +76,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -122,6 +123,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -169,6 +171,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -218,6 +221,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -267,6 +271,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -315,6 +320,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -363,6 +369,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -410,6 +417,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -457,6 +465,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -504,6 +513,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -553,6 +563,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -602,6 +613,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -650,6 +662,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -696,6 +709,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -742,6 +756,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -788,6 +803,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -834,6 +850,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -880,6 +897,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -926,6 +944,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -972,6 +991,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1018,6 +1038,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1064,6 +1085,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1110,6 +1132,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1156,6 +1179,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1202,6 +1226,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1248,6 +1273,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1294,6 +1320,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1340,6 +1367,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1388,6 +1416,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1436,6 +1465,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1484,6 +1514,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1532,6 +1563,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1589,6 +1621,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1646,6 +1679,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1703,6 +1737,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1749,6 +1784,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1783,6 +1819,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1829,6 +1866,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1875,6 +1913,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1921,6 +1960,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -1968,6 +2008,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -2014,6 +2055,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -2058,6 +2100,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -2104,6 +2147,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -2152,6 +2196,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -2198,6 +2243,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -2247,6 +2293,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -2293,6 +2340,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, @@ -2339,6 +2387,7 @@ Object { "open": Array [], "port": "", "server": Object { + "options": Object {}, "type": "http", }, "setupExitSignals": true, From 05ad835f92457048fddf00eb0798fe656abc8c05 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Wed, 27 Oct 2021 18:52:07 +0300 Subject: [PATCH 16/17] test: fix --- .../server-option.test.js.snap.webpack4 | 4 +--- .../server-option.test.js.snap.webpack5 | 4 +--- test/cli/server-option.test.js | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/test/cli/__snapshots__/server-option.test.js.snap.webpack4 b/test/cli/__snapshots__/server-option.test.js.snap.webpack4 index 037ab60bd4..3d60d4ab2e 100644 --- a/test/cli/__snapshots__/server-option.test.js.snap.webpack4 +++ b/test/cli/__snapshots__/server-option.test.js.snap.webpack4 @@ -62,9 +62,7 @@ exports[`"server" CLI options should work using "--server-options-request-cert" `; exports[`"server" CLI options should work using "--server-type http" 1`] = ` -" [webpack-dev-server] Generating SSL certificate... - [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem - [webpack-dev-server] Project is running at: +" [webpack-dev-server] Project is running at: [webpack-dev-server] Loopback: http://localhost:/ [webpack-dev-server] On Your Network (IPv4): http://:/ [webpack-dev-server] On Your Network (IPv6): http://[]:/ diff --git a/test/cli/__snapshots__/server-option.test.js.snap.webpack5 b/test/cli/__snapshots__/server-option.test.js.snap.webpack5 index 037ab60bd4..3d60d4ab2e 100644 --- a/test/cli/__snapshots__/server-option.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/server-option.test.js.snap.webpack5 @@ -62,9 +62,7 @@ exports[`"server" CLI options should work using "--server-options-request-cert" `; exports[`"server" CLI options should work using "--server-type http" 1`] = ` -" [webpack-dev-server] Generating SSL certificate... - [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem - [webpack-dev-server] Project is running at: +" [webpack-dev-server] Project is running at: [webpack-dev-server] Loopback: http://localhost:/ [webpack-dev-server] On Your Network (IPv4): http://:/ [webpack-dev-server] On Your Network (IPv6): http://[]:/ diff --git a/test/cli/server-option.test.js b/test/cli/server-option.test.js index 3119a21f5a..7b6d9b3eda 100644 --- a/test/cli/server-option.test.js +++ b/test/cli/server-option.test.js @@ -70,6 +70,8 @@ describe('"server" CLI options', () => { const { exitCode, stderr } = await testBin([ "--port", port, + "--server-type", + "https", "--server-options-key", key, "--server-options-pfx", @@ -98,6 +100,8 @@ describe('"server" CLI options', () => { const { exitCode, stderr } = await testBin([ "--port", port, + "--server-type", + "https", "--server-options-key", key, "--server-options-pfx", @@ -126,6 +130,8 @@ describe('"server" CLI options', () => { const { exitCode, stderr } = await testBin([ "--port", port, + "--server-type", + "https", "--server-options-key-reset", "--server-options-key", key, @@ -158,6 +164,8 @@ describe('"server" CLI options', () => { const { exitCode, stderr } = await testBin([ "--port", port, + "--server-type", + "https", "--server-options-key", key, "--server-options-pfx", @@ -188,6 +196,8 @@ describe('"server" CLI options', () => { const { exitCode, stderr } = await testBin([ "--port", port, + "--server-type", + "https", "--server-options-key", key, "--server-options-pfx", @@ -208,6 +218,8 @@ describe('"server" CLI options', () => { const { exitCode, stderr } = await testBin([ "--port", port, + "--server-type", + "https", "--server-options-request-cert", ]); @@ -221,6 +233,8 @@ describe('"server" CLI options', () => { const { exitCode, stderr } = await testBin([ "--port", port, + "--server-type", + "https", "--no-server-options-request-cert", ]); From 294e85f2523cbc24769a461cee5f6aca5d5f3c3a Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Wed, 27 Oct 2021 19:08:45 +0300 Subject: [PATCH 17/17] test: fix --- test/e2e/__snapshots__/https.test.js.snap.webpack4 | 11 +++++++++++ test/e2e/__snapshots__/https.test.js.snap.webpack5 | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/test/e2e/__snapshots__/https.test.js.snap.webpack4 b/test/e2e/__snapshots__/https.test.js.snap.webpack4 index 897728d71f..48326d2598 100644 --- a/test/e2e/__snapshots__/https.test.js.snap.webpack4 +++ b/test/e2e/__snapshots__/https.test.js.snap.webpack4 @@ -10,6 +10,7 @@ Object { "minVersion": "TLSv1.1", "passphrase": "webpack-dev-server", "pfx": "", + "requestCert": false, } `; @@ -39,6 +40,7 @@ Object { "pfx": Array [ "", ], + "requestCert": false, } `; @@ -68,6 +70,7 @@ Object { "pfx": Array [ "", ], + "requestCert": false, } `; @@ -173,6 +176,7 @@ QyvMqmN1kGy20SZbQDD/fLfqBQ== "pfx": Array [ "", ], + "requestCert": false, } `; @@ -194,6 +198,7 @@ Object { "key": "", "passphrase": "webpack-dev-server", "pfx": "", + "requestCert": false, } `; @@ -223,6 +228,7 @@ Object { "buf": "", }, ], + "requestCert": false, } `; @@ -244,6 +250,7 @@ Object { "key": "", "passphrase": "webpack-dev-server", "pfx": "", + "requestCert": false, } `; @@ -341,6 +348,7 @@ QyvMqmN1kGy20SZbQDD/fLfqBQ== ", "passphrase": "webpack-dev-server", "pfx": "", + "requestCert": false, } `; @@ -446,6 +454,7 @@ QyvMqmN1kGy20SZbQDD/fLfqBQ== "buf": "", }, ], + "requestCert": false, } `; @@ -467,6 +476,7 @@ Object { "key": "", "passphrase": "webpack-dev-server", "pfx": "", + "requestCert": false, } `; @@ -488,6 +498,7 @@ Object { "key": "", "passphrase": "webpack-dev-server", "pfx": "", + "requestCert": false, } `; diff --git a/test/e2e/__snapshots__/https.test.js.snap.webpack5 b/test/e2e/__snapshots__/https.test.js.snap.webpack5 index 897728d71f..48326d2598 100644 --- a/test/e2e/__snapshots__/https.test.js.snap.webpack5 +++ b/test/e2e/__snapshots__/https.test.js.snap.webpack5 @@ -10,6 +10,7 @@ Object { "minVersion": "TLSv1.1", "passphrase": "webpack-dev-server", "pfx": "", + "requestCert": false, } `; @@ -39,6 +40,7 @@ Object { "pfx": Array [ "", ], + "requestCert": false, } `; @@ -68,6 +70,7 @@ Object { "pfx": Array [ "", ], + "requestCert": false, } `; @@ -173,6 +176,7 @@ QyvMqmN1kGy20SZbQDD/fLfqBQ== "pfx": Array [ "", ], + "requestCert": false, } `; @@ -194,6 +198,7 @@ Object { "key": "", "passphrase": "webpack-dev-server", "pfx": "", + "requestCert": false, } `; @@ -223,6 +228,7 @@ Object { "buf": "", }, ], + "requestCert": false, } `; @@ -244,6 +250,7 @@ Object { "key": "", "passphrase": "webpack-dev-server", "pfx": "", + "requestCert": false, } `; @@ -341,6 +348,7 @@ QyvMqmN1kGy20SZbQDD/fLfqBQ== ", "passphrase": "webpack-dev-server", "pfx": "", + "requestCert": false, } `; @@ -446,6 +454,7 @@ QyvMqmN1kGy20SZbQDD/fLfqBQ== "buf": "", }, ], + "requestCert": false, } `; @@ -467,6 +476,7 @@ Object { "key": "", "passphrase": "webpack-dev-server", "pfx": "", + "requestCert": false, } `; @@ -488,6 +498,7 @@ Object { "key": "", "passphrase": "webpack-dev-server", "pfx": "", + "requestCert": false, } `;