@@ -55,6 +55,96 @@ describe('"https" CLI option', () => {
55
55
) . toMatchSnapshot ( ) ;
56
56
} ) ;
57
57
58
+ it ( 'should work using "--https-key <path> --https-pfx <path> --https-passphrase webpack-dev-server --https-cert <path> --https-ca <path>"' , async ( ) => {
59
+ const pfxFile = path . join ( httpsCertificateDirectory , "server.pfx" ) ;
60
+ const key = path . join ( httpsCertificateDirectory , "server.key" ) ;
61
+ const cert = path . join ( httpsCertificateDirectory , "server.crt" ) ;
62
+ const ca = path . join ( httpsCertificateDirectory , "ca.pem" ) ;
63
+ const passphrase = "webpack-dev-server" ;
64
+
65
+ const { exitCode, stderr } = await testBin ( [
66
+ "--port" ,
67
+ port ,
68
+ "--https-key" ,
69
+ key ,
70
+ "--https-pfx" ,
71
+ pfxFile ,
72
+ "--https-passphrase" ,
73
+ passphrase ,
74
+ "--https-cert" ,
75
+ cert ,
76
+ "--https-ca" ,
77
+ ca ,
78
+ ] ) ;
79
+
80
+ expect ( exitCode ) . toEqual ( 0 ) ;
81
+ expect (
82
+ normalizeStderr ( stderr , { ipv6 : true , https : true } )
83
+ ) . toMatchSnapshot ( ) ;
84
+ } ) ;
85
+
86
+ it ( 'should work using "--https-key-reset --https-key <path> --https-pfx-reset --https-pfx <path> --https-passphrase webpack-dev-server --https-cert-reset --https-cert <path> --https-ca-reset --https-ca <path>"' , async ( ) => {
87
+ const pfxFile = path . join ( httpsCertificateDirectory , "server.pfx" ) ;
88
+ const key = path . join ( httpsCertificateDirectory , "server.key" ) ;
89
+ const cert = path . join ( httpsCertificateDirectory , "server.crt" ) ;
90
+ const ca = path . join ( httpsCertificateDirectory , "ca.pem" ) ;
91
+ const passphrase = "webpack-dev-server" ;
92
+
93
+ const { exitCode, stderr } = await testBin ( [
94
+ "--port" ,
95
+ port ,
96
+ "--https-key-reset" ,
97
+ "--https-key" ,
98
+ key ,
99
+ "--https-pfx-reset" ,
100
+ "--https-pfx" ,
101
+ pfxFile ,
102
+ "--https-passphrase" ,
103
+ passphrase ,
104
+ "--https-cert-reset" ,
105
+ "--https-cert" ,
106
+ cert ,
107
+ "--https-ca-reset" ,
108
+ "--https-ca" ,
109
+ ca ,
110
+ ] ) ;
111
+
112
+ expect ( exitCode ) . toEqual ( 0 ) ;
113
+ expect (
114
+ normalizeStderr ( stderr , { ipv6 : true , https : true } )
115
+ ) . toMatchSnapshot ( ) ;
116
+ } ) ;
117
+
118
+ it ( 'should warn using "--https-cacert" and "--https-ca" together' , async ( ) => {
119
+ const pfxFile = path . join ( httpsCertificateDirectory , "server.pfx" ) ;
120
+ const key = path . join ( httpsCertificateDirectory , "server.key" ) ;
121
+ const cert = path . join ( httpsCertificateDirectory , "server.crt" ) ;
122
+ const cacert = path . join ( httpsCertificateDirectory , "ca.pem" ) ;
123
+ const passphrase = "webpack-dev-server" ;
124
+
125
+ const { exitCode, stderr } = await testBin ( [
126
+ "--port" ,
127
+ port ,
128
+ "--https-key" ,
129
+ key ,
130
+ "--https-pfx" ,
131
+ pfxFile ,
132
+ "--https-passphrase" ,
133
+ passphrase ,
134
+ "--https-cert" ,
135
+ cert ,
136
+ "--https-cacert" ,
137
+ cacert ,
138
+ "--https-ca" ,
139
+ cacert ,
140
+ ] ) ;
141
+
142
+ expect ( exitCode ) . toEqual ( 0 ) ;
143
+ expect (
144
+ normalizeStderr ( stderr , { ipv6 : true , https : true } )
145
+ ) . toMatchSnapshot ( ) ;
146
+ } ) ;
147
+
58
148
// For https://github.com/webpack/webpack-dev-server/issues/3306
59
149
it ( 'should work using "--https-key <path> --https-pfx <path> --https-passphrase webpack-dev-server --https-cert <path>"' , async ( ) => {
60
150
const pfxFile = path . join ( httpsCertificateDirectory , "server.pfx" ) ;
0 commit comments