2019-05-29 05:21:06 -04:00
|
|
|
/* eslint-disable
|
|
|
|
handle-callback-err,
|
|
|
|
no-return-assign,
|
|
|
|
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 Settings = require('settings-sharelatex')
|
|
|
|
const chai = require('chai')
|
|
|
|
const request = require('./helpers/request')
|
|
|
|
|
|
|
|
describe('siteIsOpen', function() {
|
2019-08-07 10:04:04 -04:00
|
|
|
describe('when siteIsOpen is default (true)', function() {
|
|
|
|
it('should get page', function(done) {
|
|
|
|
return request.get('/login', (error, response, body) => {
|
2019-05-29 05:21:06 -04:00
|
|
|
response.statusCode.should.equal(200)
|
|
|
|
return done()
|
2019-08-07 10:04:04 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-06-21 09:46:09 -04:00
|
|
|
describe('when siteIsOpen is false', function() {
|
2019-08-07 10:04:04 -04:00
|
|
|
beforeEach(function() {
|
|
|
|
return (Settings.siteIsOpen = false)
|
|
|
|
})
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-08-07 10:04:04 -04:00
|
|
|
afterEach(function() {
|
|
|
|
return (Settings.siteIsOpen = true)
|
|
|
|
})
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2019-08-07 10:04:04 -04:00
|
|
|
it('should return maintenance page', function(done) {
|
2020-07-27 06:46:27 -04:00
|
|
|
request.get('/login', (error, response, body) => {
|
2019-05-29 05:21:06 -04:00
|
|
|
response.statusCode.should.equal(503)
|
2020-07-27 06:46:27 -04:00
|
|
|
body.should.match(/is currently down for maintenance/)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should return a plain text message for a json request', function(done) {
|
|
|
|
request.get('/some/route', { json: true }, (error, response, body) => {
|
|
|
|
response.statusCode.should.equal(503)
|
|
|
|
body.message.should.match(/maintenance/)
|
|
|
|
body.message.should.match(/status.overleaf.com/)
|
|
|
|
done()
|
2019-08-07 10:04:04 -04:00
|
|
|
})
|
|
|
|
})
|
2020-11-30 05:10:28 -05:00
|
|
|
|
|
|
|
it('should return a 200 on / for load balancer health checks', function(done) {
|
|
|
|
request.get('/', (error, response, body) => {
|
|
|
|
response.statusCode.should.equal(200)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should return a 200 on /status for readiness checks', function(done) {
|
|
|
|
request.get('/status', (error, response, body) => {
|
|
|
|
response.statusCode.should.equal(200)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|
|
|
|
})
|