mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-08 02:04:33 +00:00
Merge pull request #1522 from sharelatex/ew-smoke-test-remove-rate-limit
Remove smoke test rate limit, use POST for logout GitOrigin-RevId: 0152f259b4a4375147857cc25156621de87f8bc9
This commit is contained in:
parent
1ee4a1816c
commit
57450bb0fb
2 changed files with 61 additions and 35 deletions
services/web
|
@ -390,15 +390,17 @@ module.exports = settings =
|
|||
# Provide log in credentials and a project to be able to run
|
||||
# some basic smoke tests to check the core functionality.
|
||||
#
|
||||
# smokeTest:
|
||||
# user: ""
|
||||
# password: ""
|
||||
# projectId: ""
|
||||
smokeTest:
|
||||
user: process.env['SMOKE_TEST_USER']
|
||||
userId: process.env['SMOKE_TEST_USER_ID']
|
||||
password: process.env['SMOKE_TEST_PASSWORD']
|
||||
projectId: process.env['SMOKE_TEST_PROJECT_ID']
|
||||
rateLimitSubject: process.env['SMOKE_TEST_RATE_LIMIT_SUBJECT'] or "127.0.0.1"
|
||||
|
||||
appName: "ShareLaTeX (Community Edition)"
|
||||
adminEmail: "placeholder@example.com"
|
||||
appName: process.env['APP_NAME'] or "ShareLaTeX (Community Edition)"
|
||||
adminEmail: process.env['ADMIN_EMAIL'] or "placeholder@example.com"
|
||||
|
||||
brandPrefix: process.env['BRAND_PREFIX'] || "sl-"
|
||||
brandPrefix: process.env['BRAND_PREFIX'] or "sl-" # Set to 'ol-' for overleaf styles
|
||||
|
||||
nav:
|
||||
title: "ShareLaTeX Community Edition"
|
||||
|
|
|
@ -10,6 +10,8 @@ port = Settings.web?.web_router_port or ownPort # send requests to web router if
|
|||
cookeFilePath = "/tmp/smoke-test-cookie-#{ownPort}-to-#{port}.txt"
|
||||
buildUrl = (path) -> " -b #{cookeFilePath} --resolve 'smoke#{Settings.cookieDomain}:#{port}:127.0.0.1' http://smoke#{Settings.cookieDomain}:#{port}/#{path}?setLng=en"
|
||||
logger = require "logger-sharelatex"
|
||||
LoginRateLimiter = require("../../../app/js/Features/Security/LoginRateLimiter.js")
|
||||
RateLimiter = require("../../../app/js/infrastructure/RateLimiter.js")
|
||||
|
||||
# Change cookie to be non secure so curl will send it
|
||||
convertCookieFile = (callback) ->
|
||||
|
@ -27,41 +29,63 @@ describe "Opening", ->
|
|||
|
||||
before (done) ->
|
||||
logger.log "smoke test: setup"
|
||||
require("../../../app/js/Features/Security/LoginRateLimiter.js").recordSuccessfulLogin Settings.smokeTest.user, (err)->
|
||||
LoginRateLimiter.recordSuccessfulLogin Settings.smokeTest.user, (err)->
|
||||
if err?
|
||||
logger.err err:err, "smoke test: error recoring successful login"
|
||||
return done(err)
|
||||
logger.log "smoke test: clearing rate limit "
|
||||
require("../../../app/js/infrastructure/RateLimiter.js").clearRateLimit "open-project", "#{Settings.smokeTest.projectId}:#{Settings.smokeTest.userId}", ->
|
||||
logger.log "smoke test: hitting dev/csrf"
|
||||
command = """
|
||||
curl -H "X-Forwarded-Proto: https" -c #{cookeFilePath} #{buildUrl('dev/csrf')}
|
||||
RateLimiter.clearRateLimit "open-project", "#{Settings.smokeTest.projectId}:#{Settings.smokeTest.userId}", (err)->
|
||||
if err?
|
||||
logger.err err:err, "smoke test: error clearing open-project rate limit"
|
||||
return done(err)
|
||||
RateLimiter.clearRateLimit "overleaf-login", Settings.smokeTest.rateLimitSubject, (err)->
|
||||
if err?
|
||||
logger.err err:err, "smoke test: error clearing overleaf-login rate limit"
|
||||
return done(err)
|
||||
done()
|
||||
return
|
||||
|
||||
before (done) ->
|
||||
logger.log "smoke test: hitting dev/csrf"
|
||||
command = """
|
||||
curl -H "X-Forwarded-Proto: https" -c #{cookeFilePath} #{buildUrl('dev/csrf')}
|
||||
"""
|
||||
child.exec command, (err, stdout, stderr)->
|
||||
if err? then done(err)
|
||||
csrf = stdout
|
||||
logger.log "smoke test: converting cookie file 1"
|
||||
convertCookieFile (err) ->
|
||||
return done(err) if err?
|
||||
logger.log "smoke test: hitting /login with csrf"
|
||||
command = """
|
||||
curl -c #{cookeFilePath} -H "Content-Type: application/json" -H "X-Forwarded-Proto: https" -d '{"_csrf":"#{csrf}", "email":"#{Settings.smokeTest.user}", "password":"#{Settings.smokeTest.password}"}' #{buildUrl('login')}
|
||||
"""
|
||||
child.exec command, (err, stdout, stderr)->
|
||||
if err? then done(err)
|
||||
csrf = stdout
|
||||
logger.log "smoke test: converting cookie file 1"
|
||||
convertCookieFile (err) ->
|
||||
return done(err) if err?
|
||||
logger.log "smoke test: hitting /login with csrf"
|
||||
command = """
|
||||
curl -c #{cookeFilePath} -H "Content-Type: application/json" -H "X-Forwarded-Proto: https" -d '{"_csrf":"#{csrf}", "email":"#{Settings.smokeTest.user}", "password":"#{Settings.smokeTest.password}"}' #{buildUrl('login')}
|
||||
"""
|
||||
child.exec command, (err) ->
|
||||
return done(err) if err?
|
||||
logger.log "smoke test: finishing setup"
|
||||
convertCookieFile done
|
||||
child.exec command, (err) ->
|
||||
return done(err) if err?
|
||||
logger.log "smoke test: finishing setup"
|
||||
convertCookieFile done
|
||||
return
|
||||
|
||||
after (done)->
|
||||
logger.log "smoke test: cleaning up"
|
||||
command = """
|
||||
curl -H "X-Forwarded-Proto: https" -c #{cookeFilePath} #{buildUrl('logout')}
|
||||
"""
|
||||
child.exec command, (err, stdout, stderr)->
|
||||
if err?
|
||||
return done(err)
|
||||
fs.unlink cookeFilePath, done
|
||||
logger.log "smoke test: converting cookie file 2"
|
||||
convertCookieFile (err) ->
|
||||
return done(err) if err?
|
||||
logger.log "smoke test: cleaning up"
|
||||
command = """
|
||||
curl -H "X-Forwarded-Proto: https" -c #{cookeFilePath} #{buildUrl('dev/csrf')}
|
||||
"""
|
||||
child.exec command, (err, stdout, stderr)->
|
||||
if err? then done(err)
|
||||
csrf = stdout
|
||||
logger.log "smoke test: converting cookie file 3"
|
||||
convertCookieFile (err) ->
|
||||
return done(err) if err?
|
||||
command = """
|
||||
curl -H "Content-Type: application/json" -H "X-Forwarded-Proto: https" -d '{"_csrf":"#{csrf}"}' -c #{cookeFilePath} #{buildUrl('logout')}
|
||||
"""
|
||||
child.exec command, (err, stdout, stderr)->
|
||||
if err?
|
||||
return done(err)
|
||||
fs.unlink cookeFilePath, done
|
||||
return
|
||||
|
||||
it "a project", (done) ->
|
||||
|
|
Loading…
Add table
Reference in a new issue