1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/test/e2e/api/admin/feature.auth.e2e.test.js
2020-02-20 08:34:18 +01:00

37 lines
1010 B
JavaScript

'use strict';
const test = require('ava');
const { setupAppWithAuth } = require('./../../helpers/test-helper');
test.serial('creates new feature toggle with createdBy', async t => {
t.plan(1);
const { request, destroy } = await setupAppWithAuth('feature_api_auth');
// Login
await request.post('/api/admin/login').send({
email: 'user@mail.com',
});
// create toggle
await request.post('/api/admin/features').send({
name: 'com.test.Username',
enabled: false,
strategies: [{ name: 'default' }],
});
await request
.get('/api/admin/events')
.expect(res => {
t.true(res.body.events[0].createdBy === 'user@mail.com');
})
.then(destroy);
});
test.serial('should require authenticated user', async t => {
t.plan(0);
const { request, destroy } = await setupAppWithAuth('feature_api_auth');
return request
.get('/api/admin/features')
.expect(401)
.then(destroy);
});