diff --git a/lib/utils.js b/lib/utils.js index d9aa65941..35d53abaa 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -233,12 +233,6 @@ var utils = { errors.push(messages["server+proxy"]); } - if (options.get("https") && options.get("proxy")) { - if (options.getIn(["proxy", "url", "protocol"]) !== "https:") { - errors.push([messages["proxy+https"], options.getIn(["proxy", "target"])].join(" ")); - } - } - return errors; }, /** diff --git a/test/specs/e2e/proxy/e2e.proxy.secure.js b/test/specs/e2e/proxy/e2e.proxy.secure.js index 9779ebfdb..648c78487 100644 --- a/test/specs/e2e/proxy/e2e.proxy.secure.js +++ b/test/specs/e2e/proxy/e2e.proxy.secure.js @@ -12,13 +12,10 @@ describe("E2E TLS proxy test", function () { this.timeout(15000); - var bs, app; - - before(function (done) { - + it("Set's a HTTPS url", function (done) { browserSync.reset(); - app = testUtils.getApp(Immutable.Map({scheme: "https"})); + var app = testUtils.getApp(Immutable.Map({scheme: "https"})); app.server.listen(); @@ -28,66 +25,83 @@ describe("E2E TLS proxy test", function () { logLevel: "silent" }; - bs = browserSync.init(config, done).instance; - }); + browserSync.init(config, function (err, bs) { + bs.cleanup(); + app.server.close(); - after(function () { - bs.cleanup(); - app.server.close(); - }); + var local = bs.options.getIn(["urls", "local"]); + assert.equal("https://localhost:" + bs.options.get("port"), local); - it("Set's a HTTPS url", function () { - var local = bs.options.getIn(["urls", "local"]); - assert.equal("https://localhost:" + bs.options.get("port"), local); + done(); + }); }); - it("proxies over https and injects snippet", function (done) { + it("Set's a HTTPS url with none-https proxy target", function (done) { + browserSync.reset(); - assert.isString(bs.options.get("snippet")); + var app = testUtils.getApp(Immutable.Map({scheme: "http"})); - var expected = app.html.replace("BS", bs.options.get("snippet") + "BS"); + app.server.listen(); - request(bs.options.getIn(["urls", "local"])) - .get("/index.html") - .set("accept", "text/html") - .expect(200, expected, done); - }); -}); + var config = { + proxy: "http://localhost:" + app.server.address().port, + open: false, + logLevel: "silent", + https: true + }; -describe("E2E TLS proxy Options test", function () { + browserSync.init(config, function (err, bs) { - this.timeout(15000); + if (err) { + throw err; + } - var app; + var local = bs.options.getIn(["urls", "local"]); + var expected = app.html.replace("BS", bs.options.get("snippet") + "BS"); - before(function () { + assert.equal("https://localhost:" + bs.options.get("port"), local); + + request(bs.options.getIn(["urls", "local"])) + .get("/index.html") + .set("accept", "text/html") + .expect(200, function (err, res) { + assert.equal(res.text, expected); + bs.cleanup(); + app.server.close(); + done(); + }); + }); + }); + + it("proxies over https and injects snippet", function (done) { browserSync.reset(); - app = testUtils.getApp(Immutable.Map({scheme: "https"})); + var app = testUtils.getApp(Immutable.Map({scheme: "https"})); app.server.listen(); - }); - - after(function () { - app.server.close(); - }); - it("Exits if https specified in options, but not in target", function (done) { - var utils = require("../../../../lib/utils"); - var errors = require("../../../../lib/config").errors; - var sinon = require("sinon"); var config = { - proxy: "http://localhost:" + app.server.address().port, - https: true, + proxy: "https://localhost:" + app.server.address().port, open: false, logLevel: "silent" }; - var stub = sinon.stub(utils, "fail"); - browserSync.init(config); - sinon.assert.called(stub); - assert.include(stub.getCall(0).args[1], errors["proxy+https"]); - utils.fail.restore(); - done(); + + browserSync.init(config, function (err, bs) { + + assert.isString(bs.options.get("snippet")); + + var expected = app.html.replace("BS", bs.options.get("snippet") + "BS"); + + request(bs.options.getIn(["urls", "local"])) + .get("/index.html") + .set("accept", "text/html") + .expect(200, expected, function () { + bs.cleanup(); + app.server.close(); + done(); + }); + }); + }); });