Artifact Content
Not logged in

Artifact eed75e1f625d5457e4e37b2a1a0aaf3c9ed2ecb9:


'use strict'
var spawn = require('child_process').spawn
var https = require('https')
var fs = require('fs')
var path = require('path')

var port = 6767

var server = https.createServer({
  key: fs.readFileSync(path.join(__dirname, '/ssl/server.key')),
  cert: fs.readFileSync(path.join(__dirname, '/ssl/server.crt')),
  ca: fs.readFileSync(path.join(__dirname, '/ssl/ca.crt')),
  requestCert: true,
  rejectUnauthorized: false
}, function (req, res) {
  // Set CORS header, since that is something we are testing.
  res.setHeader('Access-Control-Allow-Origin', '*')
  res.writeHead(200)
  res.end('Can you hear the sound of an enormous door slamming in the depths of hell?\n')
})
server.listen(port, function() {
  console.log('Started https server for karma tests on port ' + port)
  // Spawn process for karma.
  var c = spawn('karma', [
    'start',
    path.join(__dirname, '/karma.conf.js')
  ])
  c.stdout.pipe(process.stdout)
  c.stderr.pipe(process.stderr)
  c.on('exit', function(c) {
    // Exit process with karma exit code.
    if (c !== 0) {
      throw new Error('Karma exited with status code ' + c)
    }
    server.close()
  })
})