From e0788892862ce7c65d3c01f7952d882990e0ed6e Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 9 Sep 2021 13:09:38 +0530 Subject: [PATCH 01/14] fix: respect `https.cacert` option --- lib/Server.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Server.js b/lib/Server.js index 5a7d456b5f..0f5a9fc818 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -654,6 +654,11 @@ class Server { this.logger.info(`SSL certificate: ${certificatePath}`); } + if (options.https.cacert) { + options.https.ca = options.https.cacert; + delete options.https.cacert; + } + options.https.key = options.https.key || fakeCert; options.https.cert = options.https.cert || fakeCert; } From 36b0465a7068e82934c123113decf7df49bb6035 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Thu, 9 Sep 2021 14:18:52 +0300 Subject: [PATCH 02/14] feat: added `https.ca` option --- lib/Server.js | 12 +- lib/options.json | 11 ++ migration-v4.md | 4 +- .../validate-options.test.js.snap.webpack4 | 14 +- .../validate-options.test.js.snap.webpack5 | 14 +- .../__snapshots__/https.test.js.snap.webpack4 | 46 +++-- .../__snapshots__/https.test.js.snap.webpack5 | 46 +++-- test/e2e/https.test.js | 169 ++++++++++++++++-- test/validate-options.test.js | 7 + 9 files changed, 271 insertions(+), 52 deletions(-) diff --git a/lib/Server.js b/lib/Server.js index 0f5a9fc818..6e72f41946 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -517,7 +517,8 @@ class Server { // https option if (options.https) { - for (const property of ["cacert", "pfx", "key", "cert"]) { + // TODO remove the `cacert` option in favor `ca` in the next major release + for (const property of ["cacert", "ca", "pfx", "key", "cert"]) { const value = options.https[property]; const isBuffer = value instanceof Buffer; @@ -655,7 +656,14 @@ class Server { } if (options.https.cacert) { - options.https.ca = options.https.cacert; + if (options.https.ca) { + this.logger.warn( + "Do not specify 'https.ca' and 'https.cacert' options, the 'https.ca' option will be used" + ); + } else { + options.https.ca = options.https.cacert; + } + delete options.https.cacert; } diff --git a/lib/options.json b/lib/options.json index dba43c89f1..da8d1b6a26 100644 --- a/lib/options.json +++ b/lib/options.json @@ -211,6 +211,17 @@ "type": "boolean", "description": "Request for an SSL certificate." }, + "ca": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ], + "description": "Path to an SSL CA certificate." + }, "cacert": { "anyOf": [ { diff --git a/migration-v4.md b/migration-v4.md index a0f920bf51..84543d9e79 100644 --- a/migration-v4.md +++ b/migration-v4.md @@ -98,7 +98,7 @@ module.exports = { ``` - The `features` option was removed in favor `onBeforeSetupMiddleware` and `onAfterSetupMiddleware` options. -- The `key`, `cert`, `pfx`, `pfx-passphrase`, `cacert`, and `requestCert` options were moved to `https` options, please use `https.{key|cert|pfx|passphrase|requestCert|cacert}`. +- The `key`, `cert`, `pfx`, `pfx-passphrase`, `cacert`, `ca` and `requestCert` options were moved to `https` options, please use `https.{key|cert|pfx|passphrase|requestCert|ca}`. v3: @@ -121,7 +121,7 @@ v4: module.exports = { devServer: { https: { - cacert: "./server.pem", + ca: "./server.pem", pfx: "./server.pfx", key: "./server.key", cert: "./server.crt", diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack4 b/test/__snapshots__/validate-options.test.js.snap.webpack4 index c74393cbf8..18fa5d6464 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack4 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack4 @@ -322,19 +322,19 @@ exports[`options validate should throw an error on the "http2" option with '' va exports[`options validate should throw an error on the "https" 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.https should be one of these: - boolean | object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https should be a boolean. * options.https should be an object: - object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? }" + object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? }" `; exports[`options validate should throw an error on the "https" option with '{"cacert":true}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.https should be one of these: - boolean | object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: @@ -349,7 +349,7 @@ exports[`options validate should throw an error on the "https" option with '{"ca exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: @@ -364,13 +364,13 @@ exports[`options validate should throw an error on the "https" option with '{"ce exports[`options validate should throw an error on the "https" option with '{"foo":"bar"}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.https has an unknown property 'foo'. These properties are valid: - object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? }" + object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? }" `; exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: @@ -391,7 +391,7 @@ exports[`options validate should throw an error on the "https" option with '{"pa exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack5 b/test/__snapshots__/validate-options.test.js.snap.webpack5 index c74393cbf8..18fa5d6464 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack5 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack5 @@ -322,19 +322,19 @@ exports[`options validate should throw an error on the "http2" option with '' va exports[`options validate should throw an error on the "https" 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.https should be one of these: - boolean | object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https should be a boolean. * options.https should be an object: - object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? }" + object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? }" `; exports[`options validate should throw an error on the "https" option with '{"cacert":true}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.https should be one of these: - boolean | object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: @@ -349,7 +349,7 @@ exports[`options validate should throw an error on the "https" option with '{"ca exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: @@ -364,13 +364,13 @@ exports[`options validate should throw an error on the "https" option with '{"ce exports[`options validate should throw an error on the "https" option with '{"foo":"bar"}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.https has an unknown property 'foo'. These properties are valid: - object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? }" + object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? }" `; exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: @@ -391,7 +391,7 @@ exports[`options validate should throw an error on the "https" option with '{"pa exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: diff --git a/test/e2e/__snapshots__/https.test.js.snap.webpack4 b/test/e2e/__snapshots__/https.test.js.snap.webpack4 index 7599a45a04..02c3b72bc1 100644 --- a/test/e2e/__snapshots__/https.test.js.snap.webpack4 +++ b/test/e2e/__snapshots__/https.test.js.snap.webpack4 @@ -1,34 +1,56 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; +exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; -exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` +exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): response status 1`] = `200`; + +exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`https option as an object when cacert, pfx, key and cert are paths should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`https option as an object when cacert, pfx, key and cert are paths should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`https option as an object when cacert, pfx, key and cert are paths should handle GET request to index route (/): response status 1`] = `200`; +exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): response status 1`] = `200`; -exports[`https option as an object when cacert, pfx, key and cert are paths should handle GET request to index route (/): response text 1`] = ` +exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`https option as an object when cacert, pfx, key and cert are raw strings should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https 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[`https option as an object when cacert, pfx, key and cert are raw strings should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`https 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[`https option as an object when cacert, pfx, key and cert are raw strings should handle GET request to index route (/): response status 1`] = `200`; +exports[`https 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[`https option as an object when cacert, pfx, key and cert are raw strings should handle GET request to index route (/): response text 1`] = ` +exports[`https 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[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; + +exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; diff --git a/test/e2e/__snapshots__/https.test.js.snap.webpack5 b/test/e2e/__snapshots__/https.test.js.snap.webpack5 index 7599a45a04..02c3b72bc1 100644 --- a/test/e2e/__snapshots__/https.test.js.snap.webpack5 +++ b/test/e2e/__snapshots__/https.test.js.snap.webpack5 @@ -1,34 +1,56 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; +exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; -exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` +exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): response status 1`] = `200`; + +exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`https option as an object when cacert, pfx, key and cert are paths should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`https option as an object when cacert, pfx, key and cert are paths should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): page errors 1`] = `Array []`; -exports[`https option as an object when cacert, pfx, key and cert are paths should handle GET request to index route (/): response status 1`] = `200`; +exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): response status 1`] = `200`; -exports[`https option as an object when cacert, pfx, key and cert are paths should handle GET request to index route (/): response text 1`] = ` +exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; -exports[`https option as an object when cacert, pfx, key and cert are raw strings should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https 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[`https option as an object when cacert, pfx, key and cert are raw strings should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`https 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[`https option as an object when cacert, pfx, key and cert are raw strings should handle GET request to index route (/): response status 1`] = `200`; +exports[`https 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[`https option as an object when cacert, pfx, key and cert are raw strings should handle GET request to index route (/): response text 1`] = ` +exports[`https 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[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; + +exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` "Heyo. " `; diff --git a/test/e2e/https.test.js b/test/e2e/https.test.js index 00647e7dfe..8afdd6232e 100644 --- a/test/e2e/https.test.js +++ b/test/e2e/https.test.js @@ -82,7 +82,7 @@ describe("https option", () => { }); }); - describe("as an object when cacert, pfx, key and cert are buffer", () => { + describe("as an object when ca, pfx, key and cert are buffer", () => { let compiler; let server; let page; @@ -100,9 +100,7 @@ describe("https option", () => { watch: false, }, https: { - cacert: fs.readFileSync( - path.join(httpsCertificateDirectory, "ca.pem") - ), + ca: fs.readFileSync(path.join(httpsCertificateDirectory, "ca.pem")), pfx: fs.readFileSync( path.join(httpsCertificateDirectory, "server.pfx") ), @@ -157,7 +155,7 @@ describe("https option", () => { }); }); - describe("as an object when cacert, pfx, key and cert are paths", () => { + describe("as an object when ca, pfx, key and cert are paths", () => { let compiler; let server; let page; @@ -172,7 +170,7 @@ describe("https option", () => { { static: staticDirectory, https: { - cacert: path.join(httpsCertificateDirectory, "ca.pem"), + ca: path.join(httpsCertificateDirectory, "ca.pem"), pfx: path.join(httpsCertificateDirectory, "server.pfx"), key: path.join(httpsCertificateDirectory, "server.key"), cert: path.join(httpsCertificateDirectory, "server.crt"), @@ -221,7 +219,7 @@ describe("https option", () => { }); }); - describe("as an object when cacert, pfx, key and cert are symlinks", () => { + describe("as an object when ca, pfx, key and cert are symlinks", () => { if (skipTestOnWindows("Symlinks are not supported on Windows")) { return; } @@ -243,7 +241,7 @@ describe("https option", () => { watch: false, }, https: { - cacert: path.join(httpsCertificateDirectory, "ca-symlink.pem"), + 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"), @@ -290,7 +288,7 @@ describe("https option", () => { }); }); - describe("as an object when cacert, pfx, key and cert are raw strings", () => { + describe("as an object when ca, pfx, key and cert are raw strings", () => { let compiler; let server; let page; @@ -308,7 +306,7 @@ describe("https option", () => { watch: false, }, https: { - cacert: fs + ca: fs .readFileSync(path.join(httpsCertificateDirectory, "ca.pem")) .toString(), // pfx can't be string because it is binary format @@ -366,6 +364,157 @@ describe("https option", () => { }); }); + describe("as an object when cacert, pfx, key and cert are buffer", () => { + let compiler; + let server; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + https: { + 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 () => { + 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()).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 page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + + server = new Server( + { + static: { + directory: staticDirectory, + watch: false, + }, + https: { + 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 () => { + 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()).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 diff --git a/test/validate-options.test.js b/test/validate-options.test.js index d29126def2..2ce131b100 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -207,6 +207,13 @@ const tests = { cert: readFileSync(path.join(httpsCertificateDirectory, "server.crt")), passphrase: "webpack-dev-server", }, + { + ca: readFileSync(path.join(httpsCertificateDirectory, "ca.pem")), + pfx: readFileSync(path.join(httpsCertificateDirectory, "server.pfx")), + key: readFileSync(path.join(httpsCertificateDirectory, "server.key")), + cert: readFileSync(path.join(httpsCertificateDirectory, "server.crt")), + passphrase: "webpack-dev-server", + }, ], failure: [ "", From c409910ee9cfe8f4435113519cc3c9478a34176b Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Thu, 9 Sep 2021 14:43:29 +0300 Subject: [PATCH 03/14] test: more --- .../__snapshots__/https.test.js.snap.webpack4 | 146 ++++++++++++++++++ .../__snapshots__/https.test.js.snap.webpack5 | 146 ++++++++++++++++++ test/e2e/https.test.js | 79 +++++++--- test/helpers/normalize-options.js | 20 +++ 4 files changed, 373 insertions(+), 18 deletions(-) create mode 100644 test/helpers/normalize-options.js diff --git a/test/e2e/__snapshots__/https.test.js.snap.webpack4 b/test/e2e/__snapshots__/https.test.js.snap.webpack4 index 02c3b72bc1..59d71b1221 100644 --- a/test/e2e/__snapshots__/https.test.js.snap.webpack4 +++ b/test/e2e/__snapshots__/https.test.js.snap.webpack4 @@ -2,6 +2,16 @@ exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https 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": "", +} +`; + exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; @@ -13,6 +23,16 @@ exports[`https option as an object when ca, pfx, key and cert are buffer should exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "", + "cert": "", + "key": "", + "passphrase": "webpack-dev-server", + "pfx": "", +} +`; + exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): page errors 1`] = `Array []`; exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): response status 1`] = `200`; @@ -24,6 +44,92 @@ exports[`https option as an object when ca, pfx, key and cert are paths should h exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https option as an object when ca, pfx, key and cert are raw strings 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 +CgVjWNVAhysgtNtxRT4BVflffBXLVH2qsBjpsLRGU6EcMXuPGTiEp3YRHNuO6Aj8 +oP8fEsCGPc9DlJMGgxQRAKlrVF8TN/0j6Qk+YpS4MZ0YFQfBY+WdKu04Z8TVTplQ +tTkiGpBI+Oj85jF59aQiizglJgADkAZ6zmbrctm/G9jPxh7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bPZuycJSy1C9AIt0jlrxDsYm+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": "", +} +`; + exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): page errors 1`] = `Array []`; exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): response status 1`] = `200`; @@ -33,8 +139,28 @@ exports[`https option as an object when ca, pfx, key and cert are raw strings sh " `; +exports[`https option as an object when ca, pfx, key and cert are symlinks should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "", + "cert": "", + "key": "", + "passphrase": "webpack-dev-server", + "pfx": "", +} +`; + exports[`https 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[`https 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": "", +} +`; + exports[`https 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[`https 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`; @@ -46,6 +172,16 @@ exports[`https option as an object when cacert and ca, pfx, key and cert are buf exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https 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": "", +} +`; + exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; @@ -72,3 +208,13 @@ exports[`https option should support the "requestCert" option should handle GET "Heyo. " `; + +exports[`https 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, +} +`; diff --git a/test/e2e/__snapshots__/https.test.js.snap.webpack5 b/test/e2e/__snapshots__/https.test.js.snap.webpack5 index 02c3b72bc1..59d71b1221 100644 --- a/test/e2e/__snapshots__/https.test.js.snap.webpack5 +++ b/test/e2e/__snapshots__/https.test.js.snap.webpack5 @@ -2,6 +2,16 @@ exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https 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": "", +} +`; + exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; @@ -13,6 +23,16 @@ exports[`https option as an object when ca, pfx, key and cert are buffer should exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "", + "cert": "", + "key": "", + "passphrase": "webpack-dev-server", + "pfx": "", +} +`; + exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): page errors 1`] = `Array []`; exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): response status 1`] = `200`; @@ -24,6 +44,92 @@ exports[`https option as an object when ca, pfx, key and cert are paths should h exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https option as an object when ca, pfx, key and cert are raw strings 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 +CgVjWNVAhysgtNtxRT4BVflffBXLVH2qsBjpsLRGU6EcMXuPGTiEp3YRHNuO6Aj8 +oP8fEsCGPc9DlJMGgxQRA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XAH8uan8iVbxjIZKF1hnvNCxUoxYmWOmTLcEQMzmxvTzAiR+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": "", +} +`; + exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): page errors 1`] = `Array []`; exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): response status 1`] = `200`; @@ -33,8 +139,28 @@ exports[`https option as an object when ca, pfx, key and cert are raw strings sh " `; +exports[`https option as an object when ca, pfx, key and cert are symlinks should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": "", + "cert": "", + "key": "", + "passphrase": "webpack-dev-server", + "pfx": "", +} +`; + exports[`https 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[`https 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": "", +} +`; + exports[`https 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[`https 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`; @@ -46,6 +172,16 @@ exports[`https option as an object when cacert and ca, pfx, key and cert are buf exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https 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": "", +} +`; + exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `Array []`; exports[`https option as an object when cacert, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; @@ -72,3 +208,13 @@ exports[`https option should support the "requestCert" option should handle GET "Heyo. " `; + +exports[`https 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, +} +`; diff --git a/test/e2e/https.test.js b/test/e2e/https.test.js index 8afdd6232e..c1f4165f07 100644 --- a/test/e2e/https.test.js +++ b/test/e2e/https.test.js @@ -1,5 +1,6 @@ "use strict"; +const https = require("https"); const path = require("path"); const fs = require("graceful-fs"); const request = require("supertest"); @@ -8,6 +9,7 @@ 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")["https-option"]; const httpsCertificateDirectory = path.resolve( @@ -85,6 +87,7 @@ describe("https 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; @@ -93,6 +96,8 @@ describe("https option", () => { beforeEach(async () => { compiler = webpack(config); + createServerSpy = jest.spyOn(https, "createServer"); + server = new Server( { static: { @@ -126,6 +131,8 @@ describe("https option", () => { }); afterEach(async () => { + createServerSpy.mockRestore(); + await browser.close(); await server.stop(); }); @@ -143,14 +150,14 @@ describe("https option", () => { 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"); }); }); @@ -158,6 +165,7 @@ describe("https option", () => { describe("as an object when ca, pfx, key and cert are paths", () => { let compiler; let server; + let createServerSpy; let page; let browser; let pageErrors; @@ -166,6 +174,8 @@ describe("https option", () => { beforeEach(async () => { compiler = webpack(config); + createServerSpy = jest.spyOn(https, "createServer"); + server = new Server( { static: staticDirectory, @@ -190,6 +200,8 @@ describe("https option", () => { }); afterEach(async () => { + createServerSpy.mockRestore(); + await browser.close(); await server.stop(); }); @@ -207,14 +219,14 @@ describe("https option", () => { 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"); }); }); @@ -226,6 +238,7 @@ describe("https option", () => { let compiler; let server; + let createServerSpy; let page; let browser; let pageErrors; @@ -234,6 +247,8 @@ describe("https option", () => { beforeEach(async () => { compiler = webpack(config); + createServerSpy = jest.spyOn(https, "createServer"); + server = new Server( { static: { @@ -261,6 +276,8 @@ describe("https option", () => { }); afterEach(async () => { + createServerSpy.mockRestore(); + await browser.close(); await server.stop(); }); @@ -278,12 +295,12 @@ describe("https option", () => { waitUntil: "networkidle0", }); + expect( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); expect(response.status()).toEqual(200); - expect(await response.text()).toContain("Heyo"); - expect(consoleMessages.map((message) => message.text())).toEqual([]); - expect(pageErrors).toEqual([]); }); }); @@ -291,6 +308,7 @@ describe("https option", () => { describe("as an object when ca, pfx, key and cert are raw strings", () => { let compiler; let server; + let createServerSpy; let page; let browser; let pageErrors; @@ -299,6 +317,8 @@ describe("https option", () => { beforeEach(async () => { compiler = webpack(config); + createServerSpy = jest.spyOn(https, "createServer"); + server = new Server( { static: { @@ -335,6 +355,8 @@ describe("https option", () => { }); afterEach(async () => { + createServerSpy.mockRestore(); + await browser.close(); await server.stop(); }); @@ -352,14 +374,14 @@ describe("https option", () => { 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"); }); }); @@ -367,6 +389,7 @@ describe("https option", () => { describe("as an object when cacert, pfx, key and cert are buffer", () => { let compiler; let server; + let createServerSpy; let page; let browser; let pageErrors; @@ -375,6 +398,8 @@ describe("https option", () => { beforeEach(async () => { compiler = webpack(config); + createServerSpy = jest.spyOn(https, "createServer"); + server = new Server( { static: { @@ -410,6 +435,8 @@ describe("https option", () => { }); afterEach(async () => { + createServerSpy.mockRestore(); + await browser.close(); await server.stop(); }); @@ -427,14 +454,14 @@ describe("https option", () => { 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"); }); }); @@ -442,6 +469,7 @@ describe("https option", () => { 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; @@ -450,6 +478,8 @@ describe("https option", () => { beforeEach(async () => { compiler = webpack(config); + createServerSpy = jest.spyOn(https, "createServer"); + server = new Server( { static: { @@ -486,6 +516,8 @@ describe("https option", () => { }); afterEach(async () => { + createServerSpy.mockRestore(); + await browser.close(); await server.stop(); }); @@ -503,14 +535,14 @@ describe("https option", () => { 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"); }); }); @@ -521,11 +553,14 @@ describe("https option", () => { 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: { @@ -556,9 +591,17 @@ describe("https option", () => { }); 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("/"); diff --git a/test/helpers/normalize-options.js b/test/helpers/normalize-options.js new file mode 100644 index 0000000000..2c06c493fe --- /dev/null +++ b/test/helpers/normalize-options.js @@ -0,0 +1,20 @@ +"use strict"; + +function normalizeOptions(options) { + const normalizedOptions = {}; + + // eslint-disable-next-line guard-for-in + for (const propertyName in options) { + let value = options[propertyName]; + + if (Buffer.isBuffer(value)) { + value = ""; + } + + normalizedOptions[propertyName] = value; + } + + return normalizedOptions; +} + +module.exports = normalizeOptions; From d2da02bd0475843b1aa4297ce1fd7ba453a5fb29 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Thu, 9 Sep 2021 14:53:10 +0300 Subject: [PATCH 04/14] feat: allow more https options --- lib/Server.js | 2 +- lib/options.json | 2 +- .../validate-options.test.js.snap.webpack4 | 18 ++--- .../validate-options.test.js.snap.webpack5 | 18 ++--- .../__snapshots__/https.test.js.snap.webpack4 | 22 ++++++ .../__snapshots__/https.test.js.snap.webpack5 | 22 ++++++ test/e2e/https.test.js | 79 +++++++++++++++++++ test/validate-options.test.js | 11 ++- 8 files changed, 145 insertions(+), 29 deletions(-) diff --git a/lib/Server.js b/lib/Server.js index 6e72f41946..cf6460ae6c 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -658,7 +658,7 @@ class Server { if (options.https.cacert) { if (options.https.ca) { this.logger.warn( - "Do not specify 'https.ca' and 'https.cacert' options, the 'https.ca' option will be used" + "Do not specify 'https.ca' and 'https.cacert' options together, the 'https.ca' option will be used." ); } else { options.https.ca = options.https.cacert; diff --git a/lib/options.json b/lib/options.json index da8d1b6a26..8786b245f6 100644 --- a/lib/options.json +++ b/lib/options.json @@ -201,7 +201,7 @@ }, { "type": "object", - "additionalProperties": false, + "additionalProperties": true, "properties": { "passphrase": { "type": "string", diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack4 b/test/__snapshots__/validate-options.test.js.snap.webpack4 index 18fa5d6464..12e52a17ab 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack4 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack4 @@ -322,19 +322,19 @@ exports[`options validate should throw an error on the "http2" option with '' va exports[`options validate should throw an error on the "https" 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.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https should be a boolean. * options.https should be an object: - object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? }" + object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … }" `; exports[`options validate should throw an error on the "https" option with '{"cacert":true}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: @@ -349,7 +349,7 @@ exports[`options validate should throw an error on the "https" option with '{"ca exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: @@ -361,16 +361,10 @@ exports[`options validate should throw an error on the "https" option with '{"ce * options.https.cert should be an instance of Buffer." `; -exports[`options validate should throw an error on the "https" option with '{"foo":"bar"}' value 1`] = ` -"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - - options.https has an unknown property 'foo'. These properties are valid: - object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? }" -`; - exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: @@ -391,7 +385,7 @@ exports[`options validate should throw an error on the "https" option with '{"pa exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack5 b/test/__snapshots__/validate-options.test.js.snap.webpack5 index 18fa5d6464..12e52a17ab 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack5 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack5 @@ -322,19 +322,19 @@ exports[`options validate should throw an error on the "http2" option with '' va exports[`options validate should throw an error on the "https" 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.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https should be a boolean. * options.https should be an object: - object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? }" + object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … }" `; exports[`options validate should throw an error on the "https" option with '{"cacert":true}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: @@ -349,7 +349,7 @@ exports[`options validate should throw an error on the "https" option with '{"ca exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: @@ -361,16 +361,10 @@ exports[`options validate should throw an error on the "https" option with '{"ce * options.https.cert should be an instance of Buffer." `; -exports[`options validate should throw an error on the "https" option with '{"foo":"bar"}' value 1`] = ` -"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - - options.https has an unknown property 'foo'. These properties are valid: - object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? }" -`; - exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: @@ -391,7 +385,7 @@ exports[`options validate should throw an error on the "https" option with '{"pa exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert? } + boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: diff --git a/test/e2e/__snapshots__/https.test.js.snap.webpack4 b/test/e2e/__snapshots__/https.test.js.snap.webpack4 index 59d71b1221..e67d6406f6 100644 --- a/test/e2e/__snapshots__/https.test.js.snap.webpack4 +++ b/test/e2e/__snapshots__/https.test.js.snap.webpack4 @@ -1,5 +1,27 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`https option as an object and allow to pass more options should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`https 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": "", +} +`; + +exports[`https option as an object and allow to pass more options should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`https option as an object and allow to pass more options should handle GET request to index route (/): response status 1`] = `200`; + +exports[`https option as an object and allow to pass more options should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` diff --git a/test/e2e/__snapshots__/https.test.js.snap.webpack5 b/test/e2e/__snapshots__/https.test.js.snap.webpack5 index 59d71b1221..e67d6406f6 100644 --- a/test/e2e/__snapshots__/https.test.js.snap.webpack5 +++ b/test/e2e/__snapshots__/https.test.js.snap.webpack5 @@ -1,5 +1,27 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`https option as an object and allow to pass more options should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`https 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": "", +} +`; + +exports[`https option as an object and allow to pass more options should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`https option as an object and allow to pass more options should handle GET request to index route (/): response status 1`] = `200`; + +exports[`https option as an object and allow to pass more options should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` diff --git a/test/e2e/https.test.js b/test/e2e/https.test.js index c1f4165f07..afe43e2a9f 100644 --- a/test/e2e/https.test.js +++ b/test/e2e/https.test.js @@ -547,6 +547,85 @@ describe("https option", () => { }); }); + 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, + }, + https: { + 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 diff --git a/test/validate-options.test.js b/test/validate-options.test.js index 2ce131b100..2de8669be1 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -214,12 +214,17 @@ const tests = { cert: readFileSync(path.join(httpsCertificateDirectory, "server.crt")), passphrase: "webpack-dev-server", }, + { + minVersion: "TLSv1.1", + ca: readFileSync(path.join(httpsCertificateDirectory, "ca.pem")), + pfx: readFileSync(path.join(httpsCertificateDirectory, "server.pfx")), + key: readFileSync(path.join(httpsCertificateDirectory, "server.key")), + cert: readFileSync(path.join(httpsCertificateDirectory, "server.crt")), + passphrase: "webpack-dev-server", + }, ], failure: [ "", - { - foo: "bar", - }, { key: 10, }, From 844fb8a38f2f9fa2215d69d0f7c37c92fe0fa0ef Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Thu, 9 Sep 2021 15:22:07 +0300 Subject: [PATCH 05/14] feat: accept `crl` as path to file --- lib/Server.js | 2 +- .../__snapshots__/https.test.js.snap.webpack4 | 21 ------ .../__snapshots__/https.test.js.snap.webpack5 | 21 ------ test/e2e/https.test.js | 69 ------------------- 4 files changed, 1 insertion(+), 112 deletions(-) diff --git a/lib/Server.js b/lib/Server.js index cf6460ae6c..e3995367be 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -518,7 +518,7 @@ class Server { // https option if (options.https) { // TODO remove the `cacert` option in favor `ca` in the next major release - for (const property of ["cacert", "ca", "pfx", "key", "cert"]) { + for (const property of ["cacert", "ca", "cert", "crl", "key", "pfx"]) { const value = options.https[property]; const isBuffer = value instanceof Buffer; diff --git a/test/e2e/__snapshots__/https.test.js.snap.webpack4 b/test/e2e/__snapshots__/https.test.js.snap.webpack4 index e67d6406f6..1b017450c1 100644 --- a/test/e2e/__snapshots__/https.test.js.snap.webpack4 +++ b/test/e2e/__snapshots__/https.test.js.snap.webpack4 @@ -43,27 +43,6 @@ exports[`https option as an object when ca, pfx, key and cert are buffer should " `; -exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): console messages 1`] = `Array []`; - -exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): https options 1`] = ` -Object { - "ca": "", - "cert": "", - "key": "", - "passphrase": "webpack-dev-server", - "pfx": "", -} -`; - -exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): page errors 1`] = `Array []`; - -exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): response status 1`] = `200`; - -exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): console messages 1`] = `Array []`; exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): https options 1`] = ` diff --git a/test/e2e/__snapshots__/https.test.js.snap.webpack5 b/test/e2e/__snapshots__/https.test.js.snap.webpack5 index e67d6406f6..1b017450c1 100644 --- a/test/e2e/__snapshots__/https.test.js.snap.webpack5 +++ b/test/e2e/__snapshots__/https.test.js.snap.webpack5 @@ -43,27 +43,6 @@ exports[`https option as an object when ca, pfx, key and cert are buffer should " `; -exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): console messages 1`] = `Array []`; - -exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): https options 1`] = ` -Object { - "ca": "", - "cert": "", - "key": "", - "passphrase": "webpack-dev-server", - "pfx": "", -} -`; - -exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): page errors 1`] = `Array []`; - -exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): response status 1`] = `200`; - -exports[`https option as an object when ca, pfx, key and cert are paths should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): console messages 1`] = `Array []`; exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): https options 1`] = ` diff --git a/test/e2e/https.test.js b/test/e2e/https.test.js index afe43e2a9f..a6c4bbbdac 100644 --- a/test/e2e/https.test.js +++ b/test/e2e/https.test.js @@ -162,75 +162,6 @@ describe("https option", () => { }); }); - describe("as an object when ca, pfx, key and cert are paths", () => { - 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: staticDirectory, - https: { - 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; From d2c797a28f39b7b1eb6b131a684a747d31043763 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Thu, 9 Sep 2021 15:53:08 +0300 Subject: [PATCH 06/14] feat: accept https options as array of string/buffers/paths --- lib/Server.js | 35 +- lib/options.json | 105 +++++- .../validate-options.test.js.snap.webpack5 | 44 ++- .../__snapshots__/https.test.js.snap.webpack4 | 184 +++++++++ .../__snapshots__/https.test.js.snap.webpack5 | 184 +++++++++ test/e2e/https.test.js | 349 +++++++++++++++++- test/helpers/normalize-options.js | 10 +- test/validate-options.test.js | 65 +++- 8 files changed, 919 insertions(+), 57 deletions(-) diff --git a/lib/Server.js b/lib/Server.js index e3995367be..fca3225fb6 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -519,23 +519,34 @@ class Server { if (options.https) { // 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") { + // eslint-disable-next-line no-continue + continue; + } + const value = options.https[property]; - const isBuffer = value instanceof Buffer; + const readFile = (item) => { + if (Buffer.isBuffer(item)) { + return item; + } - if (value && !isBuffer) { - let stats = null; + if (item) { + let stats = null; - try { - stats = fs.lstatSync(fs.realpathSync(value)).isFile(); - } catch (error) { - // ignore error + try { + stats = fs.lstatSync(fs.realpathSync(item)).isFile(); + } catch (error) { + // Ignore error + } + + // It is file + return stats ? fs.readFileSync(item) : item; } + }; - // It is file - options.https[property] = stats - ? fs.readFileSync(path.resolve(value)) - : value; - } + options.https[property] = Array.isArray(value) + ? value.map((item) => readFile(item)) + : readFile(value); } let fakeCert; diff --git a/lib/options.json b/lib/options.json index 8786b245f6..fa038d3080 100644 --- a/lib/options.json +++ b/lib/options.json @@ -218,9 +218,22 @@ }, { "instanceof": "Buffer" + }, + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] + } } ], - "description": "Path to an SSL CA certificate." + "description": "Path to an SSL CA certificate or ." }, "cacert": { "anyOf": [ @@ -229,42 +242,118 @@ }, { "instanceof": "Buffer" + }, + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] + } } ], - "description": "Path to an SSL CA certificate." + "description": "Path to an SSL CA certificate or content of an SSL CA certificate." }, - "key": { + "cert": { "anyOf": [ { "type": "string" }, { "instanceof": "Buffer" + }, + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] + } } ], - "description": "Path to an SSL key." + "description": "Path to an SSL certificate or content of an SSL certificate." }, - "pfx": { + "crl": { "anyOf": [ { "type": "string" }, { "instanceof": "Buffer" + }, + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] + } } ], - "description": "Path to an SSL pfx file." + "description": "Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists)." }, - "cert": { + "key": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + }, + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] + } + } + ], + "description": "Path to an SSL key or content of an SSL key." + }, + "pfx": { "anyOf": [ { "type": "string" }, { "instanceof": "Buffer" + }, + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] + } } ], - "description": "Path to an SSL certificate." + "description": "Path to an SSL pfx file or content of an SSL pfx file." } } } diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack5 b/test/__snapshots__/validate-options.test.js.snap.webpack5 index 12e52a17ab..5a981d276a 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack5 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack5 @@ -322,58 +322,64 @@ exports[`options validate should throw an error on the "http2" option with '' va exports[`options validate should throw an error on the "https" 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.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } + boolean | object { passphrase?, requestCert?, ca?, cacert?, cert?, crl?, key?, pfx?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https should be a boolean. * options.https should be an object: - object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … }" + object { passphrase?, requestCert?, ca?, cacert?, cert?, crl?, key?, pfx?, … }" `; exports[`options validate should throw an error on the "https" option with '{"cacert":true}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } + boolean | object { passphrase?, requestCert?, ca?, cacert?, cert?, crl?, key?, pfx?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https.cacert should be one of these: - string | Buffer - -> Path to an SSL CA certificate. + string | Buffer | [string | Buffer, ...] + -> Path to an SSL CA certificate or content of an SSL CA certificate. Details: * options.https.cacert should be a string. - * options.https.cacert should be an instance of Buffer." + * options.https.cacert should be an instance of Buffer. + * options.https.cacert should be an array: + [string | Buffer, ...]" `; exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } + boolean | object { passphrase?, requestCert?, ca?, cacert?, cert?, crl?, key?, pfx?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https.cert should be one of these: - string | Buffer - -> Path to an SSL certificate. + string | Buffer | [string | Buffer, ...] + -> Path to an SSL certificate or content of an SSL certificate. Details: * options.https.cert should be a string. - * options.https.cert should be an instance of Buffer." + * options.https.cert should be an instance of Buffer. + * options.https.cert should be an array: + [string | Buffer, ...]" `; exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } + boolean | object { passphrase?, requestCert?, ca?, cacert?, cert?, crl?, key?, pfx?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https.key should be one of these: - string | Buffer - -> Path to an SSL key. + string | Buffer | [string | Buffer, ...] + -> Path to an SSL key or content of an SSL key. Details: * options.https.key should be a string. - * options.https.key should be an instance of Buffer." + * options.https.key should be an instance of Buffer. + * options.https.key should be an array: + [string | Buffer, ...]" `; exports[`options validate should throw an error on the "https" option with '{"passphrase":false}' value 1`] = ` @@ -385,16 +391,18 @@ exports[`options validate should throw an error on the "https" option with '{"pa exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } + boolean | object { passphrase?, requestCert?, ca?, cacert?, cert?, crl?, key?, pfx?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https.pfx should be one of these: - string | Buffer - -> Path to an SSL pfx file. + string | Buffer | [string | Buffer, ...] + -> Path to an SSL pfx file or content of an SSL pfx file. Details: * options.https.pfx should be a string. - * options.https.pfx should be an instance of Buffer." + * options.https.pfx should be an instance of Buffer. + * options.https.pfx should be an array: + [string | Buffer, ...]" `; exports[`options validate should throw an error on the "https" option with '{"requestCert":"test"}' value 1`] = ` diff --git a/test/e2e/__snapshots__/https.test.js.snap.webpack4 b/test/e2e/__snapshots__/https.test.js.snap.webpack4 index 1b017450c1..7409525fb6 100644 --- a/test/e2e/__snapshots__/https.test.js.snap.webpack4 +++ b/test/e2e/__snapshots__/https.test.js.snap.webpack4 @@ -22,6 +22,169 @@ exports[`https option as an object and allow to pass more options should handle " `; +exports[`https 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[`https 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 [ + "", + ], +} +`; + +exports[`https 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[`https 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[`https 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[`https 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[`https 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 [ + "", + ], +} +`; + +exports[`https 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[`https 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[`https 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[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`https option as an object when ca, pfx, key and cert are array of raw 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 +EENnH6sUE9HxPUgQmNt1Tbd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jrIvv9fSbycNveGTDCsNNTiYoW +QyvMqmN1kGy20SZbQDD/fLfqBQ== +-----END PRIVATE KEY----- +", + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + "", + ], +} +`; + +exports[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): response status 1`] = `200`; + +exports[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` @@ -43,6 +206,27 @@ exports[`https option as an object when ca, pfx, key and cert are buffer should " `; +exports[`https 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[`https 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": "", +} +`; + +exports[`https 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[`https 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[`https 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[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): console messages 1`] = `Array []`; exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): https options 1`] = ` diff --git a/test/e2e/__snapshots__/https.test.js.snap.webpack5 b/test/e2e/__snapshots__/https.test.js.snap.webpack5 index 1b017450c1..7409525fb6 100644 --- a/test/e2e/__snapshots__/https.test.js.snap.webpack5 +++ b/test/e2e/__snapshots__/https.test.js.snap.webpack5 @@ -22,6 +22,169 @@ exports[`https option as an object and allow to pass more options should handle " `; +exports[`https 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[`https 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 [ + "", + ], +} +`; + +exports[`https 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[`https 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[`https 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[`https 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[`https 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 [ + "", + ], +} +`; + +exports[`https 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[`https 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[`https 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[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): console messages 1`] = `Array []`; + +exports[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): https options 1`] = ` +Object { + "ca": Array [ + "-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kv +C/hf5Ei1J6qruJs3Xqg86Nl4+ed4ynUajAkRRibhp0P1SG1tgPssIK6iC7g8heYu +Dy9WkFuMie0513zjSn6bMEAK5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giThj7inMcbpkZlIclxD0Eu6 +Lof+ctCeqSAJvaVPmd+nv8Yp26zsF1yM8ax9xXjrIvv9fSbycNveGTDCsNNTiYoW +QyvMqmN1kGy20SZbQDD/fLfqBQ== +-----END PRIVATE KEY----- +", + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + "", + ], +} +`; + +exports[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): response status 1`] = `200`; + +exports[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `Array []`; exports[`https option as an object when ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` @@ -43,6 +206,27 @@ exports[`https option as an object when ca, pfx, key and cert are buffer should " `; +exports[`https 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[`https 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": "", +} +`; + +exports[`https 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[`https 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[`https 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[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): console messages 1`] = `Array []`; exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): https options 1`] = ` diff --git a/test/e2e/https.test.js b/test/e2e/https.test.js index a6c4bbbdac..1fa439be12 100644 --- a/test/e2e/https.test.js +++ b/test/e2e/https.test.js @@ -162,11 +162,7 @@ describe("https option", () => { }); }); - describe("as an object when ca, pfx, key and cert are symlinks", () => { - if (skipTestOnWindows("Symlinks are not supported on Windows")) { - return; - } - + describe("as an object when ca, pfx, key and cert are array of buffers", () => { let compiler; let server; let createServerSpy; @@ -187,10 +183,24 @@ describe("https option", () => { watch: false, }, https: { - 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"), + 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, @@ -229,10 +239,12 @@ describe("https option", () => { expect( normalizeOptions(createServerSpy.mock.calls[0][0]) ).toMatchSnapshot("https options"); - expect(response.status()).toEqual(200); - expect(await response.text()).toContain("Heyo"); - expect(consoleMessages.map((message) => message.text())).toEqual([]); - expect(pageErrors).toEqual([]); + 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"); }); }); @@ -317,6 +329,317 @@ describe("https option", () => { }); }); + describe("as an object when ca, pfx, key and cert are array of raw 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, + }, + https: { + 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, + }, + https: { + 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, + }, + https: { + 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, + }, + https: { + 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( + normalizeOptions(createServerSpy.mock.calls[0][0]) + ).toMatchSnapshot("https options"); + 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; diff --git a/test/helpers/normalize-options.js b/test/helpers/normalize-options.js index 2c06c493fe..a6bc925205 100644 --- a/test/helpers/normalize-options.js +++ b/test/helpers/normalize-options.js @@ -7,7 +7,15 @@ function normalizeOptions(options) { for (const propertyName in options) { let value = options[propertyName]; - if (Buffer.isBuffer(value)) { + if (Array.isArray(value)) { + value = value.map((item) => { + if (Buffer.isBuffer(item)) { + return ""; + } + + return item; + }); + } else if (Buffer.isBuffer(value)) { value = ""; } diff --git a/test/validate-options.test.js b/test/validate-options.test.js index 2de8669be1..c5530de958 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -192,6 +192,60 @@ const tests = { success: [ false, true, + { + ca: readFileSync( + path.join(httpsCertificateDirectory, "ca.pem") + ).toString(), + pfx: readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ).toString(), + key: readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ).toString(), + cert: readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ).toString(), + passphrase: "webpack-dev-server", + }, + { + ca: [ + readFileSync( + path.join(httpsCertificateDirectory, "ca.pem") + ).toString(), + ], + pfx: [ + readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ).toString(), + ], + key: [ + readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ).toString(), + ], + cert: [ + readFileSync( + path.join(httpsCertificateDirectory, "server.crt") + ).toString(), + ], + passphrase: "webpack-dev-server", + }, + { + ca: readFileSync(path.join(httpsCertificateDirectory, "ca.pem")), + pfx: readFileSync(path.join(httpsCertificateDirectory, "server.pfx")), + key: readFileSync(path.join(httpsCertificateDirectory, "server.key")), + cert: readFileSync(path.join(httpsCertificateDirectory, "server.crt")), + passphrase: "webpack-dev-server", + }, + { + ca: [readFileSync(path.join(httpsCertificateDirectory, "ca.pem"))], + pfx: [readFileSync(path.join(httpsCertificateDirectory, "server.pfx"))], + key: [readFileSync(path.join(httpsCertificateDirectory, "server.key"))], + cert: [ + readFileSync(path.join(httpsCertificateDirectory, "server.crt")), + ], + passphrase: "webpack-dev-server", + }, { cacert: path.join(httpsCertificateDirectory, "ca.pem"), key: path.join(httpsCertificateDirectory, "server.key"), @@ -201,14 +255,15 @@ const tests = { passphrase: "webpack-dev-server", }, { - cacert: readFileSync(path.join(httpsCertificateDirectory, "ca.pem")), - pfx: readFileSync(path.join(httpsCertificateDirectory, "server.pfx")), - key: readFileSync(path.join(httpsCertificateDirectory, "server.key")), - cert: readFileSync(path.join(httpsCertificateDirectory, "server.crt")), + cacert: [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", }, { - ca: readFileSync(path.join(httpsCertificateDirectory, "ca.pem")), + cacert: readFileSync(path.join(httpsCertificateDirectory, "ca.pem")), pfx: readFileSync(path.join(httpsCertificateDirectory, "server.pfx")), key: readFileSync(path.join(httpsCertificateDirectory, "server.key")), cert: readFileSync(path.join(httpsCertificateDirectory, "server.crt")), From c6a2ea7ba64d9b26f4ab1ffb91bd8fb890bbc0c4 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Thu, 9 Sep 2021 16:03:27 +0300 Subject: [PATCH 07/14] docs: update examples --- examples/http2/README.md | 4 ++-- examples/https/README.md | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/http2/README.md b/examples/http2/README.md index 9577973ad2..87c080f003 100644 --- a/examples/http2/README.md +++ b/examples/http2/README.md @@ -36,7 +36,7 @@ module.exports = { key: "./ssl/server.key", pfx: "./ssl/server.pfx", cert: "./ssl/server.crt", - cacert: "./ssl/ca.pem", + ca: "./ssl/ca.pem", passphrase: "webpack-dev-server", }, }, @@ -46,7 +46,7 @@ module.exports = { Usage via CLI: ```console -npx webpack serve --open --http2 --https-key ./ssl/server.key --https-pfx ./ssl/server.pfx --https-cert ./ssl/server.crt --https-cacert ./ssl/ca.pem --https-passphrase webpack-dev-server +npx webpack serve --open --http2 --https-key ./ssl/server.key --https-pfx ./ssl/server.pfx --https-cert ./ssl/server.crt --https-ca ./ssl/ca.pem --https-passphrase webpack-dev-server ``` ## What Should Happen diff --git a/examples/https/README.md b/examples/https/README.md index 2a04e83158..2d766d829e 100644 --- a/examples/https/README.md +++ b/examples/https/README.md @@ -28,7 +28,7 @@ Customize `https` configuration with the following options: - `key`: Path to an SSL key. - `pfx`: Path to an SSL pfx file. - `cert`: Path to an SSL certificate. -- `cacert`: Path to an SSL CA certificate. +- `ca`: Path to an SSL CA certificate. - `passphrase`: Passphrase for a pfx file. - `requestCert`: Request for an SSL certificate. @@ -40,7 +40,7 @@ module.exports = { key: "./ssl/server.key", pfx: "./ssl/server.pfx", cert: "./ssl/server.crt", - cacert: "./ssl/ca.pem", + ca: "./ssl/ca.pem", passphrase: "webpack-dev-server", requestCert: true, }, @@ -51,7 +51,7 @@ module.exports = { Usage via CLI: ```console -npx webpack serve --open --https-key ./ssl/server.key --https-pfx ./ssl/server.pfx --https-cert ./ssl/server.crt --https-cacert ./ssl/ca.pem --https-passphrase webpack-dev-server --https-request-cert +npx webpack serve --open --https-key ./ssl/server.key --https-pfx ./ssl/server.pfx --https-cert ./ssl/server.crt --https-ca ./ssl/ca.pem --https-passphrase webpack-dev-server --https-request-cert ``` ## What Should Happen From d2d75004d552d40888d3522409ebda3450b3432e Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Thu, 9 Sep 2021 16:26:24 +0300 Subject: [PATCH 08/14] feat: cli options --- bin/cli-flags.js | 145 ++++++++++++++++-- lib/options.json | 74 ++++----- .../__snapshots__/basic.test.js.snap.webpack5 | 16 +- 3 files changed, 183 insertions(+), 52 deletions(-) diff --git a/bin/cli-flags.js b/bin/cli-flags.js index ed9aece694..55e36d7bc4 100644 --- a/bin/cli-flags.js +++ b/bin/cli-flags.js @@ -445,57 +445,180 @@ module.exports = { simpleType: "boolean", multiple: false, }, + "https-ca": { + configs: [ + { + type: "string", + multiple: true, + description: + "Path to an SSL CA certificate or content of an SSL CA certificate.", + path: "https.ca[]", + }, + ], + description: + "Path to an SSL CA certificate or content of an SSL CA certificate.", + simpleType: "string", + multiple: true, + }, + "https-ca-reset": { + configs: [ + { + description: + "Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate.", + 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.", + multiple: false, + simpleType: "boolean", + }, "https-cacert": { configs: [ { type: "string", + multiple: true, + description: + "Path to an SSL CA certificate or content of an SSL CA certificate.", + path: "https.cacert[]", + }, + ], + description: + "Path to an SSL CA certificate or content of an SSL CA certificate.", + simpleType: "string", + multiple: true, + }, + "https-cacert-reset": { + configs: [ + { + description: + "Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate.", multiple: false, - description: "Path to an SSL CA certificate.", path: "https.cacert", + type: "reset", }, ], - description: "Path to an SSL CA certificate.", - simpleType: "string", + description: + "Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate.", multiple: false, + simpleType: "boolean", }, "https-key": { configs: [ { type: "string", + multiple: true, + description: "Path to an SSL key or content of an SSL key.", + path: "https.key[]", + }, + ], + description: "Path to an SSL key or content of an SSL key.", + simpleType: "string", + multiple: true, + }, + "https-key-reset": { + configs: [ + { + description: + "Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key.", multiple: false, - description: "Path to an SSL key.", path: "https.key", + type: "reset", }, ], - description: "Path to an SSL key.", - simpleType: "string", + description: + "Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key.", multiple: false, + simpleType: "boolean", }, "https-pfx": { configs: [ { type: "string", + multiple: true, + description: "Path to an SSL pfx file or content of an SSL pfx file.", + path: "https.pfx[]", + }, + ], + description: "Path to an SSL pfx file or content of an SSL pfx file.", + simpleType: "string", + multiple: true, + }, + "https-pfx-reset": { + configs: [ + { + description: + "Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file.", multiple: false, - description: "Path to an SSL pfx file.", path: "https.pfx", + type: "reset", }, ], - description: "Path to an SSL pfx file.", - simpleType: "string", + description: + "Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file.", multiple: false, + simpleType: "boolean", }, "https-cert": { configs: [ { type: "string", + multiple: true, + description: + "Path to an SSL certificate or content of an SSL certificate.", + path: "https.cert[]", + }, + ], + description: "Path to an SSL certificate or content of an SSL certificate.", + simpleType: "string", + multiple: true, + }, + "https-cert-reset": { + configs: [ + { + description: + "Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate.", multiple: false, - description: "Path to an SSL certificate.", 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.", + multiple: false, + simpleType: "boolean", + }, + "https-crl": { + configs: [ + { + description: + "Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).", + multiple: true, + path: "https.crl[]", + type: "string", }, ], - description: "Path to an SSL certificate.", + description: + "Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).", + multiple: true, simpleType: "string", + }, + "https-crl-reset": { + 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).", + 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).", multiple: false, + simpleType: "boolean", }, ipc: { configs: [ diff --git a/lib/options.json b/lib/options.json index fa038d3080..08845c0a45 100644 --- a/lib/options.json +++ b/lib/options.json @@ -213,12 +213,6 @@ }, "ca": { "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" - }, { "type": "array", "items": { @@ -231,18 +225,18 @@ } ] } - } - ], - "description": "Path to an SSL CA certificate or ." - }, - "cacert": { - "anyOf": [ + }, { "type": "string" }, { "instanceof": "Buffer" - }, + } + ], + "description": "Path to an SSL CA certificate or content of an SSL CA certificate." + }, + "cacert": { + "anyOf": [ { "type": "array", "items": { @@ -255,18 +249,18 @@ } ] } + }, + { + "type": "string" + }, + { + "instanceof": "Buffer" } ], "description": "Path to an SSL CA certificate or content of an SSL CA certificate." }, "cert": { "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" - }, { "type": "array", "items": { @@ -279,18 +273,18 @@ } ] } + }, + { + "type": "string" + }, + { + "instanceof": "Buffer" } ], "description": "Path to an SSL certificate or content of an SSL certificate." }, "crl": { "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" - }, { "type": "array", "items": { @@ -303,18 +297,18 @@ } ] } + }, + { + "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": "string" - }, - { - "instanceof": "Buffer" - }, { "type": "array", "items": { @@ -327,18 +321,18 @@ } ] } + }, + { + "type": "string" + }, + { + "instanceof": "Buffer" } ], "description": "Path to an SSL key or content of an SSL key." }, "pfx": { "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" - }, { "type": "array", "items": { @@ -351,6 +345,12 @@ } ] } + }, + { + "type": "string" + }, + { + "instanceof": "Buffer" } ], "description": "Path to an SSL pfx file or content of an SSL pfx file." diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack5 b/test/cli/__snapshots__/basic.test.js.snap.webpack5 index a9abd9cc46..e9ea671b59 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack5 @@ -91,10 +91,18 @@ Options: --https-passphrase Passphrase for a pfx file. --https-request-cert Request for an SSL certificate. --no-https-request-cert Negative 'https-request-cert' option. - --https-cacert Path to an SSL CA certificate. - --https-key Path to an SSL key. - --https-pfx Path to an SSL pfx file. - --https-cert Path to 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-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. --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 29944ce488394ba7760d160ab6ea26a5923fb1f3 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Thu, 9 Sep 2021 16:32:30 +0300 Subject: [PATCH 09/14] test: update snapshots --- .../__snapshots__/basic.test.js.snap.webpack4 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack4 b/test/cli/__snapshots__/basic.test.js.snap.webpack4 index 27f826749d..0e593d2855 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack4 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack4 @@ -92,10 +92,18 @@ Options: --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-cacert Path to an SSL CA certificate. - --https-key Path to an SSL key. - --https-pfx Path to an SSL pfx file. - --https-cert Path to 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). --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) From 89708063cbd31b4faa56398b374e21709f78b2c2 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Thu, 9 Sep 2021 16:34:37 +0300 Subject: [PATCH 10/14] docs: update CLI options --- README.md | 91 +++++++++++++++++++++++++++---------------------------- 1 file changed, 44 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 598dcbcd3c..6b84460521 100644 --- a/README.md +++ b/README.md @@ -73,76 +73,78 @@ Options: --node-env Sets process.env.NODE_ENV to the specified value. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. + --entry The entry point(s) of your application e.g. ./src/main.js. + -o, --output-path Output location of the file generated by webpack e.g. ./dist/. + -t, --target Sets the build target e.g. node. -d, --devtool Determine source maps to use. --no-devtool Do not generate source maps. - --entry The entry point(s) of your application e.g. ./src/main.js. --mode Defines the mode to pass to webpack. --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path Output location of the file generated by webpack e.g. ./dist/. --stats [value] It instructs webpack on how to treat the stats e.g. verbose. --no-stats Disable stats output. - -t, --target Sets the build target e.g. node. - --no-target Negative 'target' option. --watch-options-stdin Stop watching when stdin stream has ended. --no-watch-options-stdin Do not stop watching when stdin stream has ended. - --allowed-hosts Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying - dev server, by default is 'auto'). - --allowed-hosts-reset Clear all items provided in 'allowedHosts' configuration. Allows to enumerate the hosts from which access to - the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). + --allowed-hosts Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). + --allowed-hosts-reset Clear all items provided in 'allowedHosts' configuration. Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). --bonjour Allows to broadcasts dev server via ZeroConf networking on start. - --no-bonjour Negative 'bonjour' option. + --no-bonjour Disallows to broadcasts dev server via ZeroConf networking on start. + --client-web-socket-transport Allows to set custom web socket transport to communicate with dev server. --no-client Negative 'client' option. --client-logging Allows to specify options for client script in the browser or disable client script. + --client-progress Prints compilation progress in percentage in the browser. + --no-client-progress Does not print compilation progress in percentage in the browser. --client-overlay Enables a full-screen overlay in the browser when there are compiler errors or warnings. - --no-client-overlay Negative 'client-overlay' option. + --no-client-overlay Disables a full-screen overlay in the browser when there are compiler errors or warnings. --client-overlay-errors Enables a full-screen overlay in the browser when there are compiler errors. --no-client-overlay-errors Negative 'client-overlay-errors' option. --client-overlay-warnings Enables a full-screen overlay in the browser when there are compiler warnings. --no-client-overlay-warnings Negative 'client-overlay-warnings' option. - --client-progress Prints compilation progress in percentage in the browser. - --no-client-progress Negative 'client-progress' option. - --client-web-socket-transport Allows to set custom web socket transport to communicate with dev server. - --client-web-socket-url Allows to specify URL to web socket server (useful when you're proxying dev server and client script does - not always know where to connect to). + --client-web-socket-url Allows to specify URL to web socket server (useful when you're proxying dev server and client script does not always know where to connect to). --client-web-socket-url-hostname Tells clients connected to devServer to use the provided hostname. - --client-web-socket-url-pathname Tells clients connected to devServer to use the provided path to connect. - --client-web-socket-url-password Tells clients connected to devServer to use the provided password to authenticate. --client-web-socket-url-port Tells clients connected to devServer to use the provided port. + --client-web-socket-url-pathname Tells clients connected to devServer to use the provided path to connect. --client-web-socket-url-protocol Tells clients connected to devServer to use the provided protocol. --client-web-socket-url-username Tells clients connected to devServer to use the provided username to authenticate. + --client-web-socket-url-password Tells clients connected to devServer to use the provided password to authenticate. + --web-socket-server Allows to set web socket server and options (by default 'ws'). + --no-web-socket-server Negative 'web-socket-server' option. --compress Enables gzip compression for everything served. - --no-compress Negative 'compress' option. - --history-api-fallback Allows to proxy requests through a specified index page (by default 'index.html'), useful for Single Page - Applications that utilise the HTML5 History API. + --no-compress Disables gzip compression for everything served. + --history-api-fallback Allows to proxy requests through a specified index page (by default 'index.html'), useful for Single Page Applications that utilise the HTML5 History API. --no-history-api-fallback Negative 'history-api-fallback' option. --host Allows to specify a hostname to use. --hot [value] Enables Hot Module Replacement. - --no-hot Negative 'hot' option. + --no-hot Disables Hot Module Replacement. --http2 Allows to serve over HTTP/2 using SPDY. - --no-http2 Negative 'http2' option. + --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 Negative 'https' option. + --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 Negative 'https-request-cert' option. - --https-cacert Path to an SSL CA certificate. - --https-key Path to an SSL key. - --https-pfx Path to an SSL pfx file. - --https-cert Path to 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-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). --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. - --magic-html Tells dev-server whether to enable magic HTML routes (routes corresponding to your webpack output, for - example '/main' for 'main.js'). - --no-magic-html Negative 'magic-html' option. - --open [value...] Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to - true to open your default browser). - --no-open Negative 'open' option. + --no-live-reload Disables reload/refresh the page(s) when file changes are detected (enabled by default) + --magic-html Tells dev-server whether to enable magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js'). + --no-magic-html Disables magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js'). + --open [value...] Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser). + --no-open Does not open the default browser. --open-target Opens specified page in browser. --open-app-name Open specified browser. --open-app Open specified browser. - --open-reset Clear all items provided in 'open' configuration. Allows to configure dev server to open the browser(s) and - page(s) after server had been started (set it to true to open your default browser). + --open-reset Clear all items provided in 'open' configuration. Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser). --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. @@ -151,18 +153,13 @@ Options: --static-directory Directory for static contents. --static-public-path The static files will be available in the browser under this public path. --static-serve-index Tells dev server to use serveIndex middleware when enabled. - --no-static-serve-index Negative 'static-serve-index' option. + --no-static-serve-index Does not tell dev server to use serveIndex middleware. --static-watch Watches for files in static content directory. - --no-static-watch Negative 'static-watch' option. - --static-reset Clear all items provided in 'static' configuration. Allows to configure options for serving static files - from directory (by default 'public' directory). - --static-public-path-reset Clear all items provided in 'static.publicPath' configuration. The static files will be available in the - browser under this public path. + --no-static-watch Does not watch for files in static content directory. + --static-reset Clear all items provided in 'static' configuration. Allows to configure options for serving static files from directory (by default 'public' directory). + --static-public-path-reset Clear all items provided in 'static.publicPath' configuration. The static files will be available in the browser under this public path. --watch-files Allows to configure list of globs/directories/files to watch for file changes. - --watch-files-reset Clear all items provided in 'watchFiles' configuration. Allows to configure list of globs/directories/files - to watch for file changes. - --web-socket-server Allows to set web socket server and options (by default 'ws'). - --no-web-socket-server Negative 'web-socket-server' option. + --watch-files-reset Clear all items provided in 'watchFiles' configuration. Allows to configure list of globs/directories/files to watch for file changes. Global options: --color Enable colors on console. From 1b533dc8b8dd9ab6a8ad4d7a45f313d9f8d8ebf7 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Thu, 9 Sep 2021 16:47:56 +0300 Subject: [PATCH 11/14] test: fix snapshot --- .../validate-options.test.js.snap.webpack4 | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack4 b/test/__snapshots__/validate-options.test.js.snap.webpack4 index 12e52a17ab..5a981d276a 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack4 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack4 @@ -322,58 +322,64 @@ exports[`options validate should throw an error on the "http2" option with '' va exports[`options validate should throw an error on the "https" 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.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } + boolean | object { passphrase?, requestCert?, ca?, cacert?, cert?, crl?, key?, pfx?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https should be a boolean. * options.https should be an object: - object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … }" + object { passphrase?, requestCert?, ca?, cacert?, cert?, crl?, key?, pfx?, … }" `; exports[`options validate should throw an error on the "https" option with '{"cacert":true}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } + boolean | object { passphrase?, requestCert?, ca?, cacert?, cert?, crl?, key?, pfx?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https.cacert should be one of these: - string | Buffer - -> Path to an SSL CA certificate. + string | Buffer | [string | Buffer, ...] + -> Path to an SSL CA certificate or content of an SSL CA certificate. Details: * options.https.cacert should be a string. - * options.https.cacert should be an instance of Buffer." + * options.https.cacert should be an instance of Buffer. + * options.https.cacert should be an array: + [string | Buffer, ...]" `; exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } + boolean | object { passphrase?, requestCert?, ca?, cacert?, cert?, crl?, key?, pfx?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https.cert should be one of these: - string | Buffer - -> Path to an SSL certificate. + string | Buffer | [string | Buffer, ...] + -> Path to an SSL certificate or content of an SSL certificate. Details: * options.https.cert should be a string. - * options.https.cert should be an instance of Buffer." + * options.https.cert should be an instance of Buffer. + * options.https.cert should be an array: + [string | Buffer, ...]" `; exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } + boolean | object { passphrase?, requestCert?, ca?, cacert?, cert?, crl?, key?, pfx?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https.key should be one of these: - string | Buffer - -> Path to an SSL key. + string | Buffer | [string | Buffer, ...] + -> Path to an SSL key or content of an SSL key. Details: * options.https.key should be a string. - * options.https.key should be an instance of Buffer." + * options.https.key should be an instance of Buffer. + * options.https.key should be an array: + [string | Buffer, ...]" `; exports[`options validate should throw an error on the "https" option with '{"passphrase":false}' value 1`] = ` @@ -385,16 +391,18 @@ exports[`options validate should throw an error on the "https" option with '{"pa exports[`options validate should throw an error on the "https" option with '{"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.https should be one of these: - boolean | object { passphrase?, requestCert?, ca?, cacert?, key?, pfx?, cert?, … } + boolean | object { passphrase?, requestCert?, ca?, cacert?, cert?, crl?, key?, pfx?, … } -> Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https.pfx should be one of these: - string | Buffer - -> Path to an SSL pfx file. + string | Buffer | [string | Buffer, ...] + -> Path to an SSL pfx file or content of an SSL pfx file. Details: * options.https.pfx should be a string. - * options.https.pfx should be an instance of Buffer." + * options.https.pfx should be an instance of Buffer. + * options.https.pfx should be an array: + [string | Buffer, ...]" `; exports[`options validate should throw an error on the "https" option with '{"requestCert":"test"}' value 1`] = ` From 55ae45526fe3fa657c134a91689e2a7e62713ebc Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Thu, 9 Sep 2021 17:22:19 +0300 Subject: [PATCH 12/14] feat: accept `https.pfx` and `https.key` options as `Object` --- lib/Server.js | 5 +- lib/options.json | 8 + .../__snapshots__/https.test.js.snap.webpack4 | 154 ++++++++++++++- .../__snapshots__/https.test.js.snap.webpack5 | 154 ++++++++++++++- test/e2e/https.test.js | 182 +++++++++++++++++- test/helpers/normalize-options.js | 10 + 6 files changed, 490 insertions(+), 23 deletions(-) diff --git a/lib/Server.js b/lib/Server.js index fca3225fb6..fd6926aace 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -526,7 +526,10 @@ class Server { const value = options.https[property]; const readFile = (item) => { - if (Buffer.isBuffer(item)) { + if ( + Buffer.isBuffer(item) || + (typeof item === "object" && item !== null && !Array.isArray(item)) + ) { return item; } diff --git a/lib/options.json b/lib/options.json index 08845c0a45..e647804f7d 100644 --- a/lib/options.json +++ b/lib/options.json @@ -318,6 +318,10 @@ }, { "instanceof": "Buffer" + }, + { + "type": "object", + "additionalProperties": true } ] } @@ -342,6 +346,10 @@ }, { "instanceof": "Buffer" + }, + { + "type": "object", + "additionalProperties": true } ] } diff --git a/test/e2e/__snapshots__/https.test.js.snap.webpack4 b/test/e2e/__snapshots__/https.test.js.snap.webpack4 index 7409525fb6..82d8a5b194 100644 --- a/test/e2e/__snapshots__/https.test.js.snap.webpack4 +++ b/test/e2e/__snapshots__/https.test.js.snap.webpack4 @@ -80,9 +80,9 @@ exports[`https option as an object when ca, pfx, key and cert are array of paths " `; -exports[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https 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[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): https options 1`] = ` +exports[`https 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----- @@ -176,11 +176,11 @@ QyvMqmN1kGy20SZbQDD/fLfqBQ== } `; -exports[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`https 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[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): response status 1`] = `200`; +exports[`https 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[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): response text 1`] = ` +exports[`https 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. " `; @@ -206,6 +206,35 @@ exports[`https option as an object when ca, pfx, key and cert are buffer should " `; +exports[`https 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[`https 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": "", + }, + ], +} +`; + +exports[`https 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[`https 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[`https 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[`https 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[`https option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): https options 1`] = ` @@ -227,9 +256,9 @@ exports[`https option as an object when ca, pfx, key and cert are paths to files " `; -exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): https options 1`] = ` +exports[`https 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+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kv @@ -315,11 +344,116 @@ QyvMqmN1kGy20SZbQDD/fLfqBQ== } `; -exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`https option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`https option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): response status 1`] = `200`; + +exports[`https option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`https 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[`https 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 +CgVjWNVAhysgtNtxRT4BVflffBXLVH2qsBjpsLRGU6EcMXuPGTiEp3YRHNuO6Aj8 +oP8fEsCGPc9DlJMGgxQRAKlrVF8TN/0j6Qk+YpS4MZ0YFQfBY+WdKu04Z8TVTplQ +tTkiGpBI+Oj85jF59aQiizglJgADkAZ6zmbrctm/G9jPxh7JLS2cKI0ECZgK5yAc +pk10E1YWhoCksjr9arxy6fS9TiX9P15vv06k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goZS5GbLKinQCdGcgERa05BXvJmNbfZtT5a37YEnbjsTImIhDiBP5P +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": "", + }, + ], +} +`; + +exports[`https 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[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): response status 1`] = `200`; +exports[`https 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[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): response text 1`] = ` +exports[`https 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. " `; diff --git a/test/e2e/__snapshots__/https.test.js.snap.webpack5 b/test/e2e/__snapshots__/https.test.js.snap.webpack5 index 7409525fb6..82d8a5b194 100644 --- a/test/e2e/__snapshots__/https.test.js.snap.webpack5 +++ b/test/e2e/__snapshots__/https.test.js.snap.webpack5 @@ -80,9 +80,9 @@ exports[`https option as an object when ca, pfx, key and cert are array of paths " `; -exports[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https 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[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): https options 1`] = ` +exports[`https 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----- @@ -176,11 +176,11 @@ QyvMqmN1kGy20SZbQDD/fLfqBQ== } `; -exports[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`https 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[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): response status 1`] = `200`; +exports[`https 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[`https option as an object when ca, pfx, key and cert are array of raw strings should handle GET request to index route (/): response text 1`] = ` +exports[`https 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. " `; @@ -206,6 +206,35 @@ exports[`https option as an object when ca, pfx, key and cert are buffer should " `; +exports[`https 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[`https 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": "", + }, + ], +} +`; + +exports[`https 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[`https 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[`https 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[`https 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[`https option as an object when ca, pfx, key and cert are paths to files should handle GET request to index route (/): https options 1`] = ` @@ -227,9 +256,9 @@ exports[`https option as an object when ca, pfx, key and cert are paths to files " `; -exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): console messages 1`] = `Array []`; +exports[`https option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): console messages 1`] = `Array []`; -exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): https options 1`] = ` +exports[`https 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+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kv @@ -315,11 +344,116 @@ QyvMqmN1kGy20SZbQDD/fLfqBQ== } `; -exports[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): page errors 1`] = `Array []`; +exports[`https option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): page errors 1`] = `Array []`; + +exports[`https option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): response status 1`] = `200`; + +exports[`https option as an object when ca, pfx, key and cert are strings should handle GET request to index route (/): response text 1`] = ` +"Heyo. +" +`; + +exports[`https 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[`https 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----- +MIIEpQIBAAKCAQE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P3Pqr0kz9g0CRtmy8RWr28hjHDfXD3xPUZ +iGnMEz7IOHOKv722/liFAprV1cNaLUmFbDNg3jmlaQKBgQDG5WwngPhOHmjTnSml +amfEz9a4yEhQqpqgVNW5wwoXOf6DbjL2m/maJh01giThj7inMcbpkZlIclxD0Eu6 +Lof+ctCeqSAJvaVPmd+nv8Yp26zsF1yM8ax9xXjrIvv9fSbycNveGTDCsNNTiYoW +QyvMqmN1kGy20SZbQDD/fLfqBQ== +-----END PRIVATE KEY----- +", + }, + ], + "passphrase": "webpack-dev-server", + "pfx": Array [ + Object { + "buf": "", + }, + ], +} +`; + +exports[`https 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[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): response status 1`] = `200`; +exports[`https 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[`https option as an object when ca, pfx, key and cert are raw strings should handle GET request to index route (/): response text 1`] = ` +exports[`https 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. " `; diff --git a/test/e2e/https.test.js b/test/e2e/https.test.js index 1fa439be12..f2014c020c 100644 --- a/test/e2e/https.test.js +++ b/test/e2e/https.test.js @@ -248,7 +248,7 @@ describe("https option", () => { }); }); - describe("as an object when ca, pfx, key and cert are raw strings", () => { + describe("as an object when ca, pfx, key and cert are strings", () => { let compiler; let server; let createServerSpy; @@ -272,6 +272,7 @@ describe("https option", () => { 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") @@ -329,7 +330,7 @@ describe("https option", () => { }); }); - describe("as an object when ca, pfx, key and cert are array of raw strings", () => { + describe("as an object when ca, pfx, key and cert are array of strings", () => { let compiler; let server; let createServerSpy; @@ -801,6 +802,183 @@ describe("https option", () => { }); }); + 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, + }, + https: { + 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, + }, + https: { + 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; diff --git a/test/helpers/normalize-options.js b/test/helpers/normalize-options.js index a6bc925205..64814dc412 100644 --- a/test/helpers/normalize-options.js +++ b/test/helpers/normalize-options.js @@ -11,6 +11,16 @@ function normalizeOptions(options) { value = value.map((item) => { if (Buffer.isBuffer(item)) { return ""; + } else if ( + typeof item.pem !== "undefined" && + Buffer.isBuffer(item.pem) + ) { + item.pem = ""; + } else if ( + typeof item.buf !== "undefined" && + Buffer.isBuffer(item.buf) + ) { + item.buf = ""; } return item; From 5633f821223cc7523cf387bf1f0f7c8d6faa2000 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Thu, 9 Sep 2021 17:25:00 +0300 Subject: [PATCH 13/14] test: fix --- .../validate-options.test.js.snap.webpack4 | 32 +++++++++---------- .../validate-options.test.js.snap.webpack5 | 32 +++++++++---------- test/validate-options.test.js | 19 +++++++++++ 3 files changed, 51 insertions(+), 32 deletions(-) diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack4 b/test/__snapshots__/validate-options.test.js.snap.webpack4 index 5a981d276a..becb276ac9 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack4 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack4 @@ -339,13 +339,13 @@ exports[`options validate should throw an error on the "https" option with '{"ca -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https.cacert should be one of these: - string | Buffer | [string | Buffer, ...] + [string | Buffer, ...] | string | Buffer -> Path to an SSL CA certificate or content of an SSL CA certificate. Details: - * options.https.cacert should be a string. - * options.https.cacert should be an instance of Buffer. * options.https.cacert should be an array: - [string | Buffer, ...]" + [string | Buffer, ...] + * options.https.cacert should be a string. + * options.https.cacert should be an instance of Buffer." `; exports[`options validate should throw an error on the "https" option with '{"cert":true}' value 1`] = ` @@ -356,13 +356,13 @@ exports[`options validate should throw an error on the "https" option with '{"ce -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https.cert should be one of these: - string | Buffer | [string | Buffer, ...] + [string | Buffer, ...] | string | Buffer -> Path to an SSL certificate or content of an SSL certificate. Details: - * options.https.cert should be a string. - * options.https.cert should be an instance of Buffer. * options.https.cert should be an array: - [string | Buffer, ...]" + [string | Buffer, ...] + * options.https.cert should be a string. + * options.https.cert should be an instance of Buffer." `; exports[`options validate should throw an error on the "https" option with '{"key":10}' value 1`] = ` @@ -373,13 +373,13 @@ exports[`options validate should throw an error on the "https" option with '{"ke -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https.key should be one of these: - string | Buffer | [string | Buffer, ...] + [string | Buffer | object { … }, ...] | string | Buffer -> Path to an SSL key or content of an SSL key. Details: - * options.https.key should be a string. - * options.https.key should be an instance of Buffer. * options.https.key should be an array: - [string | Buffer, ...]" + [string | Buffer | object { … }, ...] + * options.https.key should be a string. + * options.https.key should be an instance of Buffer." `; exports[`options validate should throw an error on the "https" option with '{"passphrase":false}' value 1`] = ` @@ -396,13 +396,13 @@ exports[`options validate should throw an error on the "https" option with '{"pf -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https.pfx should be one of these: - string | Buffer | [string | Buffer, ...] + [string | Buffer | object { … }, ...] | string | Buffer -> Path to an SSL pfx file or content of an SSL pfx file. Details: - * options.https.pfx should be a string. - * options.https.pfx should be an instance of Buffer. * options.https.pfx should be an array: - [string | Buffer, ...]" + [string | Buffer | object { … }, ...] + * options.https.pfx should be a string. + * options.https.pfx should be an instance of Buffer." `; exports[`options validate should throw an error on the "https" option with '{"requestCert":"test"}' value 1`] = ` diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack5 b/test/__snapshots__/validate-options.test.js.snap.webpack5 index 5a981d276a..becb276ac9 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack5 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack5 @@ -339,13 +339,13 @@ exports[`options validate should throw an error on the "https" option with '{"ca -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https.cacert should be one of these: - string | Buffer | [string | Buffer, ...] + [string | Buffer, ...] | string | Buffer -> Path to an SSL CA certificate or content of an SSL CA certificate. Details: - * options.https.cacert should be a string. - * options.https.cacert should be an instance of Buffer. * options.https.cacert should be an array: - [string | Buffer, ...]" + [string | Buffer, ...] + * options.https.cacert should be a string. + * options.https.cacert should be an instance of Buffer." `; exports[`options validate should throw an error on the "https" option with '{"cert":true}' value 1`] = ` @@ -356,13 +356,13 @@ exports[`options validate should throw an error on the "https" option with '{"ce -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https.cert should be one of these: - string | Buffer | [string | Buffer, ...] + [string | Buffer, ...] | string | Buffer -> Path to an SSL certificate or content of an SSL certificate. Details: - * options.https.cert should be a string. - * options.https.cert should be an instance of Buffer. * options.https.cert should be an array: - [string | Buffer, ...]" + [string | Buffer, ...] + * options.https.cert should be a string. + * options.https.cert should be an instance of Buffer." `; exports[`options validate should throw an error on the "https" option with '{"key":10}' value 1`] = ` @@ -373,13 +373,13 @@ exports[`options validate should throw an error on the "https" option with '{"ke -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https.key should be one of these: - string | Buffer | [string | Buffer, ...] + [string | Buffer | object { … }, ...] | string | Buffer -> Path to an SSL key or content of an SSL key. Details: - * options.https.key should be a string. - * options.https.key should be an instance of Buffer. * options.https.key should be an array: - [string | Buffer, ...]" + [string | Buffer | object { … }, ...] + * options.https.key should be a string. + * options.https.key should be an instance of Buffer." `; exports[`options validate should throw an error on the "https" option with '{"passphrase":false}' value 1`] = ` @@ -396,13 +396,13 @@ exports[`options validate should throw an error on the "https" option with '{"pf -> Read more at https://webpack.js.org/configuration/dev-server/#devserverhttps Details: * options.https.pfx should be one of these: - string | Buffer | [string | Buffer, ...] + [string | Buffer | object { … }, ...] | string | Buffer -> Path to an SSL pfx file or content of an SSL pfx file. Details: - * options.https.pfx should be a string. - * options.https.pfx should be an instance of Buffer. * options.https.pfx should be an array: - [string | Buffer, ...]" + [string | Buffer | object { … }, ...] + * options.https.pfx should be a string. + * options.https.pfx should be an instance of Buffer." `; exports[`options validate should throw an error on the "https" option with '{"requestCert":"test"}' value 1`] = ` diff --git a/test/validate-options.test.js b/test/validate-options.test.js index c5530de958..1711c59e7d 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -277,6 +277,25 @@ const tests = { cert: readFileSync(path.join(httpsCertificateDirectory, "server.crt")), passphrase: "webpack-dev-server", }, + { + ca: readFileSync(path.join(httpsCertificateDirectory, "ca.pem")), + pfx: [ + { + buf: readFileSync( + path.join(httpsCertificateDirectory, "server.pfx") + ), + }, + ], + key: [ + { + pem: readFileSync( + path.join(httpsCertificateDirectory, "server.key") + ), + }, + ], + cert: readFileSync(path.join(httpsCertificateDirectory, "server.crt")), + passphrase: "webpack-dev-server", + }, ], failure: [ "", From d30fff7e2494976b67372b4de35c8b0a08bb2f66 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Thu, 9 Sep 2021 17:58:11 +0300 Subject: [PATCH 14/14] test: fix --- test/e2e/__snapshots__/https.test.js.snap.webpack4 | 10 ---------- test/e2e/__snapshots__/https.test.js.snap.webpack5 | 10 ---------- test/e2e/https.test.js | 3 --- 3 files changed, 23 deletions(-) diff --git a/test/e2e/__snapshots__/https.test.js.snap.webpack4 b/test/e2e/__snapshots__/https.test.js.snap.webpack4 index 82d8a5b194..897728d71f 100644 --- a/test/e2e/__snapshots__/https.test.js.snap.webpack4 +++ b/test/e2e/__snapshots__/https.test.js.snap.webpack4 @@ -458,16 +458,6 @@ exports[`https option as an object when ca, pfx, key and cert are strings, key a " `; -exports[`https option as an object when ca, pfx, key and cert are symlinks should handle GET request to index route (/): https options 1`] = ` -Object { - "ca": "", - "cert": "", - "key": "", - "passphrase": "webpack-dev-server", - "pfx": "", -} -`; - exports[`https 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[`https option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` diff --git a/test/e2e/__snapshots__/https.test.js.snap.webpack5 b/test/e2e/__snapshots__/https.test.js.snap.webpack5 index 82d8a5b194..897728d71f 100644 --- a/test/e2e/__snapshots__/https.test.js.snap.webpack5 +++ b/test/e2e/__snapshots__/https.test.js.snap.webpack5 @@ -458,16 +458,6 @@ exports[`https option as an object when ca, pfx, key and cert are strings, key a " `; -exports[`https option as an object when ca, pfx, key and cert are symlinks should handle GET request to index route (/): https options 1`] = ` -Object { - "ca": "", - "cert": "", - "key": "", - "passphrase": "webpack-dev-server", - "pfx": "", -} -`; - exports[`https 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[`https option as an object when cacert and ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` diff --git a/test/e2e/https.test.js b/test/e2e/https.test.js index f2014c020c..b6e384e13a 100644 --- a/test/e2e/https.test.js +++ b/test/e2e/https.test.js @@ -631,9 +631,6 @@ describe("https option", () => { waitUntil: "networkidle0", }); - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); expect(response.status()).toEqual(200); expect(await response.text()).toContain("Heyo"); expect(consoleMessages.map((message) => message.text())).toEqual([]);