(name, httpModules)
| 67 | }) |
| 68 | |
| 69 | function runTests (name, httpModules) { |
| 70 | tape(name, function (t) { |
| 71 | var toHttps = 'http://localhost:' + plainServer.port + '/to_https' |
| 72 | var toPlain = 'https://localhost:' + httpsServer.port + '/to_plain' |
| 73 | var options = { httpModules: httpModules, strictSSL: false } |
| 74 | var modulesTest = httpModules || {} |
| 75 | |
| 76 | clearFauxRequests() |
| 77 | |
| 78 | request(toHttps, options, function (err, res, body) { |
| 79 | t.equal(err, null) |
| 80 | t.equal(res.statusCode, 200) |
| 81 | t.equal(body, 'https', 'Received HTTPS server body') |
| 82 | |
| 83 | t.equal(fauxRequestsMade.http, modulesTest['http:'] ? 1 : 0) |
| 84 | t.equal(fauxRequestsMade.https, modulesTest['https:'] ? 1 : 0) |
| 85 | |
| 86 | request(toPlain, options, function (err, res, body) { |
| 87 | t.equal(err, null) |
| 88 | t.equal(res.statusCode, 200) |
| 89 | t.equal(body, 'plain', 'Received HTTPS server body') |
| 90 | |
| 91 | t.equal(fauxRequestsMade.http, modulesTest['http:'] ? 2 : 0) |
| 92 | t.equal(fauxRequestsMade.https, modulesTest['https:'] ? 2 : 0) |
| 93 | |
| 94 | t.end() |
| 95 | }) |
| 96 | }) |
| 97 | }) |
| 98 | } |
| 99 | |
| 100 | runTests('undefined') |
| 101 | runTests('empty', {}) |
no test coverage detected
searching dependent graphs…