Permalink
Browse files

mostly not-failing https test

  • Loading branch information...
1 parent a2e3243 commit 136f90b2dcaa51837cf5be9cf54933a0018f0f14 @substack committed Oct 11, 2011
Showing with 98 additions and 0 deletions.
  1. +59 −0 test/https.js
  2. +13 −0 test/https/certificate.pem
  3. +11 −0 test/https/certrequest.csr
  4. +15 −0 test/https/privatekey.pem
View
@@ -0,0 +1,59 @@
+var test = require('tap').test;
+var http = require('http');
+var https = require('https');
+var bouncy = require('../');
+
+var fs = require('fs');
+var sOpts = {
+ key : fs.readFileSync(__dirname + '/https/privatekey.pem'),
+ cert : fs.readFileSync(__dirname + '/https/certificate.pem')
+};
+
+test('https', function (t) {
+ t.plan(5);
+
+ var p0 = Math.floor(Math.random() * (Math.pow(2,16) - 1e4) + 1e4);
+ var s0 = http.createServer(function (req, res) {
+ res.setHeader('content-type', 'text/plain');
+ res.write('beep boop');
+ t.equal(req.url, '/beep');
+ t.equal(req.headers['x-forwarded-proto'], 'https');
+ res.end();
+ });
+ s0.listen(p0, connect);
+
+ var p1 = Math.floor(Math.random() * (Math.pow(2,16) - 1e4) + 1e4);
+ var s1 = bouncy(sOpts, function (req, bounce) {
+ bounce(p0);
+ });
+ s1.listen(p1, connect);
+
+ var connected = 0;
+ function connect () {
+ if (++connected !== 2) return;
+ var opts = {
+ host : 'localhost',
+ port : p1,
+ path : '/beep'
+ };
+
+ https.get(opts, function (res) {
+console.log('get!');
+ t.equal(res.statusCode, 200)
+ t.equal(res.headers['content-type'], 'text/plain');
+
+ var data = '';
+ res.on('data', function (buf) {
+ data += buf.toString();
+ });
+
+ res.on('end', function () {
+ t.equal(data, 'beep boop');
+console.log('POW!');
+ s0.close();
+ s1.close();
+ t.end();
+ });
+ });
+ }
+});
View
@@ -0,0 +1,13 @@
+-----BEGIN CERTIFICATE-----
+MIICATCCAWoCCQD5tp1iWzpetzANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB
+VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UECh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please sign in to comment.