mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore(testserver): prepare test server (#3294)
This commit is contained in:
11
test/server/run.js → test/run_static_server.js
Normal file → Executable file
11
test/server/run.js → test/run_static_server.js
Normal file → Executable file
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Copyright 2017 Google Inc. All rights reserved.
|
||||
*
|
||||
@@ -14,16 +15,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
const path = require('path');
|
||||
const SimpleServer = require('./SimpleServer');
|
||||
const {TestServer} = require('../utils/testserver/');
|
||||
|
||||
const port = 8907;
|
||||
const httpsPort = 8908;
|
||||
const assetsPath = path.join(__dirname, '..', 'assets');
|
||||
const cachedPath = path.join(__dirname, '..', 'assets', 'cached');
|
||||
const assetsPath = path.join(__dirname, 'assets');
|
||||
const cachedPath = path.join(__dirname, 'assets', 'cached');
|
||||
|
||||
Promise.all([
|
||||
SimpleServer.create(assetsPath, port),
|
||||
SimpleServer.createHTTPS(assetsPath, httpsPort)
|
||||
TestServer.create(assetsPath, port),
|
||||
TestServer.createHTTPS(assetsPath, httpsPort)
|
||||
]).then(([server, httpsServer]) => {
|
||||
server.enableHTTPCache(cachedPath);
|
||||
httpsServer.enableHTTPCache(cachedPath);
|
||||
@@ -1,249 +0,0 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
const url = require('url');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const mime = require('mime');
|
||||
const WebSocketServer = require('ws').Server;
|
||||
|
||||
const fulfillSymbol = Symbol('fullfil callback');
|
||||
const rejectSymbol = Symbol('reject callback');
|
||||
|
||||
class SimpleServer {
|
||||
/**
|
||||
* @param {string} dirPath
|
||||
* @param {number} port
|
||||
* @return {!SimpleServer}
|
||||
*/
|
||||
static async create(dirPath, port) {
|
||||
const server = new SimpleServer(dirPath, port);
|
||||
await new Promise(x => server._server.once('listening', x));
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} dirPath
|
||||
* @param {number} port
|
||||
* @return {!SimpleServer}
|
||||
*/
|
||||
static async createHTTPS(dirPath, port) {
|
||||
const server = new SimpleServer(dirPath, port, {
|
||||
key: fs.readFileSync(path.join(__dirname, 'key.pem')),
|
||||
cert: fs.readFileSync(path.join(__dirname, 'cert.pem')),
|
||||
passphrase: 'aaaa',
|
||||
});
|
||||
await new Promise(x => server._server.once('listening', x));
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} dirPath
|
||||
* @param {number} port
|
||||
* @param {!Object=} sslOptions
|
||||
*/
|
||||
constructor(dirPath, port, sslOptions) {
|
||||
if (sslOptions)
|
||||
this._server = https.createServer(sslOptions, this._onRequest.bind(this));
|
||||
else
|
||||
this._server = http.createServer(this._onRequest.bind(this));
|
||||
this._server.on('connection', socket => this._onSocket(socket));
|
||||
this._wsServer = new WebSocketServer({server: this._server});
|
||||
this._wsServer.on('connection', this._onWebSocketConnection.bind(this));
|
||||
this._server.listen(port);
|
||||
this._dirPath = dirPath;
|
||||
|
||||
this._startTime = new Date();
|
||||
this._cachedPathPrefix = null;
|
||||
|
||||
/** @type {!Set<!net.Socket>} */
|
||||
this._sockets = new Set();
|
||||
|
||||
/** @type {!Map<string, function(!IncomingMessage, !ServerResponse)>} */
|
||||
this._routes = new Map();
|
||||
/** @type {!Map<string, !{username:string, password:string}>} */
|
||||
this._auths = new Map();
|
||||
/** @type {!Map<string, string>} */
|
||||
this._csp = new Map();
|
||||
/** @type {!Map<string, !Promise>} */
|
||||
this._requestSubscribers = new Map();
|
||||
}
|
||||
|
||||
_onSocket(socket) {
|
||||
this._sockets.add(socket);
|
||||
// ECONNRESET is a legit error given
|
||||
// that tab closing simply kills process.
|
||||
socket.on('error', error => {
|
||||
if (error.code !== 'ECONNRESET')
|
||||
throw error;
|
||||
});
|
||||
socket.once('close', () => this._sockets.delete(socket));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} pathPrefix
|
||||
*/
|
||||
enableHTTPCache(pathPrefix) {
|
||||
this._cachedPathPrefix = pathPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
* @param {string} username
|
||||
* @param {string} password
|
||||
*/
|
||||
setAuth(path, username, password) {
|
||||
this._auths.set(path, {username, password});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
* @param {string} csp
|
||||
*/
|
||||
setCSP(path, csp) {
|
||||
this._csp.set(path, csp);
|
||||
}
|
||||
|
||||
async stop() {
|
||||
this.reset();
|
||||
for (const socket of this._sockets)
|
||||
socket.destroy();
|
||||
this._sockets.clear();
|
||||
await new Promise(x => this._server.close(x));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
* @param {function(!IncomingMessage, !ServerResponse)} handler
|
||||
*/
|
||||
setRoute(path, handler) {
|
||||
this._routes.set(path, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} from
|
||||
* @param {string} to
|
||||
*/
|
||||
setRedirect(from, to) {
|
||||
this.setRoute(from, (req, res) => {
|
||||
res.writeHead(302, { location: to });
|
||||
res.end();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
* @return {!Promise<!IncomingMessage>}
|
||||
*/
|
||||
waitForRequest(path) {
|
||||
let promise = this._requestSubscribers.get(path);
|
||||
if (promise)
|
||||
return promise;
|
||||
let fulfill, reject;
|
||||
promise = new Promise((f, r) => {
|
||||
fulfill = f;
|
||||
reject = r;
|
||||
});
|
||||
promise[fulfillSymbol] = fulfill;
|
||||
promise[rejectSymbol] = reject;
|
||||
this._requestSubscribers.set(path, promise);
|
||||
return promise;
|
||||
}
|
||||
|
||||
reset() {
|
||||
this._routes.clear();
|
||||
this._auths.clear();
|
||||
this._csp.clear();
|
||||
const error = new Error('Static Server has been reset');
|
||||
for (const subscriber of this._requestSubscribers.values())
|
||||
subscriber[rejectSymbol].call(null, error);
|
||||
this._requestSubscribers.clear();
|
||||
}
|
||||
|
||||
_onRequest(request, response) {
|
||||
request.on('error', error => {
|
||||
if (error.code === 'ECONNRESET')
|
||||
response.end();
|
||||
else
|
||||
throw error;
|
||||
});
|
||||
const pathName = url.parse(request.url).path;
|
||||
if (this._auths.has(pathName)) {
|
||||
const auth = this._auths.get(pathName);
|
||||
const credentials = Buffer.from((request.headers.authorization || '').split(' ')[1] || '', 'base64').toString();
|
||||
if (credentials !== `${auth.username}:${auth.password}`) {
|
||||
response.writeHead(401, { 'WWW-Authenticate': 'Basic realm="Secure Area"' });
|
||||
response.end('HTTP Error 401 Unauthorized: Access is denied');
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Notify request subscriber.
|
||||
if (this._requestSubscribers.has(pathName)) {
|
||||
this._requestSubscribers.get(pathName)[fulfillSymbol].call(null, request);
|
||||
this._requestSubscribers.delete(pathName);
|
||||
}
|
||||
const handler = this._routes.get(pathName);
|
||||
if (handler) {
|
||||
handler.call(null, request, response);
|
||||
} else {
|
||||
const pathName = url.parse(request.url).path;
|
||||
this.serveFile(request, response, pathName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {!IncomingMessage} request
|
||||
* @param {!ServerResponse} response
|
||||
* @param {string} pathName
|
||||
*/
|
||||
serveFile(request, response, pathName) {
|
||||
if (pathName === '/')
|
||||
pathName = '/index.html';
|
||||
const filePath = path.join(this._dirPath, pathName.substring(1));
|
||||
|
||||
if (this._cachedPathPrefix !== null && filePath.startsWith(this._cachedPathPrefix)) {
|
||||
if (request.headers['if-modified-since']) {
|
||||
response.statusCode = 304; // not modified
|
||||
response.end();
|
||||
return;
|
||||
}
|
||||
response.setHeader('Cache-Control', 'public, max-age=31536000');
|
||||
response.setHeader('Last-Modified', this._startTime.toISOString());
|
||||
} else {
|
||||
response.setHeader('Cache-Control', 'no-cache, no-store');
|
||||
}
|
||||
if (this._csp.has(pathName))
|
||||
response.setHeader('Content-Security-Policy', this._csp.get(pathName));
|
||||
|
||||
fs.readFile(filePath, function(err, data) {
|
||||
if (err) {
|
||||
response.statusCode = 404;
|
||||
response.end(`File not found: ${filePath}`);
|
||||
return;
|
||||
}
|
||||
response.setHeader('Content-Type', mime.getType(filePath));
|
||||
response.end(data);
|
||||
});
|
||||
}
|
||||
|
||||
_onWebSocketConnection(connection) {
|
||||
connection.send('opened');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SimpleServer;
|
||||
@@ -1,31 +0,0 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFXzCCA0egAwIBAgIJAM+8uXXn61zZMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV
|
||||
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
|
||||
aWRnaXRzIFB0eSBMdGQwIBcNMTcwNzEwMjI1MDA2WhgPMzAxNjExMTAyMjUwMDZa
|
||||
MEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJ
|
||||
bnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw
|
||||
ggIKAoICAQCfsIbw1Q91wooUdSu5tDiyrSYB6ZQmY49Y141KQ0ll0ZXzf1sPTpPg
|
||||
OuBjJE8Fre2Wn3jJ0SfLFyQBMvE49hqWyY/U5Xc367ujqKFQVoItnoV5MM2TPu5J
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RVrF7ryBcGneLTcQm/oNUp8aRyiwyQIDH7djFSp11MakXBF+EeGR523pp
|
||||
u+sleR7ZFBGyb3Z5K9NdRdUk0SWu7Hu4jQtJHn+PmIZ1qjfbPv5qDfVd1vmFwqsu
|
||||
7NfsLoNm0dQNu5WOMLISQHmQiT86AH2wWQ3l5Sm+g8/BdNLQLklhtZcRhp2efyiL
|
||||
ciUmGugKqoX+nPIZ36kuoRTZy++AnTiid011vZFe1qrfug/ykWiqWmBSvD/cfRU4
|
||||
ydoK87cfjIixqmpRZ7j2q+/cDK2SbYN0t/Xrufw3L6TjDgUEL7ZCImcwqqWJz9I8
|
||||
ASnnL5PhX8bbsUrtE21Ugqk2zYnVnqRO5FjINtlTb07y9pGC/QpBkb1AasF5okhe
|
||||
7lw/sMiryKKzS4A10nRV/+gErDBsIBj+cpGPM8brLfZuy2o=
|
||||
-----END CERTIFICATE-----
|
||||
@@ -1,54 +0,0 @@
|
||||
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
MIIJjjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQIT2qHBljWwsICAggA
|
||||
MBQGCCqGSIb3DQMHBAh5lMoGsb1UgQSCCUg/FtxOBSUG05DteTzzkdp6FptfOy5p
|
||||
iirYKWUNck6EhPdZ1RPSuCvs84S+qP6Po5gFfGz9e7tdbNSueOQnMD+vbS8vXpZU
|
||||
4KVafxUlKbAfSVj2ZY6SkbU8v/iXiTieUj3G046z5QYsfcvyEdS47Z+WbKAJKemv
|
||||
BVck4W+/gKtiukbK/94VaehC7kbbO2yp9/kYp9qqk33aB61C8xX/fILOIRdYkvut
|
||||
55pHGviN5Eajabm/d83MPAzaqUdv9NiIKej2IFXs+Oz8OYRbVVHwyN93HquHmn+V
|
||||
WKOknJXzvS5Pa+ViGmB4o6+fpluuIyHXJUUG20z/IY5n0vaBo4jRlyYZ3J1vWTZ2
|
||||
1bhLGPUPUlGt1vToY5Ejr8qxaYGxLEOOxvRL3Z1xn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LEg+xGvAUhwbdmWxzYHye2MAt4sObi4YFDb1RVkZzCj2eer
|
||||
6hzCQi5VUB3pUqr8in1TJMXPzCrl4ZdK2KoHtNA1gKT7midLzsjP+rXsgKtzcGAO
|
||||
IcNOkbv8KqzYr2OtcEW+v9z6vgSpKImQ/n+6/WLRGWh9pLCZ+onD06OLcsm55H4y
|
||||
zNacau+nT+Mf9XQTErFjj2+orjF3p2u3tY9vpoLJN653mMTNzexVZi+k9NgZz7eL
|
||||
4m8R3ai0ZeGQezo9rGHQ6ulqlueN0qXGKI07G4VKxM35OZeOyPPnrF95FQzMY5Ox
|
||||
GkQr1hR0rj+oQJTFWIfy9ffZEBzUqC8fYYvOPJO32I+fe2tvBUtpUe3w7dYHVs3a
|
||||
lqi/+Wwk0QLE4ItR5f0sZsoIeHkDeXoKYrCOOPl2bnIQA3UT/rszGl6YDY8pU/7W
|
||||
fziO/G5BzGe7LU7o26ykzkmDF5alUaNdfVnnQcm/iRy8YOsjfKQmqbFfFCKOlRMo
|
||||
RdTStOcsEzddttI57YlBHv5Gh1GfMjd5acgeQfStSMwHcahwY2Y36WcR4GE4Id/5
|
||||
ycaikCt+zYEVKUoO+JEZxvzFQIPVhT3oBOjSFj/EeMLmnGMjnohdgEmh2T7+0Ko5
|
||||
oAMzWW/XNeJlL1DAPPEpya66oSvwZvxUkGDLcIGYWgzSKz0JO8zn6wDTOU7O2YeF
|
||||
Gm8YymS0oqnK1wE6HJ1YSk2ers6kgZij3kVAnGlbI88YLeMJvteO2oL7GqfEQdSA
|
||||
HskQklLZUT2Y+m7oinVyCcdbKRGI9frnfm6j3TVkrNHjcc7aKhM+XT5ZNKxT3ftt
|
||||
4Ig=
|
||||
-----END ENCRYPTED PRIVATE KEY-----
|
||||
@@ -16,7 +16,7 @@
|
||||
const fs = require('fs');
|
||||
const rm = require('rimraf').sync;
|
||||
const path = require('path');
|
||||
const SimpleServer = require('./server/SimpleServer');
|
||||
const {TestServer} = require('../utils/testserver/');
|
||||
const GoldenUtils = require('./golden-utils');
|
||||
const GOLDEN_DIR = path.join(__dirname, 'golden');
|
||||
const OUTPUT_DIR = path.join(__dirname, 'output');
|
||||
@@ -75,7 +75,7 @@ beforeAll(async state => {
|
||||
const cachedPath = path.join(__dirname, 'assets', 'cached');
|
||||
|
||||
const port = 8907 + state.parallelIndex * 2;
|
||||
state.server = await SimpleServer.create(assetsPath, port);
|
||||
state.server = await TestServer.create(assetsPath, port);
|
||||
state.server.enableHTTPCache(cachedPath);
|
||||
state.server.PORT = port;
|
||||
state.server.PREFIX = `http://localhost:${port}`;
|
||||
@@ -83,7 +83,7 @@ beforeAll(async state => {
|
||||
state.server.EMPTY_PAGE = `http://localhost:${port}/empty.html`;
|
||||
|
||||
const httpsPort = port + 1;
|
||||
state.httpsServer = await SimpleServer.createHTTPS(assetsPath, httpsPort);
|
||||
state.httpsServer = await TestServer.createHTTPS(assetsPath, httpsPort);
|
||||
state.httpsServer.enableHTTPCache(cachedPath);
|
||||
state.httpsServer.PORT = httpsPort;
|
||||
state.httpsServer.PREFIX = `https://localhost:${httpsPort}`;
|
||||
|
||||
Reference in New Issue
Block a user