diff --git a/bin/cli-flags.js b/bin/cli-flags.js index c04814e898..8673be420f 100644 --- a/bin/cli-flags.js +++ b/bin/cli-flags.js @@ -84,36 +84,6 @@ module.exports = { group: SSL_GROUP, describe: 'HTTP/2, must be used with HTTPS', }, - { - name: 'key', - type: String, - describe: 'Path to a SSL key.', - group: SSL_GROUP, - }, - { - name: 'cert', - type: String, - describe: 'Path to a SSL certificate.', - group: SSL_GROUP, - }, - { - name: 'cacert', - type: String, - describe: 'Path to a SSL CA certificate.', - group: SSL_GROUP, - }, - { - name: 'pfx', - type: String, - describe: 'Path to a SSL pfx file.', - group: SSL_GROUP, - }, - { - name: 'pfx-passphrase', - type: String, - describe: 'Passphrase for pfx file.', - group: SSL_GROUP, - }, { name: 'content-base', type: String, diff --git a/bin/options.js b/bin/options.js index d9890dd6f1..7ca54300ec 100644 --- a/bin/options.js +++ b/bin/options.js @@ -96,31 +96,6 @@ const options = { group: SSL_GROUP, describe: 'HTTP/2, must be used with HTTPS', }, - key: { - type: 'string', - describe: 'Path to a SSL key.', - group: SSL_GROUP, - }, - cert: { - type: 'string', - describe: 'Path to a SSL certificate.', - group: SSL_GROUP, - }, - cacert: { - type: 'string', - describe: 'Path to a SSL CA certificate.', - group: SSL_GROUP, - }, - pfx: { - type: 'string', - describe: 'Path to a SSL pfx file.', - group: SSL_GROUP, - }, - 'pfx-passphrase': { - type: 'string', - describe: 'Passphrase for pfx file.', - group: SSL_GROUP, - }, 'content-base': { type: 'string', describe: 'A directory or URL to serve HTML content from.', diff --git a/examples/cli/https/README.md b/examples/cli/https/README.md deleted file mode 100644 index 11484d6bee..0000000000 --- a/examples/cli/https/README.md +++ /dev/null @@ -1,52 +0,0 @@ -# CLI: Https Option - -By default webpack-dev-server will generate a self-signed, 2048 bit, sha256 SSL -Certificate, which is used to enable https. The certificate will be located in the -`ssl` directory after the server is started for the first time. The generated -certificate is only good for 30 days, at which point it'll be regenerated. - -We highly recommend creating and managing your own certificates. Please see the -following resources for doing so: - -### MacOS - -https://certsimple.com/blog/localhost-ssl-fix - -### Windows 10 - -https://technet.microsoft.com/itpro/powershell/windows/pkiclient/new-selfsignedcertificate - -### Windows 7 - -https://msdn.microsoft.com/en-us/library/aa386968.aspx - -Example (the .pfx file generated the following way can be used without `--pfx-passphrase`): - -``` -makecert -r -pe -sky exchange -sv makecert.pvk makecert.cer -pvk2pfx -pvk makecert.pvk -spc makecert.cer -pfx makecert.pfx -``` - -## Getting Started - -```shell -npm run webpack-dev-server -- --open --https -``` - -## Using Your Certificate - -Options are available for using your own SSL Certificate in your preferred or -OS-required format. - -Given the base command `npm run webpack-dev-server -- --open --https`, append -one of the following: - -- (PEM Files) `--cert=../../ssl/server.pem --key=../../ssl/server.pem` -- (PFX and Passphrase) `--pfx=./test_cert.pfx --pfx-passphrase=sample` - -## What To Expect - -The script should open `https://localhost:8080/`in your default browser. If your -browser displays a warning about a non-trusted certificate, follow the procedure -for your browser of choice to continue. After doing so you should see "It's Working" -displayed on the page. diff --git a/examples/cli/https/app.js b/examples/cli/https/app.js deleted file mode 100644 index ae384858b9..0000000000 --- a/examples/cli/https/app.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -const target = document.querySelector('#target'); - -target.classList.add('pass'); -target.innerHTML = 'Success!'; diff --git a/examples/cli/https/test_cert.pfx b/examples/cli/https/test_cert.pfx deleted file mode 100644 index d6c2023a2d..0000000000 Binary files a/examples/cli/https/test_cert.pfx and /dev/null differ diff --git a/examples/cli/https/webpack.config.js b/examples/cli/https/webpack.config.js deleted file mode 100644 index e0e5363925..0000000000 --- a/examples/cli/https/webpack.config.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -// our setup function adds behind-the-scenes bits to the config that all of our -// examples need -const { setup } = require('../../util'); - -module.exports = setup({ - context: __dirname, - entry: './app.js', -}); diff --git a/lib/Server.js b/lib/Server.js index 72523c185d..2ac1b8edfe 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -578,23 +578,16 @@ class Server { setupHttps() { // if the user enables http2, we can safely enable https - if (this.options.http2 && !this.options.https) { - this.options.https = true; + if ( + (this.options.http2 && !this.options.https) || + this.options.https === true + ) { + this.options.https = { + requestCert: false, + }; } if (this.options.https) { - // for keep supporting CLI parameters - if (typeof this.options.https === 'boolean') { - this.options.https = { - ca: this.options.ca, - pfx: this.options.pfx, - key: this.options.key, - cert: this.options.cert, - passphrase: this.options.pfxPassphrase, - requestCert: this.options.requestCert || false, - }; - } - for (const property of ['ca', 'pfx', 'key', 'cert']) { const value = this.options.https[property]; const isBuffer = value instanceof Buffer; @@ -623,23 +616,6 @@ class Server { this.options.https.key = this.options.https.key || fakeCert; this.options.https.cert = this.options.https.cert || fakeCert; - - // note that options.spdy never existed. The user was able - // to set options.https.spdy before, though it was not in the - // docs. Keep options.https.spdy if the user sets it for - // backwards compatibility, but log a deprecation warning. - if (this.options.https.spdy) { - // for backwards compatibility: if options.https.spdy was passed in before, - // it was not altered in any way - this.log.warn( - 'Providing custom spdy server options is deprecated and will be removed in the next major version.' - ); - } else { - // if the normal https server gets this option, it will not affect it. - this.options.https.spdy = { - protocols: ['h2', 'http/1.1'], - }; - } } } @@ -648,7 +624,12 @@ class Server { if (this.options.http2) { // TODO: we need to replace spdy with http2 which is an internal module this.listeningApp = require('spdy').createServer( - this.options.https, + { + ...this.options.https, + spdy: { + protocols: ['h2', 'http/1.1'], + }, + }, this.app ); } else { diff --git a/lib/options.json b/lib/options.json index e5dee0e401..62e0899606 100644 --- a/lib/options.json +++ b/lib/options.json @@ -16,26 +16,6 @@ "bonjour": { "type": "boolean" }, - "ca": { - "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" - } - ] - }, - "cert": { - "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" - } - ] - }, "clientLogLevel": { "enum": [ "info", @@ -136,10 +116,59 @@ "https": { "anyOf": [ { - "type": "object" + "type": "boolean" }, { - "type": "boolean" + "type": "object", + "additionalProperties": false, + "properties": { + "passphrase": { + "type": "string" + }, + "requestCert": { + "type": "boolean" + }, + "ca": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] + }, + "key": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] + }, + "pfx": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] + }, + "cert": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "Buffer" + } + ] + } + } } ] }, @@ -166,16 +195,6 @@ } ] }, - "key": { - "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" - } - ] - }, "liveReload": { "type": "boolean" }, @@ -242,19 +261,6 @@ } ] }, - "pfx": { - "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "Buffer" - } - ] - }, - "pfxPassphrase": { - "type": "string" - }, "port": { "anyOf": [ { @@ -419,8 +425,6 @@ "allowedHosts": "should be {Array} (https://webpack.js.org/configuration/dev-server/#devserverallowedhosts)", "before": "should be {Function} (https://webpack.js.org/configuration/dev-server/#devserverbefore)", "bonjour": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverbonjour)", - "ca": "should be {String|Buffer}", - "cert": "should be {String|Buffer}", "clientLogLevel": "should be {String} and equal to one of the allowed values\n\n [ 'none', 'silent', 'info', 'debug', 'trace', 'error', 'warning', 'warn' ]\n\n (https://webpack.js.org/configuration/dev-server/#devserverclientloglevel)", "compress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devservercompress)", "contentBase": "should be {Number|String|Array} (https://webpack.js.org/configuration/dev-server/#devservercontentbase)", @@ -436,7 +440,6 @@ "index": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserverindex)", "injectClient": "should be {Boolean|Function} (https://webpack.js.org/configuration/dev-server/#devserverinjectclient)", "injectHot": "should be {Boolean|Function} (https://webpack.js.org/configuration/dev-server/#devserverinjecthot)", - "key": "should be {String|Buffer}", "liveReload": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverlivereload-)", "log": "should be {Function}", "logLevel": "should be {String} and equal to one of the allowed values\n\n [ 'info', 'warn', 'error', 'debug', 'trace', 'silent' ]\n\n (https://github.com/webpack/webpack-dev-middleware#loglevel)", @@ -447,8 +450,6 @@ "open": "should be {String|Boolean|Object} (https://webpack.js.org/configuration/dev-server/#devserveropen)", "openPage": "should be {String|Array} (https://webpack.js.org/configuration/dev-server/#devserveropenpage)", "overlay": "should be {Boolean|Object} (https://webpack.js.org/configuration/dev-server/#devserveroverlay)", - "pfx": "should be {String|Buffer} (https://webpack.js.org/configuration/dev-server/#devserverpfx)", - "pfxPassphrase": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserverpfxpassphrase)", "port": "should be {Number|String|Null} (https://webpack.js.org/configuration/dev-server/#devserverport)", "profile": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverprofile)", "progress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverprogress---cli-only)", diff --git a/lib/utils/createConfig.js b/lib/utils/createConfig.js index 04c262a4a0..28af60763a 100644 --- a/lib/utils/createConfig.js +++ b/lib/utils/createConfig.js @@ -151,26 +151,6 @@ function createConfig(config, argv, { port }) { options.http2 = true; } - if (argv.key) { - options.key = argv.key; - } - - if (argv.cert) { - options.cert = argv.cert; - } - - if (argv.cacert) { - options.ca = argv.cacert; - } - - if (argv.pfx) { - options.pfx = argv.pfx; - } - - if (argv.pfxPassphrase) { - options.pfxPassphrase = argv.pfxPassphrase; - } - if (argv.historyApiFallback) { options.historyApiFallback = true; } diff --git a/test/__snapshots__/Validation.test.js.snap b/test/__snapshots__/Validation.test.js.snap index 8a69b71862..f1d506b8c5 100644 --- a/test/__snapshots__/Validation.test.js.snap +++ b/test/__snapshots__/Validation.test.js.snap @@ -37,5 +37,5 @@ exports[`Validation validation should fail validation for invalid \`writeToDisk\ exports[`Validation validation should fail validation for no additional properties 1`] = ` "Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema. - configuration has an unknown property 'additional'. These properties are valid: - object { after?, allowedHosts?, before?, bonjour?, ca?, cert?, clientLogLevel?, compress?, contentBasePublicPath?, contentBase?, disableHostCheck?, features?, fs?, headers?, historyApiFallback?, host?, hot?, http2?, https?, index?, injectClient?, injectHot?, key?, liveReload?, log?, logLevel?, logTime?, mimeTypes?, noInfo?, onListening?, open?, openPage?, overlay?, pfx?, pfxPassphrase?, port?, profile?, progress?, proxy?, public?, publicPath?, quiet?, reporter?, requestCert?, serveIndex?, serverSideRender?, setup?, sockHost?, sockPath?, sockPort?, socket?, staticOptions?, stats?, transportMode?, useLocalIp?, warn?, watchContentBase?, watchOptions?, writeToDisk? }" + object { after?, allowedHosts?, before?, bonjour?, clientLogLevel?, compress?, contentBasePublicPath?, contentBase?, disableHostCheck?, features?, fs?, headers?, historyApiFallback?, host?, hot?, http2?, https?, index?, injectClient?, injectHot?, liveReload?, log?, logLevel?, logTime?, mimeTypes?, noInfo?, onListening?, open?, openPage?, overlay?, port?, profile?, progress?, proxy?, public?, publicPath?, quiet?, reporter?, requestCert?, serveIndex?, serverSideRender?, setup?, sockHost?, sockPath?, sockPort?, socket?, staticOptions?, stats?, transportMode?, useLocalIp?, warn?, watchContentBase?, watchOptions?, writeToDisk? }" `; diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js index 11672edfa7..9af88f2d30 100644 --- a/test/cli/cli.test.js +++ b/test/cli/cli.test.js @@ -6,15 +6,6 @@ const execa = require('execa'); const testBin = require('../helpers/test-bin'); const port1 = require('../ports-map').cli[0]; -const httpsCertificateDirectory = resolve( - __dirname, - '../fixtures/https-certificate' -); -const caPath = resolve(httpsCertificateDirectory, 'ca.pem'); -const pfxPath = resolve(httpsCertificateDirectory, 'server.pfx'); -const keyPath = resolve(httpsCertificateDirectory, 'server.key'); -const certPath = resolve(httpsCertificateDirectory, 'server.crt'); - describe('CLI', () => { it('--progress', (done) => { testBin('--progress') @@ -73,18 +64,6 @@ describe('CLI', () => { .catch(done); }); - it('--https --cacert --pfx --key --cert --pfx-passphrase', (done) => { - testBin( - `--https --cacert ${caPath} --pfx ${pfxPath} --key ${keyPath} --cert ${certPath} --pfx-passphrase webpack-dev-server` - ) - .then((output) => { - expect(output.exitCode).toEqual(0); - expect(output.stdout).toContain('Project is running at'); - done(); - }) - .catch(done); - }); - it('--sockPath', (done) => { testBin('--sockPath /mysockPath') .then((output) => { diff --git a/test/fixtures/schema/webpack.config.no-dev-stats.js b/test/fixtures/schema/webpack.config.no-dev-stats.js index e5664f96b7..c06ef5784b 100644 --- a/test/fixtures/schema/webpack.config.no-dev-stats.js +++ b/test/fixtures/schema/webpack.config.no-dev-stats.js @@ -18,7 +18,6 @@ module.exports = { noInfo: '_noInfo', quiet: '_quiet', https: '_https', - pfxPassphrase: '_pfxPassphrase', historyApiFallback: '_historyApiFallback', compress: '_compress', disableHostCheck: '_disableHostCheck', diff --git a/test/options.test.js b/test/options.test.js index 5b19da4b7b..e248780533 100644 --- a/test/options.test.js +++ b/test/options.test.js @@ -1,5 +1,6 @@ 'use strict'; +const { readFileSync } = require('fs'); const { join } = require('path'); const { ValidationError } = require('schema-utils'); const webpack = require('webpack'); @@ -9,6 +10,11 @@ const options = require('../lib/options.json'); const SockJSServer = require('../lib/servers/SockJSServer'); const config = require('./fixtures/simple-config/webpack.config'); +const httpsCertificateDirectory = join( + __dirname, + './fixtures/https-certificate' +); + describe('options', () => { jest.setTimeout(20000); @@ -124,14 +130,6 @@ describe('options', () => { success: [false], failure: [''], }, - ca: { - success: ['', Buffer.from('')], - failure: [false], - }, - cert: { - success: ['', Buffer.from('')], - failure: [false], - }, clientLogLevel: { success: [ 'silent', @@ -192,8 +190,36 @@ describe('options', () => { failure: [''], }, https: { - success: [true, {}], - failure: [''], + success: [ + false, + { + https: { + ca: join(httpsCertificateDirectory, 'ca.pem'), + key: join(httpsCertificateDirectory, 'server.key'), + pfx: join(httpsCertificateDirectory, 'server.pfx'), + cert: join(httpsCertificateDirectory, 'server.crt'), + requestCert: true, + passphrase: 'webpack-dev-server', + }, + }, + { + https: { + ca: readFileSync(join(httpsCertificateDirectory, 'ca.pem')), + pfx: readFileSync(join(httpsCertificateDirectory, 'server.pfx')), + key: readFileSync(join(httpsCertificateDirectory, 'server.key')), + cert: readFileSync(join(httpsCertificateDirectory, 'server.crt')), + passphrase: 'webpack-dev-server', + }, + }, + ], + failure: [ + '', + { + https: { + foo: 'bar', + }, + }, + ], }, index: { success: [''], @@ -207,10 +233,6 @@ describe('options', () => { success: [true, () => {}], failure: [''], }, - key: { - success: ['', Buffer.from('')], - failure: [false], - }, log: { success: [() => {}], failure: [''], @@ -277,14 +299,6 @@ describe('options', () => { }, ], }, - pfx: { - success: ['', Buffer.from('')], - failure: [false], - }, - pfxPassphrase: { - success: [''], - failure: [false], - }, port: { success: ['', 0, null], failure: [false], diff --git a/test/server/utils/__snapshots__/createConfig.test.js.snap b/test/server/utils/__snapshots__/createConfig.test.js.snap index c24095a43e..982c8712be 100644 --- a/test/server/utils/__snapshots__/createConfig.test.js.snap +++ b/test/server/utils/__snapshots__/createConfig.test.js.snap @@ -62,66 +62,6 @@ Object { } `; -exports[`createConfig cacert option (in devServer config) 1`] = ` -Object { - "ca": "/path/to/ca.pem", - "hot": true, - "https": true, - "noInfo": true, - "port": 8080, - "publicPath": "/", - "stats": Object { - "cached": false, - "cachedAssets": false, - }, -} -`; - -exports[`createConfig cacert option 1`] = ` -Object { - "ca": "/path/to/ca.pem", - "hot": true, - "https": true, - "noInfo": true, - "port": 8080, - "publicPath": "/", - "stats": Object { - "cached": false, - "cachedAssets": false, - }, -} -`; - -exports[`createConfig cert option (in devServer config) 1`] = ` -Object { - "cert": "/path/to/server.crt", - "hot": true, - "https": true, - "noInfo": true, - "port": 8080, - "publicPath": "/", - "stats": Object { - "cached": false, - "cachedAssets": false, - }, -} -`; - -exports[`createConfig cert option 1`] = ` -Object { - "cert": "/path/to/server.crt", - "hot": true, - "https": true, - "noInfo": true, - "port": 8080, - "publicPath": "/", - "stats": Object { - "cached": false, - "cachedAssets": false, - }, -} -`; - exports[`createConfig clientLogLevel option (in devServer config) 1`] = ` Object { "clientLogLevel": "none", @@ -448,8 +388,13 @@ Object { exports[`createConfig https option (in devServer config) 2`] = ` Object { "hot": true, + "https": Object { + "ca": Object { + "data": Array [], + "type": "Buffer", + }, + }, "noInfo": true, - "pfxPassphrase": "passphrase", "port": 8080, "publicPath": "/", "stats": Object { @@ -473,22 +418,10 @@ Object { } `; -exports[`createConfig info option (in devServer config) 1`] = ` -Object { - "hot": true, - "noInfo": true, - "port": 8080, - "publicPath": "/", - "stats": Object { - "cached": false, - "cachedAssets": false, - }, -} -`; - -exports[`createConfig info option 1`] = ` +exports[`createConfig https option 2`] = ` Object { "hot": true, + "https": true, "noInfo": true, "port": 8080, "publicPath": "/", @@ -499,11 +432,9 @@ Object { } `; -exports[`createConfig key option (in devServer config) 1`] = ` +exports[`createConfig info option (in devServer config) 1`] = ` Object { "hot": true, - "https": true, - "key": "/path/to/server.key", "noInfo": true, "port": 8080, "publicPath": "/", @@ -514,11 +445,9 @@ Object { } `; -exports[`createConfig key option 1`] = ` +exports[`createConfig info option 1`] = ` Object { "hot": true, - "https": true, - "key": "/path/to/server.key", "noInfo": true, "port": 8080, "publicPath": "/", @@ -739,50 +668,6 @@ Object { } `; -exports[`createConfig pfx option (in devServer config) 1`] = ` -Object { - "hot": true, - "https": true, - "noInfo": true, - "pfx": "/path/to/file.pfx", - "port": 8080, - "publicPath": "/", - "stats": Object { - "cached": false, - "cachedAssets": false, - }, -} -`; - -exports[`createConfig pfx option 1`] = ` -Object { - "hot": true, - "https": true, - "noInfo": true, - "pfx": "/path/to/file.pfx", - "port": 8080, - "publicPath": "/", - "stats": Object { - "cached": false, - "cachedAssets": false, - }, -} -`; - -exports[`createConfig pfxPassphrase option 1`] = ` -Object { - "hot": true, - "noInfo": true, - "pfxPassphrase": "passphrase", - "port": 8080, - "publicPath": "/", - "stats": Object { - "cached": false, - "cachedAssets": false, - }, -} -`; - exports[`createConfig port option (difference) 1`] = ` Object { "hot": true, @@ -1143,7 +1028,6 @@ Object { "noInfo": true, "open": "_open", "openPage": "_openPage", - "pfxPassphrase": "_pfxPassphrase", "port": "_port", "progress": "_progress", "public": "_public", @@ -1172,7 +1056,6 @@ Object { "noInfo": true, "open": "_open", "openPage": "_openPage", - "pfxPassphrase": "_pfxPassphrase", "port": "_port", "progress": "_progress", "public": "_public", diff --git a/test/server/utils/createConfig.test.js b/test/server/utils/createConfig.test.js index e92afe9168..d23fab737b 100644 --- a/test/server/utils/createConfig.test.js +++ b/test/server/utils/createConfig.test.js @@ -509,152 +509,61 @@ describe('createConfig', () => { }); it('https option', () => { - const config = createConfig( + const config1 = createConfig( webpackConfig, Object.assign({}, argv, { https: true }), { port: 8080 } ); - expect(config).toMatchSnapshot(); - }); - - it('https option (in devServer config)', () => { - const config = createConfig( - Object.assign({}, webpackConfig, { - devServer: { https: true }, - }), - argv, - { port: 8080 } - ); - - expect(config).toMatchSnapshot(); - }); - - it('http2 option', () => { - const config = createConfig( - webpackConfig, - Object.assign({}, argv, { https: true, http2: true }), - { port: 8080 } - ); - - expect(config).toMatchSnapshot(); - }); - - it('http2 option (in devServer config)', () => { - const config = createConfig( - Object.assign({}, webpackConfig, { - devServer: { https: true, http2: true }, - }), - argv, - { port: 8080 } - ); - - expect(config).toMatchSnapshot(); - }); + expect(config1).toMatchSnapshot(); - it('key option', () => { - const config = createConfig( + const config2 = createConfig( webpackConfig, - Object.assign({}, argv, { https: true, key: '/path/to/server.key' }), - { port: 8080 } - ); - - expect(config).toMatchSnapshot(); - }); - - it('key option (in devServer config)', () => { - const config = createConfig( - Object.assign({}, webpackConfig, { - devServer: { https: true, key: '/path/to/server.key' }, - }), - argv, - { port: 8080 } - ); - - expect(config).toMatchSnapshot(); - }); - - it('cert option', () => { - const config = createConfig( - webpackConfig, - Object.assign({}, argv, { https: true, cert: '/path/to/server.crt' }), - { port: 8080 } - ); - - expect(config).toMatchSnapshot(); - }); - - it('cert option (in devServer config)', () => { - const config = createConfig( - Object.assign({}, webpackConfig, { - devServer: { https: true, cert: '/path/to/server.crt' }, + Object.assign({}, argv, { + https: { ca: Buffer.from('') }, }), - argv, { port: 8080 } ); - expect(config).toMatchSnapshot(); + expect(config2).toMatchSnapshot(); }); - it('cacert option', () => { - const config = createConfig( - webpackConfig, - Object.assign({}, argv, { https: true, cacert: '/path/to/ca.pem' }), - { port: 8080 } - ); - - expect(config).toMatchSnapshot(); - }); - - it('cacert option (in devServer config)', () => { - const config = createConfig( + it('https option (in devServer config)', () => { + const config1 = createConfig( Object.assign({}, webpackConfig, { - // TODO rename `ca` to `cacert` for `v4` to avoid difference between CLI and configuration - devServer: { https: true, ca: '/path/to/ca.pem' }, + devServer: { https: true }, }), argv, { port: 8080 } ); - expect(config).toMatchSnapshot(); - }); + expect(config1).toMatchSnapshot(); - it('pfx option', () => { - const config = createConfig( - webpackConfig, - Object.assign({}, argv, { https: true, pfx: '/path/to/file.pfx' }), - { port: 8080 } - ); - - expect(config).toMatchSnapshot(); - }); - - it('pfx option (in devServer config)', () => { - const config = createConfig( + const config2 = createConfig( Object.assign({}, webpackConfig, { - devServer: { https: true, pfx: '/path/to/file.pfx' }, + devServer: { https: { ca: Buffer.from('') } }, }), argv, { port: 8080 } ); - expect(config).toMatchSnapshot(); + expect(config2).toMatchSnapshot(); }); - it('pfxPassphrase option', () => { + it('http2 option', () => { const config = createConfig( webpackConfig, - Object.assign({}, argv, { pfxPassphrase: 'passphrase' }), + Object.assign({}, argv, { https: true, http2: true }), { port: 8080 } ); expect(config).toMatchSnapshot(); }); - it('https option (in devServer config)', () => { + it('http2 option (in devServer config)', () => { const config = createConfig( Object.assign({}, webpackConfig, { - devServer: { pfxPassphrase: 'passphrase' }, + devServer: { https: true, http2: true }, }), argv, { port: 8080 }