overleaf/services/web/test/acceptance/coffee/ProxyUrls.coffee
James Allen 49e19cad64 Merge pull request #1162 from sharelatex/ja-show-group-management
Add group and institution membership and management info to subscription dashboard

GitOrigin-RevId: 1aba5d5a20cd00ff5090811d0f66dc9c4944dd60
2018-11-20 11:03:56 +00:00

42 lines
1.2 KiB
CoffeeScript

should = require('chai').should()
assert = require('chai').assert
async = require("async")
request = require "./helpers/request"
MockV1Api = require "./helpers/MockV1Api"
assertResponse = (path, expectedStatusCode, expectedBody, cb) ->
request.get path, (error, response) ->
should.not.exist error
response.statusCode.should.equal expectedStatusCode
assert.deepEqual(JSON.parse(response.body), expectedBody) if expectedBody
cb()
describe "ProxyUrls", ->
before ->
@timeout(1000)
it 'proxy static URLs', (done) ->
async.series [
(cb) -> assertResponse '/institutions/list', 200, [], cb
(cb) -> assertResponse '/institutions/domains', 200, [], cb
],
done
it 'proxy dynamic URLs', (done) ->
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', (done) ->
async.series [
(cb) -> assertResponse '/institutions/foobar', 404, null, cb
],
done
it 'handle missing baseUrl', (done) ->
async.series [
(cb) -> assertResponse '/proxy/missing/baseUrl', 500, null, cb
],
done