Merge pull request #3425 from overleaf/jpa-cookie-domain-in-ci

[misc] setup cookieDomain and siteUrl for acceptance tests

GitOrigin-RevId: a57a9c4f44186848ccda34316071cd65ac387310
This commit is contained in:
Paulo Jorge Reis 2020-12-02 10:16:16 +00:00 committed by Copybot
parent 4e74fb2694
commit 34f7c709f0
4 changed files with 81 additions and 0 deletions

View file

@ -998,6 +998,16 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) {
HealthCheckController.checkActiveHandles,
HealthCheckController.checkApi
)
publicApiRouter.get(
'/health_check/full',
HealthCheckController.checkActiveHandles,
HealthCheckController.check
)
privateApiRouter.get(
'/health_check/full',
HealthCheckController.checkActiveHandles,
HealthCheckController.check
)
publicApiRouter.get('/health_check/redis', HealthCheckController.checkRedis)
privateApiRouter.get('/health_check/redis', HealthCheckController.checkRedis)

View file

@ -30,6 +30,11 @@ services:
NODE_ENV: test
NODE_OPTIONS: "--unhandled-rejections=strict"
SHARELATEX_CONFIG:
COOKIE_DOMAIN: .overleaf.test
PUBLIC_URL: 'http://www.overleaf.test:3000'
HTTP_TEST_HOST: www.overleaf.test
extra_hosts:
- 'www.overleaf.test:127.0.0.1'
command: npm run test:acceptance:app
user: root
depends_on:

View file

@ -39,6 +39,11 @@ services:
MONGO_SOCKET_TIMEOUT: 60000
# SHARELATEX_ALLOW_ANONYMOUS_READ_AND_WRITE_SHARING: 'true'
SHARELATEX_CONFIG:
COOKIE_DOMAIN: .overleaf.test
PUBLIC_URL: 'http://www.overleaf.test:3000'
HTTP_TEST_HOST: www.overleaf.test
extra_hosts:
- 'www.overleaf.test:127.0.0.1'
depends_on:
- redis
- mongo

View file

@ -0,0 +1,61 @@
const { expect } = require('chai')
const Settings = require('settings-sharelatex')
const User = require('./helpers/User').promises
describe('HealthCheckController', function() {
describe('SmokeTests', function() {
let user, projectId
beforeEach(async function() {
user = new User()
await user.login()
projectId = await user.createProject('SmokeTest')
// HACK: Inject the details into the app
Settings.smokeTest.userId = user.id
Settings.smokeTest.user = user.email
Settings.smokeTest.password = user.password
Settings.smokeTest.projectId = projectId
})
async function performSmokeTestRequest() {
const { response, body } = await user.doRequest('GET', {
url: '/health_check/full',
json: true
})
expect(body).to.exist
return { response, body }
}
describe('happy path', function() {
it('should respond with a 200 and stats', async function() {
const { response, body } = await performSmokeTestRequest()
expect(body.error).to.not.exist
expect(response.statusCode).to.equal(200)
})
})
describe('when the project does not exist', function() {
beforeEach(function() {
Settings.smokeTest.projectId = '404'
})
it('should respond with a 500 ', async function() {
const { response } = await performSmokeTestRequest()
expect(response.statusCode).to.equal(500)
})
})
describe('when the password mismatches', function() {
beforeEach(function() {
Settings.smokeTest.password = 'foo-bar'
})
it('should respond with a 500 with mismatching password', async function() {
const { response } = await performSmokeTestRequest()
expect(response.statusCode).to.equal(500)
})
})
})
})