Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] add h2 / spdy support #1302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/https/hello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function hello(name){
return "hello " + (name || 'world');
}
10 changes: 10 additions & 0 deletions examples/https/hello_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var expect = chai.expect;

describe('hello', function(){
it('should say hello', function(){
expect(hello()).to.equal('hello world');
});
it('should say hello to person', function(){
expect(hello('Bob')).to.equal('hello Bob');
});
});
10 changes: 10 additions & 0 deletions examples/https/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"scripts": {
"test": "node ../../testem.js ci -P 10"
},
"repository": {
"type": "git",
"url": "git://github.com/testem/testem.git"
},
"license": "MIT"
}
19 changes: 19 additions & 0 deletions examples/https/server.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-----BEGIN CERTIFICATE-----
MIIDGjCCAgICCQCxHV+qHLznmTANBgkqhkiG9w0BAQsFADBPMQswCQYDVQQGEwJV
UzELMAkGA1UECAwCQ0ExETAPBgNVBAcMCFNhbiBKb3NlMREwDwYDVQQKDAhMaW5r
ZWRJbjENMAsGA1UEAwwEVGVzdDAeFw0xODEwMDIwNTEzMzNaFw0xOTEwMDIwNTEz
MzNaME8xCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTERMA8GA1UEBwwIU2FuIEpv
c2UxETAPBgNVBAoMCExpbmtlZEluMQ0wCwYDVQQDDARUZXN0MIIBIjANBgkqhkiG
9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoK9IvpHgzd69fuoBRO0gLHqqi4vMPa6H6W4x
hqhpkMPiDswRn1eOF6vhLHqLcHL9lAbWtFumqMeo4NZTeI28qvRcqhI45gR0meMr
ZBAxgrjPuK/XdYlGZoB9FYwSsdfldkNPpRYXAAr+sujfLvacNAWEIR2d5334X6Wm
o/zuMA9k/HHqy9lPZ5KwAHSJznFjyTSKbNiIfzYeVYB+m279ZX6M48Ur5vRMlJsk
cH0OikEjhB78fLUp3ESRJ3EKpsREAhmS/MCv3rTL6V2oZXfHBf6lIfjyPTDIVvEy
E/Ji60fobdCqeCyEjJFk0gqtuMNJvYyMGnnxrXJLy5IBKHvIAwIDAQABMA0GCSqG
SIb3DQEBCwUAA4IBAQBBm2Jy22jj4ozWV94dlLVB6K41ej4RvkPhpTnUTiQ+LliP
Jx4hy41EnWrweZLtmAdAHsGW2iNZpYv799bqA47edddIxgkGy3UBKJMXcQiPE+l3
M6tuWxLngBDk7Dncxp6SGjuQXx4jisXa5dp/D796A+mU7vdFmyKU4MRA/coQwm/h
2A2yv4a8bigd+xr+FUfQ2bqbSPJR6NppqHC9VJ0IeTaWO4c6/QOUdFRY6LEZzDq7
jR/D2EZFENoHwVoFbdGU44ftZzPEK9Y0+IwQl7yo74GkA9ZMj9t0EjkUbPhbVhKW
icR16sACYEPAzXSw+6USaOFhvr/Y+I/Lw5Xsl4vj
-----END CERTIFICATE-----
28 changes: 28 additions & 0 deletions examples/https/server.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCgr0i+keDN3r1+
6gFE7SAseqqLi8w9rofpbjGGqGmQw+IOzBGfV44Xq+Eseotwcv2UBta0W6aox6jg
1lN4jbyq9FyqEjjmBHSZ4ytkEDGCuM+4r9d1iUZmgH0VjBKx1+V2Q0+lFhcACv6y
6N8u9pw0BYQhHZ3nffhfpaaj/O4wD2T8c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eny8G51WA4XAtRWe6yhC5cIuCLIwmhkxiudfbjGJr2BtoH4E2owKMEx4
XD17peG7dijTr5I27SwjViEAH8oHTFWcnDsFzs1H6vymoN/qSVEtjNWJFNe0UvvV
9f4t3Sy2Xbkin4pyJ5++cZAKo/ABRvOkISWGRHDFEQKBgQCAsRtnKVAo/GdzV/8b
3PSx2HHf8sYBQ7ArNdSfTiMu4gDgOGC1NukYOy5WuL4kfz5gZrRhP1FLvt6WGDEN
nG/71MIZDAxc9IgrpXz1iUSihvHi+RwiF0AvNm0xaHsm2MhDDbvBK8oR5Bw3G9zU
Dka9MCKT9+E3CpOUmuPqVPfzuw==
-----END PRIVATE KEY-----
20 changes: 20 additions & 0 deletions examples/https/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!doctype html>
<html>
<head>
<title>Test'em</title>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/mocha/2.3.4/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script src="/testem.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/mocha/2.3.4/mocha.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/chai/3.4.1/chai.js"></script>
<script>mocha.setup('bdd')</script>
<script src="hello.js"></script>
<script src="hello_spec.js"></script>
<script>
Testem.hookIntoTestFramework();
mocha.run()
</script>
</body>
</html>
10 changes: 10 additions & 0 deletions examples/https/testem.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"framework": "mocha",
"test_page": "test.html",
"src_files": [
"*.js"
],
"key": "server.key",
"cert": "server.crt",
"rejectUnauthorized": false
}
13 changes: 11 additions & 2 deletions lib/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ var EventEmitter = require('events').EventEmitter;
var Mustache = require('consolidate').mustache;
var http = require('http');
var https = require('https');
var spdy = require('spdy');
var mime = require('mime-types')
var httpProxy = require('http-proxy');
var Bluebird = require('bluebird');

Expand Down Expand Up @@ -84,21 +86,28 @@ class Server extends EventEmitter {

createExpress() {
var app = this.express = express();

var serveStaticFile = (req, res) => {
this.serveStaticFile(req.params[0], req, res);
};

if (this.config.get('key') || this.config.get('pfx')) {
var options = {};

if (this.config.get('key')) {
options.key = fs.readFileSync(this.config.get('key'));
options.cert = fs.readFileSync(this.config.get('cert'));
} else {
options.pfx = fs.readFileSync(this.config.get('pfx'));
}
this.server = https.createServer(options, this.express);
this.server = spdy.createServer(options, app)
} else {
this.server = http.createServer(this.express);
this.server = spdy.createServer({
spdy: {
ssl: false,
plain: true
}
}, app);
}
this.io = socketIO(this.server);

Expand Down
Loading