-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
https-option.test.js
116 lines (98 loc) · 3.29 KB
/
https-option.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
"use strict";
const path = require("path");
const del = require("del");
const Server = require("../../lib/Server");
const { testBin, normalizeStderr } = require("../helpers/test-bin");
const port = require("../ports-map")["cli-https"];
const httpsCertificateDirectory = path.resolve(
__dirname,
"../fixtures/https-certificate"
);
const defaultCertificateDir = Server.findCacheDir();
describe('"https" CLI option', () => {
beforeEach(async () => {
await del([defaultCertificateDir]);
});
it('should work using "--https"', async () => {
const { exitCode, stderr } = await testBin(["--port", port, "--https"]);
expect(exitCode).toEqual(0);
expect(
normalizeStderr(stderr, { ipv6: true, https: true })
).toMatchSnapshot();
});
it('should work using "--https-key <path> --https-pfx <path> --https-passphrase webpack-dev-server --https-cert <path> --https-cacert <path>"', async () => {
const pfxFile = path.join(httpsCertificateDirectory, "server.pfx");
const key = path.join(httpsCertificateDirectory, "server.key");
const cert = path.join(httpsCertificateDirectory, "server.crt");
const cacert = path.join(httpsCertificateDirectory, "ca.pem");
const passphrase = "webpack-dev-server";
const { exitCode, stderr } = await testBin([
"--port",
port,
"--https-key",
key,
"--https-pfx",
pfxFile,
"--https-passphrase",
passphrase,
"--https-cert",
cert,
"--https-cacert",
cacert,
]);
expect(exitCode).toEqual(0);
expect(
normalizeStderr(stderr, { ipv6: true, https: true })
).toMatchSnapshot();
});
// For https://github.com/webpack/webpack-dev-server/issues/3306
it('should work using "--https-key <path> --https-pfx <path> --https-passphrase webpack-dev-server --https-cert <path>"', async () => {
const pfxFile = path.join(httpsCertificateDirectory, "server.pfx");
const key = path.join(httpsCertificateDirectory, "server.key");
const cert = path.join(httpsCertificateDirectory, "server.crt");
const passphrase = "webpack-dev-server";
const { exitCode, stderr } = await testBin([
"--port",
port,
"--https-key",
key,
"--https-pfx",
pfxFile,
"--https-passphrase",
passphrase,
"--https-cert",
cert,
]);
expect(exitCode).toEqual(0);
expect(
normalizeStderr(stderr, { ipv6: true, https: true })
).toMatchSnapshot();
});
it('should work using "--https-request-cert"', async () => {
const { exitCode, stderr } = await testBin([
"--port",
port,
"--https-request-cert",
]);
expect(exitCode).toEqual(0);
expect(
normalizeStderr(stderr, { ipv6: true, https: true })
).toMatchSnapshot();
});
it('should work using "--no-https-request-cert"', async () => {
const { exitCode, stderr } = await testBin([
"--port",
port,
"--no-https-request-cert",
]);
expect(exitCode).toEqual(0);
expect(
normalizeStderr(stderr, { ipv6: true, https: true })
).toMatchSnapshot();
});
it('should work using "--no-https"', async () => {
const { exitCode, stderr } = await testBin(["--port", port, "--no-https"]);
expect(exitCode).toEqual(0);
expect(normalizeStderr(stderr, { ipv6: true })).toMatchSnapshot();
});
});