mirror of
https://github.com/cypress-io/cypress.git
synced 2026-03-14 21:30:37 -05:00
remove core- prefixes from packages
This commit is contained in:
48
packages/https-proxy/test/helpers/https_server.coffee
Normal file
48
packages/https-proxy/test/helpers/https_server.coffee
Normal file
@@ -0,0 +1,48 @@
|
||||
fs = require("fs")
|
||||
path = require("path")
|
||||
https = require("https")
|
||||
Promise = require("bluebird")
|
||||
sslRootCas = require('ssl-root-cas')
|
||||
allowDestroy = require("server-destroy-vvo")
|
||||
|
||||
sslRootCas
|
||||
.inject()
|
||||
.addFile(path.join(__dirname, "certs", "server", "my-root-ca.crt.pem"))
|
||||
|
||||
options = {
|
||||
key: fs.readFileSync(path.join(__dirname, "certs", "server", "my-server.key.pem"))
|
||||
cert: fs.readFileSync(path.join(__dirname, "certs", "server", "my-server.crt.pem"))
|
||||
}
|
||||
|
||||
onRequest = (req, res) ->
|
||||
console.log "HTTPS SERVER REQUEST URL:", req.url
|
||||
console.log "HTTPS SERVER REQUEST HEADERS:", req.headers
|
||||
|
||||
res.setHeader("Content-Type", "text/html")
|
||||
res.writeHead(200)
|
||||
res.end("<html><head></head><body>https server</body></html>")
|
||||
|
||||
servers = []
|
||||
|
||||
module.exports = {
|
||||
start: (port) ->
|
||||
new Promise (resolve) ->
|
||||
srv = https.createServer(options, onRequest)
|
||||
|
||||
allowDestroy(srv)
|
||||
|
||||
servers.push(srv)
|
||||
|
||||
srv.listen port, ->
|
||||
console.log "server listening on port: #{port}"
|
||||
resolve(srv)
|
||||
|
||||
stop: ->
|
||||
stop = (srv) ->
|
||||
new Promise (resolve) ->
|
||||
srv.destroy(resolve)
|
||||
|
||||
Promise.map(servers, stop)
|
||||
.then ->
|
||||
servers = []
|
||||
}
|
||||
Reference in New Issue
Block a user