diff --git a/test/personal-data/crud.test.js b/test/personal-data/crud.test.js index f2778ab..2164e80 100644 --- a/test/personal-data/crud.test.js +++ b/test/personal-data/crud.test.js @@ -1817,6 +1817,25 @@ describe('personal data audit logging in CRUD', () => { expect(_logs).toContainMatchObject({ attributes: [{ name: 'notes', new: '***' }] }) expect(_logs).toContainMatchObject({ attributes: [{ name: 'notes' }] }) }) + + test('create an entity that references a data subject without setting a value for that reference', async () =>{ + await POST('/crud-6/CustomerPostalAddress', { street: 'street', town: 'town'}, { auth: ALICE }) + expect(_logs.length).toBe(0) + }) + + test('create and update an entity that references a data subject without a set value for that reference', async () => { + const res = await POST('/crud-6/CustomerPostalAddress', { street: 'street', town: 'town'}, { auth: ALICE }) + expect(res?.data?.ID).toBeDefined() + await PATCH(`/crud-6/CustomerPostalAddress(ID=${res.data.ID})`, { town: 'new-town'}, { auth: ALICE }) + expect(_logs.length).toBe(0) + }) + + test('create and delete an entity that references a data subject without a set value for that reference', async () => { + const res = await POST('/crud-6/CustomerPostalAddress', { street: 'street', town: 'town'}, { auth: ALICE }) + expect(res?.data?.ID).toBeDefined() + await DELETE(`/crud-6/CustomerPostalAddress(ID=${res.data.ID})`, { auth: ALICE }) + expect(_logs.length).toBe(0) + }) }) describe('with renamings', () => { diff --git a/test/personal-data/srv/crud-service.cds b/test/personal-data/srv/crud-service.cds index 5522964..c81e2aa 100644 --- a/test/personal-data/srv/crud-service.cds +++ b/test/personal-data/srv/crud-service.cds @@ -216,3 +216,22 @@ service CRUD_5 { entity C as projection on db.C; } + +@path : '/crud-6' +@requires: 'admin' +service CRUD_7 { + entity Customers as projection on db.Customers; + entity CustomerPostalAddress as projection on db.CustomerPostalAddress; + + annotate Customers with @PersonalData.EntitySemantics: 'DataSubject' { + ID @PersonalData.FieldSemantics : 'DataSubjectID'; + firstName @PersonalData.IsPotentiallyPersonal; + lastName @PersonalData.IsPotentiallyPersonal; + } + + annotate CustomerPostalAddress with @PersonalData.EntitySemantics: 'Other' { + customer @PersonalData.FieldSemantics : 'DataSubjectID'; + street @PersonalData.IsPotentiallyPersonal; + town @PersonalData.IsPotentiallyPersonal; + } +}