Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -726,13 +726,21 @@ class Server {
options.server.options.requestCert = false;
}

// TODO remove the `cacert` option in favor `ca` in the next major release
for (const property of ["cacert", "ca", "cert", "crl", "key", "pfx"]) {
if (typeof options.server.options[property] === "undefined") {
// eslint-disable-next-line no-continue
continue;
}

if (property === "cacert") {
// TODO remove the `cacert` option in favor `ca` in the next major release
util.deprecate(
() => {},
"The 'cacert' option is deprecated. Please use the 'ca' option.",
"DEP_WEBPACK_DEV_SERVER_CACERT"
)();
}

const value = options.server.options[property];
const readFile = (item) => {
if (
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/https.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,11 +655,13 @@ describe("https option", () => {
let browser;
let pageErrors;
let consoleMessages;
let utilSpy;

beforeEach(async () => {
compiler = webpack(config);

createServerSpy = jest.spyOn(https, "createServer");
utilSpy = jest.spyOn(util, "deprecate");

server = new Server(
{
Expand Down Expand Up @@ -697,6 +699,7 @@ describe("https option", () => {

afterEach(async () => {
createServerSpy.mockRestore();
utilSpy.mockRestore();

await browser.close();
await server.stop();
Expand All @@ -715,6 +718,9 @@ describe("https option", () => {
waitUntil: "networkidle0",
});

expect(utilSpy.mock.calls[1][1]).toBe(
"The 'cacert' option is deprecated. Please use the 'ca' option."
);
expect(
normalizeOptions(createServerSpy.mock.calls[0][0])
).toMatchSnapshot("https options");
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const https = require("https");
const path = require("path");
const util = require("util");
const fs = require("graceful-fs");
const request = require("supertest");
const spdy = require("spdy");
Expand Down Expand Up @@ -871,11 +872,13 @@ describe("server option", () => {
let browser;
let pageErrors;
let consoleMessages;
let utilSpy;

beforeEach(async () => {
compiler = webpack(config);

createServerSpy = jest.spyOn(https, "createServer");
utilSpy = jest.spyOn(util, "deprecate");

server = new Server(
{
Expand Down Expand Up @@ -916,6 +919,7 @@ describe("server option", () => {

afterEach(async () => {
createServerSpy.mockRestore();
utilSpy.mockRestore();

await browser.close();
await server.stop();
Expand All @@ -934,6 +938,9 @@ describe("server option", () => {
waitUntil: "networkidle0",
});

expect(utilSpy.mock.calls[0][1]).toBe(
"The 'cacert' option is deprecated. Please use the 'ca' option."
);
expect(
normalizeOptions(createServerSpy.mock.calls[0][0])
).toMatchSnapshot("https options");
Expand Down