mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 08:52:26 +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();
|
await strapi.admin.services.user.displayWarningIfUsersDontHaveRole();
|
||||||
|
|
||||||
strapi.admin.destroy = async () => {
|
strapi.admin.destroy = async () => {
|
||||||
|
strapi.admin.services.permission.conditionProvider.clear();
|
||||||
strapi.admin.services.permission.actionProvider.clear();
|
strapi.admin.services.permission.actionProvider.clear();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { yup } = require('strapi-utils');
|
||||||
const { validateRegisterProviderAction } = require('../../validation/action-provider');
|
const { validateRegisterProviderAction } = require('../../validation/action-provider');
|
||||||
const { getActionId, createAction } = require('../../domain/action');
|
const { getActionId, createAction } = require('../../domain/action');
|
||||||
|
|
||||||
@ -54,6 +55,11 @@ const createActionProvider = () => {
|
|||||||
validateRegisterProviderAction(newActions);
|
validateRegisterProviderAction(newActions);
|
||||||
newActions.forEach(newAction => {
|
newActions.forEach(newAction => {
|
||||||
const actionId = getActionId(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));
|
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.`);
|
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));
|
registry.set(conditionId, createCondition(condition));
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
@ -77,5 +81,12 @@ module.exports = () => {
|
|||||||
getAllIds() {
|
getAllIds() {
|
||||||
return Array.from(registry.keys());
|
return Array.from(registry.keys());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the actions map
|
||||||
|
*/
|
||||||
|
clear() {
|
||||||
|
registry.clear();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -70,9 +70,11 @@ describe('Admin User CRUD (e2e)', () => {
|
|||||||
|
|
||||||
// Cleanup actions
|
// Cleanup actions
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
await utils.deleteRolesById([testData.role.id]);
|
if (edition === 'EE') {
|
||||||
|
await utils.deleteRolesById([testData.role.id]);
|
||||||
|
}
|
||||||
await strapi.destroy();
|
await strapi.destroy();
|
||||||
});
|
}, 60000);
|
||||||
|
|
||||||
test('1. Creates a user (wrong body)', async () => {
|
test('1. Creates a user (wrong body)', async () => {
|
||||||
const body = {
|
const body = {
|
||||||
|
@ -34,15 +34,17 @@ describe('Content Type Builder - Content types', () => {
|
|||||||
'ct-with-dp',
|
'ct-with-dp',
|
||||||
];
|
];
|
||||||
|
|
||||||
await modelsUtils.cleanupModels(modelsName);
|
await modelsUtils.cleanupModels(modelsName, { strapi });
|
||||||
await modelsUtils.deleteContentTypes(modelsName);
|
await modelsUtils.deleteContentTypes(modelsName, { strapi });
|
||||||
|
|
||||||
|
await strapi.destroy();
|
||||||
}, 60000);
|
}, 60000);
|
||||||
|
|
||||||
describe('Collection Types', () => {
|
describe('Collection Types', () => {
|
||||||
const testCollectionTypeUID = 'application::test-collection-type.test-collection-type';
|
const testCollectionTypeUID = 'application::test-collection-type.test-collection-type';
|
||||||
const ctWithDpUID = 'application::ct-with-dp.ct-with-dp';
|
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({
|
const res = await rq({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/content-type-builder/content-types',
|
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({
|
const res = await rq({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: `/content-type-builder/content-types/${testCollectionTypeUID}`,
|
url: `/content-type-builder/content-types/${testCollectionTypeUID}`,
|
||||||
@ -115,7 +117,7 @@ describe('Content Type Builder - Content types', () => {
|
|||||||
describe('Single Types', () => {
|
describe('Single Types', () => {
|
||||||
const singleTypeUID = 'application::test-single-type.test-single-type';
|
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({
|
const res = await rq({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/content-type-builder/content-types',
|
url: '/content-type-builder/content-types',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user