@sphereon/ssi-sdk.data-store 0.18.2-next.3 → 0.18.2-unstable.10
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/contact/AbstractContactStore.d.ts +23 -23
- package/dist/contact/AbstractContactStore.js +6 -6
- package/dist/contact/ContactStore.d.ts +32 -32
- package/dist/contact/ContactStore.js +365 -365
- package/dist/entities/contact/BaseConfigEntity.d.ts +6 -6
- package/dist/entities/contact/BaseConfigEntity.js +33 -33
- package/dist/entities/contact/BaseContactEntity.d.ts +9 -9
- package/dist/entities/contact/BaseContactEntity.js +53 -53
- package/dist/entities/contact/ConnectionEntity.d.ts +10 -10
- package/dist/entities/contact/ConnectionEntity.js +46 -46
- package/dist/entities/contact/ContactEntity.d.ts +16 -0
- package/dist/entities/contact/ContactEntity.d.ts.map +1 -0
- package/dist/entities/contact/ContactEntity.js +164 -0
- package/dist/entities/contact/ContactEntity.js.map +1 -0
- package/dist/entities/contact/CorrelationIdentifierEntity.d.ts +10 -10
- package/dist/entities/contact/CorrelationIdentifierEntity.js +71 -71
- package/dist/entities/contact/DidAuthConfigEntity.d.ts +6 -6
- package/dist/entities/contact/DidAuthConfigEntity.js +32 -32
- package/dist/entities/contact/ElectronicAddressEntity.d.ts +13 -13
- package/dist/entities/contact/ElectronicAddressEntity.js +91 -91
- package/dist/entities/contact/IdentityEntity.d.ts +20 -20
- package/dist/entities/contact/IdentityEntity.js +128 -128
- package/dist/entities/contact/IdentityMetadataItemEntity.d.ts +9 -9
- package/dist/entities/contact/IdentityMetadataItemEntity.js +68 -68
- package/dist/entities/contact/NaturalPersonEntity.d.ts +8 -8
- package/dist/entities/contact/NaturalPersonEntity.js +71 -71
- package/dist/entities/contact/OpenIdConfigEntity.d.ts +10 -10
- package/dist/entities/contact/OpenIdConfigEntity.js +48 -48
- package/dist/entities/contact/OrganizationEntity.d.ts +8 -8
- package/dist/entities/contact/OrganizationEntity.js +66 -66
- package/dist/entities/contact/PartyEntity.d.ts +19 -19
- package/dist/entities/contact/PartyEntity.js +131 -131
- package/dist/entities/contact/PartyRelationshipEntity.d.ts +12 -12
- package/dist/entities/contact/PartyRelationshipEntity.js +94 -94
- package/dist/entities/contact/PartyTypeEntity.d.ts +14 -14
- package/dist/entities/contact/PartyTypeEntity.js +103 -103
- package/dist/entities/eventLogger/AuditEventEntity.d.ts +26 -26
- package/dist/entities/eventLogger/AuditEventEntity.js +123 -123
- package/dist/entities/issuanceBranding/BackgroundAttributesEntity.d.ts +10 -10
- package/dist/entities/issuanceBranding/BackgroundAttributesEntity.js +73 -73
- package/dist/entities/issuanceBranding/BaseLocaleBrandingEntity.d.ts +17 -17
- package/dist/entities/issuanceBranding/BaseLocaleBrandingEntity.js +119 -119
- package/dist/entities/issuanceBranding/CredentialBrandingEntity.d.ts +14 -14
- package/dist/entities/issuanceBranding/CredentialBrandingEntity.js +101 -101
- package/dist/entities/issuanceBranding/CredentialLocaleBrandingEntity.d.ts +8 -8
- package/dist/entities/issuanceBranding/CredentialLocaleBrandingEntity.js +48 -48
- package/dist/entities/issuanceBranding/ImageAttributesEntity.d.ts +13 -13
- package/dist/entities/issuanceBranding/ImageAttributesEntity.js +91 -91
- package/dist/entities/issuanceBranding/ImageDimensionsEntity.d.ts +8 -8
- package/dist/entities/issuanceBranding/ImageDimensionsEntity.js +38 -38
- package/dist/entities/issuanceBranding/IssuerBrandingEntity.d.ts +13 -13
- package/dist/entities/issuanceBranding/IssuerBrandingEntity.js +94 -94
- package/dist/entities/issuanceBranding/IssuerLocaleBrandingEntity.d.ts +8 -8
- package/dist/entities/issuanceBranding/IssuerLocaleBrandingEntity.js +48 -48
- package/dist/entities/issuanceBranding/TextAttributesEntity.d.ts +8 -8
- package/dist/entities/issuanceBranding/TextAttributesEntity.js +61 -61
- package/dist/entities/statusList2021/StatusList2021Entity.d.ts +18 -18
- package/dist/entities/statusList2021/StatusList2021Entity.js +114 -114
- package/dist/entities/statusList2021/StatusList2021EntryEntity.d.ts +10 -10
- package/dist/entities/statusList2021/StatusList2021EntryEntity.js +50 -50
- package/dist/entities/validators/index.d.ts +6 -6
- package/dist/entities/validators/index.js +26 -26
- package/dist/eventLogger/AbstractEventLoggerStore.d.ts +6 -6
- package/dist/eventLogger/AbstractEventLoggerStore.js +6 -6
- package/dist/eventLogger/EventLoggerStore.d.ts +12 -12
- package/dist/eventLogger/EventLoggerStore.js +43 -43
- package/dist/index.d.ts +41 -41
- package/dist/index.js +127 -127
- package/dist/issuanceBranding/AbstractIssuanceBrandingStore.d.ts +19 -19
- package/dist/issuanceBranding/AbstractIssuanceBrandingStore.js +6 -6
- package/dist/issuanceBranding/IssuanceBrandingStore.d.ts +30 -30
- package/dist/issuanceBranding/IssuanceBrandingStore.js +374 -374
- package/dist/migrations/generic/1-CreateContacts.d.ts +6 -6
- package/dist/migrations/generic/1-CreateContacts.js +77 -77
- package/dist/migrations/generic/1-CreateIssuanceBranding.d.ts +7 -0
- package/dist/migrations/generic/1-CreateIssuanceBranding.d.ts.map +1 -0
- package/dist/migrations/generic/1-CreateIssuanceBranding.js +96 -0
- package/dist/migrations/generic/1-CreateIssuanceBranding.js.map +1 -0
- package/dist/migrations/generic/2-CreateContacts.d.ts +7 -0
- package/dist/migrations/generic/2-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/generic/2-CreateContacts.js +78 -0
- package/dist/migrations/generic/2-CreateContacts.js.map +1 -0
- package/dist/migrations/generic/2-CreateIssuanceBranding.d.ts +6 -6
- package/dist/migrations/generic/2-CreateIssuanceBranding.js +77 -77
- package/dist/migrations/generic/3-CreateContacts.d.ts +6 -6
- package/dist/migrations/generic/3-CreateContacts.js +77 -77
- package/dist/migrations/generic/3-CreateStatusList.d.ts +7 -0
- package/dist/migrations/generic/3-CreateStatusList.d.ts.map +1 -0
- package/dist/migrations/generic/3-CreateStatusList.js +72 -0
- package/dist/migrations/generic/3-CreateStatusList.js.map +1 -0
- package/dist/migrations/generic/4-CreateStatusList.d.ts +6 -6
- package/dist/migrations/generic/4-CreateStatusList.js +71 -71
- package/dist/migrations/generic/5-CreateAuditEvents.d.ts +6 -6
- package/dist/migrations/generic/5-CreateAuditEvents.js +77 -77
- package/dist/migrations/generic/index.d.ts +16 -16
- package/dist/migrations/generic/index.js +27 -27
- package/dist/migrations/index.d.ts +1 -1
- package/dist/migrations/index.js +5 -5
- package/dist/migrations/internal-migrations-ormconfig.d.ts +6 -6
- package/dist/migrations/internal-migrations-ormconfig.js +26 -26
- package/dist/migrations/postgres/1659463079428-CreateContacts.d.ts +6 -6
- package/dist/migrations/postgres/1659463079428-CreateContacts.js +56 -56
- package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.d.ts +6 -6
- package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.js +68 -68
- package/dist/migrations/postgres/1690925872592-CreateContacts.d.ts +6 -6
- package/dist/migrations/postgres/1690925872592-CreateContacts.js +68 -68
- package/dist/migrations/postgres/1693866470001-CreateStatusList.d.ts +6 -6
- package/dist/migrations/postgres/1693866470001-CreateStatusList.js +31 -31
- package/dist/migrations/postgres/1701634812183-CreateAuditEvents.d.ts +6 -6
- package/dist/migrations/postgres/1701634812183-CreateAuditEvents.js +42 -42
- package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.d.ts +7 -0
- package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.d.ts.map +1 -0
- package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.js +32 -0
- package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.js.map +1 -0
- package/dist/migrations/postgres/uuid.d.ts +3 -0
- package/dist/migrations/postgres/uuid.d.ts.map +1 -0
- package/dist/migrations/postgres/uuid.js +25 -0
- package/dist/migrations/postgres/uuid.js.map +1 -0
- package/dist/migrations/sqlite/1659463069549-CreateContacts.d.ts +6 -6
- package/dist/migrations/sqlite/1659463069549-CreateContacts.js +78 -78
- package/dist/migrations/sqlite/1685628973231-CreateIssuanceBranding.d.ts +6 -6
- package/dist/migrations/sqlite/1685628973231-CreateIssuanceBranding.js +88 -88
- package/dist/migrations/sqlite/1690925872693-CreateContacts.d.ts +6 -6
- package/dist/migrations/sqlite/1690925872693-CreateContacts.js +107 -107
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.d.ts +6 -6
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.js +31 -31
- package/dist/migrations/sqlite/1701634819487-CreateAuditEvents.d.ts +6 -6
- package/dist/migrations/sqlite/1701634819487-CreateAuditEvents.js +28 -28
- package/dist/statusList/IStatusListStore.d.ts +19 -19
- package/dist/statusList/IStatusListStore.js +2 -2
- package/dist/statusList/StatusListStore.d.ts +35 -35
- package/dist/statusList/StatusListStore.js +212 -212
- package/dist/types/contact/IAbstractContactStore.d.ts +74 -74
- package/dist/types/contact/IAbstractContactStore.js +2 -2
- package/dist/types/contact/contact.d.ts +173 -173
- package/dist/types/contact/contact.js +25 -25
- package/dist/types/eventLogger/IAbstractEventLoggerStore.d.ts +9 -9
- package/dist/types/eventLogger/IAbstractEventLoggerStore.js +2 -2
- package/dist/types/eventLogger/eventLogger.d.ts +2 -2
- package/dist/types/eventLogger/eventLogger.js +2 -2
- package/dist/types/index.d.ts +9 -9
- package/dist/types/index.js +25 -25
- package/dist/types/issuanceBranding/IAbstractIssuanceBrandingStore.d.ts +58 -58
- package/dist/types/issuanceBranding/IAbstractIssuanceBrandingStore.js +2 -2
- package/dist/types/issuanceBranding/issuanceBranding.d.ts +114 -114
- package/dist/types/issuanceBranding/issuanceBranding.js +2 -2
- package/dist/types/statusList/IAbstractStatusListStore.d.ts +37 -37
- package/dist/types/statusList/IAbstractStatusListStore.js +2 -2
- package/dist/types/statusList/statusList.d.ts +24 -24
- package/dist/types/statusList/statusList.js +2 -2
- package/dist/types/validation/validation.d.ts +3 -3
- package/dist/types/validation/validation.js +2 -2
- package/dist/utils/ValidatorUtils.d.ts +3 -3
- package/dist/utils/ValidatorUtils.js +12 -12
- package/dist/utils/contact/MappingUtils.d.ts +46 -46
- package/dist/utils/contact/MappingUtils.js +290 -290
- package/package.json +4 -4
- package/src/__tests__/eventLogger.entities.test.ts +73 -73
- package/src/__tests__/eventLogger.store.test.ts +136 -136
- package/src/contact/ContactStore.ts +501 -501
- package/src/entities/eventLogger/AuditEventEntity.ts +99 -99
- 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 +113 -113
- 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/index.ts +27 -27
- package/src/migrations/postgres/1693866470001-CreateStatusList.ts +24 -24
- package/src/migrations/postgres/1701634812183-CreateAuditEvents.ts +33 -33
- package/src/migrations/sqlite/1690925872693-CreateContacts.ts +163 -163
- package/src/migrations/sqlite/1701634819487-CreateAuditEvents.ts +15 -15
- package/src/types/eventLogger/IAbstractEventLoggerStore.ts +12 -12
- package/src/types/eventLogger/eventLogger.ts +3 -3
- package/src/types/index.ts +9 -9
|
@@ -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
|
+
})
|