Skip to content

Commit 94963ab

Browse files
mmaleckiry
authored andcommitted
Add failing test for https2 compatibility
Issue #1531
1 parent 2e5a8e0 commit 94963ab

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright Joyent, Inc. and other Node contributors.
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a
4+
// copy of this software and associated documentation files (the
5+
// "Software"), to deal in the Software without restriction, including
6+
// without limitation the rights to use, copy, modify, merge, publish,
7+
// distribute, sublicense, and/or sell copies of the Software, and to permit
8+
// persons to whom the Software is furnished to do so, subject to the
9+
// following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included
12+
// in all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
22+
if (!process.versions.openssl) {
23+
console.error("Skipping because node compiled without OpenSSL.");
24+
process.exit(0);
25+
}
26+
27+
var https = require('https');
28+
var assert = require('assert');
29+
var fs = require('fs');
30+
var common = require('../common');
31+
32+
var options = {
33+
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
34+
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
35+
};
36+
37+
var gotCallback = false;
38+
39+
var server = https.createServer(options, function(req, res) {
40+
res.writeHead(200);
41+
res.end("hello world\n");
42+
});
43+
44+
server.listen(common.PORT, function() {
45+
https.get({
46+
path: '/',
47+
port: common.PORT,
48+
agent: false
49+
}, function (res) {
50+
console.error(res.statusCode);
51+
gotCallback = true;
52+
server.close();
53+
}).on('error', function (e) {
54+
console.error(e.message);
55+
process.exit(1);
56+
});
57+
});
58+
59+
process.on('exit', function() {
60+
assert.ok(gotCallback);
61+
});
62+

0 commit comments

Comments
 (0)