@sphereon/ssi-sdk.data-store 0.23.5-unstable.88 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/README.md +77 -77
- package/dist/index.d.ts +3 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -15
- package/dist/index.js.map +1 -1
- package/dist/migrations/generic/index.d.ts +0 -2
- package/dist/migrations/generic/index.d.ts.map +1 -1
- package/dist/migrations/generic/index.js +1 -4
- package/dist/migrations/generic/index.js.map +1 -1
- package/dist/migrations/index.d.ts +1 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +1 -2
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/postgres/1690925872592-CreateContacts.js +1 -1
- package/dist/migrations/postgres/1690925872592-CreateContacts.js.map +1 -1
- package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.js +22 -22
- package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.js +16 -16
- package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.js +21 -21
- package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.js +15 -15
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +1 -1
- package/package.json +4 -5
- package/src/__tests__/contact.entities.test.ts +2542 -2542
- package/src/__tests__/contact.store.test.ts +2471 -2471
- package/src/__tests__/digitalCredential.entities.test.ts +254 -254
- package/src/__tests__/digitalCredential.store.test.ts +294 -294
- package/src/__tests__/eventLogger.entities.test.ts +73 -73
- package/src/__tests__/eventLogger.store.test.ts +136 -136
- package/src/__tests__/issuanceBranding.entities.test.ts +844 -844
- package/src/__tests__/issuanceBranding.store.test.ts +1884 -1884
- package/src/__tests__/machineState.entities.test.ts +51 -51
- package/src/__tests__/machineState.store.test.ts +174 -174
- package/src/contact/AbstractContactStore.ts +71 -71
- package/src/contact/ContactStore.ts +723 -723
- package/src/digitalCredential/AbstractDigitalCredentialStore.ts +17 -17
- package/src/digitalCredential/DigitalCredentialStore.ts +127 -127
- package/src/entities/contact/BaseContactEntity.ts +39 -39
- package/src/entities/contact/ConnectionEntity.ts +29 -29
- package/src/entities/contact/CorrelationIdentifierEntity.ts +37 -37
- package/src/entities/contact/DidAuthConfigEntity.ts +14 -14
- package/src/entities/contact/ElectronicAddressEntity.ts +63 -63
- package/src/entities/contact/IdentityEntity.ts +97 -97
- package/src/entities/contact/IdentityMetadataItemEntity.ts +35 -35
- package/src/entities/contact/NaturalPersonEntity.ts +38 -38
- package/src/entities/contact/OpenIdConfigEntity.ts +26 -26
- package/src/entities/contact/OrganizationEntity.ts +34 -34
- package/src/entities/contact/PartyEntity.ts +110 -110
- package/src/entities/contact/PartyRelationshipEntity.ts +61 -61
- package/src/entities/contact/PartyTypeEntity.ts +62 -62
- package/src/entities/contact/PhysicalAddressEntity.ts +87 -87
- package/src/entities/digitalCredential/DigitalCredentialEntity.ts +64 -64
- package/src/entities/eventLogger/AuditEventEntity.ts +99 -99
- package/src/entities/issuanceBranding/CredentialBrandingEntity.ts +78 -78
- package/src/entities/issuanceBranding/ImageAttributesEntity.ts +57 -57
- package/src/entities/issuanceBranding/IssuerBrandingEntity.ts +72 -72
- package/src/entities/machineState/MachineStateInfoEntity.ts +58 -58
- package/src/entities/statusList2021/StatusList2021Entity.ts +96 -96
- package/src/eventLogger/AbstractEventLoggerStore.ts +7 -7
- package/src/eventLogger/EventLoggerStore.ts +62 -62
- package/src/index.ts +141 -154
- package/src/issuanceBranding/IssuanceBrandingStore.ts +559 -559
- package/src/machineState/IAbstractMachineStateStore.ts +65 -65
- package/src/machineState/MachineStateStore.ts +149 -149
- package/src/migrations/generic/1-CreateContacts.ts +66 -66
- package/src/migrations/generic/2-CreateIssuanceBranding.ts +64 -64
- package/src/migrations/generic/3-CreateContacts.ts +66 -66
- package/src/migrations/generic/4-CreateStatusList.ts +54 -54
- package/src/migrations/generic/5-CreateAuditEvents.ts +66 -66
- package/src/migrations/generic/6-CreateDigitalCredential.ts +66 -66
- package/src/migrations/generic/7-CreateMachineStateStore.ts +66 -66
- package/src/migrations/generic/index.ts +33 -36
- package/src/migrations/index.ts +9 -10
- package/src/migrations/postgres/1659463079428-CreateContacts.ts +63 -63
- package/src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts +85 -85
- package/src/migrations/postgres/1690925872592-CreateContacts.ts +104 -104
- package/src/migrations/postgres/1693866470001-CreateStatusList.ts +24 -24
- package/src/migrations/postgres/1701634812183-CreateAuditEvents.ts +33 -33
- package/src/migrations/postgres/1708525189001-CreateDigitalCredential.ts +44 -44
- package/src/migrations/postgres/1708797018115-CreateMachineStateStore.ts +29 -29
- package/src/migrations/sqlite/1659463069549-CreateContacts.ts +110 -110
- package/src/migrations/sqlite/1685628973231-CreateIssuanceBranding.ts +119 -119
- package/src/migrations/sqlite/1690925872693-CreateContacts.ts +161 -161
- package/src/migrations/sqlite/1693866470000-CreateStatusList.ts +24 -24
- package/src/migrations/sqlite/1701634819487-CreateAuditEvents.ts +15 -15
- package/src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts +34 -34
- package/src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts +28 -28
- package/src/statusList/StatusListStore.ts +237 -237
- package/src/types/contact/IAbstractContactStore.ts +161 -161
- package/src/types/contact/contact.ts +237 -237
- package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +37 -37
- package/src/types/digitalCredential/digitalCredential.ts +46 -46
- package/src/types/eventLogger/IAbstractEventLoggerStore.ts +12 -12
- package/src/types/eventLogger/eventLogger.ts +3 -3
- package/src/types/index.ts +10 -12
- package/src/types/machineState/IAbstractMachineStateStore.ts +68 -68
- package/src/utils/SortingUtils.ts +16 -16
- package/src/utils/contact/MappingUtils.ts +385 -385
- package/src/utils/digitalCredential/MappingUtils.ts +122 -122
- package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.d.ts +0 -13
- package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.d.ts.map +0 -1
- package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.js +0 -71
- package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.js.map +0 -1
- package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts +0 -7
- package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts.map +0 -1
- package/dist/migrations/generic/8-CreatePresentationDefinitions.js +0 -78
- package/dist/migrations/generic/8-CreatePresentationDefinitions.js.map +0 -1
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts +0 -7
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts.map +0 -1
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js +0 -40
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js.map +0 -1
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts +0 -7
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts.map +0 -1
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js +0 -37
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js.map +0 -1
- package/dist/pd/AbstractPDStore.d.ts +0 -10
- package/dist/pd/AbstractPDStore.d.ts.map +0 -1
- package/dist/pd/AbstractPDStore.js +0 -7
- package/dist/pd/AbstractPDStore.js.map +0 -1
- package/dist/pd/PDStore.d.ts +0 -14
- package/dist/pd/PDStore.d.ts.map +0 -1
- package/dist/pd/PDStore.js +0 -90
- package/dist/pd/PDStore.js.map +0 -1
- package/dist/types/pd/IAbstractPDStore.d.ts +0 -14
- package/dist/types/pd/IAbstractPDStore.d.ts.map +0 -1
- package/dist/types/pd/IAbstractPDStore.js +0 -3
- package/dist/types/pd/IAbstractPDStore.js.map +0 -1
- package/dist/types/pd/pd.d.ts +0 -15
- package/dist/types/pd/pd.d.ts.map +0 -1
- package/dist/types/pd/pd.js +0 -3
- package/dist/types/pd/pd.js.map +0 -1
- package/dist/utils/presentationDefinitions/MappingUtils.d.ts +0 -6
- package/dist/utils/presentationDefinitions/MappingUtils.d.ts.map +0 -1
- package/dist/utils/presentationDefinitions/MappingUtils.js +0 -50
- package/dist/utils/presentationDefinitions/MappingUtils.js.map +0 -1
- package/src/entities/presentationDefinitions/PresentationDefinitionItemEntity.ts +0 -41
- package/src/migrations/generic/8-CreatePresentationDefinitions.ts +0 -66
- package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +0 -24
- package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +0 -23
- package/src/pd/AbstractPDStore.ts +0 -10
- package/src/pd/PDStore.ts +0 -103
- package/src/types/pd/IAbstractPDStore.ts +0 -19
- package/src/types/pd/pd.ts +0 -16
- package/src/utils/presentationDefinitions/MappingUtils.ts +0 -54
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import { DataSource } from 'typeorm'
|
|
2
|
-
import { DataStoreEventLoggerEntities } from '../index'
|
|
3
|
-
import { DataStoreEventLoggerMigrations } from '../migrations/generic'
|
|
4
|
-
import { ActionType, InitiatorType, LogLevel, PartyCorrelationType, SubSystem, System, SystemCorrelationIdType } from '@sphereon/ssi-sdk.core'
|
|
5
|
-
import { auditEventEntityFrom, AuditEventEntity } from '../entities/eventLogger/AuditEventEntity'
|
|
6
|
-
import { NonPersistedAuditLoggingEvent } from '../types'
|
|
7
|
-
|
|
8
|
-
describe('Database entities tests', (): void => {
|
|
9
|
-
let dbConnection: DataSource
|
|
10
|
-
|
|
11
|
-
beforeEach(async (): Promise<void> => {
|
|
12
|
-
dbConnection = await new DataSource({
|
|
13
|
-
type: 'sqlite',
|
|
14
|
-
database: ':memory:',
|
|
15
|
-
//logging: 'all',
|
|
16
|
-
migrationsRun: false,
|
|
17
|
-
migrations: DataStoreEventLoggerMigrations,
|
|
18
|
-
synchronize: false,
|
|
19
|
-
entities: [...DataStoreEventLoggerEntities],
|
|
20
|
-
}).initialize()
|
|
21
|
-
await dbConnection.runMigrations()
|
|
22
|
-
expect(await dbConnection.showMigrations()).toBeFalsy()
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
afterEach(async (): Promise<void> => {
|
|
26
|
-
await (await dbConnection).destroy()
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('should save audit event to database', async (): Promise<void> => {
|
|
30
|
-
const auditEvent: NonPersistedAuditLoggingEvent = {
|
|
31
|
-
timestamp: new Date(),
|
|
32
|
-
level: LogLevel.DEBUG,
|
|
33
|
-
correlationId: 'b40b8474-58a2-4b23-9fde-bd6ee1902cdb',
|
|
34
|
-
system: System.GENERAL,
|
|
35
|
-
subSystemType: SubSystem.DID_PROVIDER,
|
|
36
|
-
actionType: ActionType.CREATE,
|
|
37
|
-
actionSubType: 'Key generation',
|
|
38
|
-
initiatorType: InitiatorType.EXTERNAL,
|
|
39
|
-
systemCorrelationIdType: SystemCorrelationIdType.DID,
|
|
40
|
-
systemCorrelationId: 'did:example:123456789abcdefghi',
|
|
41
|
-
systemAlias: 'test_alias',
|
|
42
|
-
partyCorrelationType: PartyCorrelationType.DID,
|
|
43
|
-
partyCorrelationId: '75cfd84a-0f3b-4fb1-97a3-a1506c7ab850',
|
|
44
|
-
partyAlias: 'test_alias',
|
|
45
|
-
description: 'test_description',
|
|
46
|
-
data: 'test_data_string',
|
|
47
|
-
diagnosticData: { data: 'test_data_string' },
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const auditEventEntity: AuditEventEntity = auditEventEntityFrom(auditEvent)
|
|
51
|
-
const fromDb: AuditEventEntity = await dbConnection.getRepository(AuditEventEntity).save(auditEventEntity)
|
|
52
|
-
|
|
53
|
-
expect(fromDb).toBeDefined()
|
|
54
|
-
expect(fromDb?.id).not.toBeNull()
|
|
55
|
-
expect(fromDb?.timestamp).toEqual(auditEvent.timestamp)
|
|
56
|
-
expect(fromDb?.level).toEqual(auditEvent.level)
|
|
57
|
-
expect(fromDb?.correlationId).toEqual(auditEvent.correlationId)
|
|
58
|
-
expect(fromDb?.system).toEqual(auditEvent.system)
|
|
59
|
-
expect(fromDb?.subSystemType).toEqual(auditEvent.subSystemType)
|
|
60
|
-
expect(fromDb?.actionType).toEqual(auditEvent.actionType)
|
|
61
|
-
expect(fromDb?.actionSubType).toEqual(auditEvent.actionSubType)
|
|
62
|
-
expect(fromDb?.initiatorType).toEqual(auditEvent.initiatorType)
|
|
63
|
-
expect(fromDb?.systemCorrelationIdType).toEqual(auditEvent.systemCorrelationIdType)
|
|
64
|
-
expect(fromDb?.systemCorrelationId).toEqual(auditEvent.systemCorrelationId)
|
|
65
|
-
expect(fromDb?.systemAlias).toEqual(auditEvent.systemAlias)
|
|
66
|
-
expect(fromDb?.partyCorrelationType).toEqual(auditEvent.partyCorrelationType)
|
|
67
|
-
expect(fromDb?.partyCorrelationId).toEqual(auditEvent.partyCorrelationId)
|
|
68
|
-
expect(fromDb?.partyAlias).toEqual(auditEvent.partyAlias)
|
|
69
|
-
expect(fromDb?.description).toEqual(auditEvent.description)
|
|
70
|
-
expect(fromDb?.data).toEqual(JSON.stringify(auditEvent.data))
|
|
71
|
-
expect(fromDb?.diagnosticData).toEqual(JSON.stringify(auditEvent.diagnosticData))
|
|
72
|
-
})
|
|
73
|
-
})
|
|
1
|
+
import { DataSource } from 'typeorm'
|
|
2
|
+
import { DataStoreEventLoggerEntities } from '../index'
|
|
3
|
+
import { DataStoreEventLoggerMigrations } from '../migrations/generic'
|
|
4
|
+
import { ActionType, InitiatorType, LogLevel, PartyCorrelationType, SubSystem, System, SystemCorrelationIdType } from '@sphereon/ssi-sdk.core'
|
|
5
|
+
import { auditEventEntityFrom, AuditEventEntity } from '../entities/eventLogger/AuditEventEntity'
|
|
6
|
+
import { NonPersistedAuditLoggingEvent } from '../types'
|
|
7
|
+
|
|
8
|
+
describe('Database entities tests', (): void => {
|
|
9
|
+
let dbConnection: DataSource
|
|
10
|
+
|
|
11
|
+
beforeEach(async (): Promise<void> => {
|
|
12
|
+
dbConnection = await new DataSource({
|
|
13
|
+
type: 'sqlite',
|
|
14
|
+
database: ':memory:',
|
|
15
|
+
//logging: 'all',
|
|
16
|
+
migrationsRun: false,
|
|
17
|
+
migrations: DataStoreEventLoggerMigrations,
|
|
18
|
+
synchronize: false,
|
|
19
|
+
entities: [...DataStoreEventLoggerEntities],
|
|
20
|
+
}).initialize()
|
|
21
|
+
await dbConnection.runMigrations()
|
|
22
|
+
expect(await dbConnection.showMigrations()).toBeFalsy()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
afterEach(async (): Promise<void> => {
|
|
26
|
+
await (await dbConnection).destroy()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('should save audit event to database', async (): Promise<void> => {
|
|
30
|
+
const auditEvent: NonPersistedAuditLoggingEvent = {
|
|
31
|
+
timestamp: new Date(),
|
|
32
|
+
level: LogLevel.DEBUG,
|
|
33
|
+
correlationId: 'b40b8474-58a2-4b23-9fde-bd6ee1902cdb',
|
|
34
|
+
system: System.GENERAL,
|
|
35
|
+
subSystemType: SubSystem.DID_PROVIDER,
|
|
36
|
+
actionType: ActionType.CREATE,
|
|
37
|
+
actionSubType: 'Key generation',
|
|
38
|
+
initiatorType: InitiatorType.EXTERNAL,
|
|
39
|
+
systemCorrelationIdType: SystemCorrelationIdType.DID,
|
|
40
|
+
systemCorrelationId: 'did:example:123456789abcdefghi',
|
|
41
|
+
systemAlias: 'test_alias',
|
|
42
|
+
partyCorrelationType: PartyCorrelationType.DID,
|
|
43
|
+
partyCorrelationId: '75cfd84a-0f3b-4fb1-97a3-a1506c7ab850',
|
|
44
|
+
partyAlias: 'test_alias',
|
|
45
|
+
description: 'test_description',
|
|
46
|
+
data: 'test_data_string',
|
|
47
|
+
diagnosticData: { data: 'test_data_string' },
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const auditEventEntity: AuditEventEntity = auditEventEntityFrom(auditEvent)
|
|
51
|
+
const fromDb: AuditEventEntity = await dbConnection.getRepository(AuditEventEntity).save(auditEventEntity)
|
|
52
|
+
|
|
53
|
+
expect(fromDb).toBeDefined()
|
|
54
|
+
expect(fromDb?.id).not.toBeNull()
|
|
55
|
+
expect(fromDb?.timestamp).toEqual(auditEvent.timestamp)
|
|
56
|
+
expect(fromDb?.level).toEqual(auditEvent.level)
|
|
57
|
+
expect(fromDb?.correlationId).toEqual(auditEvent.correlationId)
|
|
58
|
+
expect(fromDb?.system).toEqual(auditEvent.system)
|
|
59
|
+
expect(fromDb?.subSystemType).toEqual(auditEvent.subSystemType)
|
|
60
|
+
expect(fromDb?.actionType).toEqual(auditEvent.actionType)
|
|
61
|
+
expect(fromDb?.actionSubType).toEqual(auditEvent.actionSubType)
|
|
62
|
+
expect(fromDb?.initiatorType).toEqual(auditEvent.initiatorType)
|
|
63
|
+
expect(fromDb?.systemCorrelationIdType).toEqual(auditEvent.systemCorrelationIdType)
|
|
64
|
+
expect(fromDb?.systemCorrelationId).toEqual(auditEvent.systemCorrelationId)
|
|
65
|
+
expect(fromDb?.systemAlias).toEqual(auditEvent.systemAlias)
|
|
66
|
+
expect(fromDb?.partyCorrelationType).toEqual(auditEvent.partyCorrelationType)
|
|
67
|
+
expect(fromDb?.partyCorrelationId).toEqual(auditEvent.partyCorrelationId)
|
|
68
|
+
expect(fromDb?.partyAlias).toEqual(auditEvent.partyAlias)
|
|
69
|
+
expect(fromDb?.description).toEqual(auditEvent.description)
|
|
70
|
+
expect(fromDb?.data).toEqual(JSON.stringify(auditEvent.data))
|
|
71
|
+
expect(fromDb?.diagnosticData).toEqual(JSON.stringify(auditEvent.diagnosticData))
|
|
72
|
+
})
|
|
73
|
+
})
|
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
import { DataSource } from 'typeorm'
|
|
2
|
-
import { DataStoreEventLoggerMigrations } from '../migrations/generic'
|
|
3
|
-
import { DataStoreEventLoggerEntities } from '../index'
|
|
4
|
-
import {
|
|
5
|
-
ActionType,
|
|
6
|
-
AuditLoggingEvent,
|
|
7
|
-
InitiatorType,
|
|
8
|
-
LogLevel,
|
|
9
|
-
PartyCorrelationType,
|
|
10
|
-
SubSystem,
|
|
11
|
-
System,
|
|
12
|
-
SystemCorrelationIdType,
|
|
13
|
-
} from '@sphereon/ssi-sdk.core'
|
|
14
|
-
import { EventLoggerStore } from '../eventLogger/EventLoggerStore'
|
|
15
|
-
import { GetAuditEventsArgs, NonPersistedAuditLoggingEvent } from '../types'
|
|
16
|
-
|
|
17
|
-
describe('Database entities tests', (): void => {
|
|
18
|
-
let dbConnection: DataSource
|
|
19
|
-
let eventLoggerStore: EventLoggerStore
|
|
20
|
-
|
|
21
|
-
beforeEach(async (): Promise<void> => {
|
|
22
|
-
dbConnection = await new DataSource({
|
|
23
|
-
type: 'sqlite',
|
|
24
|
-
database: ':memory:',
|
|
25
|
-
//logging: 'all',
|
|
26
|
-
migrationsRun: false,
|
|
27
|
-
migrations: DataStoreEventLoggerMigrations,
|
|
28
|
-
synchronize: false,
|
|
29
|
-
entities: DataStoreEventLoggerEntities,
|
|
30
|
-
}).initialize()
|
|
31
|
-
await dbConnection.runMigrations()
|
|
32
|
-
expect(await dbConnection.showMigrations()).toBeFalsy()
|
|
33
|
-
eventLoggerStore = new EventLoggerStore(dbConnection)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
afterEach(async (): Promise<void> => {
|
|
37
|
-
await (await dbConnection).destroy()
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
it('should store audit event', async (): Promise<void> => {
|
|
41
|
-
const auditEvent: NonPersistedAuditLoggingEvent = {
|
|
42
|
-
timestamp: new Date(),
|
|
43
|
-
level: LogLevel.DEBUG,
|
|
44
|
-
correlationId: 'b40b8474-58a2-4b23-9fde-bd6ee1902cdb',
|
|
45
|
-
system: System.GENERAL,
|
|
46
|
-
subSystemType: SubSystem.DID_PROVIDER,
|
|
47
|
-
actionType: ActionType.CREATE,
|
|
48
|
-
actionSubType: 'Key generation',
|
|
49
|
-
initiatorType: InitiatorType.EXTERNAL,
|
|
50
|
-
systemCorrelationIdType: SystemCorrelationIdType.DID,
|
|
51
|
-
systemCorrelationId: 'did:example:123456789abcdefghi',
|
|
52
|
-
systemAlias: 'test_alias',
|
|
53
|
-
partyCorrelationType: PartyCorrelationType.DID,
|
|
54
|
-
partyCorrelationId: '75cfd84a-0f3b-4fb1-97a3-a1506c7ab850',
|
|
55
|
-
partyAlias: 'test_alias',
|
|
56
|
-
description: 'test_description',
|
|
57
|
-
data: 'test_data_string',
|
|
58
|
-
diagnosticData: { data: 'test_data_string' },
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const savedAuditEvent: AuditLoggingEvent = await eventLoggerStore.storeAuditEvent({ event: auditEvent })
|
|
62
|
-
expect(savedAuditEvent).toBeDefined()
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it('should get all audit events', async (): Promise<void> => {
|
|
66
|
-
const auditEvent: NonPersistedAuditLoggingEvent = {
|
|
67
|
-
timestamp: new Date(),
|
|
68
|
-
level: LogLevel.DEBUG,
|
|
69
|
-
correlationId: 'b40b8474-58a2-4b23-9fde-bd6ee1902cdb',
|
|
70
|
-
system: System.GENERAL,
|
|
71
|
-
subSystemType: SubSystem.DID_PROVIDER,
|
|
72
|
-
actionType: ActionType.CREATE,
|
|
73
|
-
actionSubType: 'Key generation',
|
|
74
|
-
initiatorType: InitiatorType.EXTERNAL,
|
|
75
|
-
systemCorrelationIdType: SystemCorrelationIdType.DID,
|
|
76
|
-
systemCorrelationId: 'did:example:123456789abcdefghi',
|
|
77
|
-
systemAlias: 'test_alias',
|
|
78
|
-
partyCorrelationType: PartyCorrelationType.DID,
|
|
79
|
-
partyCorrelationId: '75cfd84a-0f3b-4fb1-97a3-a1506c7ab850',
|
|
80
|
-
partyAlias: 'test_alias',
|
|
81
|
-
description: 'test_description',
|
|
82
|
-
data: 'test_data_string',
|
|
83
|
-
diagnosticData: { data: 'test_data_string' },
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const auditEvent1: AuditLoggingEvent = await eventLoggerStore.storeAuditEvent({ event: auditEvent })
|
|
87
|
-
expect(auditEvent1).toBeDefined()
|
|
88
|
-
|
|
89
|
-
const auditEvent2: AuditLoggingEvent = await eventLoggerStore.storeAuditEvent({ event: auditEvent })
|
|
90
|
-
expect(auditEvent2).toBeDefined()
|
|
91
|
-
|
|
92
|
-
const result: Array<AuditLoggingEvent> = await eventLoggerStore.getAuditEvents()
|
|
93
|
-
expect(result.length).toEqual(2)
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
it('should get audit events by filter', async (): Promise<void> => {
|
|
97
|
-
const auditEvent: NonPersistedAuditLoggingEvent = {
|
|
98
|
-
timestamp: new Date(),
|
|
99
|
-
level: LogLevel.DEBUG,
|
|
100
|
-
correlationId: 'b40b8474-58a2-4b23-9fde-bd6ee1902cdb',
|
|
101
|
-
system: System.GENERAL,
|
|
102
|
-
subSystemType: SubSystem.DID_PROVIDER,
|
|
103
|
-
actionType: ActionType.CREATE,
|
|
104
|
-
actionSubType: 'Key generation',
|
|
105
|
-
initiatorType: InitiatorType.EXTERNAL,
|
|
106
|
-
systemCorrelationIdType: SystemCorrelationIdType.DID,
|
|
107
|
-
systemCorrelationId: 'did:example:123456789abcdefghi',
|
|
108
|
-
systemAlias: 'test_alias',
|
|
109
|
-
partyCorrelationType: PartyCorrelationType.DID,
|
|
110
|
-
partyCorrelationId: '75cfd84a-0f3b-4fb1-97a3-a1506c7ab850',
|
|
111
|
-
partyAlias: 'test_alias',
|
|
112
|
-
description: 'test_description',
|
|
113
|
-
data: 'test_data_string',
|
|
114
|
-
diagnosticData: { data: 'test_data_string' },
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const savedAuditEvent: AuditLoggingEvent = await eventLoggerStore.storeAuditEvent({ event: auditEvent })
|
|
118
|
-
expect(savedAuditEvent).toBeDefined()
|
|
119
|
-
|
|
120
|
-
const args: GetAuditEventsArgs = {
|
|
121
|
-
filter: [{ correlationId: auditEvent.correlationId }],
|
|
122
|
-
}
|
|
123
|
-
const result: Array<AuditLoggingEvent> = await eventLoggerStore.getAuditEvents(args)
|
|
124
|
-
|
|
125
|
-
expect(result.length).toEqual(1)
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
it('should return no audit events if filter does not match', async (): Promise<void> => {
|
|
129
|
-
const args: GetAuditEventsArgs = {
|
|
130
|
-
filter: [{ correlationId: 'unknown_id' }],
|
|
131
|
-
}
|
|
132
|
-
const result: Array<AuditLoggingEvent> = await eventLoggerStore.getAuditEvents(args)
|
|
133
|
-
|
|
134
|
-
expect(result.length).toEqual(0)
|
|
135
|
-
})
|
|
136
|
-
})
|
|
1
|
+
import { DataSource } from 'typeorm'
|
|
2
|
+
import { DataStoreEventLoggerMigrations } from '../migrations/generic'
|
|
3
|
+
import { DataStoreEventLoggerEntities } from '../index'
|
|
4
|
+
import {
|
|
5
|
+
ActionType,
|
|
6
|
+
AuditLoggingEvent,
|
|
7
|
+
InitiatorType,
|
|
8
|
+
LogLevel,
|
|
9
|
+
PartyCorrelationType,
|
|
10
|
+
SubSystem,
|
|
11
|
+
System,
|
|
12
|
+
SystemCorrelationIdType,
|
|
13
|
+
} from '@sphereon/ssi-sdk.core'
|
|
14
|
+
import { EventLoggerStore } from '../eventLogger/EventLoggerStore'
|
|
15
|
+
import { GetAuditEventsArgs, NonPersistedAuditLoggingEvent } from '../types'
|
|
16
|
+
|
|
17
|
+
describe('Database entities tests', (): void => {
|
|
18
|
+
let dbConnection: DataSource
|
|
19
|
+
let eventLoggerStore: EventLoggerStore
|
|
20
|
+
|
|
21
|
+
beforeEach(async (): Promise<void> => {
|
|
22
|
+
dbConnection = await new DataSource({
|
|
23
|
+
type: 'sqlite',
|
|
24
|
+
database: ':memory:',
|
|
25
|
+
//logging: 'all',
|
|
26
|
+
migrationsRun: false,
|
|
27
|
+
migrations: DataStoreEventLoggerMigrations,
|
|
28
|
+
synchronize: false,
|
|
29
|
+
entities: DataStoreEventLoggerEntities,
|
|
30
|
+
}).initialize()
|
|
31
|
+
await dbConnection.runMigrations()
|
|
32
|
+
expect(await dbConnection.showMigrations()).toBeFalsy()
|
|
33
|
+
eventLoggerStore = new EventLoggerStore(dbConnection)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
afterEach(async (): Promise<void> => {
|
|
37
|
+
await (await dbConnection).destroy()
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('should store audit event', async (): Promise<void> => {
|
|
41
|
+
const auditEvent: NonPersistedAuditLoggingEvent = {
|
|
42
|
+
timestamp: new Date(),
|
|
43
|
+
level: LogLevel.DEBUG,
|
|
44
|
+
correlationId: 'b40b8474-58a2-4b23-9fde-bd6ee1902cdb',
|
|
45
|
+
system: System.GENERAL,
|
|
46
|
+
subSystemType: SubSystem.DID_PROVIDER,
|
|
47
|
+
actionType: ActionType.CREATE,
|
|
48
|
+
actionSubType: 'Key generation',
|
|
49
|
+
initiatorType: InitiatorType.EXTERNAL,
|
|
50
|
+
systemCorrelationIdType: SystemCorrelationIdType.DID,
|
|
51
|
+
systemCorrelationId: 'did:example:123456789abcdefghi',
|
|
52
|
+
systemAlias: 'test_alias',
|
|
53
|
+
partyCorrelationType: PartyCorrelationType.DID,
|
|
54
|
+
partyCorrelationId: '75cfd84a-0f3b-4fb1-97a3-a1506c7ab850',
|
|
55
|
+
partyAlias: 'test_alias',
|
|
56
|
+
description: 'test_description',
|
|
57
|
+
data: 'test_data_string',
|
|
58
|
+
diagnosticData: { data: 'test_data_string' },
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const savedAuditEvent: AuditLoggingEvent = await eventLoggerStore.storeAuditEvent({ event: auditEvent })
|
|
62
|
+
expect(savedAuditEvent).toBeDefined()
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('should get all audit events', async (): Promise<void> => {
|
|
66
|
+
const auditEvent: NonPersistedAuditLoggingEvent = {
|
|
67
|
+
timestamp: new Date(),
|
|
68
|
+
level: LogLevel.DEBUG,
|
|
69
|
+
correlationId: 'b40b8474-58a2-4b23-9fde-bd6ee1902cdb',
|
|
70
|
+
system: System.GENERAL,
|
|
71
|
+
subSystemType: SubSystem.DID_PROVIDER,
|
|
72
|
+
actionType: ActionType.CREATE,
|
|
73
|
+
actionSubType: 'Key generation',
|
|
74
|
+
initiatorType: InitiatorType.EXTERNAL,
|
|
75
|
+
systemCorrelationIdType: SystemCorrelationIdType.DID,
|
|
76
|
+
systemCorrelationId: 'did:example:123456789abcdefghi',
|
|
77
|
+
systemAlias: 'test_alias',
|
|
78
|
+
partyCorrelationType: PartyCorrelationType.DID,
|
|
79
|
+
partyCorrelationId: '75cfd84a-0f3b-4fb1-97a3-a1506c7ab850',
|
|
80
|
+
partyAlias: 'test_alias',
|
|
81
|
+
description: 'test_description',
|
|
82
|
+
data: 'test_data_string',
|
|
83
|
+
diagnosticData: { data: 'test_data_string' },
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const auditEvent1: AuditLoggingEvent = await eventLoggerStore.storeAuditEvent({ event: auditEvent })
|
|
87
|
+
expect(auditEvent1).toBeDefined()
|
|
88
|
+
|
|
89
|
+
const auditEvent2: AuditLoggingEvent = await eventLoggerStore.storeAuditEvent({ event: auditEvent })
|
|
90
|
+
expect(auditEvent2).toBeDefined()
|
|
91
|
+
|
|
92
|
+
const result: Array<AuditLoggingEvent> = await eventLoggerStore.getAuditEvents()
|
|
93
|
+
expect(result.length).toEqual(2)
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
it('should get audit events by filter', async (): Promise<void> => {
|
|
97
|
+
const auditEvent: NonPersistedAuditLoggingEvent = {
|
|
98
|
+
timestamp: new Date(),
|
|
99
|
+
level: LogLevel.DEBUG,
|
|
100
|
+
correlationId: 'b40b8474-58a2-4b23-9fde-bd6ee1902cdb',
|
|
101
|
+
system: System.GENERAL,
|
|
102
|
+
subSystemType: SubSystem.DID_PROVIDER,
|
|
103
|
+
actionType: ActionType.CREATE,
|
|
104
|
+
actionSubType: 'Key generation',
|
|
105
|
+
initiatorType: InitiatorType.EXTERNAL,
|
|
106
|
+
systemCorrelationIdType: SystemCorrelationIdType.DID,
|
|
107
|
+
systemCorrelationId: 'did:example:123456789abcdefghi',
|
|
108
|
+
systemAlias: 'test_alias',
|
|
109
|
+
partyCorrelationType: PartyCorrelationType.DID,
|
|
110
|
+
partyCorrelationId: '75cfd84a-0f3b-4fb1-97a3-a1506c7ab850',
|
|
111
|
+
partyAlias: 'test_alias',
|
|
112
|
+
description: 'test_description',
|
|
113
|
+
data: 'test_data_string',
|
|
114
|
+
diagnosticData: { data: 'test_data_string' },
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const savedAuditEvent: AuditLoggingEvent = await eventLoggerStore.storeAuditEvent({ event: auditEvent })
|
|
118
|
+
expect(savedAuditEvent).toBeDefined()
|
|
119
|
+
|
|
120
|
+
const args: GetAuditEventsArgs = {
|
|
121
|
+
filter: [{ correlationId: auditEvent.correlationId }],
|
|
122
|
+
}
|
|
123
|
+
const result: Array<AuditLoggingEvent> = await eventLoggerStore.getAuditEvents(args)
|
|
124
|
+
|
|
125
|
+
expect(result.length).toEqual(1)
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
it('should return no audit events if filter does not match', async (): Promise<void> => {
|
|
129
|
+
const args: GetAuditEventsArgs = {
|
|
130
|
+
filter: [{ correlationId: 'unknown_id' }],
|
|
131
|
+
}
|
|
132
|
+
const result: Array<AuditLoggingEvent> = await eventLoggerStore.getAuditEvents(args)
|
|
133
|
+
|
|
134
|
+
expect(result.length).toEqual(0)
|
|
135
|
+
})
|
|
136
|
+
})
|