mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
1fdf68eeec
### What We've had this marked as deprecated through our v4, this PR removes it. ### Worth noting This updates the deprecation notices with removal notices in the documentation as well. ### Considerations The tags API is still located under /api/admin/features/{featureName}/tags. It should be moved to /api/admin/projects/{project}/features/{featureName}/tags. I vote we do that in a separate PR, we'd probably also need to deprecate the existing tags endpoints for v5 and remove in v6. We could use 308s to signify that they are moved. --------- Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
70 lines
2.0 KiB
TypeScript
70 lines
2.0 KiB
TypeScript
import { setupAppWithCustomAuth } from '../../helpers/test-helper';
|
|
import AuthenticationRequired from '../../../../lib/types/authentication-required';
|
|
|
|
import dbInit from '../../helpers/database-init';
|
|
import getLogger from '../../../fixtures/no-logger';
|
|
|
|
let stores;
|
|
let db;
|
|
|
|
beforeAll(async () => {
|
|
db = await dbInit('feature_api_custom_auth', getLogger);
|
|
stores = db.stores;
|
|
});
|
|
|
|
afterAll(async () => {
|
|
if (db) {
|
|
await db.destroy();
|
|
}
|
|
});
|
|
|
|
test('should require authenticated user', async () => {
|
|
expect.assertions(0);
|
|
const preHook = (app) => {
|
|
app.use('/api/admin/', (req, res) =>
|
|
res
|
|
.status(401)
|
|
.json(
|
|
new AuthenticationRequired({
|
|
path: '/auth/demo/login',
|
|
type: 'custom',
|
|
message: 'You have to identify yourself.',
|
|
}),
|
|
)
|
|
.end(),
|
|
);
|
|
};
|
|
const { request, destroy } = await setupAppWithCustomAuth(stores, preHook);
|
|
await request.get('/api/admin/features').expect(401);
|
|
await destroy();
|
|
});
|
|
|
|
test('creates new feature toggle with createdBy', async () => {
|
|
expect.assertions(1);
|
|
const email = 'custom-user@mail.com';
|
|
|
|
const preHook = (app, config, { userService }) => {
|
|
app.use('/api/admin/', async (req, res, next) => {
|
|
req.user = await userService.loginUserWithoutPassword(email, true);
|
|
next();
|
|
});
|
|
};
|
|
const { request, destroy } = await setupAppWithCustomAuth(stores, preHook);
|
|
|
|
// create toggle
|
|
await request
|
|
.post('/api/admin/projects/default/features')
|
|
.send({
|
|
name: 'com.test.Username',
|
|
enabled: false,
|
|
strategies: [{ name: 'default' }],
|
|
})
|
|
.expect(201);
|
|
|
|
await request.get('/api/admin/events/com.test.Username').expect((res) => {
|
|
expect(res.body.events[0].createdBy).toBe(email);
|
|
});
|
|
|
|
await destroy();
|
|
});
|