mirror of
https://github.com/overleaf/overleaf.git
synced 2024-09-16 02:52:31 -04:00
convert smoke cookie to be unsecure so curl will send it
This commit is contained in:
parent
ca5b1e7422
commit
6bb4c9867e
1 changed files with 17 additions and 10 deletions
|
@ -7,26 +7,33 @@ expect = chai.expect
|
||||||
Settings = require "settings-sharelatex"
|
Settings = require "settings-sharelatex"
|
||||||
port = Settings.internal?.web?.port or Settings.port or 3000
|
port = Settings.internal?.web?.port or Settings.port or 3000
|
||||||
cookeFilePath = "/tmp/smoke-test-cookie-#{port}.txt"
|
cookeFilePath = "/tmp/smoke-test-cookie-#{port}.txt"
|
||||||
buildUrl = (path) -> " -b #{cookeFilePath} -c #{cookeFilePath} -H 'X-Forwarded-Proto: https' --resolve 'smoke#{Settings.cookieDomain}:#{port}:127.0.0.1' http://smoke#{Settings.cookieDomain}:#{port}/#{path}?setLng=en"
|
buildUrl = (path) -> " -b #{cookeFilePath} --resolve 'smoke#{Settings.cookieDomain}:#{port}:127.0.0.1' http://smoke#{Settings.cookieDomain}:#{port}/#{path}?setLng=en"
|
||||||
|
|
||||||
describe "Opening", ->
|
describe "Opening", ->
|
||||||
|
|
||||||
before (done) ->
|
before (done) ->
|
||||||
|
|
||||||
command = """
|
command = """
|
||||||
curl #{buildUrl('register')}
|
curl -H "X-Forwarded-Proto: https" -c #{cookeFilePath} #{buildUrl('register')}
|
||||||
"""
|
"""
|
||||||
child.exec command, (err, stdout, stderr)->
|
child.exec command, (err, stdout, stderr)->
|
||||||
if err? then done(err)
|
if err? then done(err)
|
||||||
csrf = stdout.match("<input name=\"_csrf\" type=\"hidden\" value=\"(.*?)\">")[1]
|
csrf = stdout.match("<input name=\"_csrf\" type=\"hidden\" value=\"(.*?)\">")[1]
|
||||||
|
|
||||||
command = """
|
|
||||||
curl -H "Content-Type: application/json" -d '{"_csrf":"#{csrf}", "email":"#{Settings.smokeTest.user}", "password":"#{Settings.smokeTest.password}"}' #{buildUrl('register')}
|
|
||||||
"""
|
|
||||||
|
|
||||||
child.exec command, (err, stdout, stderr)->
|
# Change cookie to be non secure so curl will send it
|
||||||
|
fs = require("fs")
|
||||||
|
fs.readFile cookeFilePath, "utf8", (err, data) ->
|
||||||
|
return done(err) if err
|
||||||
|
firstTrue = data.indexOf("TRUE")
|
||||||
|
secondTrue = data.indexOf("TRUE", firstTrue+4)
|
||||||
|
result = data.slice(0, secondTrue)+"FALSE"+data.slice(secondTrue+4)
|
||||||
|
fs.writeFile cookeFilePath, result, "utf8", (err) ->
|
||||||
|
return done(err) if err
|
||||||
|
|
||||||
done(err)
|
command = """
|
||||||
|
curl -H "Content-Type: application/json" -H "X-Forwarded-Proto: https" -d '{"_csrf":"#{csrf}", "email":"#{Settings.smokeTest.user}", "password":"#{Settings.smokeTest.password}"}' #{buildUrl('register')}
|
||||||
|
"""
|
||||||
|
child.exec command, done
|
||||||
|
|
||||||
after (done)->
|
after (done)->
|
||||||
fs.unlink cookeFilePath, done
|
fs.unlink cookeFilePath, done
|
||||||
|
@ -35,7 +42,7 @@ describe "Opening", ->
|
||||||
it "a project", (done) ->
|
it "a project", (done) ->
|
||||||
@timeout(4000)
|
@timeout(4000)
|
||||||
command = """
|
command = """
|
||||||
curl -v #{buildUrl("project/#{Settings.smokeTest.projectId}")}
|
curl -H "X-Forwarded-Proto: https" -v #{buildUrl("project/#{Settings.smokeTest.projectId}")}
|
||||||
"""
|
"""
|
||||||
child.exec command, (error, stdout, stderr)->
|
child.exec command, (error, stdout, stderr)->
|
||||||
expect(error, "smoke test: error in getting project").to.not.exist
|
expect(error, "smoke test: error in getting project").to.not.exist
|
||||||
|
@ -52,7 +59,7 @@ describe "Opening", ->
|
||||||
it "the project list", (done) ->
|
it "the project list", (done) ->
|
||||||
@timeout(4000)
|
@timeout(4000)
|
||||||
command = """
|
command = """
|
||||||
curl -v #{buildUrl("project")}
|
curl -H "X-Forwarded-Proto: https" -v #{buildUrl("project")}
|
||||||
"""
|
"""
|
||||||
child.exec command, (error, stdout, stderr)->
|
child.exec command, (error, stdout, stderr)->
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue