mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
9ddaa8c9f6
Upgrade to Node 12 GitOrigin-RevId: 19870922884b7c98e7e5f2c94df21829672d2db5
76 lines
1.9 KiB
JavaScript
76 lines
1.9 KiB
JavaScript
/* eslint-disable
|
|
max-len,
|
|
no-unused-vars,
|
|
*/
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
// Fix any style issues and re-enable lint.
|
|
/*
|
|
* decaffeinate suggestions:
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
*/
|
|
const { assert, expect } = require('chai')
|
|
const async = require('async')
|
|
const request = require('./helpers/request')
|
|
|
|
const assertResponse = (path, expectedStatusCode, expectedBody, cb) =>
|
|
request.get(path, (error, response) => {
|
|
expect(error).not.to.exist
|
|
response.statusCode.should.equal(expectedStatusCode)
|
|
if (expectedBody) {
|
|
assert.deepEqual(JSON.parse(response.body), expectedBody)
|
|
}
|
|
return cb()
|
|
})
|
|
|
|
describe('ProxyUrls', function() {
|
|
beforeEach(function() {
|
|
return this.timeout(1000)
|
|
})
|
|
|
|
it('proxy static URLs', function(done) {
|
|
return async.series(
|
|
[
|
|
cb => assertResponse('/institutions/list', 200, [], cb),
|
|
cb => assertResponse('/institutions/domains', 200, [], cb)
|
|
],
|
|
done
|
|
)
|
|
})
|
|
|
|
it('proxy dynamic URLs', function(done) {
|
|
return async.series(
|
|
[
|
|
cb =>
|
|
assertResponse(
|
|
'/institutions/list/123',
|
|
200,
|
|
{ id: 123, name: 'Institution 123' },
|
|
cb
|
|
),
|
|
cb =>
|
|
assertResponse(
|
|
'/institutions/list/456',
|
|
200,
|
|
{ id: 456, name: 'Institution 456' },
|
|
cb
|
|
)
|
|
],
|
|
done
|
|
)
|
|
})
|
|
|
|
it('return 404 if proxy is not set', function(done) {
|
|
return async.series(
|
|
[cb => assertResponse('/institutions/foobar', 404, null, cb)],
|
|
done
|
|
)
|
|
})
|
|
|
|
it('handle missing baseUrl', function(done) {
|
|
return async.series(
|
|
[cb => assertResponse('/proxy/missing/baseUrl', 500, null, cb)],
|
|
done
|
|
)
|
|
})
|
|
})
|