fix ssl options #230
This commit is contained in:
afrokick 2020-11-28 10:33:44 +03:00
parent 3fbaa2c2c6
commit 23a037c7d3
4 changed files with 60 additions and 8 deletions

View File

@ -2,7 +2,11 @@
### vNEXT
### 0.6.1
* New: PeerJS Server in Docker capture ^C signal and terminate gracefully. #205
* Fix: SSL options in default config. #230
### 0.6.0

View File

@ -11,9 +11,5 @@ const defaultConfig = {
allow_discovery: false,
proxied: false,
cleanup_out_msgs: 1000,
ssl: {
key: "",
cert: ""
}
};
exports.default = defaultConfig;

View File

@ -27,10 +27,6 @@ const defaultConfig: IConfig = {
allow_discovery: false,
proxied: false,
cleanup_out_msgs: 1000,
ssl: {
key: "",
cert: ""
}
};
export default defaultConfig;

56
test/peerjs.ts Normal file
View File

@ -0,0 +1,56 @@
import { expect } from 'chai';
import http from 'http';
import expectedJson from '../app.json';
import { spawn } from 'child_process';
import path from 'path';
const PORT = '9000';
async function makeRequest() {
return new Promise<object>((resolve, reject) => {
http.get(`http://localhost:${PORT}/`, resp => {
let data = '';
resp.on('data', chunk => {
data += chunk;
});
resp.on('end', () => {
resolve(JSON.parse(data));
});
}).on("error", err => {
console.log("Error: " + err.message);
reject(err);
});
});
}
describe('Check bin/peerjs', () => {
it('should return content of app.json file', async () => {
let resolver: () => void;
let rejecter: (err: Error) => void;
const promise = new Promise<void>((resolve, reject) => {
resolver = resolve;
rejecter = reject;
});
const ls = spawn('node', [path.join(__dirname, '../', 'bin/peerjs'), '--port', PORT]);
ls.stdout.on('data', async (data: string) => {
if (!data.includes('Started')) return;
try {
const resp = await makeRequest();
expect(resp).to.deep.eq(expectedJson);
resolver();
} catch (error) {
rejecter(error);
} finally {
ls.kill('SIGINT');
}
});
return promise;
});
});