mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Add acceptance tests for RedirectManager
This commit is contained in:
parent
40f08d1592
commit
83a1039b7e
2 changed files with 42 additions and 0 deletions
28
services/web/test/acceptance/coffee/RedirectUrlsTests.coffee
Normal file
28
services/web/test/acceptance/coffee/RedirectUrlsTests.coffee
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
should = require('chai').should()
|
||||||
|
assert = require('chai').assert
|
||||||
|
async = require("async")
|
||||||
|
request = require "./helpers/request"
|
||||||
|
MockV1Api = require "./helpers/MockV1Api"
|
||||||
|
|
||||||
|
assertRedirect = (method, path, expectedStatusCode, destination, cb) ->
|
||||||
|
request[method] path, (error, response) ->
|
||||||
|
should.not.exist error
|
||||||
|
response.statusCode.should.equal expectedStatusCode
|
||||||
|
response.headers.location.should.equal destination
|
||||||
|
cb()
|
||||||
|
|
||||||
|
describe "RedirectUrls", ->
|
||||||
|
before ->
|
||||||
|
@timeout(1000)
|
||||||
|
|
||||||
|
it 'proxy static URLs', (done) ->
|
||||||
|
assertRedirect 'get', '/redirect/one', 302, '/destination/one', done
|
||||||
|
|
||||||
|
it 'proxy dynamic URLs', (done) ->
|
||||||
|
assertRedirect 'get', '/redirect/params/42', 302, '/destination/42/params', done
|
||||||
|
|
||||||
|
it 'proxy URLs with baseUrl', (done) ->
|
||||||
|
assertRedirect 'get', '/redirect/base_url', 302, 'https://example.com/destination/base_url', done
|
||||||
|
|
||||||
|
it 'proxy URLs with POST', (done) ->
|
||||||
|
assertRedirect 'post', '/redirect/post', 307, '/destination/post', done
|
|
@ -108,3 +108,17 @@ module.exports =
|
||||||
|
|
||||||
overleaf:
|
overleaf:
|
||||||
host: "http://overleaf.test:5000"
|
host: "http://overleaf.test:5000"
|
||||||
|
|
||||||
|
redirects:
|
||||||
|
'/redirect/one': '/destination/one',
|
||||||
|
'/redirect/post': {
|
||||||
|
method: 'post',
|
||||||
|
url: '/destination/post'
|
||||||
|
},
|
||||||
|
'/redirect/base_url': {
|
||||||
|
baseUrl: 'https://example.com'
|
||||||
|
url: '/destination/base_url'
|
||||||
|
},
|
||||||
|
'/redirect/params/:id': {
|
||||||
|
url: (params) -> "/destination/#{params.id}/params"
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue