Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 1fb34d2

Browse files
committed
fix: skip HTTPS tests when !isNode
License: MIT Signed-off-by: Marcin Rataj <[email protected]>
1 parent 3879402 commit 1fb34d2

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/files-regular/add-from-url.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
const { getDescribe, getIt, expect } = require('../utils/mocha')
55
const parallel = require('async/parallel')
66
const EchoHttpServer = require('../utils/echo-http-server')
7-
const { isBrowser, isWebWorker } = require('ipfs-utils/src/env')
7+
const { isNode } = require('ipfs-utils/src/env')
88

99
const httpServer = EchoHttpServer.createServer()
1010
const httpsServer = EchoHttpServer.createServer({ secure: true })
@@ -68,7 +68,7 @@ module.exports = (createCommon, options) => {
6868
})
6969

7070
it('should add from a HTTPS URL', function (done) {
71-
if (isBrowser || isWebWorker) return this.skip() // unable to do self-signed HTTPS in browser
71+
if (!isNode) return this.skip() // unable to do self-signed HTTPS in browser
7272
const text = `TEST${Date.now()}`
7373
const url = httpsServer.echoUrl(text)
7474
parallel({
@@ -105,7 +105,7 @@ module.exports = (createCommon, options) => {
105105
})
106106

107107
it('should add from a HTTPS URL with redirection', function (done) {
108-
if (isBrowser || isWebWorker) return this.skip() // unable to do self-signed HTTPS in browser
108+
if (!isNode) return this.skip() // unable to do self-signed HTTPS in browser
109109
const text = `TEST${Date.now()}`
110110
const url = httpsServer.echoUrl(text) + '?foo=bar#buzz'
111111
const redirectUrl = httpsServer.redirectUrl(url)

src/utils/echo-http-server.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
const http = require('http')
55
const https = require('https')
66
const URL = require('url').URL || self.URL
7-
const { isBrowser, isWebWorker } = require('ipfs-utils/src/env')
7+
const { isNode } = require('ipfs-utils/src/env')
88

99
const loadFixture = require('aegir/fixtures')
1010
const sslOpts = Object.freeze({
@@ -14,8 +14,6 @@ const sslOpts = Object.freeze({
1414

1515
const httpPort = 11080
1616
const httpsPort = 11443
17-
module.exports.httpPort = httpPort
18-
module.exports.httpsPort = httpsPort
1917

2018
// Create a mock of remote HTTP server that can return arbitrary text in response
2119
// or redirect to other URL. Used in tests of ipfs.addFromURL etc
@@ -25,7 +23,7 @@ module.exports.createServer = (opts) => {
2523

2624
// Web browser is not able to start HTTP server
2725
// We return noop here and start it from Node via .aegir.js/hooks/browser/pre|post instead (eg. in js-ipfs)
28-
if (isBrowser || isWebWorker) {
26+
if (!isNode) {
2927
const noopServer = {
3028
start: (cb) => cb(),
3129
stop: (cb) => cb(),
@@ -75,7 +73,7 @@ module.exports.createServer = (opts) => {
7573
cb = opts
7674
opts = {}
7775
}
78-
return server.listen(Object.assign({ port: defaultPort }, opts), cb)
76+
return server.listen(Object.assign({ port: defaultPort, host: '127.0.0.1' }, opts), cb)
7977
}
8078

8179
server.stop = (cb) => server.close(cb)

0 commit comments

Comments
 (0)