mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 17:00:55 +00:00
Reimplements register checks / Clear the maps on admin destroy
Signed-off-by: Convly <jean-sebastien.herbaux@epitech.eu>
This commit is contained in:
parent
2f7615092a
commit
c8a3d29e9c
@ -25,6 +25,7 @@ module.exports = async () => {
|
||||
await strapi.admin.services.user.displayWarningIfUsersDontHaveRole();
|
||||
|
||||
strapi.admin.destroy = async () => {
|
||||
strapi.admin.services.permission.conditionProvider.clear();
|
||||
strapi.admin.services.permission.actionProvider.clear();
|
||||
};
|
||||
};
|
||||
|
@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { yup } = require('strapi-utils');
|
||||
const { validateRegisterProviderAction } = require('../../validation/action-provider');
|
||||
const { getActionId, createAction } = require('../../domain/action');
|
||||
|
||||
@ -54,6 +55,11 @@ const createActionProvider = () => {
|
||||
validateRegisterProviderAction(newActions);
|
||||
newActions.forEach(newAction => {
|
||||
const actionId = getActionId(newAction);
|
||||
if (actions.has(actionId)) {
|
||||
throw new yup.ValidationError(
|
||||
`Duplicated action id: ${actionId}. You may want to change the actions name.`
|
||||
);
|
||||
}
|
||||
|
||||
actions.set(actionId, createAction(newAction));
|
||||
|
||||
|
@ -19,6 +19,10 @@ module.exports = () => {
|
||||
throw new Error(`You can't register new conditions outside of the bootstrap function.`);
|
||||
}
|
||||
|
||||
if (this.has(condition.name, condition.plugin)) {
|
||||
throw new Error(`Duplicated condition id: ${getConditionId(condition)}.`);
|
||||
}
|
||||
|
||||
registry.set(conditionId, createCondition(condition));
|
||||
return this;
|
||||
},
|
||||
@ -77,5 +81,12 @@ module.exports = () => {
|
||||
getAllIds() {
|
||||
return Array.from(registry.keys());
|
||||
},
|
||||
|
||||
/**
|
||||
* Clear the actions map
|
||||
*/
|
||||
clear() {
|
||||
registry.clear();
|
||||
},
|
||||
};
|
||||
};
|
||||
|
@ -70,9 +70,11 @@ describe('Admin User CRUD (e2e)', () => {
|
||||
|
||||
// Cleanup actions
|
||||
afterAll(async () => {
|
||||
await utils.deleteRolesById([testData.role.id]);
|
||||
if (edition === 'EE') {
|
||||
await utils.deleteRolesById([testData.role.id]);
|
||||
}
|
||||
await strapi.destroy();
|
||||
});
|
||||
}, 60000);
|
||||
|
||||
test('1. Creates a user (wrong body)', async () => {
|
||||
const body = {
|
||||
|
@ -34,15 +34,17 @@ describe('Content Type Builder - Content types', () => {
|
||||
'ct-with-dp',
|
||||
];
|
||||
|
||||
await modelsUtils.cleanupModels(modelsName);
|
||||
await modelsUtils.deleteContentTypes(modelsName);
|
||||
await modelsUtils.cleanupModels(modelsName, { strapi });
|
||||
await modelsUtils.deleteContentTypes(modelsName, { strapi });
|
||||
|
||||
await strapi.destroy();
|
||||
}, 60000);
|
||||
|
||||
describe('Collection Types', () => {
|
||||
const testCollectionTypeUID = 'application::test-collection-type.test-collection-type';
|
||||
const ctWithDpUID = 'application::ct-with-dp.ct-with-dp';
|
||||
|
||||
test('Successfull creation of a collection type', async () => {
|
||||
test('Successful creation of a collection type', async () => {
|
||||
const res = await rq({
|
||||
method: 'POST',
|
||||
url: '/content-type-builder/content-types',
|
||||
@ -66,7 +68,7 @@ describe('Content Type Builder - Content types', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Get collection type returns full schema and informations', async () => {
|
||||
test('Get collection type returns full schema and information', async () => {
|
||||
const res = await rq({
|
||||
method: 'GET',
|
||||
url: `/content-type-builder/content-types/${testCollectionTypeUID}`,
|
||||
@ -115,7 +117,7 @@ describe('Content Type Builder - Content types', () => {
|
||||
describe('Single Types', () => {
|
||||
const singleTypeUID = 'application::test-single-type.test-single-type';
|
||||
|
||||
test('Successfull creation of a single type', async () => {
|
||||
test('Successfusl creation of a single type', async () => {
|
||||
const res = await rq({
|
||||
method: 'POST',
|
||||
url: '/content-type-builder/content-types',
|
||||
|
Loading…
x
Reference in New Issue
Block a user