summaryrefslogtreecommitdiffstats
path: root/debian/tests/test_modules/https-pem/test.js
blob: b22e2c65e4b52c3e767f8ab82fd56cc732aed2f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict'

var assert = require('assert')
var https = require('https')
var pem = require('./')

var server = https.createServer(pem, function (req, res) {
  res.end('foo')
})

server.listen(function () {
  var opts = {
    port: server.address().port,
    rejectUnauthorized: false
  }
  https.request(opts, function (res) {
    assert.strictEqual(res.statusCode, 200)
    res.on('data', function (chunk) {
      assert.strictEqual(chunk.toString(), 'foo')
      process.exit(0)
    })
  }).end()
})