diff --git a/lib/utils.js b/lib/utils.js index 1929982..79fb2a3 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -220,6 +220,7 @@ const _getDataSubjectsMap = req => { const addDataSubjectForDetailsEntity = (row, log, req, entity, model) => { const dataSubjectInfo = getDataSubject(entity, model) + if (!dataSubjectInfo) debugger const role = dataSubjectInfo.dataSubjectEntity['@PersonalData.DataSubjectRole'] log.data_subject.role ??= role log.data_subject.type = dataSubjectInfo.dataSubjectEntity.name diff --git a/test/personal-data/crud.test.js b/test/personal-data/crud.test.js index f4ee715..55b3be0 100644 --- a/test/personal-data/crud.test.js +++ b/test/personal-data/crud.test.js @@ -2146,4 +2146,19 @@ describe('personal data audit logging in CRUD', () => { await POST('/crud-5/A', { text: 'foo' }, { auth: ALICE }) expect(_logs.length).toBe(1) }) + + test('triangle', async () => { + const { data: door } = await POST('/crud-5/Door', { text: 'door' }, { auth: ALICE }) + try { + const { data: house } = await POST( + '/crud-5/House', + { text: 'house', doorID: door.ID, windows: [{ text: 'window' /* , doorID: door.ID */ }] }, + { auth: ALICE } + ) + expect(_logs.length).toBeGreaterThan(0) //> TODO + } catch (error) { + // current modeling leads to error during data subject lookup starting at Window + expect(error.response.status).toBe(500) + } + }) }) diff --git a/test/personal-data/db/schema.cds b/test/personal-data/db/schema.cds index 00fb757..8138d6b 100644 --- a/test/personal-data/db/schema.cds +++ b/test/personal-data/db/schema.cds @@ -183,3 +183,39 @@ annotate C with @PersonalData : {EntitySemantics: 'DataSubject'} { ID @PersonalData.FieldSemantics: 'DataSubjectID'; text @PersonalData.IsPotentiallyPersonal; } + +entity House { + key ID : UUID; + text : String; + windows : Composition of many Window on windows.house = $self; + doorID : UUID; + door : Association to one Door on door.ID = doorID; +} + +entity Window { + key ID : UUID; + text : String; + house : Association to one House; + // doorID : UUID; + // door : Association to one Door on door.ID = doorID; +} + +entity Door { + key ID : UUID; + text : String; +} + +annotate House with @PersonalData : {EntitySemantics: 'Other'} { + door @PersonalData.FieldSemantics: 'DataSubjectID'; + text @PersonalData.IsPotentiallyPersonal; +} + +annotate Window with @PersonalData : {EntitySemantics: 'Other'} { + // door @PersonalData.FieldSemantics: 'DataSubjectID'; + text @PersonalData.IsPotentiallyPersonal; +} + +annotate Door with @PersonalData : {EntitySemantics: 'DataSubject'} { + ID @PersonalData.FieldSemantics: 'DataSubjectID'; + text @PersonalData.IsPotentiallyPersonal; +} diff --git a/test/personal-data/srv/crud-5.js b/test/personal-data/srv/crud-5.js new file mode 100644 index 0000000..8ad1050 --- /dev/null +++ b/test/personal-data/srv/crud-5.js @@ -0,0 +1,6 @@ +module.exports = srv => { + srv.on('*', async function(req, next) { + debugger + return next() + }) +} diff --git a/test/personal-data/srv/crud-service.cds b/test/personal-data/srv/crud-service.cds index 264e6f0..d17ef00 100644 --- a/test/personal-data/srv/crud-service.cds +++ b/test/personal-data/srv/crud-service.cds @@ -200,6 +200,7 @@ service CRUD_4 { } @path : '/crud-5' +@impl : './crud-5.js' @requires: 'admin' service CRUD_5 { @@ -207,4 +208,8 @@ service CRUD_5 { entity B as projection on db.B; entity C as projection on db.C; + entity House as projection on db.House; + entity Window as projection on db.Window; + entity Door as projection on db.Door; + }