Monkey patch request in smoke tests to work around secnding secure cookie over HTTP

This commit is contained in:
James Allen 2014-04-01 12:53:16 +01:00
parent d41807e667
commit 9f966996be

View file

@ -1,18 +1,23 @@
chai = require("chai")
chai.should()
expect = chai.expect
request = require "request"
Settings = require "settings-sharelatex"
# Monkey patch request cookies, because the new tough-cookie module
# assumes it's not a secure cookie if the url is not HTTPS
request = require "request"
jar = request.jar()
jar.getCookieString = (uri) ->
return @_jar.getCookieStringSync uri, secure: true
request = request.defaults jar: jar
port = Settings.internal?.web?.port or Settings.port or 3000
buildUrl = (path) -> "http://localhost:#{port}/#{path}"
describe "Opening", ->
before (done) ->
@jar = request.jar()
request.get {
url: buildUrl("register")
jar: @jar
headers:
"X-Forwarded-Proto": "https"
}, (error, response, body) =>
@ -23,7 +28,6 @@ describe "Opening", ->
email: Settings.smokeTest.user
password: Settings.smokeTest.password
_csrf: csrf
jar: @jar
headers:
"X-Forwarded-Proto": "https"
}, (error, response, body) ->
@ -33,7 +37,6 @@ describe "Opening", ->
it "a project", (done) ->
request {
url: buildUrl("project/#{Settings.smokeTest.projectId}")
jar: @jar
headers:
"X-Forwarded-Proto": "https"
}, (error, response, body) ->
@ -47,7 +50,6 @@ describe "Opening", ->
it "the project list", (done) ->
request {
url: buildUrl("project")
jar: @jar
headers:
"X-Forwarded-Proto": "https"
}, (error, response, body) ->