Skip to content

Commit e395a96

Browse files
chaos-githiroppy
authored andcommitted
Fixes #1805: Allow symlinks for devServer.https options (#1807)
1 parent cf4d0d0 commit e395a96

File tree

7 files changed

+49
-1
lines changed

7 files changed

+49
-1
lines changed

lib/Server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ class Server {
603603
let stats = null;
604604

605605
try {
606-
stats = fs.lstatSync(value).isFile();
606+
stats = fs.lstatSync(fs.realpathSync(value)).isFile();
607607
} catch (error) {
608608
// ignore error
609609
}

test/Https.test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const fs = require('fs');
55
const request = require('supertest');
66
const helper = require('./helper');
77
const config = require('./fixtures/contentbase-config/webpack.config');
8+
const skipTestOnWindows = require('./helpers/conditional-test')
9+
.skipTestOnWindows;
810

911
const httpsCertificateDirectory = path.join(
1012
__dirname,
@@ -95,6 +97,36 @@ describe('HTTPS', () => {
9597
});
9698
});
9799

100+
describe('ca, pfx, key and cert are symlinks', () => {
101+
if (skipTestOnWindows('Symlinks are not supported on Windows')) {
102+
return;
103+
}
104+
105+
beforeAll((done) => {
106+
server = helper.start(
107+
config,
108+
{
109+
contentBase: contentBasePublic,
110+
https: {
111+
ca: path.join(httpsCertificateDirectory, 'ca-symlink.pem'),
112+
pfx: path.join(httpsCertificateDirectory, 'server-symlink.pfx'),
113+
key: path.join(httpsCertificateDirectory, 'server-symlink.key'),
114+
cert: path.join(httpsCertificateDirectory, 'server-symlink.crt'),
115+
passphrase: 'webpack-dev-server',
116+
},
117+
},
118+
done
119+
);
120+
req = request(server.app);
121+
});
122+
123+
it('Request to index', (done) => {
124+
req.get('/').expect(200, /Heyo/, done);
125+
});
126+
127+
afterAll(helper.close);
128+
});
129+
98130
describe('ca, pfx, key and cert are raw strings', () => {
99131
beforeAll((done) => {
100132
server = helper.start(
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ca.pem
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
server.crt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
server.key
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
server.pfx

test/helpers/conditional-test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
const isWindows = process.platform === 'win32';
4+
5+
function skipTestOnWindows(reason) {
6+
if (isWindows) {
7+
test.skip(reason, () => {});
8+
}
9+
return isWindows;
10+
}
11+
12+
module.exports.skipTestOnWindows = skipTestOnWindows;

0 commit comments

Comments
 (0)