Audit sécurité/qualité : corrections critiques, tests, CI et lint #4
@@ -118,6 +118,31 @@ describe('beforeUpdate — notifications Telegram/Revolt', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('beforeUpdate — createdBy/updatedBy', () => {
|
||||||
|
afterEach(() => {
|
||||||
|
delete global.strapi
|
||||||
|
})
|
||||||
|
|
||||||
|
it('retire createdBy/updatedBy du payload avant la mise à jour', async () => {
|
||||||
|
const dbQuery = {findOne: vi.fn(async () => ({publishedAt: null, artistes: []}))}
|
||||||
|
const strapiMock = {db: {query: vi.fn(() => dbQuery)}}
|
||||||
|
|
||||||
|
const {beforeUpdate} = await loadLifecycles(strapiMock)
|
||||||
|
|
||||||
|
const event = {
|
||||||
|
state: {},
|
||||||
|
params: {
|
||||||
|
data: {documentId: 'doc-1', createdBy: 999, updatedBy: 999}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await beforeUpdate(event)
|
||||||
|
|
||||||
|
expect(event.params.data.createdBy).toBeUndefined()
|
||||||
|
expect(event.params.data.updatedBy).toBeUndefined()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('afterUpdate — historique de différence', () => {
|
describe('afterUpdate — historique de différence', () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
delete global.strapi
|
delete global.strapi
|
||||||
|
|||||||
@@ -142,6 +142,10 @@ module.exports = {
|
|||||||
beforeUpdate: async event => {
|
beforeUpdate: async event => {
|
||||||
const {state} = event
|
const {state} = event
|
||||||
let {data} = event.params
|
let {data} = event.params
|
||||||
|
|
||||||
|
delete data.createdBy
|
||||||
|
delete data.updatedBy
|
||||||
|
|
||||||
const {documentId} = data
|
const {documentId} = data
|
||||||
|
|
||||||
if (data.isNewRelease === true) {
|
if (data.isNewRelease === true) {
|
||||||
|
|||||||
Vendored
+3
-4
@@ -521,6 +521,7 @@ export interface ApiParoleParole extends Struct.CollectionTypeSchema {
|
|||||||
};
|
};
|
||||||
options: {
|
options: {
|
||||||
draftAndPublish: true;
|
draftAndPublish: true;
|
||||||
|
populateCreatorFields: true;
|
||||||
};
|
};
|
||||||
attributes: {
|
attributes: {
|
||||||
annee: Schema.Attribute.Integer;
|
annee: Schema.Attribute.Integer;
|
||||||
@@ -531,8 +532,7 @@ export interface ApiParoleParole extends Struct.CollectionTypeSchema {
|
|||||||
>;
|
>;
|
||||||
couverture: Schema.Attribute.Media<'images'>;
|
couverture: Schema.Attribute.Media<'images'>;
|
||||||
createdAt: Schema.Attribute.DateTime;
|
createdAt: Schema.Attribute.DateTime;
|
||||||
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
|
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'>;
|
||||||
Schema.Attribute.Private;
|
|
||||||
creativeCommons: Schema.Attribute.Enumeration<
|
creativeCommons: Schema.Attribute.Enumeration<
|
||||||
['BY', 'BY-SA', 'BY-ND', 'BY-NC', 'BY-NC-SA', 'BY-NC-ND']
|
['BY', 'BY-SA', 'BY-ND', 'BY-NC', 'BY-NC-SA', 'BY-NC-ND']
|
||||||
>;
|
>;
|
||||||
@@ -576,8 +576,7 @@ export interface ApiParoleParole extends Struct.CollectionTypeSchema {
|
|||||||
traductions: Schema.Attribute.Component<'trad.traductions', false>;
|
traductions: Schema.Attribute.Component<'trad.traductions', false>;
|
||||||
transcription: Schema.Attribute.RichText & Schema.Attribute.Required;
|
transcription: Schema.Attribute.RichText & Schema.Attribute.Required;
|
||||||
updatedAt: Schema.Attribute.DateTime;
|
updatedAt: Schema.Attribute.DateTime;
|
||||||
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
|
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'>;
|
||||||
Schema.Attribute.Private;
|
|
||||||
user: Schema.Attribute.Relation<
|
user: Schema.Attribute.Relation<
|
||||||
'oneToOne',
|
'oneToOne',
|
||||||
'plugin::users-permissions.user'
|
'plugin::users-permissions.user'
|
||||||
|
|||||||
Reference in New Issue
Block a user