Skip to content
Snippets Groups Projects
Commit d98ba424 authored by richard.petersen's avatar richard.petersen :sailboat:
Browse files

Introduce redirect endpoint for login redirects

parent 636f711f
No related branches found
No related tags found
No related merge requests found
import request from 'supertest'
import { generateSimpleViteManifest, mockConfig, mockFetch, mockApp } from './util.js'
import { expect } from 'chai'
import * as td from 'testdouble'
describe('Redirects', function () {
let app
before(async function () {
mockConfig({ urls: ['http://ui-server/'] })
mockFetch({
'http://ui-server': {
'/manifest.json': generateSimpleViteManifest({ 'example.js': 'test' }),
'/example.js': ''
}
})
app = await mockApp()
})
after(function () {
td.reset()
})
it('without requested location', async function () {
const response = await request(app).post('/redirect')
expect(response.statusCode).to.equal(302)
expect(response.headers.location).to.equal('../busy.html')
})
it('with requested location', async function () {
const response = await request(app).post('/redirect').send('location=/appsuite/whatever/path')
expect(response.statusCode).to.equal(302)
expect(response.headers.location).to.equal('/appsuite/whatever/path')
})
})
......@@ -35,6 +35,7 @@ export function createApp () {
// The app returned by express() is in fact a JavaScript Function, designed to be passed to Node’s HTTP servers as a callback to handle requests.
const app = express()
app.use(express.urlencoded({ extended: true }))
const healthCheck = new health.HealthChecker()
const startupCheck = new health.StartupCheck('warmup cache', async function () {
......@@ -109,6 +110,11 @@ export function createApp () {
next()
})
app.post('/redirect', (req, res, next) => {
const location = req.body.location || '../busy.html'
res.redirect(location)
})
app.use(async (req, res, next) => {
const { 'content-type': contentType, content } = fileCache.get(req.path)
if (content) {
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment