Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions test/personal-data/crud.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
19 changes: 19 additions & 0 deletions test/personal-data/srv/crud-service.cds
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Loading