1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00
unleash.unleash/lib/middleware/no-authentication.test.js
Ivar Conradi Østhus 62b97ca828 fix: none authentication should have a mock user (#449)
This also fix the bug introduces where authentication mode triggers readOnly mode in the UI.
2020-02-20 08:34:25 +01:00

31 lines
750 B
JavaScript

'use strict';
const test = require('ava');
const supertest = require('supertest');
const express = require('express');
const noAuthentication = require('./no-authentication');
test('should add dummy user object to all requests', t => {
t.plan(1);
const app = express();
noAuthentication('', app);
app.get('/api/admin/test', (req, res) => {
const user = Object.assign({}, req.user);
return res
.status(200)
.json(user)
.end();
});
const request = supertest(app);
return request
.get('/api/admin/test')
.expect(200)
.expect(res => {
console.log(res.body);
t.true(res.body.email === 'none@unknown.com');
});
});