From 21c22e7c6e9cb93ee5804e7be50084847f3004a8 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 10 Jun 2024 14:33:04 +0200 Subject: [PATCH 001/105] feat: deletion process logger --- .../Identities/IIdentityDeleter.cs | 24 ++++++++- Jobs/src/Job.IdentityDeletion/Program.cs | 21 ++++++++ .../Workers/ActualDeletionWorker.cs | 7 ++- .../Identities/IdentityDeleter.cs | 3 +- .../Commands/LogDeletionProcess/Handler.cs | 23 ++++++++ .../LogDeletionProcessCommand.cs | 16 ++++++ .../Identities/IdentityDeleter.cs | 4 +- .../Entities/Identities/Identity.cs | 8 +++ .../Identities/IdentityDeletionProcess.cs | 5 ++ .../IdentityDeletionProcessAuditLogEntry.cs | 52 ++++++++++++++++++- .../Identities/LogDeletionProcessTests.cs | 10 ++++ .../Identities/IdentityDeleter.cs | 3 +- .../Identities/IdentityDeleter.cs | 3 +- .../Identities/IdentityDeleter.cs | 3 +- .../Identities/IdentityDeleter.cs | 5 +- .../Identities/IdentityDeleter.cs | 5 +- .../Identities/IdentityDeleter.cs | 3 +- 17 files changed, 183 insertions(+), 12 deletions(-) create mode 100644 Modules/Devices/src/Devices.Application/Identities/Commands/LogDeletionProcess/Handler.cs create mode 100644 Modules/Devices/src/Devices.Application/Identities/Commands/LogDeletionProcess/LogDeletionProcessCommand.cs create mode 100644 Modules/Devices/test/Devices.Domain.Tests/Identities/LogDeletionProcessTests.cs diff --git a/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs b/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs index 1175d6d7b2..0099caefb3 100644 --- a/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs +++ b/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs @@ -3,5 +3,27 @@ namespace Backbone.BuildingBlocks.Application.Identities; public interface IIdentityDeleter { - Task Delete(IdentityAddress identityAddress); + Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger); +} + +public interface IDeletionProcessLogger +{ + Task LogDeletion(IdentityAddress identityAddress, AggregateType aggregateType); +} + +public enum AggregateType +{ + Challenges, + PnsRegistrations, + Identity, + Files, + Messages, + QuotasIdentity, + Relationships, + RelationshipTemplates, + RelationshipTemplateAllocations, + ExternalEvents, + SyncRuns, + Datawallets, + Tokens } diff --git a/Jobs/src/Job.IdentityDeletion/Program.cs b/Jobs/src/Job.IdentityDeletion/Program.cs index 2271e839e9..34d344fb68 100644 --- a/Jobs/src/Job.IdentityDeletion/Program.cs +++ b/Jobs/src/Job.IdentityDeletion/Program.cs @@ -1,11 +1,14 @@ using System.Reflection; using Autofac.Extensions.DependencyInjection; using Backbone.BuildingBlocks.API.Extensions; +using Backbone.BuildingBlocks.Application.Identities; using Backbone.BuildingBlocks.Application.QuotaCheck; +using Backbone.DevelopmentKit.Identity.ValueObjects; using Backbone.Infrastructure.EventBus; using Backbone.Job.IdentityDeletion; using Backbone.Modules.Challenges.ConsumerApi; using Backbone.Modules.Devices.Application.Identities.Commands.CancelStaleIdentityDeletionProcesses; +using Backbone.Modules.Devices.Application.Identities.Commands.LogDeletionProcess; using Backbone.Modules.Devices.ConsumerApi; using Backbone.Modules.Devices.Infrastructure.PushNotifications; using Backbone.Modules.Files.ConsumerApi; @@ -15,6 +18,7 @@ using Backbone.Modules.Synchronization.ConsumerApi; using Backbone.Modules.Tokens.ConsumerApi; using FluentValidation.AspNetCore; +using MediatR; using Microsoft.Extensions.Options; using Serilog; using Serilog.Exceptions; @@ -98,6 +102,8 @@ static IHostBuilder CreateHostBuilder(string[] args) .AddModule(configuration) .AddModule(configuration); + services.AddSingleton(); + services.AddTransient(); services.AddFluentValidationAutoValidation(config => { config.DisableDataAnnotationsValidation = true; }); @@ -123,3 +129,18 @@ static IHostBuilder CreateHostBuilder(string[] args) ) ); } + +public class DeletionProcessLogger : IDeletionProcessLogger +{ + private readonly IMediator _mediator; + + public DeletionProcessLogger(IMediator mediator) + { + _mediator = mediator; + } + + public async Task LogDeletion(IdentityAddress identityAddress, AggregateType aggregateType) + { + await _mediator.Send(new LogDeletionProcessCommand(identityAddress, aggregateType)); + } +} diff --git a/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs b/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs index a07f47c37d..5c1e00a42d 100644 --- a/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs +++ b/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs @@ -20,13 +20,15 @@ public class ActualDeletionWorker : IHostedService private readonly IMediator _mediator; private readonly IPushNotificationSender _pushNotificationSender; private readonly ILogger _logger; + private readonly IDeletionProcessLogger _deletionProcessLogger; public ActualDeletionWorker(IHostApplicationLifetime host, IEnumerable identityDeleters, IMediator mediator, IPushNotificationSender pushNotificationSender, IEventBus eventBus, - ILogger logger) + ILogger logger, + IDeletionProcessLogger deletionProcessLogger) { _host = host; _identityDeleters = identityDeleters; @@ -34,6 +36,7 @@ public ActualDeletionWorker(IHostApplicationLifetime host, _pushNotificationSender = pushNotificationSender; _eventBus = eventBus; _logger = logger; + _deletionProcessLogger = deletionProcessLogger; } public async Task StartAsync(CancellationToken cancellationToken) @@ -93,7 +96,7 @@ private async Task Delete(IdentityAddress identityAddress) { foreach (var identityDeleter in _identityDeleters) { - await identityDeleter.Delete(identityAddress); + await identityDeleter.Delete(identityAddress, _deletionProcessLogger); } } diff --git a/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs b/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs index 1dc395c7f7..0e4945c780 100644 --- a/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs +++ b/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs @@ -13,8 +13,9 @@ public IdentityDeleter(IMediator mediator) _mediator = mediator; } - public async Task Delete(IdentityAddress identityAddress) + public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new DeleteChallengesOfIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Challenges); } } diff --git a/Modules/Devices/src/Devices.Application/Identities/Commands/LogDeletionProcess/Handler.cs b/Modules/Devices/src/Devices.Application/Identities/Commands/LogDeletionProcess/Handler.cs new file mode 100644 index 0000000000..b51de7c5d8 --- /dev/null +++ b/Modules/Devices/src/Devices.Application/Identities/Commands/LogDeletionProcess/Handler.cs @@ -0,0 +1,23 @@ +using Backbone.BuildingBlocks.Application.Abstractions.Exceptions; +using Backbone.Modules.Devices.Application.Infrastructure.Persistence.Repository; +using Backbone.Modules.Devices.Domain.Entities.Identities; +using MediatR; + +namespace Backbone.Modules.Devices.Application.Identities.Commands.LogDeletionProcess; +public class Handler : IRequestHandler +{ + private readonly IIdentitiesRepository _identitiesRepository; + + public Handler(IIdentitiesRepository identitiesRepository) + { + _identitiesRepository = identitiesRepository; + } + + public async Task Handle(LogDeletionProcessCommand request, CancellationToken cancellationToken) + { + var identity = await _identitiesRepository.FindByAddress(request.IdentityAddress, cancellationToken, track: true) ?? throw new NotFoundException(nameof(Identity)); + identity.LogDeletedData(request.AggregateType.ToString()); + + await _identitiesRepository.Update(identity, cancellationToken); + } +} diff --git a/Modules/Devices/src/Devices.Application/Identities/Commands/LogDeletionProcess/LogDeletionProcessCommand.cs b/Modules/Devices/src/Devices.Application/Identities/Commands/LogDeletionProcess/LogDeletionProcessCommand.cs new file mode 100644 index 0000000000..2aee6d0ccd --- /dev/null +++ b/Modules/Devices/src/Devices.Application/Identities/Commands/LogDeletionProcess/LogDeletionProcessCommand.cs @@ -0,0 +1,16 @@ +using Backbone.BuildingBlocks.Application.Identities; +using Backbone.DevelopmentKit.Identity.ValueObjects; +using MediatR; + +namespace Backbone.Modules.Devices.Application.Identities.Commands.LogDeletionProcess; +public class LogDeletionProcessCommand : IRequest +{ + public LogDeletionProcessCommand(IdentityAddress identityAddress, AggregateType aggregateType) + { + IdentityAddress = identityAddress; + AggregateType = aggregateType; + } + + public string IdentityAddress { get; set; } + public AggregateType AggregateType { get; set; } +} diff --git a/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs b/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs index 4223d17381..4e7b644eea 100644 --- a/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs +++ b/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs @@ -14,9 +14,11 @@ public IdentityDeleter(IMediator mediator) _mediator = mediator; } - public async Task Delete(IdentityAddress identityAddress) + public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new DeletePnsRegistrationsOfIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.PnsRegistrations); await _mediator.Send(new DeleteIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Identity); } } diff --git a/Modules/Devices/src/Devices.Domain/Entities/Identities/Identity.cs b/Modules/Devices/src/Devices.Domain/Entities/Identities/Identity.cs index 9555894770..c6ae7ebf38 100644 --- a/Modules/Devices/src/Devices.Domain/Entities/Identities/Identity.cs +++ b/Modules/Devices/src/Devices.Domain/Entities/Identities/Identity.cs @@ -285,6 +285,14 @@ private void EnsureDeletionProcessExists(IdentityDeletionProcessId deletionProce if (!isDeletionProcessOwnedByDevice) throw new DomainException(GenericDomainErrors.NotFound(nameof(IdentityDeletionProcess))); } + + public void LogDeletedData(string aggregateType) + { + EnsureDeletionProcessInStatusExists(DeletionProcessStatus.Deleting); + + var activeDeletionProcess = DeletionProcesses.First(d => d.Status == DeletionProcessStatus.Deleting); + activeDeletionProcess.LogDeletedData(Address, aggregateType); + } } public enum DeletionProcessStatus diff --git a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcess.cs b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcess.cs index c927edeba4..b14e284166 100644 --- a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcess.cs +++ b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcess.cs @@ -200,4 +200,9 @@ public void Cancel(IdentityAddress address) _auditLog.Add(IdentityDeletionProcessAuditLogEntry.ProcessCancelledAutomatically(Id, address)); } + + public void LogDeletedData(IdentityAddress address, string aggregateType) + { + _auditLog.Add(IdentityDeletionProcessAuditLogEntry.DataDeleted(Id, address, aggregateType)); + } } diff --git a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs index ce162892dc..01dc2f270b 100644 --- a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs +++ b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs @@ -190,6 +190,43 @@ public static IdentityDeletionProcessAuditLogEntry GracePeriodReminder3Sent(Iden DeletionProcessStatus.Approved ); } + + public static IdentityDeletionProcessAuditLogEntry DataDeleted(IdentityDeletionProcessId processId, IdentityAddress identityAddress, string aggregateType) + { + if (!TryGetMessageKey(aggregateType, out MessageKey messageKey)) + throw new ArgumentException("Invalid aggregateType", nameof(aggregateType)); + + return new IdentityDeletionProcessAuditLogEntry( + processId, + messageKey, + Hasher.HashUtf8(identityAddress.Value), + null, + DeletionProcessStatus.Deleting, + DeletionProcessStatus.Deleting + ); + } + + private static bool TryGetMessageKey(string aggregateType, out MessageKey messageKey) + { + var messageKeyMappings = new Dictionary + { + { "Challenges", MessageKey.Challenges }, + { "PnsRegistrations", MessageKey.PnsRegistrations }, + { "Identity", MessageKey.Identity }, + { "Files", MessageKey.Files }, + { "Messages", MessageKey.Messages }, + { "QuotasIdentity", MessageKey.QuotasIdentity }, + { "Relationships", MessageKey.Relationships }, + { "RelationshipTemplates", MessageKey.RelationshipTemplates }, + { "RelationshipTemplateAllocations", MessageKey.RelationshipTemplateAllocations }, + { "ExternalEvents", MessageKey.ExternalEvents }, + { "SyncRuns", MessageKey.SyncRuns }, + { "Datawallets", MessageKey.Datawallets }, + { "Tokens", MessageKey.Tokens } + }; + + return messageKeyMappings.TryGetValue(aggregateType, out messageKey); + } } public enum MessageKey @@ -206,5 +243,18 @@ public enum MessageKey ApprovalReminder3Sent = 10, GracePeriodReminder1Sent = 11, GracePeriodReminder2Sent = 12, - GracePeriodReminder3Sent = 13 + GracePeriodReminder3Sent = 13, + Challenges = 14, + PnsRegistrations = 15, + Identity = 16, + Files = 17, + Messages = 18, + QuotasIdentity = 19, + Relationships = 20, + RelationshipTemplates = 21, + RelationshipTemplateAllocations = 22, + ExternalEvents = 23, + SyncRuns = 24, + Datawallets = 25, + Tokens = 26 } diff --git a/Modules/Devices/test/Devices.Domain.Tests/Identities/LogDeletionProcessTests.cs b/Modules/Devices/test/Devices.Domain.Tests/Identities/LogDeletionProcessTests.cs new file mode 100644 index 0000000000..f6a1be3c32 --- /dev/null +++ b/Modules/Devices/test/Devices.Domain.Tests/Identities/LogDeletionProcessTests.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Backbone.Modules.Devices.Domain.Tests.Identities; +public class LogDeletionProcessTests +{ +} diff --git a/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs b/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs index 6c6cc3e98b..9c408857aa 100644 --- a/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs +++ b/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs @@ -13,8 +13,9 @@ public IdentityDeleter(IMediator mediator) _mediator = mediator; } - public async Task Delete(IdentityAddress identityAddress) + public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new DeleteFilesOfIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Files); } } diff --git a/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs b/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs index 3242c931c6..1475d0ebee 100644 --- a/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs +++ b/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs @@ -13,8 +13,9 @@ public IdentityDeleter(IMediator mediator) _mediator = mediator; } - public async Task Delete(IdentityAddress identityAddress) + public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new AnonymizeMessagesOfIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Messages); // TODO: these are not deleted but anonymized, perhaps adapt the names? } } diff --git a/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs b/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs index b63308cc3d..abf6d436d2 100644 --- a/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs +++ b/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs @@ -13,8 +13,9 @@ public IdentityDeleter(IMediator mediator) _mediator = mediator; } - public async Task Delete(IdentityAddress identityAddress) + public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new DeleteIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.QuotasIdentity); } } diff --git a/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs b/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs index d7b07c0f8b..79f4a35ceb 100644 --- a/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs +++ b/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs @@ -16,10 +16,13 @@ public IdentityDeleter(IMediator mediator) _mediator = mediator; } - public async Task Delete(IdentityAddress identityAddress) + public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new DeleteRelationshipsOfIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Relationships); await _mediator.Send(new DeleteRelationshipTemplatesOfIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplates); await _mediator.Send(new AnonymizeRelationshipTemplateAllocationsAllocatedByIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplateAllocations); } } diff --git a/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs b/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs index dd1595800f..5d0b4252c7 100644 --- a/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs +++ b/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs @@ -15,10 +15,13 @@ public IdentityDeleter(IMediator mediator) _mediator = mediator; } - public async Task Delete(IdentityAddress identityAddress) + public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new DeleteExternalEventsOfIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.ExternalEvents); await _mediator.Send(new DeleteSyncRunsOfIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.SyncRuns); await _mediator.Send(new DeleteDatawalletsOfIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Datawallets); } } diff --git a/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs b/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs index 342873f8c5..ddfef2dfb8 100644 --- a/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs +++ b/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs @@ -13,8 +13,9 @@ public IdentityDeleter(IMediator mediator) _mediator = mediator; } - public async Task Delete(IdentityAddress identityAddress) + public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new DeleteTokensOfIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Tokens); } } From f83cc1b14152283a9c6086d44c9f69e742f16845 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 10 Jun 2024 15:05:23 +0200 Subject: [PATCH 002/105] tests: adapt existing tests for new changes --- .../Tests/ActualDeletionWorkerTests.cs | 11 +++++++---- .../IdentityDeletionProcessAuditLogEntry.cs | 2 +- .../Tests/Identities/IdentityDeleterTests.cs | 6 ++++-- .../Tests/Identities/IdentityDeleterTests.cs | 7 +++++-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs index 675bcf71cd..015f7a4694 100644 --- a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs +++ b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs @@ -47,6 +47,7 @@ public async Task Calls_Deleters_For_Each_Identity() var identityAddress2 = TestDataGenerator.CreateRandomIdentityAddress(); SetupRipeDeletionProcessesCommand(mediator, identityAddress1, identityAddress2); var mockIdentityDeleter = A.Fake(); + var mockIDeletionProcessLogger = A.Fake(); var identityDeleters = new List([mockIdentityDeleter]); var worker = CreateWorker(mediator, identityDeleters); @@ -58,8 +59,8 @@ public async Task Calls_Deleters_For_Each_Identity() // Assert - A.CallTo(() => mockIdentityDeleter.Delete(identityAddress1)).MustHaveHappenedOnceExactly(); - A.CallTo(() => mockIdentityDeleter.Delete(identityAddress2)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIdentityDeleter.Delete(identityAddress1, mockIDeletionProcessLogger)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIdentityDeleter.Delete(identityAddress2, mockIDeletionProcessLogger)).MustHaveHappenedOnceExactly(); } [Fact] @@ -100,13 +101,15 @@ private static ActualDeletionWorker CreateWorker(IMediator mediator, IPushNotifi private static ActualDeletionWorker CreateWorker(IMediator mediator, List? identityDeleters = null, IEventBus? eventBus = null, - IPushNotificationSender? pushNotificationSender = null) + IPushNotificationSender? pushNotificationSender = null, + IDeletionProcessLogger? deletionProcessLogger = null) { var hostApplicationLifetime = A.Dummy(); identityDeleters ??= [A.Dummy()]; eventBus ??= A.Dummy(); pushNotificationSender ??= A.Dummy(); var logger = A.Dummy>(); - return new ActualDeletionWorker(hostApplicationLifetime, identityDeleters, mediator, pushNotificationSender, eventBus, logger); + deletionProcessLogger ??= A.Dummy(); + return new ActualDeletionWorker(hostApplicationLifetime, identityDeleters, mediator, pushNotificationSender, eventBus, logger, deletionProcessLogger); } } diff --git a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs index 01dc2f270b..3de28525bd 100644 --- a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs +++ b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs @@ -193,7 +193,7 @@ public static IdentityDeletionProcessAuditLogEntry GracePeriodReminder3Sent(Iden public static IdentityDeletionProcessAuditLogEntry DataDeleted(IdentityDeletionProcessId processId, IdentityAddress identityAddress, string aggregateType) { - if (!TryGetMessageKey(aggregateType, out MessageKey messageKey)) + if (!TryGetMessageKey(aggregateType, out var messageKey)) throw new ArgumentException("Invalid aggregateType", nameof(aggregateType)); return new IdentityDeletionProcessAuditLogEntry( diff --git a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index bdbec7a917..70ccce8393 100644 --- a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -1,4 +1,5 @@ -using Backbone.Modules.Devices.Application.Identities; +using Backbone.BuildingBlocks.Application.Identities; +using Backbone.Modules.Devices.Application.Identities; using Backbone.Modules.Devices.Application.Identities.Commands.DeleteIdentity; using Backbone.Modules.Devices.Application.PushNotifications.Commands.DeletePnsRegistrationsOfIdentity; using Backbone.UnitTestTools.BaseClasses; @@ -15,11 +16,12 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); + var mockIDeletionProcessLogger = A.Fake(); var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(mockMediator); // Act - await deleter.Delete(identityAddress); + await deleter.Delete(identityAddress, mockIDeletionProcessLogger); // Assert A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); diff --git a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 3b8e9cf480..1cf86ee24b 100644 --- a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -1,4 +1,5 @@ -using Backbone.Modules.Relationships.Application.Identities; +using Backbone.BuildingBlocks.Application.Identities; +using Backbone.Modules.Relationships.Application.Identities; using Backbone.Modules.Relationships.Application.RelationshipTemplates.Commands.DeleteRelationshipTemplatesOfIdentity; using Backbone.UnitTestTools.BaseClasses; using FakeItEasy; @@ -14,11 +15,13 @@ public async Task Deleter_calls_correct_command() { // Arrange var identityAddress = CreateRandomIdentityAddress(); + var mockIDeletionProcessLogger = A.Fake(); var mockMediator = A.Fake(); + var deleter = new IdentityDeleter(mockMediator); // Act - await deleter.Delete(identityAddress); + await deleter.Delete(identityAddress, mockIDeletionProcessLogger); // Assert A.CallTo(() => mockMediator.Send( From 87e78cc9382daf4c2c6f9a65124d6538ec3fcf80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Vetni=C4=87?= Date: Wed, 12 Jun 2024 11:28:58 +0200 Subject: [PATCH 003/105] feat: add wip implementation --- Jobs/src/Job.IdentityDeletion/Program.cs | 2 +- .../Tests/ActualDeletionWorkerTests.cs | 23 ++++++++----------- .../Tests/Identities/IdentityDeleterTests.cs | 18 +++++++++++++++ 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Jobs/src/Job.IdentityDeletion/Program.cs b/Jobs/src/Job.IdentityDeletion/Program.cs index 34d344fb68..3660095c60 100644 --- a/Jobs/src/Job.IdentityDeletion/Program.cs +++ b/Jobs/src/Job.IdentityDeletion/Program.cs @@ -102,7 +102,7 @@ static IHostBuilder CreateHostBuilder(string[] args) .AddModule(configuration) .AddModule(configuration); - services.AddSingleton(); + services.AddSingleton(); services.AddTransient(); services.AddFluentValidationAutoValidation(config => { config.DisableDataAnnotationsValidation = true; }); diff --git a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs index 015f7a4694..e0f1a3e756 100644 --- a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs +++ b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs @@ -29,7 +29,7 @@ public async Task Proxies_triggering_the_deletion_processes_to_command_handler() SetupRipeDeletionProcessesCommand(mockMediator); var identityDeleters = new List(); - var worker = CreateWorker(mockMediator, identityDeleters); + var worker = CreateWorker(mediator: mockMediator, identityDeleters); // Act await worker.StartProcessing(CancellationToken.None); @@ -42,23 +42,25 @@ public async Task Proxies_triggering_the_deletion_processes_to_command_handler() public async Task Calls_Deleters_For_Each_Identity() { // Arrange - var mediator = A.Fake(); + var mockMediator = A.Fake(); var identityAddress1 = TestDataGenerator.CreateRandomIdentityAddress(); var identityAddress2 = TestDataGenerator.CreateRandomIdentityAddress(); - SetupRipeDeletionProcessesCommand(mediator, identityAddress1, identityAddress2); + SetupRipeDeletionProcessesCommand(mockMediator, identityAddress1, identityAddress2); + var mockIdentityDeleter = A.Fake(); var mockIDeletionProcessLogger = A.Fake(); - var identityDeleters = new List([mockIdentityDeleter]); - var worker = CreateWorker(mediator, identityDeleters); + var identityDeleters = new List { mockIdentityDeleter }; - A.CallTo(() => mediator.Send(A._, A._)).Returns(new FindRelationshipsOfIdentityResponse(new List())); + var worker = CreateWorker(mediator: mockMediator, identityDeleters, deletionProcessLogger: mockIDeletionProcessLogger); + + A.CallTo(() => mockMediator.Send(A._, A._)) + .Returns(new FindRelationshipsOfIdentityResponse(new List())); // Act await worker.StartProcessing(CancellationToken.None); // Assert - A.CallTo(() => mockIdentityDeleter.Delete(identityAddress1, mockIDeletionProcessLogger)).MustHaveHappenedOnceExactly(); A.CallTo(() => mockIdentityDeleter.Delete(identityAddress2, mockIDeletionProcessLogger)).MustHaveHappenedOnceExactly(); } @@ -75,7 +77,7 @@ public async Task Sends_push_notification_for_each_relationship_of_each_identity A.CallTo(() => mockMediator.Send(A._, A._)).Returns(new FindRelationshipsOfIdentityResponse(new List())); var mockPushNotificationSender = A.Dummy(); - var worker = CreateWorker(mockMediator, mockPushNotificationSender); + var worker = CreateWorker(mediator: mockMediator, pushNotificationSender: mockPushNotificationSender); // Act await worker.StartProcessing(CancellationToken.None); @@ -93,11 +95,6 @@ private void SetupRipeDeletionProcessesCommand(IMediator mediator, params Identi A.CallTo(() => mediator.Send(A._, A._)).Returns(commandResponse); } - private static ActualDeletionWorker CreateWorker(IMediator mediator, IPushNotificationSender pushNotificationSender) - { - return CreateWorker(mediator, null, null, pushNotificationSender); - } - private static ActualDeletionWorker CreateWorker(IMediator mediator, List? identityDeleters = null, IEventBus? eventBus = null, diff --git a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 70ccce8393..3840cef675 100644 --- a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -1,6 +1,7 @@ using Backbone.BuildingBlocks.Application.Identities; using Backbone.Modules.Devices.Application.Identities; using Backbone.Modules.Devices.Application.Identities.Commands.DeleteIdentity; +using Backbone.Modules.Devices.Application.Identities.Commands.LogDeletionProcess; using Backbone.Modules.Devices.Application.PushNotifications.Commands.DeletePnsRegistrationsOfIdentity; using Backbone.UnitTestTools.BaseClasses; using FakeItEasy; @@ -27,4 +28,21 @@ public async Task Deleter_calls_correct_command() A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); } + + [Fact] + public async Task Deleter_correctly_logs_commands() + { + // Arrange + var mockMediator = A.Fake(); + var mockIDeletionProcessLogger = A.Fake(); + var identityAddress = CreateRandomIdentityAddress(); + var deleter = new IdentityDeleter(mockMediator); + + // Act + await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + + // Assert + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.Identity)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.PnsRegistrations)).MustHaveHappenedOnceExactly(); + } } From 4a88578ebd1407bc1162ff046585bd57acc82e55 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Wed, 12 Jun 2024 16:27:24 +0200 Subject: [PATCH 004/105] tests: improve tests --- Backbone.sln | 7 +++ .../Challenges.Application.Tests.csproj | 2 +- .../HandlerTests.cs | 2 +- .../Tests/Identities/IdentityDeleterTests.cs | 26 ++++++++-- .../Tests/Identities/IdentityDeleterTests.cs | 3 +- .../Tests/Identities/IdentityDeleterTests.cs | 43 ++++++++++++++++ .../Tests/Identities/IdentityDeleterTests.cs | 44 +++++++++++++++++ .../Tests/Identities/IdentityDeleterTests.cs | 43 ++++++++++++++++ .../Tests/Identities/IdentityDeleterTests.cs | 27 ++++++++++ .../Tests/Identities/IdentityDeleterTests.cs | 49 +++++++++++++++++++ .../Tests/Identities/IdentityDeleterTests.cs | 43 ++++++++++++++++ 11 files changed, 281 insertions(+), 8 deletions(-) create mode 100644 Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs create mode 100644 Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs create mode 100644 Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs create mode 100644 Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs create mode 100644 Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs diff --git a/Backbone.sln b/Backbone.sln index 3805154b47..805ceb08d4 100644 --- a/Backbone.sln +++ b/Backbone.sln @@ -297,6 +297,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventHandlerService.Tests", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DatabaseMigrator", "DatabaseMigrator\DatabaseMigrator.csproj", "{143EAC38-A2D0-4F74-88F1-3EF27413A8C6}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Challenges.Application.Tests", "Modules\Challenges\test\Challenges.Application.Tests\Challenges.Application.Tests.csproj", "{EAA10D43-BD28-40D8-BE07-B8F6DE47C156}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -715,6 +717,10 @@ Global {143EAC38-A2D0-4F74-88F1-3EF27413A8C6}.Debug|Any CPU.Build.0 = Debug|Any CPU {143EAC38-A2D0-4F74-88F1-3EF27413A8C6}.Release|Any CPU.ActiveCfg = Release|Any CPU {143EAC38-A2D0-4F74-88F1-3EF27413A8C6}.Release|Any CPU.Build.0 = Release|Any CPU + {EAA10D43-BD28-40D8-BE07-B8F6DE47C156}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EAA10D43-BD28-40D8-BE07-B8F6DE47C156}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EAA10D43-BD28-40D8-BE07-B8F6DE47C156}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EAA10D43-BD28-40D8-BE07-B8F6DE47C156}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -849,6 +855,7 @@ Global {2429FCAB-2058-4403-94DA-DA26B1655A7D} = {11FE034C-FA73-4766-99DB-D2C606018934} {B4664E79-77A5-41AE-8480-C449ED5B2576} = {D54A9259-7708-45C1-B8D9-448B97F43B80} {D47E0FE1-23A0-4A96-AF57-E3CE71A132AD} = {2429FCAB-2058-4403-94DA-DA26B1655A7D} + {EAA10D43-BD28-40D8-BE07-B8F6DE47C156} = {EFC1F89E-1C44-4385-A0F6-1F2124260561} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1F3BD2C6-7CB3-450F-A21A-23EA520D5B7A} diff --git a/Modules/Challenges/test/Challenges.Application.Tests/Challenges.Application.Tests.csproj b/Modules/Challenges/test/Challenges.Application.Tests/Challenges.Application.Tests.csproj index c6ac290cc9..045862bff2 100644 --- a/Modules/Challenges/test/Challenges.Application.Tests/Challenges.Application.Tests.csproj +++ b/Modules/Challenges/test/Challenges.Application.Tests/Challenges.Application.Tests.csproj @@ -7,7 +7,7 @@ - + diff --git a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/Commands/DeleteIdentityCommandTests/HandlerTests.cs b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/Commands/DeleteIdentityCommandTests/HandlerTests.cs index d6d217dc19..c8456d2fd2 100644 --- a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/Commands/DeleteIdentityCommandTests/HandlerTests.cs +++ b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/Commands/DeleteIdentityCommandTests/HandlerTests.cs @@ -20,7 +20,7 @@ public async Task Handler_calls_deletion_method_on_repository() await handler.Handle(new DeleteChallengesOfIdentityCommand(identityAddress), CancellationToken.None); // Assert - A.CallTo(() => mockChallengesRepository.DeleteChallenges(A>>._, A._)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockChallengesRepository.Delete(A>>._, A._)).MustHaveHappenedOnceExactly(); } private static Handler CreateHandler(IChallengesRepository challengesRepository) diff --git a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 3e6304997f..2b92df9f45 100644 --- a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -1,9 +1,10 @@ -using Backbone.Modules.Challenges.Application.Challenges.Commands.DeleteChallengesOfIdentity; +using Backbone.BuildingBlocks.Application.Identities; +using Backbone.Modules.Challenges.Application.Challenges.Commands.DeleteChallengesOfIdentity; using Backbone.Modules.Challenges.Application.Identities; -using Backbone.UnitTestTools.Data; using FakeItEasy; using MediatR; using Xunit; +using static Backbone.UnitTestTools.Data.TestDataGenerator; namespace Backbone.Modules.Challenges.Application.Tests.Tests.Identities; public class IdentityDeleterTests @@ -13,13 +14,30 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var identityAddress = TestDataGenerator.CreateRandomIdentityAddress(); + var mockIDeletionProcessLogger = A.Fake(); + var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(mockMediator); // Act - await deleter.Delete(identityAddress); + await deleter.Delete(identityAddress, mockIDeletionProcessLogger); // Assert A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); } + + [Fact] + public async Task Deleter_correctly_creates_audit_log() + { + // Arrange + var mockMediator = A.Fake(); + var mockIDeletionProcessLogger = A.Fake(); + var identityAddress = CreateRandomIdentityAddress(); + var deleter = new IdentityDeleter(mockMediator); + + // Act + await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + + // Assert + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.Challenges)).MustHaveHappenedOnceExactly(); + } } diff --git a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 3840cef675..bc14a4f3fa 100644 --- a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -1,7 +1,6 @@ using Backbone.BuildingBlocks.Application.Identities; using Backbone.Modules.Devices.Application.Identities; using Backbone.Modules.Devices.Application.Identities.Commands.DeleteIdentity; -using Backbone.Modules.Devices.Application.Identities.Commands.LogDeletionProcess; using Backbone.Modules.Devices.Application.PushNotifications.Commands.DeletePnsRegistrationsOfIdentity; using Backbone.UnitTestTools.BaseClasses; using FakeItEasy; @@ -30,7 +29,7 @@ public async Task Deleter_calls_correct_command() } [Fact] - public async Task Deleter_correctly_logs_commands() + public async Task Deleter_correctly_creates_audit_log() { // Arrange var mockMediator = A.Fake(); diff --git a/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs new file mode 100644 index 0000000000..2592ed4b57 --- /dev/null +++ b/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -0,0 +1,43 @@ +using Backbone.BuildingBlocks.Application.Identities; +using Backbone.Modules.Files.Application.Identities; +using Backbone.Modules.Files.Application.Identities.Commands.DeleteFilesOfIdentity; +using FakeItEasy; +using MediatR; +using Xunit; +using static Backbone.UnitTestTools.Data.TestDataGenerator; + +namespace Backbone.Modules.Files.Application.Tests.Tests.Identities; +public class IdentityDeleterTests +{ + [Fact] + public async Task Deleter_calls_correct_command() + { + // Arrange + var mockMediator = A.Fake(); + var mockIDeletionProcessLogger = A.Fake(); + var identityAddress = CreateRandomIdentityAddress(); + var deleter = new IdentityDeleter(mockMediator); + + // Act + await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + + // Assert + A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); + } + + [Fact] + public async Task Deleter_correctly_creates_audit_log() + { + // Arrange + var mockMediator = A.Fake(); + var mockIDeletionProcessLogger = A.Fake(); + var identityAddress = CreateRandomIdentityAddress(); + var deleter = new IdentityDeleter(mockMediator); + + // Act + await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + + // Assert + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.Files)).MustHaveHappenedOnceExactly(); + } +} diff --git a/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs new file mode 100644 index 0000000000..09410ce2a7 --- /dev/null +++ b/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -0,0 +1,44 @@ +using Backbone.BuildingBlocks.Application.Identities; +using Backbone.Modules.Messages.Application.Identities; +using Backbone.Modules.Messages.Application.Messages.Commands.AnonymizeMessagesOfIdentity; +using Backbone.UnitTestTools.BaseClasses; +using FakeItEasy; +using MediatR; +using Xunit; +using static Backbone.UnitTestTools.Data.TestDataGenerator; + +namespace Backbone.Modules.Messages.Application.Tests.Tests.Identities; +public class IdentityDeleterTests : AbstractTestsBase +{ + [Fact] + public async Task Deleter_calls_correct_command() + { + // Arrange + var mockMediator = A.Fake(); + var mockIDeletionProcessLogger = A.Fake(); + var identityAddress = CreateRandomIdentityAddress(); + var deleter = new IdentityDeleter(mockMediator); + + // Act + await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + + // Assert + A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); + } + + [Fact] + public async Task Deleter_correctly_creates_audit_log() + { + // Arrange + var mockMediator = A.Fake(); + var mockIDeletionProcessLogger = A.Fake(); + var identityAddress = CreateRandomIdentityAddress(); + var deleter = new IdentityDeleter(mockMediator); + + // Act + await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + + // Assert + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.Messages)).MustHaveHappenedOnceExactly(); + } +} diff --git a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs new file mode 100644 index 0000000000..1fb821576b --- /dev/null +++ b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -0,0 +1,43 @@ +using Backbone.BuildingBlocks.Application.Identities; +using Backbone.Modules.Quotas.Application.Identities; +using Backbone.Modules.Quotas.Application.Identities.Commands.DeleteIdentity; +using FakeItEasy; +using MediatR; +using Xunit; +using static Backbone.UnitTestTools.Data.TestDataGenerator; + +namespace Backbone.Modules.Quotas.Application.Tests.Tests.Identities; +public class IdentityDeleterTests +{ + [Fact] + public async Task Deleter_calls_correct_command() + { + // Arrange + var mockMediator = A.Fake(); + var mockIDeletionProcessLogger = A.Fake(); + var identityAddress = CreateRandomIdentityAddress(); + var deleter = new IdentityDeleter(mockMediator); + + // Act + await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + + // Assert + A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); + } + + [Fact] + public async Task Deleter_correctly_creates_audit_log() + { + // Arrange + var mockMediator = A.Fake(); + var mockIDeletionProcessLogger = A.Fake(); + var identityAddress = CreateRandomIdentityAddress(); + var deleter = new IdentityDeleter(mockMediator); + + // Act + await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + + // Assert + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.QuotasIdentity)).MustHaveHappenedOnceExactly(); + } +} diff --git a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 1cf86ee24b..ba76cabe32 100644 --- a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -1,5 +1,7 @@ using Backbone.BuildingBlocks.Application.Identities; using Backbone.Modules.Relationships.Application.Identities; +using Backbone.Modules.Relationships.Application.Relationships.Commands.DeleteRelationshipsOfIdentity; +using Backbone.Modules.Relationships.Application.RelationshipTemplates.Commands.AnonymizeRelationshipTemplateAllocationsAllocatedByIdentity; using Backbone.Modules.Relationships.Application.RelationshipTemplates.Commands.DeleteRelationshipTemplatesOfIdentity; using Backbone.UnitTestTools.BaseClasses; using FakeItEasy; @@ -24,8 +26,33 @@ public async Task Deleter_calls_correct_command() await deleter.Delete(identityAddress, mockIDeletionProcessLogger); // Assert + A.CallTo(() => mockMediator.Send( + A.That.Matches(i => i.IdentityAddress == identityAddress), + A._)).MustHaveHappenedOnceExactly(); A.CallTo(() => mockMediator.Send( A.That.Matches(i => i.IdentityAddress == identityAddress), + A._)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockMediator.Send( + A.That.Matches(i => i.IdentityAddress == identityAddress), A._)).MustHaveHappenedOnceExactly(); } + + + [Fact] + public async Task Deleter_correctly_creates_audit_log() + { + // Arrange + var mockMediator = A.Fake(); + var mockIDeletionProcessLogger = A.Fake(); + var identityAddress = CreateRandomIdentityAddress(); + var deleter = new IdentityDeleter(mockMediator); + + // Act + await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + + // Assert + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.Relationships)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplates)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplateAllocations)).MustHaveHappenedOnceExactly(); + } } diff --git a/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs new file mode 100644 index 0000000000..bf64d84f90 --- /dev/null +++ b/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -0,0 +1,49 @@ +using Backbone.BuildingBlocks.Application.Identities; +using Backbone.Modules.Synchronization.Application.Datawallets.Commands.DeleteDatawalletsOfIdentity; +using Backbone.Modules.Synchronization.Application.Identities; +using Backbone.Modules.Synchronization.Application.SyncRuns.Commands.DeleteExternalEventsOfIdentity; +using Backbone.Modules.Synchronization.Application.SyncRuns.Commands.DeleteSyncRunsOfIdentity; +using FakeItEasy; +using MediatR; +using Xunit; +using static Backbone.UnitTestTools.Data.TestDataGenerator; + +namespace Backbone.Modules.Synchronization.Application.Tests.Tests.Identities; +public class IdentityDeleterTests +{ + [Fact] + public async Task Deleter_calls_correct_command() + { + // Arrange + var mockMediator = A.Fake(); + var mockIDeletionProcessLogger = A.Fake(); + var identityAddress = CreateRandomIdentityAddress(); + var deleter = new IdentityDeleter(mockMediator); + + // Act + await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + + // Assert + A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); + A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); + A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); + } + + [Fact] + public async Task Deleter_correctly_creates_audit_log() + { + // Arrange + var mockMediator = A.Fake(); + var mockIDeletionProcessLogger = A.Fake(); + var identityAddress = CreateRandomIdentityAddress(); + var deleter = new IdentityDeleter(mockMediator); + + // Act + await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + + // Assert + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.ExternalEvents)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.SyncRuns)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.Datawallets)).MustHaveHappenedOnceExactly(); + } +} diff --git a/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs new file mode 100644 index 0000000000..f3389913bc --- /dev/null +++ b/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -0,0 +1,43 @@ +using Backbone.BuildingBlocks.Application.Identities; +using Backbone.Modules.Tokens.Application.Identities; +using Backbone.Modules.Tokens.Application.Tokens.Commands.DeleteTokensOfIdentity; +using FakeItEasy; +using MediatR; +using Xunit; +using static Backbone.UnitTestTools.Data.TestDataGenerator; + +namespace Backbone.Modules.Tokens.Application.Tests.Tests.Identities; +public class IdentityDeleterTests +{ + [Fact] + public async Task Deleter_calls_correct_command() + { + // Arrange + var mockMediator = A.Fake(); + var mockIDeletionProcessLogger = A.Fake(); + var identityAddress = CreateRandomIdentityAddress(); + var deleter = new IdentityDeleter(mockMediator); + + // Act + await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + + // Assert + A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); + } + + [Fact] + public async Task Deleter_correctly_creates_audit_log() + { + // Arrange + var mockMediator = A.Fake(); + var mockIDeletionProcessLogger = A.Fake(); + var identityAddress = CreateRandomIdentityAddress(); + var deleter = new IdentityDeleter(mockMediator); + + // Act + await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + + // Assert + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.Tokens)).MustHaveHappenedOnceExactly(); + } +} From 7816ff61cf501f85462afa53d019b23a7f24378f Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Wed, 12 Jun 2024 16:35:10 +0200 Subject: [PATCH 005/105] fix: add AbstractTestsBase & formatting issues --- .../Tests/Identities/IdentityDeleterTests.cs | 3 ++- .../Tests/Identities/IdentityDeleterTests.cs | 3 ++- .../Tests/Identities/IdentityDeleterTests.cs | 3 ++- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 3 ++- .../Tests/Identities/IdentityDeleterTests.cs | 3 ++- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 2b92df9f45..abc817750a 100644 --- a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -1,13 +1,14 @@ using Backbone.BuildingBlocks.Application.Identities; using Backbone.Modules.Challenges.Application.Challenges.Commands.DeleteChallengesOfIdentity; using Backbone.Modules.Challenges.Application.Identities; +using Backbone.UnitTestTools.BaseClasses; using FakeItEasy; using MediatR; using Xunit; using static Backbone.UnitTestTools.Data.TestDataGenerator; namespace Backbone.Modules.Challenges.Application.Tests.Tests.Identities; -public class IdentityDeleterTests +public class IdentityDeleterTests : AbstractTestsBase { [Fact] public async Task Deleter_calls_correct_command() diff --git a/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 2592ed4b57..13e38e7e24 100644 --- a/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -1,13 +1,14 @@ using Backbone.BuildingBlocks.Application.Identities; using Backbone.Modules.Files.Application.Identities; using Backbone.Modules.Files.Application.Identities.Commands.DeleteFilesOfIdentity; +using Backbone.UnitTestTools.BaseClasses; using FakeItEasy; using MediatR; using Xunit; using static Backbone.UnitTestTools.Data.TestDataGenerator; namespace Backbone.Modules.Files.Application.Tests.Tests.Identities; -public class IdentityDeleterTests +public class IdentityDeleterTests : AbstractTestsBase { [Fact] public async Task Deleter_calls_correct_command() diff --git a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 1fb821576b..c119b0918a 100644 --- a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -1,13 +1,14 @@ using Backbone.BuildingBlocks.Application.Identities; using Backbone.Modules.Quotas.Application.Identities; using Backbone.Modules.Quotas.Application.Identities.Commands.DeleteIdentity; +using Backbone.UnitTestTools.BaseClasses; using FakeItEasy; using MediatR; using Xunit; using static Backbone.UnitTestTools.Data.TestDataGenerator; namespace Backbone.Modules.Quotas.Application.Tests.Tests.Identities; -public class IdentityDeleterTests +public class IdentityDeleterTests : AbstractTestsBase { [Fact] public async Task Deleter_calls_correct_command() diff --git a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index ba76cabe32..6cc518d92d 100644 --- a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -28,10 +28,10 @@ public async Task Deleter_calls_correct_command() // Assert A.CallTo(() => mockMediator.Send( A.That.Matches(i => i.IdentityAddress == identityAddress), - A._)).MustHaveHappenedOnceExactly(); + A._)).MustHaveHappenedOnceExactly(); A.CallTo(() => mockMediator.Send( A.That.Matches(i => i.IdentityAddress == identityAddress), - A._)).MustHaveHappenedOnceExactly(); + A._)).MustHaveHappenedOnceExactly(); A.CallTo(() => mockMediator.Send( A.That.Matches(i => i.IdentityAddress == identityAddress), A._)).MustHaveHappenedOnceExactly(); diff --git a/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index bf64d84f90..dc98fcf89b 100644 --- a/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -3,13 +3,14 @@ using Backbone.Modules.Synchronization.Application.Identities; using Backbone.Modules.Synchronization.Application.SyncRuns.Commands.DeleteExternalEventsOfIdentity; using Backbone.Modules.Synchronization.Application.SyncRuns.Commands.DeleteSyncRunsOfIdentity; +using Backbone.UnitTestTools.BaseClasses; using FakeItEasy; using MediatR; using Xunit; using static Backbone.UnitTestTools.Data.TestDataGenerator; namespace Backbone.Modules.Synchronization.Application.Tests.Tests.Identities; -public class IdentityDeleterTests +public class IdentityDeleterTests : AbstractTestsBase { [Fact] public async Task Deleter_calls_correct_command() diff --git a/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index f3389913bc..a5f625d8d7 100644 --- a/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -1,13 +1,14 @@ using Backbone.BuildingBlocks.Application.Identities; using Backbone.Modules.Tokens.Application.Identities; using Backbone.Modules.Tokens.Application.Tokens.Commands.DeleteTokensOfIdentity; +using Backbone.UnitTestTools.BaseClasses; using FakeItEasy; using MediatR; using Xunit; using static Backbone.UnitTestTools.Data.TestDataGenerator; namespace Backbone.Modules.Tokens.Application.Tests.Tests.Identities; -public class IdentityDeleterTests +public class IdentityDeleterTests : AbstractTestsBase { [Fact] public async Task Deleter_calls_correct_command() From 98750aa0ef6d09229aaed1ff227a36579b3963c4 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Wed, 12 Jun 2024 16:47:43 +0200 Subject: [PATCH 006/105] fix: add AbstractTestsBase to HandlerTests --- .../Commands/DeleteIdentityCommandTests/HandlerTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/Commands/DeleteIdentityCommandTests/HandlerTests.cs b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/Commands/DeleteIdentityCommandTests/HandlerTests.cs index c8456d2fd2..576d6e3e47 100644 --- a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/Commands/DeleteIdentityCommandTests/HandlerTests.cs +++ b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/Commands/DeleteIdentityCommandTests/HandlerTests.cs @@ -2,11 +2,12 @@ using Backbone.Modules.Challenges.Application.Challenges.Commands.DeleteChallengesOfIdentity; using Backbone.Modules.Challenges.Application.Infrastructure.Persistence.Repository; using Backbone.Modules.Challenges.Domain.Entities; +using Backbone.UnitTestTools.BaseClasses; using FakeItEasy; using Xunit; namespace Backbone.Modules.Challenges.Application.Tests.Tests.Identities.Commands.DeleteIdentityCommandTests; -public class HandlerTests +public class HandlerTests : AbstractTestsBase { [Fact] public async Task Handler_calls_deletion_method_on_repository() From d34278ca1e2a97acc14119d8cd9409a17ca8cf5a Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Wed, 12 Jun 2024 17:04:43 +0200 Subject: [PATCH 007/105] fix: remove LogDeletionProcessTests --- .../Identities/LogDeletionProcessTests.cs | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 Modules/Devices/test/Devices.Domain.Tests/Identities/LogDeletionProcessTests.cs diff --git a/Modules/Devices/test/Devices.Domain.Tests/Identities/LogDeletionProcessTests.cs b/Modules/Devices/test/Devices.Domain.Tests/Identities/LogDeletionProcessTests.cs deleted file mode 100644 index f6a1be3c32..0000000000 --- a/Modules/Devices/test/Devices.Domain.Tests/Identities/LogDeletionProcessTests.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Backbone.Modules.Devices.Domain.Tests.Identities; -public class LogDeletionProcessTests -{ -} From f37bd880ce9315ec1492928f5c37a6c0aeaef2ac Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Thu, 13 Jun 2024 08:42:57 +0200 Subject: [PATCH 008/105] chore: rename --- .../Identities/IIdentityDeleter.cs | 4 ++-- .../src/Devices.Application/Identities/IdentityDeleter.cs | 2 +- .../Identities/IdentityDeletionProcessAuditLogEntry.cs | 8 ++++---- .../Messages.Application/Identities/IdentityDeleter.cs | 2 +- .../src/Quotas.Application/Identities/IdentityDeleter.cs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs b/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs index 0099caefb3..55da605618 100644 --- a/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs +++ b/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs @@ -15,10 +15,10 @@ public enum AggregateType { Challenges, PnsRegistrations, - Identity, + Identities, Files, Messages, - QuotasIdentity, + QuotaIdentities, Relationships, RelationshipTemplates, RelationshipTemplateAllocations, diff --git a/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs b/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs index 4e7b644eea..2df200ffa7 100644 --- a/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs +++ b/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs @@ -19,6 +19,6 @@ public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger await _mediator.Send(new DeletePnsRegistrationsOfIdentityCommand(identityAddress)); await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.PnsRegistrations); await _mediator.Send(new DeleteIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Identity); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Identities); } } diff --git a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs index 35ee310675..a3df898217 100644 --- a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs +++ b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs @@ -213,10 +213,10 @@ private static bool TryGetMessageKey(string aggregateType, out MessageKey messag { { "Challenges", MessageKey.Challenges }, { "PnsRegistrations", MessageKey.PnsRegistrations }, - { "Identity", MessageKey.Identity }, + { "Identity", MessageKey.Identities }, { "Files", MessageKey.Files }, { "Messages", MessageKey.Messages }, - { "QuotasIdentity", MessageKey.QuotasIdentity }, + { "QuotaIdentities", MessageKey.QuotaIdentities }, { "Relationships", MessageKey.Relationships }, { "RelationshipTemplates", MessageKey.RelationshipTemplates }, { "RelationshipTemplateAllocations", MessageKey.RelationshipTemplateAllocations }, @@ -247,10 +247,10 @@ public enum MessageKey GracePeriodReminder3Sent = 13, Challenges = 14, PnsRegistrations = 15, - Identity = 16, + Identities = 16, Files = 17, Messages = 18, - QuotasIdentity = 19, + QuotaIdentities = 19, Relationships = 20, RelationshipTemplates = 21, RelationshipTemplateAllocations = 22, diff --git a/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs b/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs index 1475d0ebee..caef566026 100644 --- a/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs +++ b/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs @@ -16,6 +16,6 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new AnonymizeMessagesOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Messages); // TODO: these are not deleted but anonymized, perhaps adapt the names? + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Messages); } } diff --git a/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs b/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs index abf6d436d2..d772d95b58 100644 --- a/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs +++ b/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs @@ -16,6 +16,6 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new DeleteIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.QuotasIdentity); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.QuotaIdentities); } } From 6d9a1f9db446ab04f33a7e9c1a05c8410c810dc6 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Thu, 13 Jun 2024 09:04:06 +0200 Subject: [PATCH 009/105] tests: fix --- .../Tests/Identities/IdentityDeleterTests.cs | 2 +- .../Tests/Identities/IdentityDeleterTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index bc14a4f3fa..474095f101 100644 --- a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -41,7 +41,7 @@ public async Task Deleter_correctly_creates_audit_log() await deleter.Delete(identityAddress, mockIDeletionProcessLogger); // Assert - A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.Identity)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.Identities)).MustHaveHappenedOnceExactly(); A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.PnsRegistrations)).MustHaveHappenedOnceExactly(); } } diff --git a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index c119b0918a..0b228afd03 100644 --- a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -39,6 +39,6 @@ public async Task Deleter_correctly_creates_audit_log() await deleter.Delete(identityAddress, mockIDeletionProcessLogger); // Assert - A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.QuotasIdentity)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.QuotaIdentities)).MustHaveHappenedOnceExactly(); } } From 7e6fac360e1d669edbd317f5b2e7d080e74f38d2 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Tue, 18 Jun 2024 11:38:32 +0200 Subject: [PATCH 010/105] fix: include github actions test logger --- .../Challenges.Application.Tests.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/Challenges/test/Challenges.Application.Tests/Challenges.Application.Tests.csproj b/Modules/Challenges/test/Challenges.Application.Tests/Challenges.Application.Tests.csproj index 045862bff2..f8c106d836 100644 --- a/Modules/Challenges/test/Challenges.Application.Tests/Challenges.Application.Tests.csproj +++ b/Modules/Challenges/test/Challenges.Application.Tests/Challenges.Application.Tests.csproj @@ -8,6 +8,10 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + From aef637943150ed10b1c169893bb9ea06de070586 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Thu, 20 Jun 2024 12:26:41 +0200 Subject: [PATCH 011/105] test: remove unused eventBus --- .../Tests/ActualDeletionWorkerTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs index e98b8616a2..9fe82150ca 100644 --- a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs +++ b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs @@ -109,6 +109,6 @@ private static ActualDeletionWorker CreateWorker(IMediator mediator, pushNotificationSender ??= A.Dummy(); var logger = A.Dummy>(); deletionProcessLogger ??= A.Dummy(); - return new ActualDeletionWorker(hostApplicationLifetime, identityDeleters, mediator, pushNotificationSender, eventBus, logger, deletionProcessLogger); + return new ActualDeletionWorker(hostApplicationLifetime, identityDeleters, mediator, pushNotificationSender, logger, deletionProcessLogger); } } From 5e643cfe69e0e2c122accb02b0ed16e8ad044b3e Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Thu, 20 Jun 2024 12:41:42 +0200 Subject: [PATCH 012/105] fix: typo --- .../Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs index a3df898217..fb374b5cfe 100644 --- a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs +++ b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs @@ -213,7 +213,7 @@ private static bool TryGetMessageKey(string aggregateType, out MessageKey messag { { "Challenges", MessageKey.Challenges }, { "PnsRegistrations", MessageKey.PnsRegistrations }, - { "Identity", MessageKey.Identities }, + { "Identities", MessageKey.Identities }, { "Files", MessageKey.Files }, { "Messages", MessageKey.Messages }, { "QuotaIdentities", MessageKey.QuotaIdentities }, From 17d51d7846db607383dcdcacda8ee62a38dc3fc3 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Thu, 20 Jun 2024 16:21:17 +0200 Subject: [PATCH 013/105] fix: delete identity last --- .../Job.IdentityDeletion/Workers/ActualDeletionWorker.cs | 8 +++++++- .../src/Devices.Application/Identities/IdentityDeleter.cs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs b/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs index 2b1649f103..27ed1a0437 100644 --- a/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs +++ b/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs @@ -77,10 +77,16 @@ private async Task NotifyIdentityAboutStartingDeletion(CancellationToken cancell private async Task Delete(IdentityAddress identityAddress) { - foreach (var identityDeleter in _identityDeleters) + + var identityDeletersWithoutDevices = _identityDeleters.Where(i => i.GetType() != typeof(Backbone.Modules.Devices.Application.Identities.IdentityDeleter)); + var deviceIdentityDeleter = _identityDeleters.FirstOrDefault(i => !identityDeletersWithoutDevices.Contains(i)); + + foreach (var identityDeleter in identityDeletersWithoutDevices) { await identityDeleter.Delete(identityAddress, _deletionProcessLogger); } + + await deviceIdentityDeleter!.Delete(identityAddress, _deletionProcessLogger); } private void LogErroringDeletionTriggers(IEnumerable>> erroringDeletionTriggers) diff --git a/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs b/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs index 2df200ffa7..43f15e9bdb 100644 --- a/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs +++ b/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs @@ -18,7 +18,7 @@ public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger { await _mediator.Send(new DeletePnsRegistrationsOfIdentityCommand(identityAddress)); await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.PnsRegistrations); - await _mediator.Send(new DeleteIdentityCommand(identityAddress)); await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Identities); + await _mediator.Send(new DeleteIdentityCommand(identityAddress)); } } From 6ad12b09726a36fa157970d35b9e17d7a35deb00 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Thu, 20 Jun 2024 16:36:55 +0200 Subject: [PATCH 014/105] test: rename --- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index abc817750a..7cfc1de808 100644 --- a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -15,12 +15,12 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var mockIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Fake(); var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(mockMediator); // Act - await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); // Assert A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); diff --git a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 474095f101..4e5f43636e 100644 --- a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -16,12 +16,12 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var mockIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Fake(); var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(mockMediator); // Act - await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); // Assert A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); diff --git a/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 13e38e7e24..1557857cf9 100644 --- a/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -15,12 +15,12 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var mockIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Fake(); var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(mockMediator); // Act - await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); // Assert A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); diff --git a/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 09410ce2a7..ee27ad4f2d 100644 --- a/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -15,12 +15,12 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var mockIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Fake(); var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(mockMediator); // Act - await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); // Assert A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); diff --git a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 0b228afd03..ca4a7e8604 100644 --- a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -15,12 +15,12 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var mockIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Fake(); var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(mockMediator); // Act - await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); // Assert A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); diff --git a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 6cc518d92d..6aa9032d94 100644 --- a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -17,13 +17,13 @@ public async Task Deleter_calls_correct_command() { // Arrange var identityAddress = CreateRandomIdentityAddress(); - var mockIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Fake(); var mockMediator = A.Fake(); var deleter = new IdentityDeleter(mockMediator); // Act - await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); // Assert A.CallTo(() => mockMediator.Send( diff --git a/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index dc98fcf89b..21219bd453 100644 --- a/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -17,12 +17,12 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var mockIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Fake(); var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(mockMediator); // Act - await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); // Assert A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); diff --git a/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index a5f625d8d7..8f66445b52 100644 --- a/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -15,12 +15,12 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var mockIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Fake(); var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(mockMediator); // Act - await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); // Assert A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); From 25b5a23291ca1052971b8c49d5c37865db19b38e Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 24 Jun 2024 09:18:17 +0200 Subject: [PATCH 015/105] test: improve tests --- .../Workers/ActualDeletionWorker.cs | 19 +++++++------- .../Tests/ActualDeletionWorkerTests.cs | 26 +++++++++++-------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs b/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs index 27ed1a0437..969a8c78c7 100644 --- a/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs +++ b/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs @@ -12,13 +12,15 @@ namespace Backbone.Job.IdentityDeletion.Workers; public class ActualDeletionWorker : IHostedService { private readonly IHostApplicationLifetime _host; - private readonly IEnumerable _identityDeleters; private readonly IMediator _mediator; private readonly IPushNotificationSender _pushNotificationSender; private readonly ILogger _logger; private readonly IDeletionProcessLogger _deletionProcessLogger; + private readonly List _remainingIdentityDeleters; + private readonly IIdentityDeleter? _deviceIdentityDeleter; - public ActualDeletionWorker(IHostApplicationLifetime host, + public ActualDeletionWorker( + IHostApplicationLifetime host, IEnumerable identityDeleters, IMediator mediator, IPushNotificationSender pushNotificationSender, @@ -26,7 +28,9 @@ public ActualDeletionWorker(IHostApplicationLifetime host, IDeletionProcessLogger deletionProcessLogger) { _host = host; - _identityDeleters = identityDeleters; + _remainingIdentityDeleters = identityDeleters.ToList(); + _deviceIdentityDeleter = _remainingIdentityDeleters.First(i => i.GetType() == typeof(Modules.Devices.Application.Identities.IdentityDeleter)); + _remainingIdentityDeleters.Remove(_deviceIdentityDeleter); _mediator = mediator; _pushNotificationSender = pushNotificationSender; _logger = logger; @@ -68,6 +72,7 @@ private async Task ExecuteDeletion(CancellationToken cancellationToken, Identity { await NotifyIdentityAboutStartingDeletion(cancellationToken, identityAddress); await Delete(identityAddress); + await _deviceIdentityDeleter!.Delete(identityAddress, _deletionProcessLogger); } private async Task NotifyIdentityAboutStartingDeletion(CancellationToken cancellationToken, IdentityAddress identityAddress) @@ -77,16 +82,10 @@ private async Task NotifyIdentityAboutStartingDeletion(CancellationToken cancell private async Task Delete(IdentityAddress identityAddress) { - - var identityDeletersWithoutDevices = _identityDeleters.Where(i => i.GetType() != typeof(Backbone.Modules.Devices.Application.Identities.IdentityDeleter)); - var deviceIdentityDeleter = _identityDeleters.FirstOrDefault(i => !identityDeletersWithoutDevices.Contains(i)); - - foreach (var identityDeleter in identityDeletersWithoutDevices) + foreach (var identityDeleter in _remainingIdentityDeleters) { await identityDeleter.Delete(identityAddress, _deletionProcessLogger); } - - await deviceIdentityDeleter!.Delete(identityAddress, _deletionProcessLogger); } private void LogErroringDeletionTriggers(IEnumerable>> erroringDeletionTriggers) diff --git a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs index 9fe82150ca..ee20bb040a 100644 --- a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs +++ b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs @@ -3,6 +3,7 @@ using Backbone.BuildingBlocks.Domain.Errors; using Backbone.DevelopmentKit.Identity.ValueObjects; using Backbone.Job.IdentityDeletion.Workers; +using Backbone.Modules.Devices.Application.Identities; using Backbone.Modules.Devices.Application.Identities.Commands.TriggerRipeDeletionProcesses; using Backbone.Modules.Relationships.Application.Relationships.Commands.FindRelationshipsOfIdentity; using Backbone.Modules.Relationships.Domain.Entities; @@ -23,12 +24,14 @@ public class ActualDeletionWorkerTests : AbstractTestsBase public async Task Proxies_triggering_the_deletion_processes_to_command_handler() { // Arrange - var mockMediator = A.Fake(); - + var mockMediator = A.Fake() SetupRipeDeletionProcessesCommand(mockMediator); - var identityDeleters = new List(); - var worker = CreateWorker(mediator: mockMediator, identityDeleters); + var dummyDevicesIdentityDeleter = new IdentityDeleter(mockMediator); + var mockIDeletionProcessLogger = A.Fake(); + var identityDeleters = new List { dummyDevicesIdentityDeleter }; + + var worker = CreateWorker(mediator: mockMediator, identityDeleters, deletionProcessLogger: mockIDeletionProcessLogger); // Act await worker.StartProcessing(CancellationToken.None); @@ -47,9 +50,10 @@ public async Task Calls_Deleters_For_Each_Identity() SetupRipeDeletionProcessesCommand(mockMediator, identityAddress1, identityAddress2); var mockIdentityDeleter = A.Fake(); + var dummyDevicesIdentityDeleter = new IdentityDeleter(mockMediator); var mockIDeletionProcessLogger = A.Fake(); - var identityDeleters = new List { mockIdentityDeleter }; + var identityDeleters = new List { mockIdentityDeleter, dummyDevicesIdentityDeleter }; var worker = CreateWorker(mediator: mockMediator, identityDeleters, deletionProcessLogger: mockIDeletionProcessLogger); @@ -76,7 +80,12 @@ public async Task Sends_push_notification_for_each_relationship_of_each_identity A.CallTo(() => mockMediator.Send(A._, A._)).Returns(new FindRelationshipsOfIdentityResponse(new List())); var mockPushNotificationSender = A.Dummy(); - var worker = CreateWorker(mediator: mockMediator, pushNotificationSender: mockPushNotificationSender); + var dummyDevicesIdentityDeleter = new IdentityDeleter(mockMediator); + + var identityDeleters = new List { dummyDevicesIdentityDeleter }; + var mockIDeletionProcessLogger = A.Fake(); + + var worker = CreateWorker(mediator: mockMediator, identityDeleters, deletionProcessLogger: mockIDeletionProcessLogger, pushNotificationSender: mockPushNotificationSender); // Act await worker.StartProcessing(CancellationToken.None); @@ -94,11 +103,6 @@ private void SetupRipeDeletionProcessesCommand(IMediator mediator, params Identi A.CallTo(() => mediator.Send(A._, A._)).Returns(commandResponse); } - private static ActualDeletionWorker CreateWorker(IMediator mediator, IPushNotificationSender pushNotificationSender) - { - return CreateWorker(mediator, null, pushNotificationSender); - } - private static ActualDeletionWorker CreateWorker(IMediator mediator, List? identityDeleters = null, IPushNotificationSender? pushNotificationSender = null, From 394094f736919bdaabf34d9ec1112d10f17b619e Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 24 Jun 2024 11:25:12 +0200 Subject: [PATCH 016/105] fix: missing semicolon --- .../Tests/ActualDeletionWorkerTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs index ee20bb040a..6e832a7603 100644 --- a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs +++ b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs @@ -24,7 +24,7 @@ public class ActualDeletionWorkerTests : AbstractTestsBase public async Task Proxies_triggering_the_deletion_processes_to_command_handler() { // Arrange - var mockMediator = A.Fake() + var mockMediator = A.Fake(); SetupRipeDeletionProcessesCommand(mockMediator); var dummyDevicesIdentityDeleter = new IdentityDeleter(mockMediator); From 1a6612c95c8af72c7c62cf7416d0705c55c176d7 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 24 Jun 2024 11:35:05 +0200 Subject: [PATCH 017/105] chore: rename --- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 7cfc1de808..d9b6287e16 100644 --- a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -30,10 +30,10 @@ public async Task Deleter_calls_correct_command() public async Task Deleter_correctly_creates_audit_log() { // Arrange - var mockMediator = A.Fake(); + var dummyMediator = A.Fake(); var mockIDeletionProcessLogger = A.Fake(); var identityAddress = CreateRandomIdentityAddress(); - var deleter = new IdentityDeleter(mockMediator); + var deleter = new IdentityDeleter(dummyMediator); // Act await deleter.Delete(identityAddress, mockIDeletionProcessLogger); diff --git a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 4e5f43636e..e7c97d5d2e 100644 --- a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -32,10 +32,10 @@ public async Task Deleter_calls_correct_command() public async Task Deleter_correctly_creates_audit_log() { // Arrange - var mockMediator = A.Fake(); + var dummyMediator = A.Fake(); var mockIDeletionProcessLogger = A.Fake(); var identityAddress = CreateRandomIdentityAddress(); - var deleter = new IdentityDeleter(mockMediator); + var deleter = new IdentityDeleter(dummyMediator); // Act await deleter.Delete(identityAddress, mockIDeletionProcessLogger); diff --git a/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 1557857cf9..4322b4e6e7 100644 --- a/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -30,10 +30,10 @@ public async Task Deleter_calls_correct_command() public async Task Deleter_correctly_creates_audit_log() { // Arrange - var mockMediator = A.Fake(); + var dummyMediator = A.Fake(); var mockIDeletionProcessLogger = A.Fake(); var identityAddress = CreateRandomIdentityAddress(); - var deleter = new IdentityDeleter(mockMediator); + var deleter = new IdentityDeleter(dummyMediator); // Act await deleter.Delete(identityAddress, mockIDeletionProcessLogger); diff --git a/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index ee27ad4f2d..7b5280e22f 100644 --- a/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -30,10 +30,10 @@ public async Task Deleter_calls_correct_command() public async Task Deleter_correctly_creates_audit_log() { // Arrange - var mockMediator = A.Fake(); + var dummyMediator = A.Fake(); var mockIDeletionProcessLogger = A.Fake(); var identityAddress = CreateRandomIdentityAddress(); - var deleter = new IdentityDeleter(mockMediator); + var deleter = new IdentityDeleter(dummyMediator); // Act await deleter.Delete(identityAddress, mockIDeletionProcessLogger); diff --git a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index ca4a7e8604..f86e24befc 100644 --- a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -30,10 +30,10 @@ public async Task Deleter_calls_correct_command() public async Task Deleter_correctly_creates_audit_log() { // Arrange - var mockMediator = A.Fake(); + var dummyMediator = A.Fake(); var mockIDeletionProcessLogger = A.Fake(); var identityAddress = CreateRandomIdentityAddress(); - var deleter = new IdentityDeleter(mockMediator); + var deleter = new IdentityDeleter(dummyMediator); // Act await deleter.Delete(identityAddress, mockIDeletionProcessLogger); diff --git a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 6aa9032d94..42937722b8 100644 --- a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -42,10 +42,10 @@ public async Task Deleter_calls_correct_command() public async Task Deleter_correctly_creates_audit_log() { // Arrange - var mockMediator = A.Fake(); + var dummyMediator = A.Fake(); var mockIDeletionProcessLogger = A.Fake(); var identityAddress = CreateRandomIdentityAddress(); - var deleter = new IdentityDeleter(mockMediator); + var deleter = new IdentityDeleter(dummyMediator); // Act await deleter.Delete(identityAddress, mockIDeletionProcessLogger); diff --git a/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 21219bd453..59740fc9d0 100644 --- a/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -34,10 +34,10 @@ public async Task Deleter_calls_correct_command() public async Task Deleter_correctly_creates_audit_log() { // Arrange - var mockMediator = A.Fake(); + var dummyMediator = A.Fake(); var mockIDeletionProcessLogger = A.Fake(); var identityAddress = CreateRandomIdentityAddress(); - var deleter = new IdentityDeleter(mockMediator); + var deleter = new IdentityDeleter(dummyMediator); // Act await deleter.Delete(identityAddress, mockIDeletionProcessLogger); diff --git a/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 8f66445b52..899c4e987f 100644 --- a/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -30,10 +30,10 @@ public async Task Deleter_calls_correct_command() public async Task Deleter_correctly_creates_audit_log() { // Arrange - var mockMediator = A.Fake(); + var dummyMediator = A.Fake(); var mockIDeletionProcessLogger = A.Fake(); var identityAddress = CreateRandomIdentityAddress(); - var deleter = new IdentityDeleter(mockMediator); + var deleter = new IdentityDeleter(dummyMediator); // Act await deleter.Delete(identityAddress, mockIDeletionProcessLogger); From cc149800a7591513fab908cb1add888a89fd6646 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 24 Jun 2024 11:57:56 +0200 Subject: [PATCH 018/105] fix: update FakeItEasy to 8.3.0 in Challenges module fix: formatting --- .../Challenges.Application.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Challenges/test/Challenges.Application.Tests/Challenges.Application.Tests.csproj b/Modules/Challenges/test/Challenges.Application.Tests/Challenges.Application.Tests.csproj index f8c106d836..274488c39b 100644 --- a/Modules/Challenges/test/Challenges.Application.Tests/Challenges.Application.Tests.csproj +++ b/Modules/Challenges/test/Challenges.Application.Tests/Challenges.Application.Tests.csproj @@ -7,7 +7,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all From e3124caac21d75598871cbc9df58c40b3ac63a51 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 1 Jul 2024 12:09:13 +0200 Subject: [PATCH 019/105] chore: log before command --- .../Challenges.Application/Identities/IdentityDeleter.cs | 2 +- .../src/Devices.Application/Identities/IdentityDeleter.cs | 2 +- .../src/Files.Application/Identities/IdentityDeleter.cs | 2 +- .../src/Messages.Application/Identities/IdentityDeleter.cs | 2 +- .../src/Quotas.Application/Identities/IdentityDeleter.cs | 2 +- .../Relationships.Application/Identities/IdentityDeleter.cs | 6 +++--- .../Identities/IdentityDeleter.cs | 6 +++--- .../src/Tokens.Application/Identities/IdentityDeleter.cs | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs b/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs index 0e4945c780..d6be165792 100644 --- a/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs +++ b/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs @@ -15,7 +15,7 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { - await _mediator.Send(new DeleteChallengesOfIdentityCommand(identityAddress)); await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Challenges); + await _mediator.Send(new DeleteChallengesOfIdentityCommand(identityAddress)); } } diff --git a/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs b/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs index 43f15e9bdb..f9d2d0a985 100644 --- a/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs +++ b/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs @@ -16,8 +16,8 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { - await _mediator.Send(new DeletePnsRegistrationsOfIdentityCommand(identityAddress)); await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.PnsRegistrations); + await _mediator.Send(new DeletePnsRegistrationsOfIdentityCommand(identityAddress)); await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Identities); await _mediator.Send(new DeleteIdentityCommand(identityAddress)); } diff --git a/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs b/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs index 9c408857aa..ef3378dedb 100644 --- a/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs +++ b/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs @@ -15,7 +15,7 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { - await _mediator.Send(new DeleteFilesOfIdentityCommand(identityAddress)); await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Files); + await _mediator.Send(new DeleteFilesOfIdentityCommand(identityAddress)); } } diff --git a/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs b/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs index caef566026..7da93bdad4 100644 --- a/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs +++ b/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs @@ -15,7 +15,7 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { - await _mediator.Send(new AnonymizeMessagesOfIdentityCommand(identityAddress)); await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Messages); + await _mediator.Send(new AnonymizeMessagesOfIdentityCommand(identityAddress)); } } diff --git a/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs b/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs index d772d95b58..b724cfb4d3 100644 --- a/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs +++ b/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs @@ -15,7 +15,7 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { - await _mediator.Send(new DeleteIdentityCommand(identityAddress)); await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.QuotaIdentities); + await _mediator.Send(new DeleteIdentityCommand(identityAddress)); } } diff --git a/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs b/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs index 79f4a35ceb..2179e375a9 100644 --- a/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs +++ b/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs @@ -18,11 +18,11 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { - await _mediator.Send(new DeleteRelationshipsOfIdentityCommand(identityAddress)); await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Relationships); - await _mediator.Send(new DeleteRelationshipTemplatesOfIdentityCommand(identityAddress)); + await _mediator.Send(new DeleteRelationshipsOfIdentityCommand(identityAddress)); await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplates); - await _mediator.Send(new AnonymizeRelationshipTemplateAllocationsAllocatedByIdentityCommand(identityAddress)); + await _mediator.Send(new DeleteRelationshipTemplatesOfIdentityCommand(identityAddress)); await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplateAllocations); + await _mediator.Send(new AnonymizeRelationshipTemplateAllocationsAllocatedByIdentityCommand(identityAddress)); } } diff --git a/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs b/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs index 5d0b4252c7..03d530026a 100644 --- a/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs +++ b/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs @@ -17,11 +17,11 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { - await _mediator.Send(new DeleteExternalEventsOfIdentityCommand(identityAddress)); await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.ExternalEvents); - await _mediator.Send(new DeleteSyncRunsOfIdentityCommand(identityAddress)); + await _mediator.Send(new DeleteExternalEventsOfIdentityCommand(identityAddress)); await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.SyncRuns); - await _mediator.Send(new DeleteDatawalletsOfIdentityCommand(identityAddress)); + await _mediator.Send(new DeleteSyncRunsOfIdentityCommand(identityAddress)); await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Datawallets); + await _mediator.Send(new DeleteDatawalletsOfIdentityCommand(identityAddress)); } } diff --git a/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs b/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs index ddfef2dfb8..03311b10c9 100644 --- a/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs +++ b/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs @@ -15,7 +15,7 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { - await _mediator.Send(new DeleteTokensOfIdentityCommand(identityAddress)); await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Tokens); + await _mediator.Send(new DeleteTokensOfIdentityCommand(identityAddress)); } } From 5f0bb2f50a992e4c4e05ca3db5b44bcf1388679c Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 1 Jul 2024 12:30:56 +0200 Subject: [PATCH 020/105] chore: rearrange variables for better readability --- .../Tests/Identities/IdentityDeleterTests.cs | 8 ++++---- .../Tests/Identities/IdentityDeleterTests.cs | 8 ++++---- .../Tests/Identities/IdentityDeleterTests.cs | 8 ++++---- .../Tests/Identities/IdentityDeleterTests.cs | 8 ++++---- .../Tests/Identities/IdentityDeleterTests.cs | 8 ++++---- .../Tests/Identities/IdentityDeleterTests.cs | 9 ++++----- .../Tests/Identities/IdentityDeleterTests.cs | 8 ++++---- .../Tests/Identities/IdentityDeleterTests.cs | 8 ++++---- 8 files changed, 32 insertions(+), 33 deletions(-) diff --git a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index d9b6287e16..0d37b1d489 100644 --- a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -15,9 +15,9 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var dummyIDeletionProcessLogger = A.Fake(); - var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(mockMediator); + var identityAddress = CreateRandomIdentityAddress(); + var dummyIDeletionProcessLogger = A.Fake(); // Act await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); @@ -31,9 +31,9 @@ public async Task Deleter_correctly_creates_audit_log() { // Arrange var dummyMediator = A.Fake(); - var mockIDeletionProcessLogger = A.Fake(); - var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(dummyMediator); + var identityAddress = CreateRandomIdentityAddress(); + var mockIDeletionProcessLogger = A.Fake(); // Act await deleter.Delete(identityAddress, mockIDeletionProcessLogger); diff --git a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index e7c97d5d2e..bd172b3610 100644 --- a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -16,9 +16,9 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var dummyIDeletionProcessLogger = A.Fake(); - var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(mockMediator); + var identityAddress = CreateRandomIdentityAddress(); + var dummyIDeletionProcessLogger = A.Fake(); // Act await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); @@ -33,9 +33,9 @@ public async Task Deleter_correctly_creates_audit_log() { // Arrange var dummyMediator = A.Fake(); - var mockIDeletionProcessLogger = A.Fake(); - var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(dummyMediator); + var identityAddress = CreateRandomIdentityAddress(); + var mockIDeletionProcessLogger = A.Fake(); // Act await deleter.Delete(identityAddress, mockIDeletionProcessLogger); diff --git a/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 4322b4e6e7..8000ac1d32 100644 --- a/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -15,9 +15,9 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var dummyIDeletionProcessLogger = A.Fake(); - var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(mockMediator); + var identityAddress = CreateRandomIdentityAddress(); + var dummyIDeletionProcessLogger = A.Fake(); // Act await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); @@ -31,9 +31,9 @@ public async Task Deleter_correctly_creates_audit_log() { // Arrange var dummyMediator = A.Fake(); - var mockIDeletionProcessLogger = A.Fake(); - var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(dummyMediator); + var identityAddress = CreateRandomIdentityAddress(); + var mockIDeletionProcessLogger = A.Fake(); // Act await deleter.Delete(identityAddress, mockIDeletionProcessLogger); diff --git a/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 7b5280e22f..579e7f4629 100644 --- a/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -15,9 +15,9 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var dummyIDeletionProcessLogger = A.Fake(); - var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(mockMediator); + var identityAddress = CreateRandomIdentityAddress(); + var dummyIDeletionProcessLogger = A.Fake(); // Act await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); @@ -31,9 +31,9 @@ public async Task Deleter_correctly_creates_audit_log() { // Arrange var dummyMediator = A.Fake(); - var mockIDeletionProcessLogger = A.Fake(); - var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(dummyMediator); + var identityAddress = CreateRandomIdentityAddress(); + var mockIDeletionProcessLogger = A.Fake(); // Act await deleter.Delete(identityAddress, mockIDeletionProcessLogger); diff --git a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index f86e24befc..5e17e919dc 100644 --- a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -15,9 +15,9 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var dummyIDeletionProcessLogger = A.Fake(); - var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(mockMediator); + var identityAddress = CreateRandomIdentityAddress(); + var dummyIDeletionProcessLogger = A.Fake(); // Act await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); @@ -31,9 +31,9 @@ public async Task Deleter_correctly_creates_audit_log() { // Arrange var dummyMediator = A.Fake(); - var mockIDeletionProcessLogger = A.Fake(); - var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(dummyMediator); + var identityAddress = CreateRandomIdentityAddress(); + var mockIDeletionProcessLogger = A.Fake(); // Act await deleter.Delete(identityAddress, mockIDeletionProcessLogger); diff --git a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 42937722b8..6a6cefea24 100644 --- a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -16,11 +16,10 @@ public class IdentityDeleterTests : AbstractTestsBase public async Task Deleter_calls_correct_command() { // Arrange - var identityAddress = CreateRandomIdentityAddress(); - var dummyIDeletionProcessLogger = A.Fake(); var mockMediator = A.Fake(); - var deleter = new IdentityDeleter(mockMediator); + var identityAddress = CreateRandomIdentityAddress(); + var dummyIDeletionProcessLogger = A.Fake(); // Act await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); @@ -43,9 +42,9 @@ public async Task Deleter_correctly_creates_audit_log() { // Arrange var dummyMediator = A.Fake(); - var mockIDeletionProcessLogger = A.Fake(); - var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(dummyMediator); + var identityAddress = CreateRandomIdentityAddress(); + var mockIDeletionProcessLogger = A.Fake(); // Act await deleter.Delete(identityAddress, mockIDeletionProcessLogger); diff --git a/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 59740fc9d0..1c44499f49 100644 --- a/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -17,9 +17,9 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var dummyIDeletionProcessLogger = A.Fake(); - var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(mockMediator); + var identityAddress = CreateRandomIdentityAddress(); + var dummyIDeletionProcessLogger = A.Fake(); // Act await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); @@ -35,9 +35,9 @@ public async Task Deleter_correctly_creates_audit_log() { // Arrange var dummyMediator = A.Fake(); - var mockIDeletionProcessLogger = A.Fake(); - var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(dummyMediator); + var identityAddress = CreateRandomIdentityAddress(); + var mockIDeletionProcessLogger = A.Fake(); // Act await deleter.Delete(identityAddress, mockIDeletionProcessLogger); diff --git a/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 899c4e987f..40983793ab 100644 --- a/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -15,9 +15,9 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var dummyIDeletionProcessLogger = A.Fake(); - var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(mockMediator); + var identityAddress = CreateRandomIdentityAddress(); + var dummyIDeletionProcessLogger = A.Fake(); // Act await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); @@ -31,9 +31,9 @@ public async Task Deleter_correctly_creates_audit_log() { // Arrange var dummyMediator = A.Fake(); - var mockIDeletionProcessLogger = A.Fake(); - var identityAddress = CreateRandomIdentityAddress(); var deleter = new IdentityDeleter(dummyMediator); + var identityAddress = CreateRandomIdentityAddress(); + var mockIDeletionProcessLogger = A.Fake(); // Act await deleter.Delete(identityAddress, mockIDeletionProcessLogger); From 83b02ad9bbd6a7170a3e5c0eed1e856d30c2ff1f Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 1 Jul 2024 14:10:52 +0200 Subject: [PATCH 021/105] refactor: extract method --- .../Job.IdentityDeletion/Workers/ActualDeletionWorker.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs b/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs index 969a8c78c7..5e471b76e0 100644 --- a/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs +++ b/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs @@ -72,7 +72,7 @@ private async Task ExecuteDeletion(CancellationToken cancellationToken, Identity { await NotifyIdentityAboutStartingDeletion(cancellationToken, identityAddress); await Delete(identityAddress); - await _deviceIdentityDeleter!.Delete(identityAddress, _deletionProcessLogger); + await DeleteDeviceIdentity(identityAddress); } private async Task NotifyIdentityAboutStartingDeletion(CancellationToken cancellationToken, IdentityAddress identityAddress) @@ -88,6 +88,11 @@ private async Task Delete(IdentityAddress identityAddress) } } + private async Task DeleteDeviceIdentity(IdentityAddress identityAddress) + { + await _deviceIdentityDeleter!.Delete(identityAddress, _deletionProcessLogger); + } + private void LogErroringDeletionTriggers(IEnumerable>> erroringDeletionTriggers) { foreach (var erroringDeletion in erroringDeletionTriggers) From d89aee90460825a789ca86e0fe79d0b2e76e2ef7 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 1 Jul 2024 14:20:22 +0200 Subject: [PATCH 022/105] chore: rename test variables --- .../Tests/ActualDeletionWorkerTests.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs index 6e832a7603..f1a7f5ba2c 100644 --- a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs +++ b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs @@ -28,10 +28,10 @@ public async Task Proxies_triggering_the_deletion_processes_to_command_handler() SetupRipeDeletionProcessesCommand(mockMediator); var dummyDevicesIdentityDeleter = new IdentityDeleter(mockMediator); - var mockIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Fake(); var identityDeleters = new List { dummyDevicesIdentityDeleter }; - var worker = CreateWorker(mediator: mockMediator, identityDeleters, deletionProcessLogger: mockIDeletionProcessLogger); + var worker = CreateWorker(mediator: mockMediator, identityDeleters, deletionProcessLogger: dummyIDeletionProcessLogger); // Act await worker.StartProcessing(CancellationToken.None); @@ -51,11 +51,11 @@ public async Task Calls_Deleters_For_Each_Identity() var mockIdentityDeleter = A.Fake(); var dummyDevicesIdentityDeleter = new IdentityDeleter(mockMediator); - var mockIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Fake(); var identityDeleters = new List { mockIdentityDeleter, dummyDevicesIdentityDeleter }; - var worker = CreateWorker(mediator: mockMediator, identityDeleters, deletionProcessLogger: mockIDeletionProcessLogger); + var worker = CreateWorker(mediator: mockMediator, identityDeleters, deletionProcessLogger: dummyIDeletionProcessLogger); A.CallTo(() => mockMediator.Send(A._, A._)) .Returns(new FindRelationshipsOfIdentityResponse(new List())); @@ -64,8 +64,8 @@ public async Task Calls_Deleters_For_Each_Identity() await worker.StartProcessing(CancellationToken.None); // Assert - A.CallTo(() => mockIdentityDeleter.Delete(identityAddress1, mockIDeletionProcessLogger)).MustHaveHappenedOnceExactly(); - A.CallTo(() => mockIdentityDeleter.Delete(identityAddress2, mockIDeletionProcessLogger)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIdentityDeleter.Delete(identityAddress1, dummyIDeletionProcessLogger)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIdentityDeleter.Delete(identityAddress2, dummyIDeletionProcessLogger)).MustHaveHappenedOnceExactly(); } [Fact] @@ -83,9 +83,9 @@ public async Task Sends_push_notification_for_each_relationship_of_each_identity var dummyDevicesIdentityDeleter = new IdentityDeleter(mockMediator); var identityDeleters = new List { dummyDevicesIdentityDeleter }; - var mockIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Fake(); - var worker = CreateWorker(mediator: mockMediator, identityDeleters, deletionProcessLogger: mockIDeletionProcessLogger, pushNotificationSender: mockPushNotificationSender); + var worker = CreateWorker(mediator: mockMediator, identityDeleters, deletionProcessLogger: dummyIDeletionProcessLogger, pushNotificationSender: mockPushNotificationSender); // Act await worker.StartProcessing(CancellationToken.None); From 4b7000e93f08b9a76bff445c24634f54eb67e782 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 1 Jul 2024 15:30:15 +0200 Subject: [PATCH 023/105] core: remove unnecessary deletion process logger --- .../Tests/ActualDeletionWorkerTests.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs index f1a7f5ba2c..c7e22d3b2a 100644 --- a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs +++ b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs @@ -28,10 +28,9 @@ public async Task Proxies_triggering_the_deletion_processes_to_command_handler() SetupRipeDeletionProcessesCommand(mockMediator); var dummyDevicesIdentityDeleter = new IdentityDeleter(mockMediator); - var dummyIDeletionProcessLogger = A.Fake(); var identityDeleters = new List { dummyDevicesIdentityDeleter }; - var worker = CreateWorker(mediator: mockMediator, identityDeleters, deletionProcessLogger: dummyIDeletionProcessLogger); + var worker = CreateWorker(mediator: mockMediator, identityDeleters); // Act await worker.StartProcessing(CancellationToken.None); @@ -81,11 +80,9 @@ public async Task Sends_push_notification_for_each_relationship_of_each_identity var mockPushNotificationSender = A.Dummy(); var dummyDevicesIdentityDeleter = new IdentityDeleter(mockMediator); - var identityDeleters = new List { dummyDevicesIdentityDeleter }; - var dummyIDeletionProcessLogger = A.Fake(); - var worker = CreateWorker(mediator: mockMediator, identityDeleters, deletionProcessLogger: dummyIDeletionProcessLogger, pushNotificationSender: mockPushNotificationSender); + var worker = CreateWorker(mediator: mockMediator, identityDeleters, pushNotificationSender: mockPushNotificationSender); // Act await worker.StartProcessing(CancellationToken.None); From 11ee72170dd02eff217780ba98147e6e70fe996c Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Tue, 2 Jul 2024 11:10:17 +0200 Subject: [PATCH 024/105] chore: rename --- .../Workers/ActualDeletionWorker.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs b/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs index 5e471b76e0..b8b22b2c55 100644 --- a/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs +++ b/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs @@ -16,7 +16,7 @@ public class ActualDeletionWorker : IHostedService private readonly IPushNotificationSender _pushNotificationSender; private readonly ILogger _logger; private readonly IDeletionProcessLogger _deletionProcessLogger; - private readonly List _remainingIdentityDeleters; + private readonly List _nonDeviceIdentityDeleters; private readonly IIdentityDeleter? _deviceIdentityDeleter; public ActualDeletionWorker( @@ -28,9 +28,9 @@ public ActualDeletionWorker( IDeletionProcessLogger deletionProcessLogger) { _host = host; - _remainingIdentityDeleters = identityDeleters.ToList(); - _deviceIdentityDeleter = _remainingIdentityDeleters.First(i => i.GetType() == typeof(Modules.Devices.Application.Identities.IdentityDeleter)); - _remainingIdentityDeleters.Remove(_deviceIdentityDeleter); + _nonDeviceIdentityDeleters = identityDeleters.ToList(); + _deviceIdentityDeleter = _nonDeviceIdentityDeleters.First(i => i.GetType() == typeof(Modules.Devices.Application.Identities.IdentityDeleter)); + _nonDeviceIdentityDeleters.Remove(_deviceIdentityDeleter); _mediator = mediator; _pushNotificationSender = pushNotificationSender; _logger = logger; @@ -82,7 +82,7 @@ private async Task NotifyIdentityAboutStartingDeletion(CancellationToken cancell private async Task Delete(IdentityAddress identityAddress) { - foreach (var identityDeleter in _remainingIdentityDeleters) + foreach (var identityDeleter in _nonDeviceIdentityDeleters) { await identityDeleter.Delete(identityAddress, _deletionProcessLogger); } From ecb75016f406f07884ea79ab87ac004d8e4d3910 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Tue, 2 Jul 2024 11:34:50 +0200 Subject: [PATCH 025/105] chore: rename message keys for deletion purposes --- .../IdentityDeletionProcessAuditLogEntry.cs | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs index fb374b5cfe..f45bc96f83 100644 --- a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs +++ b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs @@ -211,19 +211,19 @@ private static bool TryGetMessageKey(string aggregateType, out MessageKey messag { var messageKeyMappings = new Dictionary { - { "Challenges", MessageKey.Challenges }, - { "PnsRegistrations", MessageKey.PnsRegistrations }, - { "Identities", MessageKey.Identities }, - { "Files", MessageKey.Files }, - { "Messages", MessageKey.Messages }, - { "QuotaIdentities", MessageKey.QuotaIdentities }, - { "Relationships", MessageKey.Relationships }, - { "RelationshipTemplates", MessageKey.RelationshipTemplates }, - { "RelationshipTemplateAllocations", MessageKey.RelationshipTemplateAllocations }, - { "ExternalEvents", MessageKey.ExternalEvents }, - { "SyncRuns", MessageKey.SyncRuns }, - { "Datawallets", MessageKey.Datawallets }, - { "Tokens", MessageKey.Tokens } + { "Challenges", MessageKey.ChallengesDeleted }, + { "PnsRegistrations", MessageKey.PnsRegistrationsDeleted }, + { "Identities", MessageKey.IdentitiesDeleted }, + { "Files", MessageKey.FilesDeleted }, + { "Messages", MessageKey.MessagesDeleted }, + { "QuotaIdentities", MessageKey.QuotaIdentitiesDeleted }, + { "Relationships", MessageKey.RelationshipsDeleted }, + { "RelationshipTemplates", MessageKey.RelationshipTemplatesDeleted }, + { "RelationshipTemplateAllocations", MessageKey.RelationshipTemplateAllocationsDeleted }, + { "ExternalEvents", MessageKey.ExternalEventsDeleted }, + { "SyncRuns", MessageKey.SyncRunsDeleted }, + { "Datawallets", MessageKey.DatawalletsDeleted }, + { "Tokens", MessageKey.TokensDeleted } }; return messageKeyMappings.TryGetValue(aggregateType, out messageKey); @@ -245,17 +245,17 @@ public enum MessageKey GracePeriodReminder1Sent = 11, GracePeriodReminder2Sent = 12, GracePeriodReminder3Sent = 13, - Challenges = 14, - PnsRegistrations = 15, - Identities = 16, - Files = 17, - Messages = 18, - QuotaIdentities = 19, - Relationships = 20, - RelationshipTemplates = 21, - RelationshipTemplateAllocations = 22, - ExternalEvents = 23, - SyncRuns = 24, - Datawallets = 25, - Tokens = 26 + ChallengesDeleted = 14, + PnsRegistrationsDeleted = 15, + IdentitiesDeleted = 16, + FilesDeleted = 17, + MessagesDeleted = 18, + QuotaIdentitiesDeleted = 19, + RelationshipsDeleted = 20, + RelationshipTemplatesDeleted = 21, + RelationshipTemplateAllocationsDeleted = 22, + ExternalEventsDeleted = 23, + SyncRunsDeleted = 24, + DatawalletsDeleted = 25, + TokensDeleted = 26 } From d54f188e14531b858403b2a271336ee1b3221ade Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Wed, 3 Jul 2024 15:37:14 +0200 Subject: [PATCH 026/105] fix: configure RelationshipAuditLog to cascade delete on relationship deletion --- ...tionshipAuditLogDeleteBehavior.Designer.cs | 257 ++++++++++++++++++ ...igureRelationshipAuditLogDeleteBehavior.cs | 47 ++++ .../RelationshipsDbContextModelSnapshot.cs | 3 +- ...tionshipAuditLogDeleteBehavior.Designer.cs | 257 ++++++++++++++++++ ...igureRelationshipAuditLogDeleteBehavior.cs | 47 ++++ .../RelationshipsDbContextModelSnapshot.cs | 3 +- .../RelationshipEntityTypeConfiguration.cs | 3 + 7 files changed, 615 insertions(+), 2 deletions(-) create mode 100644 Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/20240703100000_ConfigureRelationshipAuditLogDeleteBehavior.Designer.cs create mode 100644 Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/20240703100000_ConfigureRelationshipAuditLogDeleteBehavior.cs create mode 100644 Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/20240703095959_ConfigureRelationshipAuditLogDeleteBehavior.Designer.cs create mode 100644 Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/20240703095959_ConfigureRelationshipAuditLogDeleteBehavior.cs diff --git a/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/20240703100000_ConfigureRelationshipAuditLogDeleteBehavior.Designer.cs b/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/20240703100000_ConfigureRelationshipAuditLogDeleteBehavior.Designer.cs new file mode 100644 index 0000000000..2423c87518 --- /dev/null +++ b/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/20240703100000_ConfigureRelationshipAuditLogDeleteBehavior.Designer.cs @@ -0,0 +1,257 @@ +// +using System; +using Backbone.Modules.Relationships.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Backbone.Modules.Relationships.Infrastructure.Database.Postgres.Migrations +{ + [DbContext(typeof(RelationshipsDbContext))] + [Migration("20240703100000_ConfigureRelationshipAuditLogDeleteBehavior")] + partial class ConfigureRelationshipAuditLogDeleteBehavior + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Relationships") + .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("Content") + .HasColumnType("bytea"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character varying(80)") + .IsFixedLength(false); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.Property("MaxNumberOfAllocations") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("RelationshipTemplates", "Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplateAllocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("AllocatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character varying(80)") + .IsFixedLength(false); + + b.Property("AllocatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("RelationshipTemplateId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("RelationshipTemplateId", "AllocatedBy"); + + b.ToTable("RelationshipTemplateAllocations", "Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreationContent") + .HasColumnType("bytea"); + + b.Property("CreationResponseContent") + .HasColumnType("bytea"); + + b.Property("From") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character varying(80)") + .IsFixedLength(false); + + b.Property("FromHasDecomposed") + .HasColumnType("boolean"); + + b.Property("RelationshipTemplateId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("To") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character varying(80)") + .IsFixedLength(false); + + b.Property("ToHasDecomposed") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("From"); + + b.HasIndex("RelationshipTemplateId"); + + b.HasIndex("To"); + + b.ToTable("Relationships", "Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.RelationshipAuditLogEntry", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character varying(80)") + .IsFixedLength(false); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("NewStatus") + .HasColumnType("integer"); + + b.Property("OldStatus") + .HasColumnType("integer"); + + b.Property("Reason") + .HasColumnType("integer"); + + b.Property("RelationshipId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("RelationshipId"); + + b.ToTable("RelationshipAuditLog", "Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplateAllocation", b => + { + b.HasOne("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", null) + .WithMany("Allocations") + .HasForeignKey("RelationshipTemplateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", b => + { + b.HasOne("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", "RelationshipTemplate") + .WithMany("Relationships") + .HasForeignKey("RelationshipTemplateId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("RelationshipTemplate"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.RelationshipAuditLogEntry", b => + { + b.HasOne("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", null) + .WithMany("AuditLog") + .HasForeignKey("RelationshipId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", b => + { + b.Navigation("Allocations"); + + b.Navigation("Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", b => + { + b.Navigation("AuditLog"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/20240703100000_ConfigureRelationshipAuditLogDeleteBehavior.cs b/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/20240703100000_ConfigureRelationshipAuditLogDeleteBehavior.cs new file mode 100644 index 0000000000..08294f924a --- /dev/null +++ b/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/20240703100000_ConfigureRelationshipAuditLogDeleteBehavior.cs @@ -0,0 +1,47 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Relationships.Infrastructure.Database.Postgres.Migrations +{ + /// + public partial class ConfigureRelationshipAuditLogDeleteBehavior : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_RelationshipAuditLog_Relationships_RelationshipId", + schema: "Relationships", + table: "RelationshipAuditLog"); + + migrationBuilder.AddForeignKey( + name: "FK_RelationshipAuditLog_Relationships_RelationshipId", + schema: "Relationships", + table: "RelationshipAuditLog", + column: "RelationshipId", + principalSchema: "Relationships", + principalTable: "Relationships", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_RelationshipAuditLog_Relationships_RelationshipId", + schema: "Relationships", + table: "RelationshipAuditLog"); + + migrationBuilder.AddForeignKey( + name: "FK_RelationshipAuditLog_Relationships_RelationshipId", + schema: "Relationships", + table: "RelationshipAuditLog", + column: "RelationshipId", + principalSchema: "Relationships", + principalTable: "Relationships", + principalColumn: "Id"); + } + } +} diff --git a/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/RelationshipsDbContextModelSnapshot.cs b/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/RelationshipsDbContextModelSnapshot.cs index 08ee62b13e..741a9e8695 100644 --- a/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/RelationshipsDbContextModelSnapshot.cs +++ b/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/RelationshipsDbContextModelSnapshot.cs @@ -233,7 +233,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.HasOne("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", null) .WithMany("AuditLog") - .HasForeignKey("RelationshipId"); + .HasForeignKey("RelationshipId") + .OnDelete(DeleteBehavior.Cascade); }); modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", b => diff --git a/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/20240703095959_ConfigureRelationshipAuditLogDeleteBehavior.Designer.cs b/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/20240703095959_ConfigureRelationshipAuditLogDeleteBehavior.Designer.cs new file mode 100644 index 0000000000..056f0fe387 --- /dev/null +++ b/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/20240703095959_ConfigureRelationshipAuditLogDeleteBehavior.Designer.cs @@ -0,0 +1,257 @@ +// +using System; +using Backbone.Modules.Relationships.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Backbone.Modules.Relationships.Infrastructure.Database.SqlServer.Migrations +{ + [DbContext(typeof(RelationshipsDbContext))] + [Migration("20240703095959_ConfigureRelationshipAuditLogDeleteBehavior")] + partial class ConfigureRelationshipAuditLogDeleteBehavior + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Relationships") + .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("Content") + .HasColumnType("varbinary(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("varchar(80)") + .IsFixedLength(false); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("DeletedAt") + .HasColumnType("datetime2"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("MaxNumberOfAllocations") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("RelationshipTemplates", "Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplateAllocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AllocatedAt") + .HasColumnType("datetime2"); + + b.Property("AllocatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("varchar(80)") + .IsFixedLength(false); + + b.Property("AllocatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("RelationshipTemplateId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("RelationshipTemplateId", "AllocatedBy"); + + b.ToTable("RelationshipTemplateAllocations", "Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreationContent") + .HasColumnType("varbinary(max)"); + + b.Property("CreationResponseContent") + .HasColumnType("varbinary(max)"); + + b.Property("From") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("varchar(80)") + .IsFixedLength(false); + + b.Property("FromHasDecomposed") + .HasColumnType("bit"); + + b.Property("RelationshipTemplateId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("To") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("varchar(80)") + .IsFixedLength(false); + + b.Property("ToHasDecomposed") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("From"); + + b.HasIndex("RelationshipTemplateId"); + + b.HasIndex("To"); + + b.ToTable("Relationships", "Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.RelationshipAuditLogEntry", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("varchar(80)") + .IsFixedLength(false); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("NewStatus") + .HasColumnType("int"); + + b.Property("OldStatus") + .HasColumnType("int"); + + b.Property("Reason") + .HasColumnType("int"); + + b.Property("RelationshipId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("RelationshipId"); + + b.ToTable("RelationshipAuditLog", "Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplateAllocation", b => + { + b.HasOne("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", null) + .WithMany("Allocations") + .HasForeignKey("RelationshipTemplateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", b => + { + b.HasOne("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", "RelationshipTemplate") + .WithMany("Relationships") + .HasForeignKey("RelationshipTemplateId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("RelationshipTemplate"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.RelationshipAuditLogEntry", b => + { + b.HasOne("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", null) + .WithMany("AuditLog") + .HasForeignKey("RelationshipId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", b => + { + b.Navigation("Allocations"); + + b.Navigation("Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", b => + { + b.Navigation("AuditLog"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/20240703095959_ConfigureRelationshipAuditLogDeleteBehavior.cs b/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/20240703095959_ConfigureRelationshipAuditLogDeleteBehavior.cs new file mode 100644 index 0000000000..4a264237be --- /dev/null +++ b/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/20240703095959_ConfigureRelationshipAuditLogDeleteBehavior.cs @@ -0,0 +1,47 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Relationships.Infrastructure.Database.SqlServer.Migrations +{ + /// + public partial class ConfigureRelationshipAuditLogDeleteBehavior : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_RelationshipAuditLog_Relationships_RelationshipId", + schema: "Relationships", + table: "RelationshipAuditLog"); + + migrationBuilder.AddForeignKey( + name: "FK_RelationshipAuditLog_Relationships_RelationshipId", + schema: "Relationships", + table: "RelationshipAuditLog", + column: "RelationshipId", + principalSchema: "Relationships", + principalTable: "Relationships", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_RelationshipAuditLog_Relationships_RelationshipId", + schema: "Relationships", + table: "RelationshipAuditLog"); + + migrationBuilder.AddForeignKey( + name: "FK_RelationshipAuditLog_Relationships_RelationshipId", + schema: "Relationships", + table: "RelationshipAuditLog", + column: "RelationshipId", + principalSchema: "Relationships", + principalTable: "Relationships", + principalColumn: "Id"); + } + } +} diff --git a/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/RelationshipsDbContextModelSnapshot.cs b/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/RelationshipsDbContextModelSnapshot.cs index 31397a7551..e4961b6148 100644 --- a/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/RelationshipsDbContextModelSnapshot.cs +++ b/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/RelationshipsDbContextModelSnapshot.cs @@ -233,7 +233,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.HasOne("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", null) .WithMany("AuditLog") - .HasForeignKey("RelationshipId"); + .HasForeignKey("RelationshipId") + .OnDelete(DeleteBehavior.Cascade); }); modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", b => diff --git a/Modules/Relationships/src/Relationships.Infrastructure/Persistence/Database/EntityTypeConfigurations/RelationshipEntityTypeConfiguration.cs b/Modules/Relationships/src/Relationships.Infrastructure/Persistence/Database/EntityTypeConfigurations/RelationshipEntityTypeConfiguration.cs index a4ed3d3a9f..af8a5d773d 100644 --- a/Modules/Relationships/src/Relationships.Infrastructure/Persistence/Database/EntityTypeConfigurations/RelationshipEntityTypeConfiguration.cs +++ b/Modules/Relationships/src/Relationships.Infrastructure/Persistence/Database/EntityTypeConfigurations/RelationshipEntityTypeConfiguration.cs @@ -1,5 +1,6 @@ using Backbone.BuildingBlocks.Infrastructure.Persistence.Database.EntityTypeConfigurations; using Backbone.Modules.Relationships.Domain.Aggregates.Relationships; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Backbone.Modules.Relationships.Infrastructure.Persistence.Database.EntityTypeConfigurations; @@ -22,5 +23,7 @@ public override void Configure(EntityTypeBuilder builder) builder.Property(x => x.CreationContent); builder.Property(x => x.CreationResponseContent); + + builder.HasMany(r => r.AuditLog).WithOne().OnDelete(DeleteBehavior.Cascade); } } From 197de16df89314478e50b550064a081488f47594 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Wed, 3 Jul 2024 15:55:59 +0200 Subject: [PATCH 027/105] test: move SaveEntity extensions to UnitTestTools and make them async --- .../ApplicationDbContextExtensions.cs | 26 +++++++++++++++++++ .../ApplicationDbContextExtensions.cs | 26 ------------------- .../HandlerTests.cs | 19 +++++++------- .../Identities/IdentityDeleter.cs | 1 + 4 files changed, 37 insertions(+), 35 deletions(-) create mode 100644 BuildingBlocks/src/UnitTestTools/Extensions/ApplicationDbContextExtensions.cs delete mode 100644 Modules/Devices/test/Devices.Application.Tests/ApplicationDbContextExtensions.cs diff --git a/BuildingBlocks/src/UnitTestTools/Extensions/ApplicationDbContextExtensions.cs b/BuildingBlocks/src/UnitTestTools/Extensions/ApplicationDbContextExtensions.cs new file mode 100644 index 0000000000..3543ab5e36 --- /dev/null +++ b/BuildingBlocks/src/UnitTestTools/Extensions/ApplicationDbContextExtensions.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore; + +namespace Backbone.UnitTestTools.Extensions; + +public static class ApplicationDbContextExtensions +{ + public static async Task SaveEntities(this DbContext dbContext, params TEntity[] entities) where TEntity : class + { + dbContext.Set().AddRange(entities); + await dbContext.SaveChangesAsync(); + return entities; + } + + public static async Task SaveEntity(this DbContext dbContext, TEntity entity) where TEntity : class + { + dbContext.Set().Add(entity); + await dbContext.SaveChangesAsync(); + return entity; + } + + public static async Task RemoveEntity(this DbContext dbContext, TEntity entity) where TEntity : class + { + dbContext.Set().Remove(entity); + await dbContext.SaveChangesAsync(); + } +} diff --git a/Modules/Devices/test/Devices.Application.Tests/ApplicationDbContextExtensions.cs b/Modules/Devices/test/Devices.Application.Tests/ApplicationDbContextExtensions.cs deleted file mode 100644 index abfbd2049e..0000000000 --- a/Modules/Devices/test/Devices.Application.Tests/ApplicationDbContextExtensions.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Backbone.Modules.Devices.Infrastructure.Persistence.Database; - -namespace Backbone.Modules.Devices.Application.Tests; - -public static class ApplicationDbContextExtensions -{ - public static TEntity[] SaveEntities(this DevicesDbContext dbContext, params TEntity[] entities) where TEntity : class - { - dbContext.Set().AddRange(entities); - dbContext.SaveChanges(); - return entities; - } - - public static TEntity SaveEntity(this DevicesDbContext dbContext, TEntity entity) where TEntity : class - { - dbContext.Set().Add(entity); - dbContext.SaveChanges(); - return entity; - } - - public static void RemoveEntity(this DevicesDbContext dbContext, TEntity entity) where TEntity : class - { - dbContext.Set().Remove(entity); - dbContext.SaveChanges(); - } -} diff --git a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/Queries/GetDeletionProcessesAuditLogs/HandlerTests.cs b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/Queries/GetDeletionProcessesAuditLogs/HandlerTests.cs index a602cc589e..80f4129817 100644 --- a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/Queries/GetDeletionProcessesAuditLogs/HandlerTests.cs +++ b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/Queries/GetDeletionProcessesAuditLogs/HandlerTests.cs @@ -3,6 +3,7 @@ using Backbone.Modules.Devices.Infrastructure.Persistence.Database; using Backbone.Modules.Devices.Infrastructure.Persistence.Repository; using Backbone.UnitTestTools.BaseClasses; +using Backbone.UnitTestTools.Extensions; using Backbone.UnitTestTools.TestDoubles.Fakes; using FakeItEasy; using FluentAssertions; @@ -31,8 +32,8 @@ public async Task Gets_successfully() var identity = TestDataGenerator.CreateIdentityWithOneDevice(); TestDataGenerator.CreateCancelledDeletionProcessFor(identity); - _arrangeDbContext.SaveEntity(identity); - _arrangeDbContext.RemoveEntity(identity); + await _arrangeDbContext.SaveEntity(identity); + await _arrangeDbContext.RemoveEntity(identity); var handler = CreateHandler(_actDbContext); @@ -50,7 +51,7 @@ public async Task Returns_empty_list_for_non_existent_address() var identity = TestDataGenerator.CreateIdentityWithOneDevice(); TestDataGenerator.CreateCancelledDeletionProcessFor(identity); - _arrangeDbContext.SaveEntity(identity); + await _arrangeDbContext.SaveEntity(identity); var handler = CreateHandler(_actDbContext); @@ -70,8 +71,8 @@ public async Task Gets_for_multiple_deletion_processes() TestDataGenerator.CreateRejectedDeletionProcessFor(identity, identity.Devices.First().Id); TestDataGenerator.CreateApprovedDeletionProcessFor(identity, identity.Devices.First().Id); - _arrangeDbContext.SaveEntity(identity); - _arrangeDbContext.RemoveEntity(identity); + await _arrangeDbContext.SaveEntity(identity); + await _arrangeDbContext.RemoveEntity(identity); var handler = CreateHandler(_actDbContext); @@ -89,8 +90,8 @@ public async Task Gets_for_deletion_process_in_status_deleting() var identity = TestDataGenerator.CreateIdentityWithOneDevice(); TestDataGenerator.CreateDeletingDeletionProcessFor(identity, identity.Devices.First().Id); - _arrangeDbContext.SaveEntity(identity); - _arrangeDbContext.RemoveEntity(identity); + await _arrangeDbContext.SaveEntity(identity); + await _arrangeDbContext.RemoveEntity(identity); var handler = CreateHandler(_actDbContext); @@ -108,8 +109,8 @@ public async Task Gets_for_deleted_identity() var identity = TestDataGenerator.CreateIdentityWithOneDevice(); TestDataGenerator.CreateDeletingDeletionProcessFor(identity, identity.Devices.First().Id); - _arrangeDbContext.SaveEntity(identity); - _arrangeDbContext.RemoveEntity(identity); + await _arrangeDbContext.SaveEntity(identity); + await _arrangeDbContext.RemoveEntity(identity); var handler = CreateHandler(_actDbContext); diff --git a/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs b/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs index 7da93bdad4..7ed1a78a83 100644 --- a/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs +++ b/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs @@ -4,6 +4,7 @@ using MediatR; namespace Backbone.Modules.Messages.Application.Identities; + public class IdentityDeleter : IIdentityDeleter { private readonly IMediator _mediator; From 137ada775ddbc1b36708584b61740eef76d8cee8 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Wed, 3 Jul 2024 15:59:32 +0200 Subject: [PATCH 028/105] refactor: log AuditLogEntries during identity deletion via repository instead of via identity --- .../Identities/Commands/LogDeletionProcess/Handler.cs | 9 +++------ .../Persistence/Repository/IIdentitiesRepository.cs | 9 +++++++++ .../Commands/DeletePnsRegistrationsOfIdentity/Handler.cs | 1 + .../src/Devices.Domain/Entities/Identities/Identity.cs | 8 -------- .../Entities/Identities/IdentityDeletionProcess.cs | 5 ----- .../Identities/IdentityDeletionProcessAuditLogEntry.cs | 8 ++++---- .../Persistence/Repository/IdentitiesRepository.cs | 8 ++++++++ 7 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Modules/Devices/src/Devices.Application/Identities/Commands/LogDeletionProcess/Handler.cs b/Modules/Devices/src/Devices.Application/Identities/Commands/LogDeletionProcess/Handler.cs index b51de7c5d8..28732d1e7e 100644 --- a/Modules/Devices/src/Devices.Application/Identities/Commands/LogDeletionProcess/Handler.cs +++ b/Modules/Devices/src/Devices.Application/Identities/Commands/LogDeletionProcess/Handler.cs @@ -1,9 +1,9 @@ -using Backbone.BuildingBlocks.Application.Abstractions.Exceptions; -using Backbone.Modules.Devices.Application.Infrastructure.Persistence.Repository; +using Backbone.Modules.Devices.Application.Infrastructure.Persistence.Repository; using Backbone.Modules.Devices.Domain.Entities.Identities; using MediatR; namespace Backbone.Modules.Devices.Application.Identities.Commands.LogDeletionProcess; + public class Handler : IRequestHandler { private readonly IIdentitiesRepository _identitiesRepository; @@ -15,9 +15,6 @@ public Handler(IIdentitiesRepository identitiesRepository) public async Task Handle(LogDeletionProcessCommand request, CancellationToken cancellationToken) { - var identity = await _identitiesRepository.FindByAddress(request.IdentityAddress, cancellationToken, track: true) ?? throw new NotFoundException(nameof(Identity)); - identity.LogDeletedData(request.AggregateType.ToString()); - - await _identitiesRepository.Update(identity, cancellationToken); + await _identitiesRepository.AddDeletionProcessAuditLogEntry(IdentityDeletionProcessAuditLogEntry.DataDeleted(request.IdentityAddress, request.AggregateType.ToString())); } } diff --git a/Modules/Devices/src/Devices.Application/Infrastructure/Persistence/Repository/IIdentitiesRepository.cs b/Modules/Devices/src/Devices.Application/Infrastructure/Persistence/Repository/IIdentitiesRepository.cs index 922a03c60c..ad72c45047 100644 --- a/Modules/Devices/src/Devices.Application/Infrastructure/Persistence/Repository/IIdentitiesRepository.cs +++ b/Modules/Devices/src/Devices.Application/Infrastructure/Persistence/Repository/IIdentitiesRepository.cs @@ -9,6 +9,7 @@ namespace Backbone.Modules.Devices.Application.Infrastructure.Persistence.Reposi public interface IIdentitiesRepository { #region Identities + Task Update(Identity identity, CancellationToken cancellationToken); Task FindByAddress(IdentityAddress address, CancellationToken cancellationToken, bool track = false); Task Exists(IdentityAddress address, CancellationToken cancellationToken); @@ -16,19 +17,27 @@ public interface IIdentitiesRepository Task CountByClientId(string clientId, CancellationToken cancellationToken); Task> Find(Expression> filter, CancellationToken cancellationToken, bool track = false); Task Delete(Expression> filter, CancellationToken cancellationToken); + #endregion #region Users + Task AddUser(ApplicationUser user, string password); + #endregion #region Devices + Task> FindAllDevicesOfIdentity(IdentityAddress identity, IEnumerable ids, PaginationFilter paginationFilter, CancellationToken cancellationToken); Task GetDeviceById(DeviceId deviceId, CancellationToken cancellationToken, bool track = false); Task Update(Device device, CancellationToken cancellationToken); + #endregion #region Deletion Process Audit Logs + Task> GetIdentityDeletionProcessAuditLogsByAddress(byte[] identityAddressHash, CancellationToken cancellationToken); + Task AddDeletionProcessAuditLogEntry(IdentityDeletionProcessAuditLogEntry auditLogEntry); + #endregion } diff --git a/Modules/Devices/src/Devices.Application/PushNotifications/Commands/DeletePnsRegistrationsOfIdentity/Handler.cs b/Modules/Devices/src/Devices.Application/PushNotifications/Commands/DeletePnsRegistrationsOfIdentity/Handler.cs index cbef231839..3f0e65a115 100644 --- a/Modules/Devices/src/Devices.Application/PushNotifications/Commands/DeletePnsRegistrationsOfIdentity/Handler.cs +++ b/Modules/Devices/src/Devices.Application/PushNotifications/Commands/DeletePnsRegistrationsOfIdentity/Handler.cs @@ -3,6 +3,7 @@ using MediatR; namespace Backbone.Modules.Devices.Application.PushNotifications.Commands.DeletePnsRegistrationsOfIdentity; + public class Handler : IRequestHandler { private readonly IPnsRegistrationsRepository _pnsRegistrationRepository; diff --git a/Modules/Devices/src/Devices.Domain/Entities/Identities/Identity.cs b/Modules/Devices/src/Devices.Domain/Entities/Identities/Identity.cs index ea2729c2d4..393cc5a9b5 100644 --- a/Modules/Devices/src/Devices.Domain/Entities/Identities/Identity.cs +++ b/Modules/Devices/src/Devices.Domain/Entities/Identities/Identity.cs @@ -298,14 +298,6 @@ private IdentityDeletionProcess GetDeletionProcessWithId(IdentityDeletionProcess { return DeletionProcesses.FirstOrDefault(x => x.Id == deletionProcessId) ?? throw new DomainException(GenericDomainErrors.NotFound(nameof(IdentityDeletionProcess))); } - - public void LogDeletedData(string aggregateType) - { - EnsureDeletionProcessInStatusExists(DeletionProcessStatus.Deleting); - - var activeDeletionProcess = DeletionProcesses.First(d => d.Status == DeletionProcessStatus.Deleting); - activeDeletionProcess.LogDeletedData(Address, aggregateType); - } } public enum DeletionProcessStatus diff --git a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcess.cs b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcess.cs index 8d28499f6d..48f8ccfa37 100644 --- a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcess.cs +++ b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcess.cs @@ -205,9 +205,4 @@ private void ChangeStatus(DeletionProcessStatus newStatus, IdentityAddress addre Status = newStatus; RaiseDomainEvent(new IdentityDeletionProcessStatusChangedDomainEvent(address, Id, initiator)); } - - public void LogDeletedData(IdentityAddress address, string aggregateType) - { - _auditLog.Add(IdentityDeletionProcessAuditLogEntry.DataDeleted(Id, address, aggregateType)); - } } diff --git a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs index f45bc96f83..e60d39c266 100644 --- a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs +++ b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs @@ -15,7 +15,7 @@ private IdentityDeletionProcessAuditLogEntry() IdentityAddressHash = null!; } - private IdentityDeletionProcessAuditLogEntry(IdentityDeletionProcessId processId, MessageKey messageKey, byte[] identityAddressHash, byte[]? deviceIdHash, DeletionProcessStatus? oldStatus, + private IdentityDeletionProcessAuditLogEntry(IdentityDeletionProcessId? processId, MessageKey messageKey, byte[] identityAddressHash, byte[]? deviceIdHash, DeletionProcessStatus? oldStatus, DeletionProcessStatus newStatus) { Id = IdentityDeletionProcessAuditLogEntryId.Generate(); @@ -29,7 +29,7 @@ private IdentityDeletionProcessAuditLogEntry(IdentityDeletionProcessId processId } public IdentityDeletionProcessAuditLogEntryId Id { get; } - public IdentityDeletionProcessId ProcessId { get; } + public IdentityDeletionProcessId? ProcessId { get; } public DateTime CreatedAt { get; } public MessageKey MessageKey { get; } public byte[] IdentityAddressHash { get; } @@ -192,13 +192,13 @@ public static IdentityDeletionProcessAuditLogEntry GracePeriodReminder3Sent(Iden ); } - public static IdentityDeletionProcessAuditLogEntry DataDeleted(IdentityDeletionProcessId processId, IdentityAddress identityAddress, string aggregateType) + public static IdentityDeletionProcessAuditLogEntry DataDeleted(IdentityAddress identityAddress, string aggregateType) { if (!TryGetMessageKey(aggregateType, out var messageKey)) throw new ArgumentException("Invalid aggregateType", nameof(aggregateType)); return new IdentityDeletionProcessAuditLogEntry( - processId, + null, messageKey, Hasher.HashUtf8(identityAddress.Value), null, diff --git a/Modules/Devices/src/Devices.Infrastructure/Persistence/Repository/IdentitiesRepository.cs b/Modules/Devices/src/Devices.Infrastructure/Persistence/Repository/IdentitiesRepository.cs index 334ca0d7a3..fbef1f4e03 100644 --- a/Modules/Devices/src/Devices.Infrastructure/Persistence/Repository/IdentitiesRepository.cs +++ b/Modules/Devices/src/Devices.Infrastructure/Persistence/Repository/IdentitiesRepository.cs @@ -22,6 +22,7 @@ public class IdentitiesRepository : IIdentitiesRepository private readonly DbSet _devices; private readonly IQueryable _readonlyDevices; private readonly UserManager _userManager; + private readonly DbSet _identityDeletionProcessAuditLogs; private readonly IQueryable _readonlyIdentityDeletionProcessAuditLogs; public IdentitiesRepository(DevicesDbContext dbContext, UserManager userManager) @@ -31,6 +32,7 @@ public IdentitiesRepository(DevicesDbContext dbContext, UserManager> filter, CancellationTo { await _identities.Where(filter).ExecuteDeleteAsync(cancellationToken); } + + public async Task AddDeletionProcessAuditLogEntry(IdentityDeletionProcessAuditLogEntry auditLogEntry) + { + _identityDeletionProcessAuditLogs.Add(auditLogEntry); + await _dbContext.SaveChangesAsync(); + } } From 3da7170305a5d5f38b86c9e42d8b0b6552d75033 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Wed, 3 Jul 2024 16:00:24 +0200 Subject: [PATCH 029/105] fix: anonymize recipients of messages as well --- .../Messages/Commands/AnonymizeMessagesOfIdentity/Handler.cs | 2 +- Modules/Messages/src/Messages.Domain/Entities/Message.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Messages/src/Messages.Application/Messages/Commands/AnonymizeMessagesOfIdentity/Handler.cs b/Modules/Messages/src/Messages.Application/Messages/Commands/AnonymizeMessagesOfIdentity/Handler.cs index 85c3c45cc2..1bcf6ecde9 100644 --- a/Modules/Messages/src/Messages.Application/Messages/Commands/AnonymizeMessagesOfIdentity/Handler.cs +++ b/Modules/Messages/src/Messages.Application/Messages/Commands/AnonymizeMessagesOfIdentity/Handler.cs @@ -21,7 +21,7 @@ public Handler(IMessagesRepository messagesRepository, IOptions> WasCreatedBy(IdentityAddress identityAddress) + public static Expression> HasParticipant(IdentityAddress identityAddress) { - return i => i.CreatedBy == identityAddress.ToString(); + return i => i.CreatedBy == identityAddress || i.Recipients.Any(r => r.Address == identityAddress); } } From 8aaec84d69a629d400313a4702a5e92641b8e307 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Wed, 3 Jul 2024 16:02:44 +0200 Subject: [PATCH 030/105] fix: log after deletion --- .../Challenges.Application/Identities/IdentityDeleter.cs | 3 ++- .../src/Devices.Application/Identities/IdentityDeleter.cs | 5 +++-- .../src/Files.Application/Identities/IdentityDeleter.cs | 3 ++- .../src/Messages.Application/Identities/IdentityDeleter.cs | 2 +- .../src/Quotas.Application/Identities/IdentityDeleter.cs | 3 ++- .../Identities/IdentityDeleter.cs | 6 +++--- .../Identities/IdentityDeleter.cs | 7 ++++--- .../src/Tokens.Application/Identities/IdentityDeleter.cs | 3 ++- 8 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs b/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs index d6be165792..3c741d5044 100644 --- a/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs +++ b/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs @@ -4,6 +4,7 @@ using MediatR; namespace Backbone.Modules.Challenges.Application.Identities; + public class IdentityDeleter : IIdentityDeleter { private readonly IMediator _mediator; @@ -15,7 +16,7 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Challenges); await _mediator.Send(new DeleteChallengesOfIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Challenges); } } diff --git a/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs b/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs index f9d2d0a985..4e56833629 100644 --- a/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs +++ b/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs @@ -5,6 +5,7 @@ using MediatR; namespace Backbone.Modules.Devices.Application.Identities; + public class IdentityDeleter : IIdentityDeleter { private readonly IMediator _mediator; @@ -16,9 +17,9 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.PnsRegistrations); await _mediator.Send(new DeletePnsRegistrationsOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Identities); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.PnsRegistrations); await _mediator.Send(new DeleteIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Identities); } } diff --git a/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs b/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs index ef3378dedb..2d30500bb2 100644 --- a/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs +++ b/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs @@ -4,6 +4,7 @@ using MediatR; namespace Backbone.Modules.Files.Application.Identities; + public class IdentityDeleter : IIdentityDeleter { private readonly IMediator _mediator; @@ -15,7 +16,7 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Files); await _mediator.Send(new DeleteFilesOfIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Files); } } diff --git a/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs b/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs index 7ed1a78a83..8a36d34643 100644 --- a/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs +++ b/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs @@ -16,7 +16,7 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Messages); await _mediator.Send(new AnonymizeMessagesOfIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Messages); } } diff --git a/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs b/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs index b724cfb4d3..9892063e53 100644 --- a/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs +++ b/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs @@ -4,6 +4,7 @@ using MediatR; namespace Backbone.Modules.Quotas.Application.Identities; + public class IdentityDeleter : IIdentityDeleter { private readonly IMediator _mediator; @@ -15,7 +16,7 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.QuotaIdentities); await _mediator.Send(new DeleteIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.QuotaIdentities); } } diff --git a/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs b/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs index 2179e375a9..79f4a35ceb 100644 --- a/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs +++ b/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs @@ -18,11 +18,11 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Relationships); await _mediator.Send(new DeleteRelationshipsOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplates); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Relationships); await _mediator.Send(new DeleteRelationshipTemplatesOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplateAllocations); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplates); await _mediator.Send(new AnonymizeRelationshipTemplateAllocationsAllocatedByIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplateAllocations); } } diff --git a/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs b/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs index 03d530026a..411245c9c8 100644 --- a/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs +++ b/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs @@ -6,6 +6,7 @@ using MediatR; namespace Backbone.Modules.Synchronization.Application.Identities; + public class IdentityDeleter : IIdentityDeleter { private readonly IMediator _mediator; @@ -17,11 +18,11 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.ExternalEvents); await _mediator.Send(new DeleteExternalEventsOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.SyncRuns); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.ExternalEvents); await _mediator.Send(new DeleteSyncRunsOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Datawallets); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.SyncRuns); await _mediator.Send(new DeleteDatawalletsOfIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Datawallets); } } diff --git a/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs b/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs index 03311b10c9..3c1b237ded 100644 --- a/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs +++ b/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs @@ -4,6 +4,7 @@ using MediatR; namespace Backbone.Modules.Tokens.Application.Identities; + public class IdentityDeleter : IIdentityDeleter { private readonly IMediator _mediator; @@ -15,7 +16,7 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Tokens); await _mediator.Send(new DeleteTokensOfIdentityCommand(identityAddress)); + await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Tokens); } } From 73855c9b69593ead76eceec9660fac552908dc13 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Wed, 3 Jul 2024 16:12:45 +0200 Subject: [PATCH 031/105] test: add integration tests Job.IdentityDeletion --- Backbone.sln | 7 + Jobs/src/Job.IdentityDeletion/Program.cs | 184 ++++++++-------- .../ActualDeletionWorkerTests.cs | 200 ++++++++++++++++++ ....IdentityDeletion.Tests.Integration.csproj | 50 +++++ .../appsettings.override.json | 107 ++++++++++ .../HandlerTests.cs | 3 +- ...ProcessAuditLogsByAddressStubRepository.cs | 5 + .../FindByAddressStubRepository.cs | 5 + .../ListIdentities/FindAllStubRepository.cs | 5 + 9 files changed, 475 insertions(+), 91 deletions(-) create mode 100644 Jobs/test/Job.IdentityDeletion.Tests.Integration/ActualDeletionWorkerTests.cs create mode 100644 Jobs/test/Job.IdentityDeletion.Tests.Integration/Job.IdentityDeletion.Tests.Integration.csproj create mode 100644 Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json diff --git a/Backbone.sln b/Backbone.sln index fb640aba01..b9d0bc4f66 100644 --- a/Backbone.sln +++ b/Backbone.sln @@ -311,6 +311,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SseServerTests", "SseServer EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Challenges.Application.Tests", "Modules\Challenges\test\Challenges.Application.Tests\Challenges.Application.Tests.csproj", "{EAA10D43-BD28-40D8-BE07-B8F6DE47C156}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Job.IdentityDeletion.Tests.Integration", "Jobs\test\Job.IdentityDeletion.Tests.Integration\Job.IdentityDeletion.Tests.Integration.csproj", "{63BC08F3-5DA8-4AC5-877A-89B6ABA05F44}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -745,6 +747,10 @@ Global {EAA10D43-BD28-40D8-BE07-B8F6DE47C156}.Debug|Any CPU.Build.0 = Debug|Any CPU {EAA10D43-BD28-40D8-BE07-B8F6DE47C156}.Release|Any CPU.ActiveCfg = Release|Any CPU {EAA10D43-BD28-40D8-BE07-B8F6DE47C156}.Release|Any CPU.Build.0 = Release|Any CPU + {63BC08F3-5DA8-4AC5-877A-89B6ABA05F44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {63BC08F3-5DA8-4AC5-877A-89B6ABA05F44}.Debug|Any CPU.Build.0 = Debug|Any CPU + {63BC08F3-5DA8-4AC5-877A-89B6ABA05F44}.Release|Any CPU.ActiveCfg = Release|Any CPU + {63BC08F3-5DA8-4AC5-877A-89B6ABA05F44}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -885,6 +891,7 @@ Global {824495A9-A255-487D-AF26-6F6CA92BC715} = {4C2E211B-37C8-4449-9595-7D019AC92AC3} {94A32246-991D-483D-8241-E1E4DD6DE145} = {824495A9-A255-487D-AF26-6F6CA92BC715} {EAA10D43-BD28-40D8-BE07-B8F6DE47C156} = {EFC1F89E-1C44-4385-A0F6-1F2124260561} + {63BC08F3-5DA8-4AC5-877A-89B6ABA05F44} = {4F812E23-62EB-4B79-8ECA-5CA72CF5D3BC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1F3BD2C6-7CB3-450F-A21A-23EA520D5B7A} diff --git a/Jobs/src/Job.IdentityDeletion/Program.cs b/Jobs/src/Job.IdentityDeletion/Program.cs index 3660095c60..89274ecf14 100644 --- a/Jobs/src/Job.IdentityDeletion/Program.cs +++ b/Jobs/src/Job.IdentityDeletion/Program.cs @@ -5,9 +5,7 @@ using Backbone.BuildingBlocks.Application.QuotaCheck; using Backbone.DevelopmentKit.Identity.ValueObjects; using Backbone.Infrastructure.EventBus; -using Backbone.Job.IdentityDeletion; using Backbone.Modules.Challenges.ConsumerApi; -using Backbone.Modules.Devices.Application.Identities.Commands.CancelStaleIdentityDeletionProcesses; using Backbone.Modules.Devices.Application.Identities.Commands.LogDeletionProcess; using Backbone.Modules.Devices.ConsumerApi; using Backbone.Modules.Devices.Infrastructure.PushNotifications; @@ -25,109 +23,115 @@ using Serilog.Exceptions.Core; using Serilog.Exceptions.EntityFrameworkCore.Destructurers; using Serilog.Settings.Configuration; -using DevicesConfiguration = Backbone.Modules.Devices.ConsumerApi.Configuration; +using Configuration = Backbone.Modules.Devices.ConsumerApi.Configuration; +namespace Backbone.Job.IdentityDeletion; -Log.Logger = new LoggerConfiguration() - .WriteTo.Console() - .CreateBootstrapLogger(); - -try +public class Program { - Log.Information("Creating app..."); - - var app = CreateHostBuilder(args); + public static async Task Main(params string[] args) + { + Log.Logger = new LoggerConfiguration() + .WriteTo.Console() + .CreateBootstrapLogger(); - Log.Information("App created."); - Log.Information("Starting app..."); + try + { + Log.Information("Creating app..."); - await app.Build().RunAsync(); + var app = CreateHostBuilder(args); - return 0; -} -catch (Exception ex) -{ - Log.Fatal(ex, "Host terminated unexpectedly"); - return 1; -} -finally -{ - await Log.CloseAndFlushAsync(); -} + Log.Information("App created."); + Log.Information("Starting app..."); + await app.Build().RunAsync(); -static IHostBuilder CreateHostBuilder(string[] args) -{ - return Host.CreateDefaultBuilder(args) - .ConfigureAppConfiguration((hostContext, configuration) => + return 0; + } + catch (Exception ex) { - configuration.Sources.Clear(); - var env = hostContext.HostingEnvironment; - - configuration - .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) - .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true) - .AddJsonFile("appsettings.override.json", optional: true, reloadOnChange: true); + Log.Fatal(ex, "Host terminated unexpectedly"); + return 1; + } + finally + { + await Log.CloseAndFlushAsync(); + } + } - if (env.IsDevelopment()) + public static IHostBuilder CreateHostBuilder(string[] args) + { + return Host.CreateDefaultBuilder(args) + .ConfigureAppConfiguration((hostContext, configuration) => { - var appAssembly = Assembly.Load(new AssemblyName(env.ApplicationName)); - configuration.AddUserSecrets(appAssembly, optional: true); - } - - configuration.AddEnvironmentVariables(); - configuration.AddCommandLine(args); - }) - .ConfigureServices((hostContext, services) => - { - var configuration = hostContext.Configuration; - services.ConfigureAndValidate(configuration.Bind); + configuration.Sources.Clear(); + var env = hostContext.HostingEnvironment; + + configuration + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) + .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true) + .AddJsonFile("appsettings.override.json", optional: true, reloadOnChange: true); + + if (env.IsDevelopment()) + { + var appAssembly = Assembly.Load(new AssemblyName(env.ApplicationName)); + configuration.AddUserSecrets(appAssembly, optional: true); + } + + configuration.AddEnvironmentVariables(); + configuration.AddCommandLine(args); + }) + .ConfigureServices((hostContext, services) => + { + var configuration = hostContext.Configuration; + services.ConfigureAndValidate(configuration.Bind); #pragma warning disable ASP0000 // We retrieve the BackboneConfiguration via IOptions here so that it is validated - var parsedConfiguration = - services.BuildServiceProvider().GetRequiredService>().Value; + var parsedConfiguration = + services.BuildServiceProvider().GetRequiredService>().Value; #pragma warning restore ASP0000 - var worker = Assembly.GetExecutingAssembly().DefinedTypes.FirstOrDefault(t => t.Name == parsedConfiguration.Worker) ?? - throw new ArgumentException($"The specified worker could not be recognized, or no worker was set."); - services.AddTransient(typeof(IHostedService), worker); - - services - .AddModule(configuration) - .AddModule(configuration) - .AddModule(configuration) - .AddModule(configuration) - .AddModule(configuration) - .AddModule(configuration) - .AddModule(configuration) - .AddModule(configuration); - - services.AddSingleton(); - - services.AddTransient(); - services.AddFluentValidationAutoValidation(config => { config.DisableDataAnnotationsValidation = true; }); - - services.AddCustomIdentity(hostContext.HostingEnvironment); - - services.RegisterIdentityDeleters(); - - services.AddEventBus(parsedConfiguration.Infrastructure.EventBus); - - var devicesConfiguration = new DevicesConfiguration(); - configuration.GetSection("Modules:Devices").Bind(devicesConfiguration); - services.AddPushNotifications(devicesConfiguration.Infrastructure.PushNotifications); - }) - .UseServiceProviderFactory(new AutofacServiceProviderFactory()) - .UseSerilog((context, configuration) => configuration - .ReadFrom.Configuration(context.Configuration, new ConfigurationReaderOptions { SectionName = "Logging" }) - .Enrich.WithDemystifiedStackTraces() - .Enrich.FromLogContext() - .Enrich.WithProperty("service", "jobs.identitydeletion") - .Enrich.WithExceptionDetails(new DestructuringOptionsBuilder() - .WithDefaultDestructurers() - .WithDestructurers(new[] { new DbUpdateExceptionDestructurer() }) - ) - ); + var worker = Assembly.GetExecutingAssembly().DefinedTypes.FirstOrDefault(t => t.Name == parsedConfiguration.Worker) ?? + throw new ArgumentException($"The specified worker could not be recognized, or no worker was set."); + services.AddTransient(typeof(IHostedService), worker); + + services + .AddModule(configuration) + .AddModule(configuration) + .AddModule(configuration) + .AddModule(configuration) + .AddModule(configuration) + .AddModule(configuration) + .AddModule(configuration) + .AddModule(configuration); + + services.AddSingleton(); + + services.AddTransient(); + services.AddFluentValidationAutoValidation(config => { config.DisableDataAnnotationsValidation = true; }); + + services.AddCustomIdentity(hostContext.HostingEnvironment); + + services.RegisterIdentityDeleters(); + + services.AddEventBus(parsedConfiguration.Infrastructure.EventBus); + + var devicesConfiguration = new Configuration(); + configuration.GetSection("Modules:Devices").Bind(devicesConfiguration); + services.AddPushNotifications(devicesConfiguration.Infrastructure.PushNotifications); + }) + .UseServiceProviderFactory(new AutofacServiceProviderFactory()) + .UseSerilog((context, configuration) => configuration + .ReadFrom.Configuration(context.Configuration, new ConfigurationReaderOptions { SectionName = "Logging" }) + .Enrich.WithDemystifiedStackTraces() + .Enrich.FromLogContext() + .Enrich.WithProperty("service", "jobs.identitydeletion") + .Enrich.WithExceptionDetails(new DestructuringOptionsBuilder() + .WithDefaultDestructurers() + .WithDestructurers(new[] { new DbUpdateExceptionDestructurer() }) + ) + ); + } } public class DeletionProcessLogger : IDeletionProcessLogger diff --git a/Jobs/test/Job.IdentityDeletion.Tests.Integration/ActualDeletionWorkerTests.cs b/Jobs/test/Job.IdentityDeletion.Tests.Integration/ActualDeletionWorkerTests.cs new file mode 100644 index 0000000000..9a121b1ee9 --- /dev/null +++ b/Jobs/test/Job.IdentityDeletion.Tests.Integration/ActualDeletionWorkerTests.cs @@ -0,0 +1,200 @@ +using Backbone.DevelopmentKit.Identity.ValueObjects; +using Backbone.Modules.Devices.Domain.Aggregates.Tier; +using Backbone.Modules.Devices.Domain.Entities.Identities; +using Backbone.Modules.Devices.Infrastructure.Persistence.Database; +using Backbone.Modules.Messages.Domain.Entities; +using Backbone.Modules.Messages.Infrastructure.Persistence.Database; +using Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates; +using Backbone.Modules.Relationships.Infrastructure.Persistence.Database; +using Backbone.Tooling; +using Backbone.UnitTestTools.Data; +using Backbone.UnitTestTools.Extensions; +using FluentAssertions; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Xunit; +using Relationship = Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship; + +namespace Backbone.Job.IdentityDeletion.Tests.Integration; + +public class ActualDeletionWorkerTests +{ + private readonly IHost _host; + + public ActualDeletionWorkerTests() + { + var hostBuilder = Program.CreateHostBuilder(["--Worker", "ActualDeletionWorker"]); + + _host = hostBuilder.Build(); + + GetService().Database.Migrate(); + GetService().Database.Migrate(); + } + + [Fact] + public async Task Logs_that_data_was_deleted() + { + // Arrange + var identity = await SeedDatabaseWithIdentityWithRipeDeletionProcess(); + + // Act + await _host.StartAsync(); + + // Assert + var assertionContext = GetService(); + + var auditLogEntries = await assertionContext.IdentityDeletionProcessAuditLogs.Where(a => a.IdentityAddressHash == Hasher.HashUtf8(identity.Address)).ToListAsync(); + auditLogEntries.Should().HaveCount(14); + auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.ChallengesDeleted); + auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.PnsRegistrationsDeleted); + auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.IdentitiesDeleted); + auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.FilesDeleted); + auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.MessagesDeleted); + auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.QuotaIdentitiesDeleted); + auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.RelationshipsDeleted); + auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.RelationshipTemplatesDeleted); + auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.RelationshipTemplateAllocationsDeleted); + auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.ExternalEventsDeleted); + auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.SyncRunsDeleted); + auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.DatawalletsDeleted); + auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.TokensDeleted); + } + + [Fact] + public async Task Deletes_the_identity() + { + // Arrange + var identity = await SeedDatabaseWithIdentityWithRipeDeletionProcess(); + + // Act + await _host.StartAsync(); + + // Assert + var assertionContext = GetService(); + + var identityAfterAct = await assertionContext.Identities.FirstOrDefaultAsync(i => i.Address == identity.Address); + identityAfterAct.Should().BeNull(); + } + + [Fact] + public async Task Anonymizes_the_identity_in_all_messages_instead_of_deleting_the_message() + { + // Arrange + var identityToBeDeleted = await SeedDatabaseWithIdentityWithRipeDeletionProcess(); + var peer = TestDataGenerator.CreateRandomIdentityAddress(); + + GetService(); + + var sentMessage = await SeedDatabaseWithMessage(from: identityToBeDeleted.Address, to: peer); + var receivedMessage = await SeedDatabaseWithMessage(from: peer, to: identityToBeDeleted.Address); + + // Act + await _host.StartAsync(); + + // Assert + var assertionContext = GetService(); + + var messagesOfIdentityAfterAct = await assertionContext.Messages.Where(Message.HasParticipant(identityToBeDeleted.Address)).ToListAsync(); + messagesOfIdentityAfterAct.Should().BeEmpty(); + + var sentMessageAfterAct = await assertionContext.Messages.FirstOrDefaultAsync(m => m.Id == sentMessage.Id); + sentMessageAfterAct.Should().NotBeNull(); + + var receivedMessageAfterAct = await assertionContext.Messages.FirstOrDefaultAsync(m => m.Id == receivedMessage.Id); + receivedMessageAfterAct.Should().NotBeNull(); + } + + [Fact] + public async Task Deletes_relationships() + { + // Arrange + var identityToBeDeleted = await SeedDatabaseWithIdentityWithRipeDeletionProcess(); + var peer = TestDataGenerator.CreateRandomIdentityAddress(); + + GetService(); + + await SeedDatabaseWithActiveRelationshipBetween(peer, identityToBeDeleted.Address); + + // Act + await _host.StartAsync(); + + // Assert + var assertionContext = GetService(); + + var relationshipsAfterAct = await assertionContext.Relationships.Where(Relationship.HasParticipant(identityToBeDeleted.Address)).ToListAsync(); + relationshipsAfterAct.Should().BeEmpty(); + } + + [Fact] + public async Task Deletes_relationship_templates() + { + // Arrange + var identityToBeDeleted = await SeedDatabaseWithIdentityWithRipeDeletionProcess(); + + GetService(); + + await SeedDatabaseWithRelationshipTemplateOf(identityToBeDeleted.Address); + + // Act + await _host.StartAsync(); + + // Assert + var assertionContext = GetService(); + + var templatesAfterAct = await assertionContext.RelationshipTemplates.Where(rt => rt.CreatedBy == identityToBeDeleted.Address).ToListAsync(); + templatesAfterAct.Should().BeEmpty(); + } + + private async Task SeedDatabaseWithMessage(IdentityAddress from, IdentityAddress to) + { + var dbContext = GetService(); + + var recipient = new RecipientInformation(to, []); + + var message = new Message(from, DeviceId.New(), [], [], [recipient]); + + await dbContext.SaveEntity(message); + + return message; + } + + private async Task SeedDatabaseWithActiveRelationshipBetween(IdentityAddress from, IdentityAddress to) + { + var template = new RelationshipTemplate(from, DeviceId.New(), null, null, []); + var relationship = new Relationship(template, to, DeviceId.New(), [], []); + relationship.Accept(from, DeviceId.New(), []); + var dbContext = GetService(); + await dbContext.SaveEntity(relationship); + } + + private async Task SeedDatabaseWithRelationshipTemplateOf(IdentityAddress owner) + { + var template = new RelationshipTemplate(owner, DeviceId.New(), null, null, []); + var dbContext = GetService(); + await dbContext.SaveEntity(template); + } + + private async Task SeedDatabaseWithIdentityWithRipeDeletionProcess() + { + var dbContext = GetService(); + + var identity = new Identity("test", TestDataGenerator.CreateRandomIdentityAddress(), [], TierId.Generate(), 1); + + var device = new Device(identity, CommunicationLanguage.DEFAULT_LANGUAGE); + identity.Devices.Add(device); + + SystemTime.Set(SystemTime.UtcNow.AddMonths(-1)); + identity.StartDeletionProcessAsOwner(device.Id); + SystemTime.Reset(); + + await dbContext.SaveEntity(identity); + + return identity; + } + + private T GetService() where T : notnull + { + return _host.Services.CreateScope().ServiceProvider.GetRequiredService(); + } +} diff --git a/Jobs/test/Job.IdentityDeletion.Tests.Integration/Job.IdentityDeletion.Tests.Integration.csproj b/Jobs/test/Job.IdentityDeletion.Tests.Integration/Job.IdentityDeletion.Tests.Integration.csproj new file mode 100644 index 0000000000..9e8921c3a1 --- /dev/null +++ b/Jobs/test/Job.IdentityDeletion.Tests.Integration/Job.IdentityDeletion.Tests.Integration.csproj @@ -0,0 +1,50 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + PreserveNewest + + + + + + PreserveNewest + + + + diff --git a/Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json b/Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json new file mode 100644 index 0000000000..8218c447b5 --- /dev/null +++ b/Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json @@ -0,0 +1,107 @@ +{ + "Infrastructure": { + "EventBus": { + "Vendor": "RabbitMQ", // possible values: InMemory, RabbitMQ, GoogleCloud, Azure + "ConnectionInfo": "localhost", + + "RabbitMQUsername": "guest", // only available for RabbitMQ + "RabbitMQPassword": "guest", // only available for RabbitMQ + "ConnectionRetryCount": 5, // only available for RabbitMQ + + "GcpPubSubProjectId": "", // only available for Google Cloud Pub/Sub + "GcpPubSubTopicName": "" // only available for Google Cloud Pub/Sub + } + }, + "Modules": { + "Challenges": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "Postgres", + "ConnectionString": "User ID=postgres;Password=admin;Server=localhost;Port=5432;Database=enmeshed;" // postgres + // "ConnectionString": "Server=localhost;Database=enmeshed;User Id=challenges;Password=Passw0rd;TrustServerCertificate=True" // sqlserver + } + } + }, + "Quotas": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "Postgres", + "ConnectionString": "User ID=postgres;Password=admin;Server=localhost;Port=5432;Database=enmeshed;" // postgres + // "ConnectionString": "Server=localhost;Database=enmeshed;User Id=quotas;Password=Passw0rd;TrustServerCertificate=True" // sqlserver + } + } + }, + "Devices": { + "Application": { + "DidDomainName": "localhost" + }, + "Infrastructure": { + "SqlDatabase": { + "Provider": "Postgres", + "ConnectionString": "User ID=postgres;Password=admin;Server=localhost;Port=5432;Database=enmeshed;" // postgres + // "ConnectionString": "Server=localhost;Database=enmeshed;User Id=devices;Password=Passw0rd;TrustServerCertificate=True" // sqlserver + }, + "PushNotifications": { + "Providers": { + "Dummy": { + "IsEnabled": true + } + } + } + } + }, + "Files": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "Postgres", + "ConnectionString": "User ID=postgres;Password=admin;Server=localhost;Port=5432;Database=enmeshed;" // postgres + // "ConnectionString": "Server=localhost;Database=enmeshed;User Id=files;Password=Passw0rd;TrustServerCertificate=True" // sqlserver + }, + "BlobStorage": { + "CloudProvider": "Azure", + "ConnectionInfo": "", + "ContainerName": "" + } + } + }, + "Messages": { + "Application": { + "DidDomainName": "localhost" + }, + "Infrastructure": { + "SqlDatabase": { + "Provider": "Postgres", + "ConnectionString": "User ID=postgres;Password=admin;Server=localhost;Port=5432;Database=enmeshed;" // postgres + // "ConnectionString": "Server=localhost;Database=enmeshed;User Id=messages;Password=Passw0rd;TrustServerCertificate=True" // sqlserver + } + } + }, + "Relationships": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "Postgres", + "ConnectionString": "User ID=postgres;Password=admin;Server=localhost;Port=5432;Database=enmeshed;" // postgres + // "ConnectionString": "Server=localhost;Database=enmeshed;User Id=relationships;Password=Passw0rd;TrustServerCertificate=True" // sqlserver + } + } + }, + "Synchronization": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "Postgres", + "ConnectionString": "User ID=postgres;Password=admin;Server=localhost;Port=5432;Database=enmeshed;" // postgres + // "ConnectionString": "Server=localhost;Database=enmeshed;User Id=synchronization;Password=Passw0rd;TrustServerCertificate=True" // sqlserver + } + } + }, + "Tokens": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "Postgres", + "ConnectionString": "User ID=postgres;Password=admin;Server=localhost;Port=5432;Database=enmeshed;" // postgres + // "ConnectionString": "Server=localhost;Database=enmeshed;User Id=tokens;Password=Passw0rd;TrustServerCertificate=True" // sqlserver + } + } + } + } +} diff --git a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/Commands/DeleteIdentityCommandTests/HandlerTests.cs b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/Commands/DeleteIdentityCommandTests/HandlerTests.cs index 576d6e3e47..433849cc7e 100644 --- a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/Commands/DeleteIdentityCommandTests/HandlerTests.cs +++ b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/Commands/DeleteIdentityCommandTests/HandlerTests.cs @@ -7,13 +7,14 @@ using Xunit; namespace Backbone.Modules.Challenges.Application.Tests.Tests.Identities.Commands.DeleteIdentityCommandTests; + public class HandlerTests : AbstractTestsBase { [Fact] public async Task Handler_calls_deletion_method_on_repository() { // Arrange - var identityAddress = "identity-address"; + const string identityAddress = "identity-address"; var mockChallengesRepository = A.Fake(); var handler = CreateHandler(mockChallengesRepository); diff --git a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/Queries/GetDeletionProcessesAuditLogs/FindDeletionProcessAuditLogsByAddressStubRepository.cs b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/Queries/GetDeletionProcessesAuditLogs/FindDeletionProcessAuditLogsByAddressStubRepository.cs index c17377124d..85d03f57a6 100644 --- a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/Queries/GetDeletionProcessesAuditLogs/FindDeletionProcessAuditLogsByAddressStubRepository.cs +++ b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/Queries/GetDeletionProcessesAuditLogs/FindDeletionProcessAuditLogsByAddressStubRepository.cs @@ -61,6 +61,11 @@ public Task> GetIdentityDeleti return Task.FromResult(_identityDeletionProcessAuditLogs); } + public Task AddDeletionProcessAuditLogEntry(IdentityDeletionProcessAuditLogEntry auditLogEntry) + { + throw new NotSupportedException(); + } + public Task Update(Identity identity, CancellationToken cancellationToken) { throw new NotSupportedException(); diff --git a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/Queries/GetIdentity/FindByAddressStubRepository.cs b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/Queries/GetIdentity/FindByAddressStubRepository.cs index b172969c4d..eb7dd14298 100644 --- a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/Queries/GetIdentity/FindByAddressStubRepository.cs +++ b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/Queries/GetIdentity/FindByAddressStubRepository.cs @@ -56,6 +56,11 @@ public Task> GetIdentityDeleti throw new NotSupportedException(); } + public Task AddDeletionProcessAuditLogEntry(IdentityDeletionProcessAuditLogEntry auditLogEntry) + { + throw new NotSupportedException(); + } + public Task Update(Identity identity, CancellationToken cancellationToken) { throw new NotSupportedException(); diff --git a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/Queries/ListIdentities/FindAllStubRepository.cs b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/Queries/ListIdentities/FindAllStubRepository.cs index 72ed9d572b..f5920502a4 100644 --- a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/Queries/ListIdentities/FindAllStubRepository.cs +++ b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/Queries/ListIdentities/FindAllStubRepository.cs @@ -56,6 +56,11 @@ public Task> GetIdentityDeleti throw new NotSupportedException(); } + public Task AddDeletionProcessAuditLogEntry(IdentityDeletionProcessAuditLogEntry auditLogEntry) + { + throw new NotSupportedException(); + } + public Task Update(Identity identity, CancellationToken cancellationToken) { throw new NotSupportedException(); From e333c749175f691b8f120da812b3bcecab110a84 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Wed, 3 Jul 2024 16:36:04 +0200 Subject: [PATCH 032/105] feat: add "Integration" category to integration tests to exclude them from unit test pipeline --- .../Job.IdentityDeletion.Tests.Integration/AssemblyInfo.cs | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Jobs/test/Job.IdentityDeletion.Tests.Integration/AssemblyInfo.cs diff --git a/Jobs/test/Job.IdentityDeletion.Tests.Integration/AssemblyInfo.cs b/Jobs/test/Job.IdentityDeletion.Tests.Integration/AssemblyInfo.cs new file mode 100644 index 0000000000..925a8793f8 --- /dev/null +++ b/Jobs/test/Job.IdentityDeletion.Tests.Integration/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using Xunit; + +[assembly: AssemblyTrait("Category", "Integration")] From 7a3721487b139fa25331847e4368d5b04b6a2557 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Thu, 4 Jul 2024 08:06:34 +0200 Subject: [PATCH 033/105] ci: run integration test projects directly instead of filtering for tag --- .ci/integrationTest.postgres.sh | 4 +++- .ci/integrationTest.sqlserver.sh | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.ci/integrationTest.postgres.sh b/.ci/integrationTest.postgres.sh index e25f3e6d80..32f2dedbb6 100755 --- a/.ci/integrationTest.postgres.sh +++ b/.ci/integrationTest.postgres.sh @@ -18,4 +18,6 @@ wait export CONSUMER_API_BASE_ADDRESS="http://localhost:5000" export ADMIN_API_BASE_ADDRESS="http://localhost:5173" -dotnet test --no-restore --no-build --filter "Category=Integration&TestCategory!~ignore" --logger "GitHubActions;summary.includeNotFoundTests=false" "Backbone.sln" +dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration.csproj +dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ConsumerApi.Tests.Integration + diff --git a/.ci/integrationTest.sqlserver.sh b/.ci/integrationTest.sqlserver.sh index 8b9cf954a7..f04d8ef948 100755 --- a/.ci/integrationTest.sqlserver.sh +++ b/.ci/integrationTest.sqlserver.sh @@ -18,4 +18,6 @@ wait export CONSUMER_API_BASE_ADDRESS="http://localhost:5000" export ADMIN_API_BASE_ADDRESS="http://localhost:5173" -dotnet test --no-restore --no-build --filter "Category=Integration&TestCategory!~ignore" --logger "GitHubActions;summary.includeNotFoundTests=false" "Backbone.sln" +dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration.csproj +dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ConsumerApi.Tests.Integration + From da01b9bbd04bddeca7f0651d1d537fe1c6ce2c37 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Thu, 4 Jul 2024 08:07:14 +0200 Subject: [PATCH 034/105] ci: add appsettings for integration tests of identity deletion job --- ...appsettings.override.postgres.docker.json} | 7 +- .ci/appsettings.override.postgres.local.json | 118 ++++++++++++++++++ ...ppsettings.override.sqlserver.docker.json} | 7 +- .ci/appsettings.override.sqlserver.local.json | 118 ++++++++++++++++++ .ci/docker-compose.test.postgres.yml | 2 +- .ci/docker-compose.test.sqlserver.yml | 2 +- .ci/integrationTest.postgres.sh | 3 + .ci/integrationTest.sqlserver.sh | 3 + 8 files changed, 248 insertions(+), 12 deletions(-) rename .ci/{appsettings.override.postgres.json => appsettings.override.postgres.docker.json} (97%) create mode 100644 .ci/appsettings.override.postgres.local.json rename .ci/{appsettings.override.sqlserver.json => appsettings.override.sqlserver.docker.json} (98%) create mode 100644 .ci/appsettings.override.sqlserver.local.json diff --git a/.ci/appsettings.override.postgres.json b/.ci/appsettings.override.postgres.docker.json similarity index 97% rename from .ci/appsettings.override.postgres.json rename to .ci/appsettings.override.postgres.docker.json index db969cf1ec..f149b8ccad 100644 --- a/.ci/appsettings.override.postgres.json +++ b/.ci/appsettings.override.postgres.docker.json @@ -4,17 +4,14 @@ }, "Authentication": { "ApiKey": "test", - "JwtSigningCertificate": "MIIJ7wIBAzCCCaUGCSqGSIb3DQEHAaCCCZYEggmSMIIJjjCCBAIGCSqGSIb3DQEHBqCCA/MwggPvAgEAMIID6AYJKoZIhvcNAQcBMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAiIVEGIEnzbyAICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEC1tOaulJJjkAl2W7xeF3G6AggOAm1VdXzAQ6MhHabp6+rzEuaAyBpuMi8zD8OEl8/xMv47UsFUor38aZjQd14qTTLz5MnksI/qgjQHLuMEmN1eWARsUBkeYvLuz0icl2q9A5Rn9CaKHIemQWq9mIobq3XnXhwDFEd+G/WgjNoK65Ndu20pnuc9LDlfq6fx2eXDbHAWLeUTnlQsEY4M/owNKIjlO/VsYJCshvEPlbtCnyzXwkrtQ5i2XufIJsfX0qoK/dXfoMVUjPxa/L8uR40bAWc1LVkvO0Ox4rY9VCtC1eHe3fcS48AaYCGRMpkZ7N+nDOb7lPs7BcxVoIrj/PkqiNI4rMOZVEgz21OWhueIjBv4gxfV+vW7IZ7xWvC1uUYIKEKEl6mk8KJ5zruO3tObX70+4saBiTNd/76+CVR4qCSwYcD7bZjpMOiaVFyxy0ay3dCwoivLK1jWNFJ25tngYpXKGCtOP0/Zi1fyseo4C54Ef5Yoo+BG3bkKR9VHChWzbB+b1p2lOwfBWIWlGjoZ+expyBjnk+FWrFDZeMknpW3PANCtcT/zqzqPKG3g4DAnSx9xDqvR7GBEgUlaUBAsCM3NvbahzevFFNE21aVajmTpSdejqvgNgvHPHA+BHfhMYx3mcMEkZ+phEHrWRSg925Iy64afL9/XvxoB/uFOYta/ir4ZqCbOy+yrc4+ppQlvLEIUnL4BGWcZ7d2NNRHWOHg0UqzxakezWhoGh1DDWfNdEj+eoa8DTvQr9hX0DQljym1I51qYdrv18rSf+MQj9jhBgQ77WBCX4sDkj4W9d7kKah8Fa0v+4bB1CqrETAsCESvBzSNyYEXKpyjdR/m8w/dti13Kz9ptvi8zd70tcqsqjaB3Qaz3gZRzRlPJORrg2cjWm+xLTOIQ+thk+O3U7l5R47h7QT44eSroKmX8Ptt/wkn9HRcI9bjylzrjTFw45/Re61RpHm3+NXUfvTPLaaXYSolldAgYN1gq+yYZJvBViWQB7gE05fpph6t6DYhEr2VtkLljxDclRPF14AKZaQCIndTiUX69eQfIpD4edHyBvFWSkf+fC1whOE/tqKY0vDflhBDrWFsvDwnEo0iYy671nu19RnBnZws0vseJeikQdCWBY6m0Wq7oViCyFCWyJPDukz3E9uCRrckki2i5+V2MM2IMtgImVFvRqaRbi7vF+Qjccs9Ri0+evcsc9dWjsnHkwggWEBgkqhkiG9w0BBwGgggV1BIIFcTCCBW0wggVpBgsqhkiG9w0BDAoBAqCCBTEwggUtMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAj06Hc+Gh2z5wICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEOwPSnf4F479I2AKr8i0TLYEggTQFtwGZHL6BF2++nDi2EAjc7XXIxp0u4qM17eZjafdltFpketf6pQCD/hDry+mVeIapTY9hOPE5XdjdFoJtOZPZHfvrrb0Jn+rgGAPYGBzqGK4NPVWHiDZ3uA4R4Tiwhgqd/ZQIdRshUEPVfu4EzTIAEhmHl+1g8JiD8EcYAXO1IRCLm17IsIYXT6d8cYe3Zy3AgULsF0/OwQIPVqaJCIwPR3qw68GXNA4iWWHuXJhdtrqHrGrkfBRuZZ5+7R838RM9Bk+ljWphidPmIFZmhjACt/c1qorGPhQTil0WT9VU9rN/gJ1rKcu3RQ1TRJDTjZYaPSMu9ycvFLpsP8XBJUpfHnczPS25bclKaJRUvou6aiwtyQsqWCDLGRuwN06Oins28R5/QQNYbcOr77WBlgh28K1TLcnQopE9xp12XBj8iOeUlVMiMVlph02TrGMXOqU0rlRpsYECMSfHw4xdH87GBUxmE4ndE7JI7wu73MsHQ+3kDTTvGG6xzY6rbNg+V6CfOZc102645sJskdCD6ygzUfgDwDcxjyky2u86qBFR/9d3M7Vh+PQpijYxQ/w4FzwgHUPII+JqqY8secPSA64L8qXj4daG74Wc3y+veajJzkFBUiaJnCER1WEJf0b4eBAEG1gaJ/B2hrp+lEd30qbE//iJWna5gYboIzMENfJ4RsqxlW4hZs6aqBuDr8QXL1chc11g0nMY9sI0kZVwF8+13eFh4ypt4H34usOiWHft2eeA/Z2h8agrT8UFkRfy3/1dGoNwqicXgqY3MgoxqlfDQ6hjPkO5JAbRc0cuZQMPu38dO66+qoI/Db4zdo+8G6sXOgZkzduQlARhx6VORq2QFoufsyqXvsUWFWSXEOjWLbLwKK5og8sV4OmWXGRPbTo+Hc3pmmuYcpEwtH6wFCb0vXVeOhSd7GX8Yv2V0yVt19IjgUGtukVWt9DUe6uImzsPm9ZdivWUB3RlKYRGpS16yhG0ZdRwBJweDoitK091ooN6Um74eO17dH0jAQw3XPBxgJ64qEdSzfJ/xybM45BSUPAft2wXXlckLOId9Us56oV7WeszTOkOPDKz9GnKT05xPXNDgAqstVZc0nXEq0eFzTORREBP0w2ijwPu9mfPvRACY8p7YMnNbZzMGBvpa3ILezRIgThMbnzf+YiBP2Ddt9bWoxDsIj7jaqDzxjG2WtI1qGEqFyLCeUkSx2UpkbGViCkx8CsMwXJwLrYdoxqjyOg2Oz09EFF5eI1wkLqEtez8dOTLEn7oFjTyFbRkNoynuwvNqHEG2qzbw02Rb82qyrurKmOnNHog7FXLDe0kGFgKuNXbCw+to2lAhWY0CmEe8qfQLeAiV3TsGHSrGSkoegmfPHsuboCdez/ETJZWoodryUPdY3PFNa0xZOJvbtkiG2Vo55Rjq9wbd+MWAGcxhaCVEmEJ0UWWsn3Oe+h4mn3wT9+P+hkAR9duXT6tq+5DmKB2RD3fR3vIc4H5eLaIzOOmjSdfGFvIaj+06jS7SGicuKqF5ND4HPtXJrQgQUdO/gIHCkE9nn4hXCoz/bGkU4FN2WPz5TTMVsYuxMVp1I2UayoQppltkp3oaDb/S36FeO644d5zb7ARayF68NL5MrM/MRK24jhtx2WV4ZN9HIxJTAjBgkqhkiG9w0BCRUxFgQU/S6zDu6S3P4i1WdDz+j3esGxT4UwQTAxMA0GCWCGSAFlAwQCAQUABCCiOwVWGDHil8dA7XvoQNTLTJDm7EwdfGC4KJUV9smgUgQI4ZRrDNXXl8cCAggA", - "JwtLifetimeInSeconds": 300 + "JwtSigningCertificate": "MIIJ7wIBAzCCCaUGCSqGSIb3DQEHAaCCCZYEggmSMIIJjjCCBAIGCSqGSIb3DQEHBqCCA/MwggPvAgEAMIID6AYJKoZIhvcNAQcBMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAiIVEGIEnzbyAICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEC1tOaulJJjkAl2W7xeF3G6AggOAm1VdXzAQ6MhHabp6+rzEuaAyBpuMi8zD8OEl8/xMv47UsFUor38aZjQd14qTTLz5MnksI/qgjQHLuMEmN1eWARsUBkeYvLuz0icl2q9A5Rn9CaKHIemQWq9mIobq3XnXhwDFEd+G/WgjNoK65Ndu20pnuc9LDlfq6fx2eXDbHAWLeUTnlQsEY4M/owNKIjlO/VsYJCshvEPlbtCnyzXwkrtQ5i2XufIJsfX0qoK/dXfoMVUjPxa/L8uR40bAWc1LVkvO0Ox4rY9VCtC1eHe3fcS48AaYCGRMpkZ7N+nDOb7lPs7BcxVoIrj/PkqiNI4rMOZVEgz21OWhueIjBv4gxfV+vW7IZ7xWvC1uUYIKEKEl6mk8KJ5zruO3tObX70+4saBiTNd/76+CVR4qCSwYcD7bZjpMOiaVFyxy0ay3dCwoivLK1jWNFJ25tngYpXKGCtOP0/Zi1fyseo4C54Ef5Yoo+BG3bkKR9VHChWzbB+b1p2lOwfBWIWlGjoZ+expyBjnk+FWrFDZeMknpW3PANCtcT/zqzqPKG3g4DAnSx9xDqvR7GBEgUlaUBAsCM3NvbahzevFFNE21aVajmTpSdejqvgNgvHPHA+BHfhMYx3mcMEkZ+phEHrWRSg925Iy64afL9/XvxoB/uFOYta/ir4ZqCbOy+yrc4+ppQlvLEIUnL4BGWcZ7d2NNRHWOHg0UqzxakezWhoGh1DDWfNdEj+eoa8DTvQr9hX0DQljym1I51qYdrv18rSf+MQj9jhBgQ77WBCX4sDkj4W9d7kKah8Fa0v+4bB1CqrETAsCESvBzSNyYEXKpyjdR/m8w/dti13Kz9ptvi8zd70tcqsqjaB3Qaz3gZRzRlPJORrg2cjWm+xLTOIQ+thk+O3U7l5R47h7QT44eSroKmX8Ptt/wkn9HRcI9bjylzrjTFw45/Re61RpHm3+NXUfvTPLaaXYSolldAgYN1gq+yYZJvBViWQB7gE05fpph6t6DYhEr2VtkLljxDclRPF14AKZaQCIndTiUX69eQfIpD4edHyBvFWSkf+fC1whOE/tqKY0vDflhBDrWFsvDwnEo0iYy671nu19RnBnZws0vseJeikQdCWBY6m0Wq7oViCyFCWyJPDukz3E9uCRrckki2i5+V2MM2IMtgImVFvRqaRbi7vF+Qjccs9Ri0+evcsc9dWjsnHkwggWEBgkqhkiG9w0BBwGgggV1BIIFcTCCBW0wggVpBgsqhkiG9w0BDAoBAqCCBTEwggUtMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAj06Hc+Gh2z5wICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEOwPSnf4F479I2AKr8i0TLYEggTQFtwGZHL6BF2++nDi2EAjc7XXIxp0u4qM17eZjafdltFpketf6pQCD/hDry+mVeIapTY9hOPE5XdjdFoJtOZPZHfvrrb0Jn+rgGAPYGBzqGK4NPVWHiDZ3uA4R4Tiwhgqd/ZQIdRshUEPVfu4EzTIAEhmHl+1g8JiD8EcYAXO1IRCLm17IsIYXT6d8cYe3Zy3AgULsF0/OwQIPVqaJCIwPR3qw68GXNA4iWWHuXJhdtrqHrGrkfBRuZZ5+7R838RM9Bk+ljWphidPmIFZmhjACt/c1qorGPhQTil0WT9VU9rN/gJ1rKcu3RQ1TRJDTjZYaPSMu9ycvFLpsP8XBJUpfHnczPS25bclKaJRUvou6aiwtyQsqWCDLGRuwN06Oins28R5/QQNYbcOr77WBlgh28K1TLcnQopE9xp12XBj8iOeUlVMiMVlph02TrGMXOqU0rlRpsYECMSfHw4xdH87GBUxmE4ndE7JI7wu73MsHQ+3kDTTvGG6xzY6rbNg+V6CfOZc102645sJskdCD6ygzUfgDwDcxjyky2u86qBFR/9d3M7Vh+PQpijYxQ/w4FzwgHUPII+JqqY8secPSA64L8qXj4daG74Wc3y+veajJzkFBUiaJnCER1WEJf0b4eBAEG1gaJ/B2hrp+lEd30qbE//iJWna5gYboIzMENfJ4RsqxlW4hZs6aqBuDr8QXL1chc11g0nMY9sI0kZVwF8+13eFh4ypt4H34usOiWHft2eeA/Z2h8agrT8UFkRfy3/1dGoNwqicXgqY3MgoxqlfDQ6hjPkO5JAbRc0cuZQMPu38dO66+qoI/Db4zdo+8G6sXOgZkzduQlARhx6VORq2QFoufsyqXvsUWFWSXEOjWLbLwKK5og8sV4OmWXGRPbTo+Hc3pmmuYcpEwtH6wFCb0vXVeOhSd7GX8Yv2V0yVt19IjgUGtukVWt9DUe6uImzsPm9ZdivWUB3RlKYRGpS16yhG0ZdRwBJweDoitK091ooN6Um74eO17dH0jAQw3XPBxgJ64qEdSzfJ/xybM45BSUPAft2wXXlckLOId9Us56oV7WeszTOkOPDKz9GnKT05xPXNDgAqstVZc0nXEq0eFzTORREBP0w2ijwPu9mfPvRACY8p7YMnNbZzMGBvpa3ILezRIgThMbnzf+YiBP2Ddt9bWoxDsIj7jaqDzxjG2WtI1qGEqFyLCeUkSx2UpkbGViCkx8CsMwXJwLrYdoxqjyOg2Oz09EFF5eI1wkLqEtez8dOTLEn7oFjTyFbRkNoynuwvNqHEG2qzbw02Rb82qyrurKmOnNHog7FXLDe0kGFgKuNXbCw+to2lAhWY0CmEe8qfQLeAiV3TsGHSrGSkoegmfPHsuboCdez/ETJZWoodryUPdY3PFNa0xZOJvbtkiG2Vo55Rjq9wbd+MWAGcxhaCVEmEJ0UWWsn3Oe+h4mn3wT9+P+hkAR9duXT6tq+5DmKB2RD3fR3vIc4H5eLaIzOOmjSdfGFvIaj+06jS7SGicuKqF5ND4HPtXJrQgQUdO/gIHCkE9nn4hXCoz/bGkU4FN2WPz5TTMVsYuxMVp1I2UayoQppltkp3oaDb/S36FeO644d5zb7ARayF68NL5MrM/MRK24jhtx2WV4ZN9HIxJTAjBgkqhkiG9w0BCRUxFgQU/S6zDu6S3P4i1WdDz+j3esGxT4UwQTAxMA0GCWCGSAFlAwQCAQUABCCiOwVWGDHil8dA7XvoQNTLTJDm7EwdfGC4KJUV9smgUgQI4ZRrDNXXl8cCAggA" }, "Infrastructure": { "EventBus": { "Vendor": "RabbitMQ", "ConnectionInfo": "rabbitmq", - "RabbitMQUsername": "guest", - "RabbitMQPassword": "guest", - "ConnectionRetryCount": 5 + "RabbitMQPassword": "guest" }, "SqlDatabase": { "Provider": "Postgres", diff --git a/.ci/appsettings.override.postgres.local.json b/.ci/appsettings.override.postgres.local.json new file mode 100644 index 0000000000..f201d25508 --- /dev/null +++ b/.ci/appsettings.override.postgres.local.json @@ -0,0 +1,118 @@ +{ + "Cors": { + "AccessControlAllowCredentials": true + }, + "Authentication": { + "ApiKey": "test", + "JwtSigningCertificate": "MIIJ7wIBAzCCCaUGCSqGSIb3DQEHAaCCCZYEggmSMIIJjjCCBAIGCSqGSIb3DQEHBqCCA/MwggPvAgEAMIID6AYJKoZIhvcNAQcBMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAiIVEGIEnzbyAICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEC1tOaulJJjkAl2W7xeF3G6AggOAm1VdXzAQ6MhHabp6+rzEuaAyBpuMi8zD8OEl8/xMv47UsFUor38aZjQd14qTTLz5MnksI/qgjQHLuMEmN1eWARsUBkeYvLuz0icl2q9A5Rn9CaKHIemQWq9mIobq3XnXhwDFEd+G/WgjNoK65Ndu20pnuc9LDlfq6fx2eXDbHAWLeUTnlQsEY4M/owNKIjlO/VsYJCshvEPlbtCnyzXwkrtQ5i2XufIJsfX0qoK/dXfoMVUjPxa/L8uR40bAWc1LVkvO0Ox4rY9VCtC1eHe3fcS48AaYCGRMpkZ7N+nDOb7lPs7BcxVoIrj/PkqiNI4rMOZVEgz21OWhueIjBv4gxfV+vW7IZ7xWvC1uUYIKEKEl6mk8KJ5zruO3tObX70+4saBiTNd/76+CVR4qCSwYcD7bZjpMOiaVFyxy0ay3dCwoivLK1jWNFJ25tngYpXKGCtOP0/Zi1fyseo4C54Ef5Yoo+BG3bkKR9VHChWzbB+b1p2lOwfBWIWlGjoZ+expyBjnk+FWrFDZeMknpW3PANCtcT/zqzqPKG3g4DAnSx9xDqvR7GBEgUlaUBAsCM3NvbahzevFFNE21aVajmTpSdejqvgNgvHPHA+BHfhMYx3mcMEkZ+phEHrWRSg925Iy64afL9/XvxoB/uFOYta/ir4ZqCbOy+yrc4+ppQlvLEIUnL4BGWcZ7d2NNRHWOHg0UqzxakezWhoGh1DDWfNdEj+eoa8DTvQr9hX0DQljym1I51qYdrv18rSf+MQj9jhBgQ77WBCX4sDkj4W9d7kKah8Fa0v+4bB1CqrETAsCESvBzSNyYEXKpyjdR/m8w/dti13Kz9ptvi8zd70tcqsqjaB3Qaz3gZRzRlPJORrg2cjWm+xLTOIQ+thk+O3U7l5R47h7QT44eSroKmX8Ptt/wkn9HRcI9bjylzrjTFw45/Re61RpHm3+NXUfvTPLaaXYSolldAgYN1gq+yYZJvBViWQB7gE05fpph6t6DYhEr2VtkLljxDclRPF14AKZaQCIndTiUX69eQfIpD4edHyBvFWSkf+fC1whOE/tqKY0vDflhBDrWFsvDwnEo0iYy671nu19RnBnZws0vseJeikQdCWBY6m0Wq7oViCyFCWyJPDukz3E9uCRrckki2i5+V2MM2IMtgImVFvRqaRbi7vF+Qjccs9Ri0+evcsc9dWjsnHkwggWEBgkqhkiG9w0BBwGgggV1BIIFcTCCBW0wggVpBgsqhkiG9w0BDAoBAqCCBTEwggUtMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAj06Hc+Gh2z5wICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEOwPSnf4F479I2AKr8i0TLYEggTQFtwGZHL6BF2++nDi2EAjc7XXIxp0u4qM17eZjafdltFpketf6pQCD/hDry+mVeIapTY9hOPE5XdjdFoJtOZPZHfvrrb0Jn+rgGAPYGBzqGK4NPVWHiDZ3uA4R4Tiwhgqd/ZQIdRshUEPVfu4EzTIAEhmHl+1g8JiD8EcYAXO1IRCLm17IsIYXT6d8cYe3Zy3AgULsF0/OwQIPVqaJCIwPR3qw68GXNA4iWWHuXJhdtrqHrGrkfBRuZZ5+7R838RM9Bk+ljWphidPmIFZmhjACt/c1qorGPhQTil0WT9VU9rN/gJ1rKcu3RQ1TRJDTjZYaPSMu9ycvFLpsP8XBJUpfHnczPS25bclKaJRUvou6aiwtyQsqWCDLGRuwN06Oins28R5/QQNYbcOr77WBlgh28K1TLcnQopE9xp12XBj8iOeUlVMiMVlph02TrGMXOqU0rlRpsYECMSfHw4xdH87GBUxmE4ndE7JI7wu73MsHQ+3kDTTvGG6xzY6rbNg+V6CfOZc102645sJskdCD6ygzUfgDwDcxjyky2u86qBFR/9d3M7Vh+PQpijYxQ/w4FzwgHUPII+JqqY8secPSA64L8qXj4daG74Wc3y+veajJzkFBUiaJnCER1WEJf0b4eBAEG1gaJ/B2hrp+lEd30qbE//iJWna5gYboIzMENfJ4RsqxlW4hZs6aqBuDr8QXL1chc11g0nMY9sI0kZVwF8+13eFh4ypt4H34usOiWHft2eeA/Z2h8agrT8UFkRfy3/1dGoNwqicXgqY3MgoxqlfDQ6hjPkO5JAbRc0cuZQMPu38dO66+qoI/Db4zdo+8G6sXOgZkzduQlARhx6VORq2QFoufsyqXvsUWFWSXEOjWLbLwKK5og8sV4OmWXGRPbTo+Hc3pmmuYcpEwtH6wFCb0vXVeOhSd7GX8Yv2V0yVt19IjgUGtukVWt9DUe6uImzsPm9ZdivWUB3RlKYRGpS16yhG0ZdRwBJweDoitK091ooN6Um74eO17dH0jAQw3XPBxgJ64qEdSzfJ/xybM45BSUPAft2wXXlckLOId9Us56oV7WeszTOkOPDKz9GnKT05xPXNDgAqstVZc0nXEq0eFzTORREBP0w2ijwPu9mfPvRACY8p7YMnNbZzMGBvpa3ILezRIgThMbnzf+YiBP2Ddt9bWoxDsIj7jaqDzxjG2WtI1qGEqFyLCeUkSx2UpkbGViCkx8CsMwXJwLrYdoxqjyOg2Oz09EFF5eI1wkLqEtez8dOTLEn7oFjTyFbRkNoynuwvNqHEG2qzbw02Rb82qyrurKmOnNHog7FXLDe0kGFgKuNXbCw+to2lAhWY0CmEe8qfQLeAiV3TsGHSrGSkoegmfPHsuboCdez/ETJZWoodryUPdY3PFNa0xZOJvbtkiG2Vo55Rjq9wbd+MWAGcxhaCVEmEJ0UWWsn3Oe+h4mn3wT9+P+hkAR9duXT6tq+5DmKB2RD3fR3vIc4H5eLaIzOOmjSdfGFvIaj+06jS7SGicuKqF5ND4HPtXJrQgQUdO/gIHCkE9nn4hXCoz/bGkU4FN2WPz5TTMVsYuxMVp1I2UayoQppltkp3oaDb/S36FeO644d5zb7ARayF68NL5MrM/MRK24jhtx2WV4ZN9HIxJTAjBgkqhkiG9w0BCRUxFgQU/S6zDu6S3P4i1WdDz+j3esGxT4UwQTAxMA0GCWCGSAFlAwQCAQUABCCiOwVWGDHil8dA7XvoQNTLTJDm7EwdfGC4KJUV9smgUgQI4ZRrDNXXl8cCAggA" + }, + "Infrastructure": { + "EventBus": { + "Vendor": "RabbitMQ", + "ConnectionInfo": "localhost", + "RabbitMQUsername": "guest", + "RabbitMQPassword": "guest" + }, + "SqlDatabase": { + "Provider": "Postgres", + "ConnectionString": "User Id=adminUi;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;" + } + }, + "Modules": { + "Challenges": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "Postgres", + "ConnectionString": "User ID=challenges;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;" + } + } + }, + "Quotas": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "Postgres", + "ConnectionString": "User ID=quotas;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;" + } + } + }, + "Devices": { + "Application": { + "DidDomainName": "localhost" + }, + "Infrastructure": { + "SqlDatabase": { + "Provider": "Postgres", + "ConnectionString": "User ID=devices;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;" + }, + "PushNotifications": { + "Providers": { + "dummy": { + "enabled": true + } + } + } + } + }, + "Files": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "Postgres", + "ConnectionString": "User ID=files;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;" + }, + "BlobStorage": { + "CloudProvider": "Azure", + "ConnectionInfo": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://localhost:10000/devstoreaccount1;" + } + } + }, + "Messages": { + "Application": { + "DidDomainName": "localhost" + }, + "Infrastructure": { + "SqlDatabase": { + "Provider": "Postgres", + "ConnectionString": "User ID=messages;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;" + } + } + }, + "Relationships": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "Postgres", + "ConnectionString": "User ID=relationships;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;" + } + } + }, + "Synchronization": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "Postgres", + "ConnectionString": "User ID=synchronization;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;" + } + } + }, + "Tokens": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "Postgres", + "ConnectionString": "User ID=tokens;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;" + } + } + } + }, + "Serilog": { + "MinimumLevel": { + "Default": "Debug" + }, + "Enrich": ["FromLogContext", "WithProcessId", "WithThreadId"], + "WriteTo": [ + { + "Name": "Console", + "Args": { + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff}|{Level} - CorrelationId:{CorrelationId} - RequestId:{RequestId} - RequestPath:{RequestPath}{NewLine} {SourceContext}{NewLine} {Message}{NewLine}{Exception}" + } + } + ] + } +} diff --git a/.ci/appsettings.override.sqlserver.json b/.ci/appsettings.override.sqlserver.docker.json similarity index 98% rename from .ci/appsettings.override.sqlserver.json rename to .ci/appsettings.override.sqlserver.docker.json index 4729176977..c0671695df 100644 --- a/.ci/appsettings.override.sqlserver.json +++ b/.ci/appsettings.override.sqlserver.docker.json @@ -4,17 +4,14 @@ }, "Authentication": { "ApiKey": "test", - "JwtSigningCertificate": "MIIJ7wIBAzCCCaUGCSqGSIb3DQEHAaCCCZYEggmSMIIJjjCCBAIGCSqGSIb3DQEHBqCCA/MwggPvAgEAMIID6AYJKoZIhvcNAQcBMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAiIVEGIEnzbyAICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEC1tOaulJJjkAl2W7xeF3G6AggOAm1VdXzAQ6MhHabp6+rzEuaAyBpuMi8zD8OEl8/xMv47UsFUor38aZjQd14qTTLz5MnksI/qgjQHLuMEmN1eWARsUBkeYvLuz0icl2q9A5Rn9CaKHIemQWq9mIobq3XnXhwDFEd+G/WgjNoK65Ndu20pnuc9LDlfq6fx2eXDbHAWLeUTnlQsEY4M/owNKIjlO/VsYJCshvEPlbtCnyzXwkrtQ5i2XufIJsfX0qoK/dXfoMVUjPxa/L8uR40bAWc1LVkvO0Ox4rY9VCtC1eHe3fcS48AaYCGRMpkZ7N+nDOb7lPs7BcxVoIrj/PkqiNI4rMOZVEgz21OWhueIjBv4gxfV+vW7IZ7xWvC1uUYIKEKEl6mk8KJ5zruO3tObX70+4saBiTNd/76+CVR4qCSwYcD7bZjpMOiaVFyxy0ay3dCwoivLK1jWNFJ25tngYpXKGCtOP0/Zi1fyseo4C54Ef5Yoo+BG3bkKR9VHChWzbB+b1p2lOwfBWIWlGjoZ+expyBjnk+FWrFDZeMknpW3PANCtcT/zqzqPKG3g4DAnSx9xDqvR7GBEgUlaUBAsCM3NvbahzevFFNE21aVajmTpSdejqvgNgvHPHA+BHfhMYx3mcMEkZ+phEHrWRSg925Iy64afL9/XvxoB/uFOYta/ir4ZqCbOy+yrc4+ppQlvLEIUnL4BGWcZ7d2NNRHWOHg0UqzxakezWhoGh1DDWfNdEj+eoa8DTvQr9hX0DQljym1I51qYdrv18rSf+MQj9jhBgQ77WBCX4sDkj4W9d7kKah8Fa0v+4bB1CqrETAsCESvBzSNyYEXKpyjdR/m8w/dti13Kz9ptvi8zd70tcqsqjaB3Qaz3gZRzRlPJORrg2cjWm+xLTOIQ+thk+O3U7l5R47h7QT44eSroKmX8Ptt/wkn9HRcI9bjylzrjTFw45/Re61RpHm3+NXUfvTPLaaXYSolldAgYN1gq+yYZJvBViWQB7gE05fpph6t6DYhEr2VtkLljxDclRPF14AKZaQCIndTiUX69eQfIpD4edHyBvFWSkf+fC1whOE/tqKY0vDflhBDrWFsvDwnEo0iYy671nu19RnBnZws0vseJeikQdCWBY6m0Wq7oViCyFCWyJPDukz3E9uCRrckki2i5+V2MM2IMtgImVFvRqaRbi7vF+Qjccs9Ri0+evcsc9dWjsnHkwggWEBgkqhkiG9w0BBwGgggV1BIIFcTCCBW0wggVpBgsqhkiG9w0BDAoBAqCCBTEwggUtMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAj06Hc+Gh2z5wICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEOwPSnf4F479I2AKr8i0TLYEggTQFtwGZHL6BF2++nDi2EAjc7XXIxp0u4qM17eZjafdltFpketf6pQCD/hDry+mVeIapTY9hOPE5XdjdFoJtOZPZHfvrrb0Jn+rgGAPYGBzqGK4NPVWHiDZ3uA4R4Tiwhgqd/ZQIdRshUEPVfu4EzTIAEhmHl+1g8JiD8EcYAXO1IRCLm17IsIYXT6d8cYe3Zy3AgULsF0/OwQIPVqaJCIwPR3qw68GXNA4iWWHuXJhdtrqHrGrkfBRuZZ5+7R838RM9Bk+ljWphidPmIFZmhjACt/c1qorGPhQTil0WT9VU9rN/gJ1rKcu3RQ1TRJDTjZYaPSMu9ycvFLpsP8XBJUpfHnczPS25bclKaJRUvou6aiwtyQsqWCDLGRuwN06Oins28R5/QQNYbcOr77WBlgh28K1TLcnQopE9xp12XBj8iOeUlVMiMVlph02TrGMXOqU0rlRpsYECMSfHw4xdH87GBUxmE4ndE7JI7wu73MsHQ+3kDTTvGG6xzY6rbNg+V6CfOZc102645sJskdCD6ygzUfgDwDcxjyky2u86qBFR/9d3M7Vh+PQpijYxQ/w4FzwgHUPII+JqqY8secPSA64L8qXj4daG74Wc3y+veajJzkFBUiaJnCER1WEJf0b4eBAEG1gaJ/B2hrp+lEd30qbE//iJWna5gYboIzMENfJ4RsqxlW4hZs6aqBuDr8QXL1chc11g0nMY9sI0kZVwF8+13eFh4ypt4H34usOiWHft2eeA/Z2h8agrT8UFkRfy3/1dGoNwqicXgqY3MgoxqlfDQ6hjPkO5JAbRc0cuZQMPu38dO66+qoI/Db4zdo+8G6sXOgZkzduQlARhx6VORq2QFoufsyqXvsUWFWSXEOjWLbLwKK5og8sV4OmWXGRPbTo+Hc3pmmuYcpEwtH6wFCb0vXVeOhSd7GX8Yv2V0yVt19IjgUGtukVWt9DUe6uImzsPm9ZdivWUB3RlKYRGpS16yhG0ZdRwBJweDoitK091ooN6Um74eO17dH0jAQw3XPBxgJ64qEdSzfJ/xybM45BSUPAft2wXXlckLOId9Us56oV7WeszTOkOPDKz9GnKT05xPXNDgAqstVZc0nXEq0eFzTORREBP0w2ijwPu9mfPvRACY8p7YMnNbZzMGBvpa3ILezRIgThMbnzf+YiBP2Ddt9bWoxDsIj7jaqDzxjG2WtI1qGEqFyLCeUkSx2UpkbGViCkx8CsMwXJwLrYdoxqjyOg2Oz09EFF5eI1wkLqEtez8dOTLEn7oFjTyFbRkNoynuwvNqHEG2qzbw02Rb82qyrurKmOnNHog7FXLDe0kGFgKuNXbCw+to2lAhWY0CmEe8qfQLeAiV3TsGHSrGSkoegmfPHsuboCdez/ETJZWoodryUPdY3PFNa0xZOJvbtkiG2Vo55Rjq9wbd+MWAGcxhaCVEmEJ0UWWsn3Oe+h4mn3wT9+P+hkAR9duXT6tq+5DmKB2RD3fR3vIc4H5eLaIzOOmjSdfGFvIaj+06jS7SGicuKqF5ND4HPtXJrQgQUdO/gIHCkE9nn4hXCoz/bGkU4FN2WPz5TTMVsYuxMVp1I2UayoQppltkp3oaDb/S36FeO644d5zb7ARayF68NL5MrM/MRK24jhtx2WV4ZN9HIxJTAjBgkqhkiG9w0BCRUxFgQU/S6zDu6S3P4i1WdDz+j3esGxT4UwQTAxMA0GCWCGSAFlAwQCAQUABCCiOwVWGDHil8dA7XvoQNTLTJDm7EwdfGC4KJUV9smgUgQI4ZRrDNXXl8cCAggA", - "JwtLifetimeInSeconds": 300 + "JwtSigningCertificate": "MIIJ7wIBAzCCCaUGCSqGSIb3DQEHAaCCCZYEggmSMIIJjjCCBAIGCSqGSIb3DQEHBqCCA/MwggPvAgEAMIID6AYJKoZIhvcNAQcBMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAiIVEGIEnzbyAICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEC1tOaulJJjkAl2W7xeF3G6AggOAm1VdXzAQ6MhHabp6+rzEuaAyBpuMi8zD8OEl8/xMv47UsFUor38aZjQd14qTTLz5MnksI/qgjQHLuMEmN1eWARsUBkeYvLuz0icl2q9A5Rn9CaKHIemQWq9mIobq3XnXhwDFEd+G/WgjNoK65Ndu20pnuc9LDlfq6fx2eXDbHAWLeUTnlQsEY4M/owNKIjlO/VsYJCshvEPlbtCnyzXwkrtQ5i2XufIJsfX0qoK/dXfoMVUjPxa/L8uR40bAWc1LVkvO0Ox4rY9VCtC1eHe3fcS48AaYCGRMpkZ7N+nDOb7lPs7BcxVoIrj/PkqiNI4rMOZVEgz21OWhueIjBv4gxfV+vW7IZ7xWvC1uUYIKEKEl6mk8KJ5zruO3tObX70+4saBiTNd/76+CVR4qCSwYcD7bZjpMOiaVFyxy0ay3dCwoivLK1jWNFJ25tngYpXKGCtOP0/Zi1fyseo4C54Ef5Yoo+BG3bkKR9VHChWzbB+b1p2lOwfBWIWlGjoZ+expyBjnk+FWrFDZeMknpW3PANCtcT/zqzqPKG3g4DAnSx9xDqvR7GBEgUlaUBAsCM3NvbahzevFFNE21aVajmTpSdejqvgNgvHPHA+BHfhMYx3mcMEkZ+phEHrWRSg925Iy64afL9/XvxoB/uFOYta/ir4ZqCbOy+yrc4+ppQlvLEIUnL4BGWcZ7d2NNRHWOHg0UqzxakezWhoGh1DDWfNdEj+eoa8DTvQr9hX0DQljym1I51qYdrv18rSf+MQj9jhBgQ77WBCX4sDkj4W9d7kKah8Fa0v+4bB1CqrETAsCESvBzSNyYEXKpyjdR/m8w/dti13Kz9ptvi8zd70tcqsqjaB3Qaz3gZRzRlPJORrg2cjWm+xLTOIQ+thk+O3U7l5R47h7QT44eSroKmX8Ptt/wkn9HRcI9bjylzrjTFw45/Re61RpHm3+NXUfvTPLaaXYSolldAgYN1gq+yYZJvBViWQB7gE05fpph6t6DYhEr2VtkLljxDclRPF14AKZaQCIndTiUX69eQfIpD4edHyBvFWSkf+fC1whOE/tqKY0vDflhBDrWFsvDwnEo0iYy671nu19RnBnZws0vseJeikQdCWBY6m0Wq7oViCyFCWyJPDukz3E9uCRrckki2i5+V2MM2IMtgImVFvRqaRbi7vF+Qjccs9Ri0+evcsc9dWjsnHkwggWEBgkqhkiG9w0BBwGgggV1BIIFcTCCBW0wggVpBgsqhkiG9w0BDAoBAqCCBTEwggUtMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAj06Hc+Gh2z5wICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEOwPSnf4F479I2AKr8i0TLYEggTQFtwGZHL6BF2++nDi2EAjc7XXIxp0u4qM17eZjafdltFpketf6pQCD/hDry+mVeIapTY9hOPE5XdjdFoJtOZPZHfvrrb0Jn+rgGAPYGBzqGK4NPVWHiDZ3uA4R4Tiwhgqd/ZQIdRshUEPVfu4EzTIAEhmHl+1g8JiD8EcYAXO1IRCLm17IsIYXT6d8cYe3Zy3AgULsF0/OwQIPVqaJCIwPR3qw68GXNA4iWWHuXJhdtrqHrGrkfBRuZZ5+7R838RM9Bk+ljWphidPmIFZmhjACt/c1qorGPhQTil0WT9VU9rN/gJ1rKcu3RQ1TRJDTjZYaPSMu9ycvFLpsP8XBJUpfHnczPS25bclKaJRUvou6aiwtyQsqWCDLGRuwN06Oins28R5/QQNYbcOr77WBlgh28K1TLcnQopE9xp12XBj8iOeUlVMiMVlph02TrGMXOqU0rlRpsYECMSfHw4xdH87GBUxmE4ndE7JI7wu73MsHQ+3kDTTvGG6xzY6rbNg+V6CfOZc102645sJskdCD6ygzUfgDwDcxjyky2u86qBFR/9d3M7Vh+PQpijYxQ/w4FzwgHUPII+JqqY8secPSA64L8qXj4daG74Wc3y+veajJzkFBUiaJnCER1WEJf0b4eBAEG1gaJ/B2hrp+lEd30qbE//iJWna5gYboIzMENfJ4RsqxlW4hZs6aqBuDr8QXL1chc11g0nMY9sI0kZVwF8+13eFh4ypt4H34usOiWHft2eeA/Z2h8agrT8UFkRfy3/1dGoNwqicXgqY3MgoxqlfDQ6hjPkO5JAbRc0cuZQMPu38dO66+qoI/Db4zdo+8G6sXOgZkzduQlARhx6VORq2QFoufsyqXvsUWFWSXEOjWLbLwKK5og8sV4OmWXGRPbTo+Hc3pmmuYcpEwtH6wFCb0vXVeOhSd7GX8Yv2V0yVt19IjgUGtukVWt9DUe6uImzsPm9ZdivWUB3RlKYRGpS16yhG0ZdRwBJweDoitK091ooN6Um74eO17dH0jAQw3XPBxgJ64qEdSzfJ/xybM45BSUPAft2wXXlckLOId9Us56oV7WeszTOkOPDKz9GnKT05xPXNDgAqstVZc0nXEq0eFzTORREBP0w2ijwPu9mfPvRACY8p7YMnNbZzMGBvpa3ILezRIgThMbnzf+YiBP2Ddt9bWoxDsIj7jaqDzxjG2WtI1qGEqFyLCeUkSx2UpkbGViCkx8CsMwXJwLrYdoxqjyOg2Oz09EFF5eI1wkLqEtez8dOTLEn7oFjTyFbRkNoynuwvNqHEG2qzbw02Rb82qyrurKmOnNHog7FXLDe0kGFgKuNXbCw+to2lAhWY0CmEe8qfQLeAiV3TsGHSrGSkoegmfPHsuboCdez/ETJZWoodryUPdY3PFNa0xZOJvbtkiG2Vo55Rjq9wbd+MWAGcxhaCVEmEJ0UWWsn3Oe+h4mn3wT9+P+hkAR9duXT6tq+5DmKB2RD3fR3vIc4H5eLaIzOOmjSdfGFvIaj+06jS7SGicuKqF5ND4HPtXJrQgQUdO/gIHCkE9nn4hXCoz/bGkU4FN2WPz5TTMVsYuxMVp1I2UayoQppltkp3oaDb/S36FeO644d5zb7ARayF68NL5MrM/MRK24jhtx2WV4ZN9HIxJTAjBgkqhkiG9w0BCRUxFgQU/S6zDu6S3P4i1WdDz+j3esGxT4UwQTAxMA0GCWCGSAFlAwQCAQUABCCiOwVWGDHil8dA7XvoQNTLTJDm7EwdfGC4KJUV9smgUgQI4ZRrDNXXl8cCAggA" }, "Infrastructure": { "EventBus": { "Vendor": "RabbitMQ", "ConnectionInfo": "rabbitmq", - "RabbitMQUsername": "guest", - "RabbitMQPassword": "guest", - "ConnectionRetryCount": 5 + "RabbitMQPassword": "guest" }, "SqlDatabase": { "Provider": "SqlServer", diff --git a/.ci/appsettings.override.sqlserver.local.json b/.ci/appsettings.override.sqlserver.local.json new file mode 100644 index 0000000000..4a2b8120fe --- /dev/null +++ b/.ci/appsettings.override.sqlserver.local.json @@ -0,0 +1,118 @@ +{ + "Cors": { + "AccessControlAllowCredentials": true + }, + "Authentication": { + "ApiKey": "test", + "JwtSigningCertificate": "MIIJ7wIBAzCCCaUGCSqGSIb3DQEHAaCCCZYEggmSMIIJjjCCBAIGCSqGSIb3DQEHBqCCA/MwggPvAgEAMIID6AYJKoZIhvcNAQcBMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAiIVEGIEnzbyAICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEC1tOaulJJjkAl2W7xeF3G6AggOAm1VdXzAQ6MhHabp6+rzEuaAyBpuMi8zD8OEl8/xMv47UsFUor38aZjQd14qTTLz5MnksI/qgjQHLuMEmN1eWARsUBkeYvLuz0icl2q9A5Rn9CaKHIemQWq9mIobq3XnXhwDFEd+G/WgjNoK65Ndu20pnuc9LDlfq6fx2eXDbHAWLeUTnlQsEY4M/owNKIjlO/VsYJCshvEPlbtCnyzXwkrtQ5i2XufIJsfX0qoK/dXfoMVUjPxa/L8uR40bAWc1LVkvO0Ox4rY9VCtC1eHe3fcS48AaYCGRMpkZ7N+nDOb7lPs7BcxVoIrj/PkqiNI4rMOZVEgz21OWhueIjBv4gxfV+vW7IZ7xWvC1uUYIKEKEl6mk8KJ5zruO3tObX70+4saBiTNd/76+CVR4qCSwYcD7bZjpMOiaVFyxy0ay3dCwoivLK1jWNFJ25tngYpXKGCtOP0/Zi1fyseo4C54Ef5Yoo+BG3bkKR9VHChWzbB+b1p2lOwfBWIWlGjoZ+expyBjnk+FWrFDZeMknpW3PANCtcT/zqzqPKG3g4DAnSx9xDqvR7GBEgUlaUBAsCM3NvbahzevFFNE21aVajmTpSdejqvgNgvHPHA+BHfhMYx3mcMEkZ+phEHrWRSg925Iy64afL9/XvxoB/uFOYta/ir4ZqCbOy+yrc4+ppQlvLEIUnL4BGWcZ7d2NNRHWOHg0UqzxakezWhoGh1DDWfNdEj+eoa8DTvQr9hX0DQljym1I51qYdrv18rSf+MQj9jhBgQ77WBCX4sDkj4W9d7kKah8Fa0v+4bB1CqrETAsCESvBzSNyYEXKpyjdR/m8w/dti13Kz9ptvi8zd70tcqsqjaB3Qaz3gZRzRlPJORrg2cjWm+xLTOIQ+thk+O3U7l5R47h7QT44eSroKmX8Ptt/wkn9HRcI9bjylzrjTFw45/Re61RpHm3+NXUfvTPLaaXYSolldAgYN1gq+yYZJvBViWQB7gE05fpph6t6DYhEr2VtkLljxDclRPF14AKZaQCIndTiUX69eQfIpD4edHyBvFWSkf+fC1whOE/tqKY0vDflhBDrWFsvDwnEo0iYy671nu19RnBnZws0vseJeikQdCWBY6m0Wq7oViCyFCWyJPDukz3E9uCRrckki2i5+V2MM2IMtgImVFvRqaRbi7vF+Qjccs9Ri0+evcsc9dWjsnHkwggWEBgkqhkiG9w0BBwGgggV1BIIFcTCCBW0wggVpBgsqhkiG9w0BDAoBAqCCBTEwggUtMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAj06Hc+Gh2z5wICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEOwPSnf4F479I2AKr8i0TLYEggTQFtwGZHL6BF2++nDi2EAjc7XXIxp0u4qM17eZjafdltFpketf6pQCD/hDry+mVeIapTY9hOPE5XdjdFoJtOZPZHfvrrb0Jn+rgGAPYGBzqGK4NPVWHiDZ3uA4R4Tiwhgqd/ZQIdRshUEPVfu4EzTIAEhmHl+1g8JiD8EcYAXO1IRCLm17IsIYXT6d8cYe3Zy3AgULsF0/OwQIPVqaJCIwPR3qw68GXNA4iWWHuXJhdtrqHrGrkfBRuZZ5+7R838RM9Bk+ljWphidPmIFZmhjACt/c1qorGPhQTil0WT9VU9rN/gJ1rKcu3RQ1TRJDTjZYaPSMu9ycvFLpsP8XBJUpfHnczPS25bclKaJRUvou6aiwtyQsqWCDLGRuwN06Oins28R5/QQNYbcOr77WBlgh28K1TLcnQopE9xp12XBj8iOeUlVMiMVlph02TrGMXOqU0rlRpsYECMSfHw4xdH87GBUxmE4ndE7JI7wu73MsHQ+3kDTTvGG6xzY6rbNg+V6CfOZc102645sJskdCD6ygzUfgDwDcxjyky2u86qBFR/9d3M7Vh+PQpijYxQ/w4FzwgHUPII+JqqY8secPSA64L8qXj4daG74Wc3y+veajJzkFBUiaJnCER1WEJf0b4eBAEG1gaJ/B2hrp+lEd30qbE//iJWna5gYboIzMENfJ4RsqxlW4hZs6aqBuDr8QXL1chc11g0nMY9sI0kZVwF8+13eFh4ypt4H34usOiWHft2eeA/Z2h8agrT8UFkRfy3/1dGoNwqicXgqY3MgoxqlfDQ6hjPkO5JAbRc0cuZQMPu38dO66+qoI/Db4zdo+8G6sXOgZkzduQlARhx6VORq2QFoufsyqXvsUWFWSXEOjWLbLwKK5og8sV4OmWXGRPbTo+Hc3pmmuYcpEwtH6wFCb0vXVeOhSd7GX8Yv2V0yVt19IjgUGtukVWt9DUe6uImzsPm9ZdivWUB3RlKYRGpS16yhG0ZdRwBJweDoitK091ooN6Um74eO17dH0jAQw3XPBxgJ64qEdSzfJ/xybM45BSUPAft2wXXlckLOId9Us56oV7WeszTOkOPDKz9GnKT05xPXNDgAqstVZc0nXEq0eFzTORREBP0w2ijwPu9mfPvRACY8p7YMnNbZzMGBvpa3ILezRIgThMbnzf+YiBP2Ddt9bWoxDsIj7jaqDzxjG2WtI1qGEqFyLCeUkSx2UpkbGViCkx8CsMwXJwLrYdoxqjyOg2Oz09EFF5eI1wkLqEtez8dOTLEn7oFjTyFbRkNoynuwvNqHEG2qzbw02Rb82qyrurKmOnNHog7FXLDe0kGFgKuNXbCw+to2lAhWY0CmEe8qfQLeAiV3TsGHSrGSkoegmfPHsuboCdez/ETJZWoodryUPdY3PFNa0xZOJvbtkiG2Vo55Rjq9wbd+MWAGcxhaCVEmEJ0UWWsn3Oe+h4mn3wT9+P+hkAR9duXT6tq+5DmKB2RD3fR3vIc4H5eLaIzOOmjSdfGFvIaj+06jS7SGicuKqF5ND4HPtXJrQgQUdO/gIHCkE9nn4hXCoz/bGkU4FN2WPz5TTMVsYuxMVp1I2UayoQppltkp3oaDb/S36FeO644d5zb7ARayF68NL5MrM/MRK24jhtx2WV4ZN9HIxJTAjBgkqhkiG9w0BCRUxFgQU/S6zDu6S3P4i1WdDz+j3esGxT4UwQTAxMA0GCWCGSAFlAwQCAQUABCCiOwVWGDHil8dA7XvoQNTLTJDm7EwdfGC4KJUV9smgUgQI4ZRrDNXXl8cCAggA" + }, + "Infrastructure": { + "EventBus": { + "Vendor": "RabbitMQ", + "ConnectionInfo": "localhost", + "RabbitMQUsername": "guest", + "RabbitMQPassword": "guest" + }, + "SqlDatabase": { + "Provider": "SqlServer", + "ConnectionString": "Server=localhost;Database=enmeshed;User Id=adminUi;Password=Passw0rd;TrustServerCertificate=True" + } + }, + "Modules": { + "Challenges": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "SqlServer", + "ConnectionString": "Server=localhost;Database=enmeshed;User Id=challenges;Password=Passw0rd;TrustServerCertificate=True" + } + } + }, + "Quotas": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "SqlServer", + "ConnectionString": "Server=localhost;Database=enmeshed;User Id=quotas;Password=Passw0rd;TrustServerCertificate=True" + } + } + }, + "Devices": { + "Application": { + "DidDomainName": "localhost" + }, + "Infrastructure": { + "SqlDatabase": { + "Provider": "SqlServer", + "ConnectionString": "Server=localhost;Database=enmeshed;User Id=devices;Password=Passw0rd;TrustServerCertificate=True" + }, + "PushNotifications": { + "Providers": { + "dummy": { + "enabled": true + } + } + } + } + }, + "Files": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "SqlServer", + "ConnectionString": "Server=localhost;Database=enmeshed;User Id=files;Password=Passw0rd;TrustServerCertificate=True" + }, + "BlobStorage": { + "CloudProvider": "Azure", + "ConnectionInfo": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://localhost:10000/devstoreaccount1;" + } + } + }, + "Messages": { + "Application": { + "DidDomainName": "localhost" + }, + "Infrastructure": { + "SqlDatabase": { + "Provider": "SqlServer", + "ConnectionString": "Server=localhost;Database=enmeshed;User Id=messages;Password=Passw0rd;TrustServerCertificate=True" + } + } + }, + "Relationships": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "SqlServer", + "ConnectionString": "Server=localhost;Database=enmeshed;User Id=relationships;Password=Passw0rd;TrustServerCertificate=True" + } + } + }, + "Synchronization": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "SqlServer", + "ConnectionString": "Server=localhost;Database=enmeshed;User Id=synchronization;Password=Passw0rd;TrustServerCertificate=True" + } + } + }, + "Tokens": { + "Infrastructure": { + "SqlDatabase": { + "Provider": "SqlServer", + "ConnectionString": "Server=localhost;Database=enmeshed;User Id=tokens;Password=Passw0rd;TrustServerCertificate=True" + } + } + } + }, + "Serilog": { + "MinimumLevel": { + "Default": "Debug" + }, + "Enrich": ["FromLogContext", "WithProcessId", "WithThreadId"], + "WriteTo": [ + { + "Name": "Console", + "Args": { + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff}|{Level} - CorrelationId:{CorrelationId} - RequestId:{RequestId} - RequestPath:{RequestPath}{NewLine} {SourceContext}{NewLine} {Message}{NewLine}{Exception}" + } + } + ] + } +} diff --git a/.ci/docker-compose.test.postgres.yml b/.ci/docker-compose.test.postgres.yml index 3f3a183907..65149755dc 100644 --- a/.ci/docker-compose.test.postgres.yml +++ b/.ci/docker-compose.test.postgres.yml @@ -36,7 +36,7 @@ services: configs: Config: - file: appsettings.override.postgres.json + file: appsettings.override.postgres.docker.json networks: default: diff --git a/.ci/docker-compose.test.sqlserver.yml b/.ci/docker-compose.test.sqlserver.yml index 5fa2f2066b..dd06c1754e 100644 --- a/.ci/docker-compose.test.sqlserver.yml +++ b/.ci/docker-compose.test.sqlserver.yml @@ -35,7 +35,7 @@ services: configs: Config: - file: appsettings.override.sqlserver.json + file: appsettings.override.sqlserver.docker.json networks: default: diff --git a/.ci/integrationTest.postgres.sh b/.ci/integrationTest.postgres.sh index 32f2dedbb6..136e1f99fa 100755 --- a/.ci/integrationTest.postgres.sh +++ b/.ci/integrationTest.postgres.sh @@ -21,3 +21,6 @@ export ADMIN_API_BASE_ADDRESS="http://localhost:5173" dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration.csproj dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ConsumerApi.Tests.Integration +mv ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak +cp ./.ci/appsettings.override.postgres.local.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json +dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ConsumerApi.Tests.Integration diff --git a/.ci/integrationTest.sqlserver.sh b/.ci/integrationTest.sqlserver.sh index f04d8ef948..587d9f4331 100755 --- a/.ci/integrationTest.sqlserver.sh +++ b/.ci/integrationTest.sqlserver.sh @@ -21,3 +21,6 @@ export ADMIN_API_BASE_ADDRESS="http://localhost:5173" dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration.csproj dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ConsumerApi.Tests.Integration +mv ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak +cp ./.ci/appsettings.override.sqlserver.local.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json +dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ConsumerApi.Tests.Integration From 8a040ccb9ed230bac98ad7bdc51789e85c8a5856 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Thu, 4 Jul 2024 08:13:48 +0200 Subject: [PATCH 035/105] ci: replace deprecated env var of docker/build-push-action --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2bad7a6b7b..f4b4cf2453 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -166,7 +166,7 @@ jobs: - name: Build Image uses: docker/build-push-action@v6 env: - DOCKER_BUILD_NO_SUMMARY: true + DOCKER_BUILD_SUMMARY: false with: context: . file: ${{ matrix.dockerfile }} From 08ffb8892dd14df71f51187b91240f59748a3833 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Thu, 4 Jul 2024 08:17:00 +0200 Subject: [PATCH 036/105] ci: fix integrationTest scripts and run job tests first --- .ci/integrationTest.postgres.sh | 8 ++++---- .ci/integrationTest.sqlserver.sh | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.ci/integrationTest.postgres.sh b/.ci/integrationTest.postgres.sh index 136e1f99fa..124a93f391 100755 --- a/.ci/integrationTest.postgres.sh +++ b/.ci/integrationTest.postgres.sh @@ -18,9 +18,9 @@ wait export CONSUMER_API_BASE_ADDRESS="http://localhost:5000" export ADMIN_API_BASE_ADDRESS="http://localhost:5173" -dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration.csproj +dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ConsumerApi.Tests.Integration -mv ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak -cp ./.ci/appsettings.override.postgres.local.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json -dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ConsumerApi.Tests.Integration +mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak +cp .ci/appsettings.override.postgres.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json +dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" Jobs/test/Job.IdentityDeletion.Tests.Integration diff --git a/.ci/integrationTest.sqlserver.sh b/.ci/integrationTest.sqlserver.sh index 587d9f4331..d679344821 100755 --- a/.ci/integrationTest.sqlserver.sh +++ b/.ci/integrationTest.sqlserver.sh @@ -18,9 +18,9 @@ wait export CONSUMER_API_BASE_ADDRESS="http://localhost:5000" export ADMIN_API_BASE_ADDRESS="http://localhost:5173" -dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration.csproj -dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ConsumerApi.Tests.Integration +mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak +cp .ci/appsettings.override.sqlserver.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json +dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" Jobs/test/Job.IdentityDeletion.Tests.Integration -mv ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak -cp ./.ci/appsettings.override.sqlserver.local.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json +dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration.csproj dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ConsumerApi.Tests.Integration From 1f691d9224b03bfbdf2ca3ff6dff4e33f820fba7 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Thu, 4 Jul 2024 08:30:45 +0200 Subject: [PATCH 037/105] ci: replace configuration before build --- .ci/integrationTest.postgres.sh | 5 ++--- .ci/integrationTest.sqlserver.sh | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.ci/integrationTest.postgres.sh b/.ci/integrationTest.postgres.sh index 124a93f391..e1a2c9f0ad 100755 --- a/.ci/integrationTest.postgres.sh +++ b/.ci/integrationTest.postgres.sh @@ -10,6 +10,8 @@ dockerCompose() { dockerCompose up -d --no-build } & { + mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak + cp .ci/appsettings.override.postgres.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json dotnet restore "Backbone.sln"; dotnet build --no-restore "Backbone.sln" } @@ -20,7 +22,4 @@ export ADMIN_API_BASE_ADDRESS="http://localhost:5173" dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ConsumerApi.Tests.Integration - -mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak -cp .ci/appsettings.override.postgres.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" Jobs/test/Job.IdentityDeletion.Tests.Integration diff --git a/.ci/integrationTest.sqlserver.sh b/.ci/integrationTest.sqlserver.sh index d679344821..1453b23a74 100755 --- a/.ci/integrationTest.sqlserver.sh +++ b/.ci/integrationTest.sqlserver.sh @@ -10,6 +10,8 @@ dockerCompose() { dockerCompose up -d --no-build } & { + mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak + cp .ci/appsettings.override.sqlserver.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json dotnet restore "Backbone.sln"; dotnet build --no-restore "Backbone.sln" } @@ -18,8 +20,6 @@ wait export CONSUMER_API_BASE_ADDRESS="http://localhost:5000" export ADMIN_API_BASE_ADDRESS="http://localhost:5173" -mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak -cp .ci/appsettings.override.sqlserver.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" Jobs/test/Job.IdentityDeletion.Tests.Integration dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration.csproj From 7d4d6360fd4bacede7b70cc86696cd122c8de6ab Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Thu, 4 Jul 2024 08:40:00 +0200 Subject: [PATCH 038/105] ci: fix test location --- .ci/integrationTest.postgres.sh | 2 +- .ci/integrationTest.sqlserver.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.ci/integrationTest.postgres.sh b/.ci/integrationTest.postgres.sh index e1a2c9f0ad..cd3edf5949 100755 --- a/.ci/integrationTest.postgres.sh +++ b/.ci/integrationTest.postgres.sh @@ -20,6 +20,6 @@ wait export CONSUMER_API_BASE_ADDRESS="http://localhost:5000" export ADMIN_API_BASE_ADDRESS="http://localhost:5173" +dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" Jobs/test/Job.IdentityDeletion.Tests.Integration dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ConsumerApi.Tests.Integration -dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" Jobs/test/Job.IdentityDeletion.Tests.Integration diff --git a/.ci/integrationTest.sqlserver.sh b/.ci/integrationTest.sqlserver.sh index 1453b23a74..c3c458597b 100755 --- a/.ci/integrationTest.sqlserver.sh +++ b/.ci/integrationTest.sqlserver.sh @@ -21,6 +21,5 @@ export CONSUMER_API_BASE_ADDRESS="http://localhost:5000" export ADMIN_API_BASE_ADDRESS="http://localhost:5173" dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" Jobs/test/Job.IdentityDeletion.Tests.Integration - -dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration.csproj +dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ConsumerApi.Tests.Integration From c354092aff1047c85c2532c90d001aa8aebdef24 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Thu, 4 Jul 2024 08:56:34 +0200 Subject: [PATCH 039/105] ci: remove unnecessary installation of script dependencies --- .github/workflows/test.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f4b4cf2453..a2e21e5121 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -51,8 +51,6 @@ jobs: key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-npm- - - name: Install script dependencies - run: npm install --prefix ./.ci - name: Setup dotnet uses: actions/setup-dotnet@v4 with: @@ -85,8 +83,6 @@ jobs: key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-npm- - - name: Install script dependencies - run: npm install --prefix ./.ci - name: Setup dotnet uses: actions/setup-dotnet@v4 with: @@ -160,9 +156,6 @@ jobs: restore-keys: | buildx-${{ matrix.image }}-cache- - - name: Install script dependencies - run: npm install --prefix ./.ci - - name: Build Image uses: docker/build-push-action@v6 env: @@ -209,9 +202,6 @@ jobs: with: dotnet-version: 8.x - - name: Install script dependencies - run: npm install --prefix ./.ci - - name: Download cached Docker images uses: actions/download-artifact@v4 with: @@ -257,9 +247,6 @@ jobs: with: dotnet-version: 8.x - - name: Install script dependencies - run: npm install --prefix ./.ci - - name: Download cached Docker images uses: actions/download-artifact@v4 with: From 853acbf74bc95ec7570cd0c42f6ce99184ee527c Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Thu, 4 Jul 2024 12:07:12 +0200 Subject: [PATCH 040/105] test: do not migrate in ActualDeletionWorkerTests --- .../ActualDeletionWorkerTests.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/Jobs/test/Job.IdentityDeletion.Tests.Integration/ActualDeletionWorkerTests.cs b/Jobs/test/Job.IdentityDeletion.Tests.Integration/ActualDeletionWorkerTests.cs index 9a121b1ee9..feec3cbfec 100644 --- a/Jobs/test/Job.IdentityDeletion.Tests.Integration/ActualDeletionWorkerTests.cs +++ b/Jobs/test/Job.IdentityDeletion.Tests.Integration/ActualDeletionWorkerTests.cs @@ -27,9 +27,6 @@ public ActualDeletionWorkerTests() var hostBuilder = Program.CreateHostBuilder(["--Worker", "ActualDeletionWorker"]); _host = hostBuilder.Build(); - - GetService().Database.Migrate(); - GetService().Database.Migrate(); } [Fact] From 69666b6dc3f35a85dbcc80e3961cf36000a3c027 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Thu, 4 Jul 2024 13:09:31 +0200 Subject: [PATCH 041/105] ci: run integration tests in separate steps --- .ci/compose.test.aui.yml | 17 ++ .ci/compose.test.capi.yml | 19 ++ ...postgres.yml => compose.test.postgres.yml} | 0 ...lserver.yml => compose.test.sqlserver.yml} | 0 ...cker-compose.test.yml => compose.test.yml} | 36 ---- .github/workflows/test.yml | 162 +++++++++++++++--- 6 files changed, 175 insertions(+), 59 deletions(-) create mode 100644 .ci/compose.test.aui.yml create mode 100644 .ci/compose.test.capi.yml rename .ci/{docker-compose.test.postgres.yml => compose.test.postgres.yml} (100%) rename .ci/{docker-compose.test.sqlserver.yml => compose.test.sqlserver.yml} (100%) rename .ci/{docker-compose.test.yml => compose.test.yml} (66%) diff --git a/.ci/compose.test.aui.yml b/.ci/compose.test.aui.yml new file mode 100644 index 0000000000..c96e332e70 --- /dev/null +++ b/.ci/compose.test.aui.yml @@ -0,0 +1,17 @@ +services: + admin-ui: + container_name: admin-ui-test + hostname: admin-ui + image: admin-ui:0.0.1 + environment: + - ASPNETCORE_ENVIRONMENT=Development + ports: + - "5173:8080" + depends_on: + database-migrator: + condition: service_completed_successfully + rabbitmq: + condition: service_started + configs: + - source: Config + target: app/appsettings.override.json diff --git a/.ci/compose.test.capi.yml b/.ci/compose.test.capi.yml new file mode 100644 index 0000000000..62e1b3fc35 --- /dev/null +++ b/.ci/compose.test.capi.yml @@ -0,0 +1,19 @@ +services: + consumer-api: + container_name: consumer-api-test + hostname: consumer-api + image: consumer-api:0.0.1 + environment: + - ASPNETCORE_ENVIRONMENT=Development + ports: + - "5000:8080" + depends_on: + database-migrator: + condition: service_completed_successfully + rabbitmq: + condition: service_started + azure-storage-emulator: + condition: service_started + configs: + - source: Config + target: app/appsettings.override.json diff --git a/.ci/docker-compose.test.postgres.yml b/.ci/compose.test.postgres.yml similarity index 100% rename from .ci/docker-compose.test.postgres.yml rename to .ci/compose.test.postgres.yml diff --git a/.ci/docker-compose.test.sqlserver.yml b/.ci/compose.test.sqlserver.yml similarity index 100% rename from .ci/docker-compose.test.sqlserver.yml rename to .ci/compose.test.sqlserver.yml diff --git a/.ci/docker-compose.test.yml b/.ci/compose.test.yml similarity index 66% rename from .ci/docker-compose.test.yml rename to .ci/compose.test.yml index 391acf0b8f..e44fe35169 100644 --- a/.ci/docker-compose.test.yml +++ b/.ci/compose.test.yml @@ -1,40 +1,4 @@ services: - consumer-api: - container_name: consumer-api-test - hostname: consumer-api - image: consumer-api:0.0.1 - environment: - - ASPNETCORE_ENVIRONMENT=Development - ports: - - "5000:8080" - depends_on: - database-migrator: - condition: service_completed_successfully - rabbitmq: - condition: service_started - azure-storage-emulator: - condition: service_started - configs: - - source: Config - target: app/appsettings.override.json - - admin-ui: - container_name: admin-ui-test - hostname: admin-ui - image: admin-ui:0.0.1 - environment: - - ASPNETCORE_ENVIRONMENT=Development - ports: - - "5173:8080" - depends_on: - database-migrator: - condition: service_completed_successfully - rabbitmq: - condition: service_started - configs: - - source: Config - target: app/appsettings.override.json - event-handler-service: container_name: event-handler-service-test image: event-handler-service:0.0.1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a2e21e5121..abf6c1b4e8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -209,27 +209,85 @@ jobs: pattern: docker-* merge-multiple: true - - name: Load Docker images - run: ./.ci/loadDockerImages.sh + - name: Load Docker images and build test code + run: | + { + ./.ci/loadDockerImages.sh + } & + { + dotnet restore Backbone.sln; + dotnet build --no-restore Backbone.sln + } + wait + + #### Admin UI integration tests + + - name: Restart compose stack + id: restart-compose-stack-1 + run: | + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.aui.yml down -v; + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.aui.yml up -d --no-build - - name: Run integration tests - run: ./.ci/integrationTest.sqlserver.sh + - name: Run Admin UI integration tests + id: run-aui-integration-tests + if: (success() || failure()) && (steps.restart-compose-stack-1.outcome == 'success') + run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration + env: + ADMIN_API_BASE_ADDRESS: "http://localhost:5173" - name: Save Docker Logs - if: failure() - run: docker compose -f ./.ci/docker-compose.test.yml -f ./.ci/docker-compose.test.sqlserver.yml logs > docker-log.txt + if: (success() || failure()) && (steps.run-aui-integration-tests.outcome == 'failure') + run: docker compose -f ./.ci/compose.test.aui.yml logs > aui.integration-test.sqlserver.txt + + #### Consumer API integration tests + + - name: Restart compose stack + id: restart-compose-stack-2 + if: success() || failure() + run: | + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.capi.yml down -v; + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.capi.yml up -d --no-build + + - name: Run Consumer API integration tests + id: run-capi-integration-tests + if: (success() || failure()) && (steps.restart-compose-stack-2.outcome == 'success') + run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration + env: + CONSUMER_API_BASE_ADDRESS: "http://localhost:5000" + + - name: Save Docker Logs + if: (success() || failure()) && (steps.run-capi-integration-tests.outcome == 'failure') + run: docker compose -f ./.ci/compose.test.capi.yml logs > capi.integration-test.sqlserver.txt + + #### Identity Deletion Job integration tests + + - name: Restart compose stack + id: restart-compose-stack-3 + if: success() || failure() + run: | + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml down -v; + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml up -d --no-build + + - name: Run Identity Deletion Job integration tests + id: run-idj-integration-tests + if: (success() || failure()) && (steps.restart-compose-stack-3.outcome == 'success') + run: | + mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak + cp .ci/appsettings.override.postgres.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json + dotnet build --no-restore Jobs/test/Job.IdentityDeletion.Tests.Integration + dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" Jobs/test/Job.IdentityDeletion.Tests.Integration - name: Archive logs if: failure() uses: actions/upload-artifact@v4 with: - name: integration-test-sqlserver-docker-logs - path: docker-log.txt + name: aui.integration-test.sqlserver + path: capi.integration-test.sqlserver.txt env: DOTNET_CONSOLE_ANSI_COLOR: true integration-test-postgres: - name: Run Integration Tests (on Postgres) + name: Run Integration Tests (on SQL Server) runs-on: ubuntu-latest needs: image-test-builds steps: @@ -254,22 +312,80 @@ jobs: pattern: docker-* merge-multiple: true - - name: Load Docker images - run: ./.ci/loadDockerImages.sh + - name: Load Docker images and build test code + run: | + { + ./.ci/loadDockerImages.sh + } & + { + dotnet restore Backbone.sln; + dotnet build --no-restore Backbone.sln + } + wait + + #### Admin UI integration tests + + - name: Restart compose stack + id: restart-compose-stack-1 + run: | + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.aui.yml down -v; + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.aui.yml up -d --no-build - - name: Run integration tests - run: ./.ci/integrationTest.postgres.sh + - name: Run Admin UI integration tests + id: run-aui-integration-tests + if: (success() || failure()) && (steps.restart-compose-stack-1.outcome == 'success') + run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration + env: + ADMIN_API_BASE_ADDRESS: "http://localhost:5173" - name: Save Docker Logs - if: failure() - run: docker compose -f ./.ci/docker-compose.test.yml -f ./.ci/docker-compose.test.postgres.yml logs > docker-log.txt + if: (success() || failure()) && (steps.run-aui-integration-tests.outcome == 'failure') + run: docker compose -f ./.ci/compose.test.aui.yml logs > aui.integration-test.postgres.txt + + #### Consumer API integration tests + + - name: Restart compose stack + id: restart-compose-stack-2 + if: success() || failure() + run: | + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.capi.yml down -v; + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.capi.yml up -d --no-build + + - name: Run Consumer API integration tests + id: run-capi-integration-tests + if: (success() || failure()) && (steps.restart-compose-stack-2.outcome == 'success') + run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration + env: + CONSUMER_API_BASE_ADDRESS: "http://localhost:5000" + + - name: Save Docker Logs + if: (success() || failure()) && (steps.run-capi-integration-tests.outcome == 'failure') + run: docker compose -f ./.ci/compose.test.capi.yml logs > capi.integration-test.postgres.txt + + #### Identity Deletion Job integration tests + + - name: Restart compose stack + id: restart-compose-stack-3 + if: success() || failure() + run: | + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml down -v; + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml up -d --no-build + + - name: Run Identity Deletion Job integration tests + id: run-idj-integration-tests + if: (success() || failure()) && (steps.restart-compose-stack-3.outcome == 'success') + run: | + mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak + cp .ci/appsettings.override.postgres.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json + dotnet build --no-restore Jobs/test/Job.IdentityDeletion.Tests.Integration + dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" Jobs/test/Job.IdentityDeletion.Tests.Integration - name: Archive logs if: failure() uses: actions/upload-artifact@v4 with: - name: integration-test-postgres-docker-logs - path: docker-log.txt + name: aui.integration-test.postgres + path: capi.integration-test.postgres.txt env: DOTNET_CONSOLE_ANSI_COLOR: true @@ -307,7 +423,7 @@ jobs: run: ./backbone/.ci/loadDockerImages.sh - name: Run Consumer API & Admin API - run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.sqlserver.yml up -d --no-build + run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.capi.yml up -d --no-build - name: Install runtime dependencies working-directory: ./runtime @@ -325,7 +441,7 @@ jobs: - name: Save Docker Logs if: failure() - run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.sqlserver.yml logs > docker-log.txt + run: docker compose -f ./.ci/compose.test.capi.yml logs > docker-log.txt - name: Archive logs if: failure() @@ -335,7 +451,7 @@ jobs: path: docker-log.txt - name: Stop Consumer API - run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.sqlserver.yml down + run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.capi.yml down transport-test-postgres: name: Run transport Tests (on Postgres) @@ -371,7 +487,7 @@ jobs: run: ./backbone/.ci/loadDockerImages.sh - name: Run Consumer API & Admin API - run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.postgres.yml up -d --no-build + run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.postgres.yml -f ./.ci/compose.test.capi.yml up -d --no-build - name: Install runtime dependencies working-directory: ./runtime @@ -389,7 +505,7 @@ jobs: - name: Save Docker Logs if: failure() - run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.postgres.yml logs > docker-log.txt + run: docker compose -f ./.ci/compose.test.capi.yml logs > docker-log.txt - name: Archive logs if: failure() @@ -399,7 +515,7 @@ jobs: path: docker-log.txt - name: Stop Consumer API - run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.postgres.yml down + run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.postgres.yml -f ./.ci/compose.test.capi.yml down build-helm-chart: name: Build Helm Chart From f2903fb5d354e927bcf0945901b3899cebef045c Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Thu, 4 Jul 2024 13:21:21 +0200 Subject: [PATCH 042/105] ci: fix path to compose.test.capi.yml in transport tests --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index abf6c1b4e8..b1daaa14db 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -423,7 +423,7 @@ jobs: run: ./backbone/.ci/loadDockerImages.sh - name: Run Consumer API & Admin API - run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.capi.yml up -d --no-build + run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.sqlserver.yml -f ./backbone/.ci/compose.test.capi.yml up -d --no-build - name: Install runtime dependencies working-directory: ./runtime @@ -451,7 +451,7 @@ jobs: path: docker-log.txt - name: Stop Consumer API - run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.capi.yml down + run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.sqlserver.yml -f ./backbone/.ci/compose.test.capi.yml down transport-test-postgres: name: Run transport Tests (on Postgres) @@ -487,7 +487,7 @@ jobs: run: ./backbone/.ci/loadDockerImages.sh - name: Run Consumer API & Admin API - run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.postgres.yml -f ./.ci/compose.test.capi.yml up -d --no-build + run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.postgres.yml -f ./backbone/.ci/compose.test.capi.yml up -d --no-build - name: Install runtime dependencies working-directory: ./runtime @@ -515,7 +515,7 @@ jobs: path: docker-log.txt - name: Stop Consumer API - run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.postgres.yml -f ./.ci/compose.test.capi.yml down + run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.postgres.yml -f ./backbone/.ci/compose.test.capi.yml down build-helm-chart: name: Build Helm Chart From 01f7afd2e624aa148c0d3ba358c77e82a4fb766c Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Thu, 4 Jul 2024 13:21:36 +0200 Subject: [PATCH 043/105] ci: remove dependency from admin-cli to consumer-api --- .ci/compose.test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.ci/compose.test.yml b/.ci/compose.test.yml index e44fe35169..e97c587b81 100644 --- a/.ci/compose.test.yml +++ b/.ci/compose.test.yml @@ -63,9 +63,6 @@ services: admin-cli: container_name: admin-cli-test image: admin-cli:0.0.1 - depends_on: - consumer-api: - condition: service_healthy command: backbone client create --clientId test --clientSecret test --defaultTier Basic networks: From 8f6ec6bc34e8ed512ed24eaa0e700d50be3c8591 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Thu, 4 Jul 2024 13:34:18 +0200 Subject: [PATCH 044/105] ci: add dependency from admin-cli to database-migrator --- .ci/compose.test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.ci/compose.test.yml b/.ci/compose.test.yml index e97c587b81..5a0a619a24 100644 --- a/.ci/compose.test.yml +++ b/.ci/compose.test.yml @@ -63,6 +63,9 @@ services: admin-cli: container_name: admin-cli-test image: admin-cli:0.0.1 + depends_on: + database-migrator: + condition: service_completed_successfully command: backbone client create --clientId test --clientSecret test --defaultTier Basic networks: From 265634627795b66c72fb50e2b825a8271b5b8806 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Thu, 4 Jul 2024 13:44:30 +0200 Subject: [PATCH 045/105] ci: fix path to compose.test.capi.yml in transport tests --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b1daaa14db..e78214fd5a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -441,7 +441,7 @@ jobs: - name: Save Docker Logs if: failure() - run: docker compose -f ./.ci/compose.test.capi.yml logs > docker-log.txt + run: docker compose -f ./backbone/.ci/compose.test.capi.yml logs > docker-log.txt - name: Archive logs if: failure() @@ -505,7 +505,7 @@ jobs: - name: Save Docker Logs if: failure() - run: docker compose -f ./.ci/compose.test.capi.yml logs > docker-log.txt + run: docker compose -f ./backbone/.ci/compose.test.capi.yml logs > docker-log.txt - name: Archive logs if: failure() From b260ed2219f32e78b8748cc0c59739f814f354d6 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Thu, 4 Jul 2024 14:04:55 +0200 Subject: [PATCH 046/105] ci: add --wait to docker compose up commands --- .github/workflows/test.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e78214fd5a..bb9e06d944 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -225,8 +225,8 @@ jobs: - name: Restart compose stack id: restart-compose-stack-1 run: | - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.aui.yml down -v; - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.aui.yml up -d --no-build + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.aui.yml down -v + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.aui.yml up --no-build --wait -d - name: Run Admin UI integration tests id: run-aui-integration-tests @@ -245,8 +245,8 @@ jobs: id: restart-compose-stack-2 if: success() || failure() run: | - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.capi.yml down -v; - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.capi.yml up -d --no-build + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.capi.yml down -v + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.capi.yml up --no-build --wait -d - name: Run Consumer API integration tests id: run-capi-integration-tests @@ -265,15 +265,15 @@ jobs: id: restart-compose-stack-3 if: success() || failure() run: | - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml down -v; - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml up -d --no-build + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml down -v + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml up --no-build --wait -d - name: Run Identity Deletion Job integration tests id: run-idj-integration-tests if: (success() || failure()) && (steps.restart-compose-stack-3.outcome == 'success') run: | mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak - cp .ci/appsettings.override.postgres.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json + cp .ci/appsettings.override.sqlserver.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json dotnet build --no-restore Jobs/test/Job.IdentityDeletion.Tests.Integration dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" Jobs/test/Job.IdentityDeletion.Tests.Integration @@ -328,8 +328,8 @@ jobs: - name: Restart compose stack id: restart-compose-stack-1 run: | - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.aui.yml down -v; - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.aui.yml up -d --no-build + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.aui.yml down -v + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.aui.yml up --no-build --wait -d - name: Run Admin UI integration tests id: run-aui-integration-tests @@ -348,8 +348,8 @@ jobs: id: restart-compose-stack-2 if: success() || failure() run: | - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.capi.yml down -v; - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.capi.yml up -d --no-build + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.capi.yml down -v + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.capi.yml up --no-build --wait -d - name: Run Consumer API integration tests id: run-capi-integration-tests @@ -368,8 +368,8 @@ jobs: id: restart-compose-stack-3 if: success() || failure() run: | - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml down -v; - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml up -d --no-build + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml down -v + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml up --no-build --wait -d - name: Run Identity Deletion Job integration tests id: run-idj-integration-tests @@ -423,7 +423,7 @@ jobs: run: ./backbone/.ci/loadDockerImages.sh - name: Run Consumer API & Admin API - run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.sqlserver.yml -f ./backbone/.ci/compose.test.capi.yml up -d --no-build + run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.sqlserver.yml -f ./backbone/.ci/compose.test.capi.yml up --no-build --wait -d - name: Install runtime dependencies working-directory: ./runtime @@ -487,7 +487,7 @@ jobs: run: ./backbone/.ci/loadDockerImages.sh - name: Run Consumer API & Admin API - run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.postgres.yml -f ./backbone/.ci/compose.test.capi.yml up -d --no-build + run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.postgres.yml -f ./backbone/.ci/compose.test.capi.yml up --no-build --wait -d - name: Install runtime dependencies working-directory: ./runtime From 7a82e4bc8d88c975337efbe7857818d5327d416a Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Thu, 4 Jul 2024 14:33:40 +0200 Subject: [PATCH 047/105] ci: try to use matrix build --- .github/workflows/test.yml | 69 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bb9e06d944..b6a6290b8e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -183,6 +183,75 @@ jobs: rm -rf /tmp/.buildx-${{ matrix.image }}-cache mv /tmp/.buildx-${{ matrix.image }}-cache-new /tmp/.buildx-${{ matrix.image }}-cache + integration-test: + name: Run ${{matrix.test-project}} on ${{matrix.database}} + runs-on: ubuntu-latest + strategy: + matrix: + database: [sqlserver, postgres] + test-project: + - name: AdminApi/test/AdminApi.Tests.Integration + additional-compose-files: -f ./.ci/compose.test.aui.yml + # - ConsumerApi.Tests.Integration + # - Job.IdentityDeletion.Tests.Integration + needs: image-test-builds + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: latest + cache: "npm" + cache-dependency-path: "**/package-lock.json" + + - name: Setup NuGet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.x + + - name: Download cached Docker images + uses: actions/download-artifact@v4 + with: + path: /tmp + pattern: docker-* + merge-multiple: true + + - name: Load Docker images and build test code + run: | + { + ./.ci/loadDockerImages.sh + } & + { + dotnet restore Backbone.sln + mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak + cp .ci/appsettings.override.sqlserver.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json + dotnet build --no-restore Backbone.sln + } + wait + + - name: Start compose stack + run: | + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml ${{matrix.test-project.additional-compose-files}} down -v + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml ${{matrix.test-project.additional-compose-files}} up --no-build --wait -d + + - name: Run integration tests + run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ${{matrix.test-project.name}} + env: + ADMIN_API_BASE_ADDRESS: "http://localhost:5173" + CONSUMER_API_BASE_ADDRESS: "http://localhost:5000" + + # - name: Save Docker Logs + # if: failure() + # run: docker compose -f ./.ci/compose.test.aui.yml logs > aui.integration-test.${{matrix.database}}.txt + + - name: Cache NuGet packages + uses: actions/cache@v4 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} + restore-keys: ${{ runner.os }}-nuget- + integration-test-sqlserver: name: Run Integration Tests (on SQL Server) runs-on: ubuntu-latest From 356c0b9544bd6e09ecd9babacc960537884f1b84 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Thu, 4 Jul 2024 14:35:22 +0200 Subject: [PATCH 048/105] ci: remove single integration tests --- .github/workflows/test.yml | 206 ------------------------------------- 1 file changed, 206 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b6a6290b8e..cc881ffe09 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -252,212 +252,6 @@ jobs: key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} restore-keys: ${{ runner.os }}-nuget- - integration-test-sqlserver: - name: Run Integration Tests (on SQL Server) - runs-on: ubuntu-latest - needs: image-test-builds - steps: - - name: Checkout - uses: actions/checkout@v4 - - - uses: actions/setup-node@v4 - with: - node-version: latest - cache: "npm" - cache-dependency-path: "**/package-lock.json" - - - name: Setup NuGet - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.x - - - name: Download cached Docker images - uses: actions/download-artifact@v4 - with: - path: /tmp - pattern: docker-* - merge-multiple: true - - - name: Load Docker images and build test code - run: | - { - ./.ci/loadDockerImages.sh - } & - { - dotnet restore Backbone.sln; - dotnet build --no-restore Backbone.sln - } - wait - - #### Admin UI integration tests - - - name: Restart compose stack - id: restart-compose-stack-1 - run: | - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.aui.yml down -v - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.aui.yml up --no-build --wait -d - - - name: Run Admin UI integration tests - id: run-aui-integration-tests - if: (success() || failure()) && (steps.restart-compose-stack-1.outcome == 'success') - run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration - env: - ADMIN_API_BASE_ADDRESS: "http://localhost:5173" - - - name: Save Docker Logs - if: (success() || failure()) && (steps.run-aui-integration-tests.outcome == 'failure') - run: docker compose -f ./.ci/compose.test.aui.yml logs > aui.integration-test.sqlserver.txt - - #### Consumer API integration tests - - - name: Restart compose stack - id: restart-compose-stack-2 - if: success() || failure() - run: | - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.capi.yml down -v - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml -f ./.ci/compose.test.capi.yml up --no-build --wait -d - - - name: Run Consumer API integration tests - id: run-capi-integration-tests - if: (success() || failure()) && (steps.restart-compose-stack-2.outcome == 'success') - run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration - env: - CONSUMER_API_BASE_ADDRESS: "http://localhost:5000" - - - name: Save Docker Logs - if: (success() || failure()) && (steps.run-capi-integration-tests.outcome == 'failure') - run: docker compose -f ./.ci/compose.test.capi.yml logs > capi.integration-test.sqlserver.txt - - #### Identity Deletion Job integration tests - - - name: Restart compose stack - id: restart-compose-stack-3 - if: success() || failure() - run: | - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml down -v - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.sqlserver.yml up --no-build --wait -d - - - name: Run Identity Deletion Job integration tests - id: run-idj-integration-tests - if: (success() || failure()) && (steps.restart-compose-stack-3.outcome == 'success') - run: | - mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak - cp .ci/appsettings.override.sqlserver.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json - dotnet build --no-restore Jobs/test/Job.IdentityDeletion.Tests.Integration - dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" Jobs/test/Job.IdentityDeletion.Tests.Integration - - - name: Archive logs - if: failure() - uses: actions/upload-artifact@v4 - with: - name: aui.integration-test.sqlserver - path: capi.integration-test.sqlserver.txt - env: - DOTNET_CONSOLE_ANSI_COLOR: true - - integration-test-postgres: - name: Run Integration Tests (on SQL Server) - runs-on: ubuntu-latest - needs: image-test-builds - steps: - - name: Checkout - uses: actions/checkout@v4 - - - uses: actions/setup-node@v4 - with: - node-version: latest - cache: "npm" - cache-dependency-path: "**/package-lock.json" - - - name: Setup NuGet - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.x - - - name: Download cached Docker images - uses: actions/download-artifact@v4 - with: - path: /tmp - pattern: docker-* - merge-multiple: true - - - name: Load Docker images and build test code - run: | - { - ./.ci/loadDockerImages.sh - } & - { - dotnet restore Backbone.sln; - dotnet build --no-restore Backbone.sln - } - wait - - #### Admin UI integration tests - - - name: Restart compose stack - id: restart-compose-stack-1 - run: | - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.aui.yml down -v - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.aui.yml up --no-build --wait -d - - - name: Run Admin UI integration tests - id: run-aui-integration-tests - if: (success() || failure()) && (steps.restart-compose-stack-1.outcome == 'success') - run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration - env: - ADMIN_API_BASE_ADDRESS: "http://localhost:5173" - - - name: Save Docker Logs - if: (success() || failure()) && (steps.run-aui-integration-tests.outcome == 'failure') - run: docker compose -f ./.ci/compose.test.aui.yml logs > aui.integration-test.postgres.txt - - #### Consumer API integration tests - - - name: Restart compose stack - id: restart-compose-stack-2 - if: success() || failure() - run: | - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.capi.yml down -v - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml -f ./.ci/compose.test.capi.yml up --no-build --wait -d - - - name: Run Consumer API integration tests - id: run-capi-integration-tests - if: (success() || failure()) && (steps.restart-compose-stack-2.outcome == 'success') - run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration - env: - CONSUMER_API_BASE_ADDRESS: "http://localhost:5000" - - - name: Save Docker Logs - if: (success() || failure()) && (steps.run-capi-integration-tests.outcome == 'failure') - run: docker compose -f ./.ci/compose.test.capi.yml logs > capi.integration-test.postgres.txt - - #### Identity Deletion Job integration tests - - - name: Restart compose stack - id: restart-compose-stack-3 - if: success() || failure() - run: | - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml down -v - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.postgres.yml up --no-build --wait -d - - - name: Run Identity Deletion Job integration tests - id: run-idj-integration-tests - if: (success() || failure()) && (steps.restart-compose-stack-3.outcome == 'success') - run: | - mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak - cp .ci/appsettings.override.postgres.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json - dotnet build --no-restore Jobs/test/Job.IdentityDeletion.Tests.Integration - dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" Jobs/test/Job.IdentityDeletion.Tests.Integration - - - name: Archive logs - if: failure() - uses: actions/upload-artifact@v4 - with: - name: aui.integration-test.postgres - path: capi.integration-test.postgres.txt - env: - DOTNET_CONSOLE_ANSI_COLOR: true - transport-test-sqlserver: name: Run transport Tests (on SQL Server) runs-on: ubuntu-latest From 37fcc9306657c015d67d8d0000623c9541f88560 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 10:23:16 +0200 Subject: [PATCH 049/105] ci: fix pipeline? --- .github/workflows/test.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cc881ffe09..183b81665d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -184,7 +184,7 @@ jobs: mv /tmp/.buildx-${{ matrix.image }}-cache-new /tmp/.buildx-${{ matrix.image }}-cache integration-test: - name: Run ${{matrix.test-project}} on ${{matrix.database}} + name: Run ${{matrix.test-project.name}} on ${{matrix.database}} runs-on: ubuntu-latest strategy: matrix: @@ -210,6 +210,13 @@ jobs: with: dotnet-version: 8.x + - name: Cache NuGet packages + uses: actions/cache@v4 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} + restore-keys: ${{ runner.os }}-nuget- + - name: Download cached Docker images uses: actions/download-artifact@v4 with: @@ -241,16 +248,9 @@ jobs: ADMIN_API_BASE_ADDRESS: "http://localhost:5173" CONSUMER_API_BASE_ADDRESS: "http://localhost:5000" - # - name: Save Docker Logs - # if: failure() - # run: docker compose -f ./.ci/compose.test.aui.yml logs > aui.integration-test.${{matrix.database}}.txt - - - name: Cache NuGet packages - uses: actions/cache@v4 - with: - path: ~/.nuget/packages - key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} - restore-keys: ${{ runner.os }}-nuget- + - name: Save Docker Logs + if: failure() + run: docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml ${{matrix.test-project.additional-compose-files}} logs > ${{matrix.test-project.name}}.${{matrix.database}}.txt transport-test-sqlserver: name: Run transport Tests (on SQL Server) From 8cdc1f20f810ca18749e72807843cf7ecc8003d9 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 10:37:12 +0200 Subject: [PATCH 050/105] ci: archive logs --- .github/workflows/test.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 183b81665d..1f5bbb26e2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -190,7 +190,8 @@ jobs: matrix: database: [sqlserver, postgres] test-project: - - name: AdminApi/test/AdminApi.Tests.Integration + - display-name: AdminApi + - path: AdminApi/test/AdminApi.Tests.Integration additional-compose-files: -f ./.ci/compose.test.aui.yml # - ConsumerApi.Tests.Integration # - Job.IdentityDeletion.Tests.Integration @@ -250,7 +251,14 @@ jobs: - name: Save Docker Logs if: failure() - run: docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml ${{matrix.test-project.additional-compose-files}} logs > ${{matrix.test-project.name}}.${{matrix.database}}.txt + run: docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml ${{matrix.test-project.additional-compose-files}} logs > logs.txt + + - name: Archive logs + if: failure() + uses: actions/upload-artifact@v4 + with: + name: ${{matrix.test-project.display-name}}-${{matrix.database}} + path: logs.txt transport-test-sqlserver: name: Run transport Tests (on SQL Server) @@ -285,7 +293,7 @@ jobs: - name: Load Docker images run: ./backbone/.ci/loadDockerImages.sh - - name: Run Consumer API & Admin API + - name: Start compose stack run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.sqlserver.yml -f ./backbone/.ci/compose.test.capi.yml up --no-build --wait -d - name: Install runtime dependencies @@ -304,7 +312,7 @@ jobs: - name: Save Docker Logs if: failure() - run: docker compose -f ./backbone/.ci/compose.test.capi.yml logs > docker-log.txt + run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.sqlserver.yml -f ./backbone/.ci/compose.test.capi.yml logs > docker-log.txt - name: Archive logs if: failure() @@ -313,7 +321,7 @@ jobs: name: transport-test-sqlserver-docker-logs path: docker-log.txt - - name: Stop Consumer API + - name: Stop compose stack run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.sqlserver.yml -f ./backbone/.ci/compose.test.capi.yml down transport-test-postgres: @@ -349,7 +357,7 @@ jobs: - name: Load Docker images run: ./backbone/.ci/loadDockerImages.sh - - name: Run Consumer API & Admin API + - name: Run compose stack run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.postgres.yml -f ./backbone/.ci/compose.test.capi.yml up --no-build --wait -d - name: Install runtime dependencies @@ -368,7 +376,7 @@ jobs: - name: Save Docker Logs if: failure() - run: docker compose -f ./backbone/.ci/compose.test.capi.yml logs > docker-log.txt + run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.postgres.yml -f ./backbone/.ci/compose.test.capi.yml logs > docker-log.txt - name: Archive logs if: failure() @@ -377,7 +385,7 @@ jobs: name: transport-test-postgres-docker-logs path: docker-log.txt - - name: Stop Consumer API + - name: Stop compose stack run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.postgres.yml -f ./backbone/.ci/compose.test.capi.yml down build-helm-chart: From 4f0455bb5b207c702030bda58f41a479f4710d69 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 11:49:56 +0200 Subject: [PATCH 051/105] ci: fix matrix parameters --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1f5bbb26e2..37683d3e4a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -184,14 +184,14 @@ jobs: mv /tmp/.buildx-${{ matrix.image }}-cache-new /tmp/.buildx-${{ matrix.image }}-cache integration-test: - name: Run ${{matrix.test-project.name}} on ${{matrix.database}} + name: Run ${{matrix.test-project.path}} on ${{matrix.database}} runs-on: ubuntu-latest strategy: matrix: database: [sqlserver, postgres] test-project: - display-name: AdminApi - - path: AdminApi/test/AdminApi.Tests.Integration + path: AdminApi/test/AdminApi.Tests.Integration additional-compose-files: -f ./.ci/compose.test.aui.yml # - ConsumerApi.Tests.Integration # - Job.IdentityDeletion.Tests.Integration From ec50f643f8a585d17d5c959da36ab3166e3d85d7 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 13:05:44 +0200 Subject: [PATCH 052/105] ci: let sse-server depend on database-migrator and rabbitmq --- .ci/compose.test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.ci/compose.test.yml b/.ci/compose.test.yml index 5a0a619a24..f675e93e14 100644 --- a/.ci/compose.test.yml +++ b/.ci/compose.test.yml @@ -18,6 +18,11 @@ services: image: sse-server:0.0.1 environment: - ASPNETCORE_ENVIRONMENT=Development + depends_on: + database-migrator: + condition: service_completed_successfully + rabbitmq: + condition: service_started configs: - source: Config target: app/appsettings.override.json From d779bd339ce7aed898679cc97d7cc4312ad73180 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 13:16:49 +0200 Subject: [PATCH 053/105] ci: replace hardcoded sqlserver --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 37683d3e4a..8c37727f78 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -233,7 +233,7 @@ jobs: { dotnet restore Backbone.sln mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak - cp .ci/appsettings.override.sqlserver.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json + cp .ci/appsettings.override.${{matrix.database}}.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json dotnet build --no-restore Backbone.sln } wait From 3cadebed4f0aef5e68ed785827a9844b27c5b3c7 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 14:18:53 +0200 Subject: [PATCH 054/105] ci: add capi to admin ui tests --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8c37727f78..2bac08c778 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -192,7 +192,7 @@ jobs: test-project: - display-name: AdminApi path: AdminApi/test/AdminApi.Tests.Integration - additional-compose-files: -f ./.ci/compose.test.aui.yml + additional-compose-files: -f ./.ci/compose.test.aui.yml -f ./.ci/compose.test.capi.yml # - ConsumerApi.Tests.Integration # - Job.IdentityDeletion.Tests.Integration needs: image-test-builds From 32d61650785a7b6eb5cb4fb7ce63eb212e113f4e Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 14:21:54 +0200 Subject: [PATCH 055/105] ci: set fail-fast to false --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2bac08c778..40234af4e9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -102,6 +102,7 @@ jobs: name: Build ${{matrix.image}} Image runs-on: ubuntu-latest strategy: + fail-fast: false matrix: include: - dockerfile: ConsumerApi/Dockerfile @@ -187,6 +188,7 @@ jobs: name: Run ${{matrix.test-project.path}} on ${{matrix.database}} runs-on: ubuntu-latest strategy: + fail-fast: false matrix: database: [sqlserver, postgres] test-project: From e1facbbfc9f7d25d4352af4e399b55d7b586ac96 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 14:22:11 +0200 Subject: [PATCH 056/105] ci: add remaining integration tests --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 40234af4e9..dc961d1e1e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -195,6 +195,11 @@ jobs: - display-name: AdminApi path: AdminApi/test/AdminApi.Tests.Integration additional-compose-files: -f ./.ci/compose.test.aui.yml -f ./.ci/compose.test.capi.yml + - display-name: ConsumerApi + path: ConsumerApi.Tests.Integration + additional-compose-files: -f ./.ci/compose.test.capi.yml + - display-name: IdentityDeletionJob + path: Jobs/test/Job.IdentityDeletion.Tests.Integration # - ConsumerApi.Tests.Integration # - Job.IdentityDeletion.Tests.Integration needs: image-test-builds From 710ae8ea7081bb0e1a3a3a1a69e190840cebaed4 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 14:33:00 +0200 Subject: [PATCH 057/105] ci: create matrix for transport tests --- .github/workflows/test.yml | 82 +++++--------------------------------- 1 file changed, 11 insertions(+), 71 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dc961d1e1e..9586cf3498 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -267,9 +267,13 @@ jobs: name: ${{matrix.test-project.display-name}}-${{matrix.database}} path: logs.txt - transport-test-sqlserver: - name: Run transport Tests (on SQL Server) + transport-test: + name: Run transport tests on ${{matrix.database}} runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + database: [sqlserver, postgres] needs: image-test-builds steps: - name: Checkout backbone repository @@ -301,7 +305,7 @@ jobs: run: ./backbone/.ci/loadDockerImages.sh - name: Start compose stack - run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.sqlserver.yml -f ./backbone/.ci/compose.test.capi.yml up --no-build --wait -d + run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.${{matrix.database}}.yml -f ./backbone/.ci/compose.test.capi.yml up --no-build --wait -d - name: Install runtime dependencies working-directory: ./runtime @@ -319,81 +323,17 @@ jobs: - name: Save Docker Logs if: failure() - run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.sqlserver.yml -f ./backbone/.ci/compose.test.capi.yml logs > docker-log.txt + run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.${{matrix.database}}.yml -f ./backbone/.ci/compose.test.capi.yml logs > logs.txt - name: Archive logs if: failure() uses: actions/upload-artifact@v4 with: - name: transport-test-sqlserver-docker-logs - path: docker-log.txt - - - name: Stop compose stack - run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.sqlserver.yml -f ./backbone/.ci/compose.test.capi.yml down - - transport-test-postgres: - name: Run transport Tests (on Postgres) - runs-on: ubuntu-latest - needs: image-test-builds - steps: - - name: Checkout backbone repository - uses: actions/checkout@v4 - with: - path: backbone - - - name: Checkout runtime repository - uses: actions/checkout@v4 - with: - repository: nmshd/runtime - path: runtime - ref: release/v5 - - - uses: actions/setup-node@v4 - with: - node-version: latest - cache: "npm" - cache-dependency-path: "**/package-lock.json" - - - name: Download cached Docker images - uses: actions/download-artifact@v4 - with: - path: /tmp - pattern: docker-* - merge-multiple: true - - - name: Load Docker images - run: ./backbone/.ci/loadDockerImages.sh - - - name: Run compose stack - run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.postgres.yml -f ./backbone/.ci/compose.test.capi.yml up --no-build --wait -d - - - name: Install runtime dependencies - working-directory: ./runtime - run: npm install - - - name: Run transport Tests - working-directory: ./runtime/packages/transport - env: - NMSHD_TEST_BASEURL: http://localhost:5000 - NMSHD_TEST_CLIENTID: test - NMSHD_TEST_CLIENTSECRET: test - NMSHD_TEST_BASEURL_ADMIN_API: http://localhost:5173 - NMSHD_TEST_ADMIN_API_KEY: test - run: npm run test:local:lokijs - - - name: Save Docker Logs - if: failure() - run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.postgres.yml -f ./backbone/.ci/compose.test.capi.yml logs > docker-log.txt - - - name: Archive logs - if: failure() - uses: actions/upload-artifact@v4 - with: - name: transport-test-postgres-docker-logs - path: docker-log.txt + name: transport-test-${{matrix.database}}-docker-logs + path: logs.txt - name: Stop compose stack - run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.postgres.yml -f ./backbone/.ci/compose.test.capi.yml down + run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.${{matrix.database}}.yml -f ./backbone/.ci/compose.test.capi.yml down build-helm-chart: name: Build Helm Chart From f585e0435549296971de8e8ae1a41293c5b80663 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 14:33:20 +0200 Subject: [PATCH 058/105] ci: let admin-cli depend on consumer-api --- .ci/compose.test.yml | 2 ++ .github/workflows/test.yml | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.ci/compose.test.yml b/.ci/compose.test.yml index f675e93e14..55371e8ec3 100644 --- a/.ci/compose.test.yml +++ b/.ci/compose.test.yml @@ -71,6 +71,8 @@ services: depends_on: database-migrator: condition: service_completed_successfully + consumer-api: + condition: service_healthy command: backbone client create --clientId test --clientSecret test --defaultTier Basic networks: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9586cf3498..805968a2c3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ concurrency: cancel-in-progress: true jobs: - run-adminUi-checks: + adminui-checks: runs-on: ubuntu-latest name: Run Admin UI Checks steps: @@ -21,7 +21,7 @@ jobs: - name: Run Checks run: ./.ci/aui/runChecks.sh - run-adminUi-flutter-checks: + adminui-flutter-checks: runs-on: ubuntu-latest name: Run Admin UI Flutter Checks steps: @@ -197,7 +197,7 @@ jobs: additional-compose-files: -f ./.ci/compose.test.aui.yml -f ./.ci/compose.test.capi.yml - display-name: ConsumerApi path: ConsumerApi.Tests.Integration - additional-compose-files: -f ./.ci/compose.test.capi.yml + additional-compose-files: -f ./.ci/compose.test.aui.yml -f ./.ci/compose.test.capi.yml - display-name: IdentityDeletionJob path: Jobs/test/Job.IdentityDeletion.Tests.Integration # - ConsumerApi.Tests.Integration From c722301fbc5d4c415b7b0983f508f517beafa6bb Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 14:53:21 +0200 Subject: [PATCH 059/105] ci: use path instead of name for dotnet test command --- .github/workflows/test.yml | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 805968a2c3..04b4d403d3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -185,23 +185,19 @@ jobs: mv /tmp/.buildx-${{ matrix.image }}-cache-new /tmp/.buildx-${{ matrix.image }}-cache integration-test: - name: Run ${{matrix.test-project.path}} on ${{matrix.database}} + name: Run ${{matrix.test-project.display-name}} integration tests on ${{matrix.database}} runs-on: ubuntu-latest strategy: fail-fast: false matrix: database: [sqlserver, postgres] test-project: - - display-name: AdminApi + - display-name: admin-api path: AdminApi/test/AdminApi.Tests.Integration - additional-compose-files: -f ./.ci/compose.test.aui.yml -f ./.ci/compose.test.capi.yml - - display-name: ConsumerApi + - display-name: consumer-api path: ConsumerApi.Tests.Integration - additional-compose-files: -f ./.ci/compose.test.aui.yml -f ./.ci/compose.test.capi.yml - - display-name: IdentityDeletionJob + - display-name: identity-deletion-job path: Jobs/test/Job.IdentityDeletion.Tests.Integration - # - ConsumerApi.Tests.Integration - # - Job.IdentityDeletion.Tests.Integration needs: image-test-builds steps: - name: Checkout @@ -239,26 +235,29 @@ jobs: } & { dotnet restore Backbone.sln + + # The following two lines are for the identity deletion job only mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak cp .ci/appsettings.override.${{matrix.database}}.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json + dotnet build --no-restore Backbone.sln } wait - name: Start compose stack run: | - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml ${{matrix.test-project.additional-compose-files}} down -v - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml ${{matrix.test-project.additional-compose-files}} up --no-build --wait -d + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml -f ./.ci/compose.test.aui.yml -f ./.ci/compose.test.capi.yml down -v + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml -f ./.ci/compose.test.aui.yml -f ./.ci/compose.test.capi.yml up --no-build --wait -d - name: Run integration tests - run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ${{matrix.test-project.name}} + run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ${{matrix.test-project.path}} env: ADMIN_API_BASE_ADDRESS: "http://localhost:5173" CONSUMER_API_BASE_ADDRESS: "http://localhost:5000" - name: Save Docker Logs if: failure() - run: docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml ${{matrix.test-project.additional-compose-files}} logs > logs.txt + run: docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml -f ./.ci/compose.test.aui.yml -f ./.ci/compose.test.capi.yml logs > logs.txt - name: Archive logs if: failure() From 04d1603add1c019b9abb6f6d27a69adad7d2a51e Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 15:08:51 +0200 Subject: [PATCH 060/105] ci: remove integrationTest script files --- .ci/integrationTest.postgres.sh | 25 ------------------------- .ci/integrationTest.sqlserver.sh | 25 ------------------------- 2 files changed, 50 deletions(-) delete mode 100755 .ci/integrationTest.postgres.sh delete mode 100755 .ci/integrationTest.sqlserver.sh diff --git a/.ci/integrationTest.postgres.sh b/.ci/integrationTest.postgres.sh deleted file mode 100755 index cd3edf5949..0000000000 --- a/.ci/integrationTest.postgres.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -set -e - -dockerCompose() { - docker compose -f ./.ci/docker-compose.test.yml -f ./.ci/docker-compose.test.postgres.yml "$@" -} - -{ - dockerCompose down; - dockerCompose up -d --no-build -} & -{ - mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak - cp .ci/appsettings.override.postgres.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json - dotnet restore "Backbone.sln"; - dotnet build --no-restore "Backbone.sln" -} -wait - -export CONSUMER_API_BASE_ADDRESS="http://localhost:5000" -export ADMIN_API_BASE_ADDRESS="http://localhost:5173" - -dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" Jobs/test/Job.IdentityDeletion.Tests.Integration -dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration -dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ConsumerApi.Tests.Integration diff --git a/.ci/integrationTest.sqlserver.sh b/.ci/integrationTest.sqlserver.sh deleted file mode 100755 index c3c458597b..0000000000 --- a/.ci/integrationTest.sqlserver.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -set -e - -dockerCompose() { - docker compose -f ./.ci/docker-compose.test.yml -f ./.ci/docker-compose.test.sqlserver.yml "$@" -} - -{ - dockerCompose down; - dockerCompose up -d --no-build -} & -{ - mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak - cp .ci/appsettings.override.sqlserver.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json - dotnet restore "Backbone.sln"; - dotnet build --no-restore "Backbone.sln" -} -wait - -export CONSUMER_API_BASE_ADDRESS="http://localhost:5000" -export ADMIN_API_BASE_ADDRESS="http://localhost:5173" - -dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" Jobs/test/Job.IdentityDeletion.Tests.Integration -dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" AdminApi/test/AdminApi.Tests.Integration -dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ConsumerApi.Tests.Integration From f30ebcaf2dd7e311279fa093d85251522a5e6f34 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 15:10:50 +0200 Subject: [PATCH 061/105] ci: move capi and aui back to compose.test.yml --- .ci/compose.test.aui.yml | 17 ----------------- .ci/compose.test.capi.yml | 19 ------------------- .ci/compose.test.yml | 36 ++++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 10 +++++----- 4 files changed, 41 insertions(+), 41 deletions(-) delete mode 100644 .ci/compose.test.aui.yml delete mode 100644 .ci/compose.test.capi.yml diff --git a/.ci/compose.test.aui.yml b/.ci/compose.test.aui.yml deleted file mode 100644 index c96e332e70..0000000000 --- a/.ci/compose.test.aui.yml +++ /dev/null @@ -1,17 +0,0 @@ -services: - admin-ui: - container_name: admin-ui-test - hostname: admin-ui - image: admin-ui:0.0.1 - environment: - - ASPNETCORE_ENVIRONMENT=Development - ports: - - "5173:8080" - depends_on: - database-migrator: - condition: service_completed_successfully - rabbitmq: - condition: service_started - configs: - - source: Config - target: app/appsettings.override.json diff --git a/.ci/compose.test.capi.yml b/.ci/compose.test.capi.yml deleted file mode 100644 index 62e1b3fc35..0000000000 --- a/.ci/compose.test.capi.yml +++ /dev/null @@ -1,19 +0,0 @@ -services: - consumer-api: - container_name: consumer-api-test - hostname: consumer-api - image: consumer-api:0.0.1 - environment: - - ASPNETCORE_ENVIRONMENT=Development - ports: - - "5000:8080" - depends_on: - database-migrator: - condition: service_completed_successfully - rabbitmq: - condition: service_started - azure-storage-emulator: - condition: service_started - configs: - - source: Config - target: app/appsettings.override.json diff --git a/.ci/compose.test.yml b/.ci/compose.test.yml index 55371e8ec3..be4201fc59 100644 --- a/.ci/compose.test.yml +++ b/.ci/compose.test.yml @@ -1,4 +1,40 @@ services: + consumer-api: + container_name: consumer-api-test + hostname: consumer-api + image: consumer-api:0.0.1 + environment: + - ASPNETCORE_ENVIRONMENT=Development + ports: + - "5000:8080" + depends_on: + database-migrator: + condition: service_completed_successfully + rabbitmq: + condition: service_started + azure-storage-emulator: + condition: service_started + configs: + - source: Config + target: app/appsettings.override.json + + admin-ui: + container_name: admin-ui-test + hostname: admin-ui + image: admin-ui:0.0.1 + environment: + - ASPNETCORE_ENVIRONMENT=Development + ports: + - "5173:8080" + depends_on: + database-migrator: + condition: service_completed_successfully + rabbitmq: + condition: service_started + configs: + - source: Config + target: app/appsettings.override.json + event-handler-service: container_name: event-handler-service-test image: event-handler-service:0.0.1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 04b4d403d3..36db668706 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -246,18 +246,18 @@ jobs: - name: Start compose stack run: | - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml -f ./.ci/compose.test.aui.yml -f ./.ci/compose.test.capi.yml down -v - docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml -f ./.ci/compose.test.aui.yml -f ./.ci/compose.test.capi.yml up --no-build --wait -d + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml down -v + docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml up --no-build --wait -d - name: Run integration tests - run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false" ${{matrix.test-project.path}} + run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false;summary.includeSkippedTests=false;summary.includePassedTests=false" ${{matrix.test-project.path}} env: ADMIN_API_BASE_ADDRESS: "http://localhost:5173" CONSUMER_API_BASE_ADDRESS: "http://localhost:5000" - name: Save Docker Logs if: failure() - run: docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml -f ./.ci/compose.test.aui.yml -f ./.ci/compose.test.capi.yml logs > logs.txt + run: docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml logs > logs.txt - name: Archive logs if: failure() @@ -304,7 +304,7 @@ jobs: run: ./backbone/.ci/loadDockerImages.sh - name: Start compose stack - run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.${{matrix.database}}.yml -f ./backbone/.ci/compose.test.capi.yml up --no-build --wait -d + run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.${{matrix.database}}.yml up --no-build --wait -d - name: Install runtime dependencies working-directory: ./runtime From 610d134446a256c0bef0b1f4193112124f3ca82b Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 15:21:48 +0200 Subject: [PATCH 062/105] ci: fix docker compose commands --- .github/workflows/test.yml | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 36db668706..b19854e066 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,15 +46,13 @@ jobs: - name: Cache npm dependencies uses: actions/cache@v4 with: - path: | - ./runtime/node_modules + path: ./runtime/node_modules key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-npm- + restore-keys: ${{ runner.os }}-npm- - name: Setup dotnet uses: actions/setup-dotnet@v4 with: - dotnet-version: "8.0.x" + dotnet-version: "8.x" - name: Cache NuGet packages uses: actions/cache@v4 with: @@ -78,15 +76,13 @@ jobs: - name: Cache npm dependencies uses: actions/cache@v4 with: - path: | - ./runtime/node_modules + path: ./runtime/node_modules key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-npm- + restore-keys: ${{ runner.os }}-npm- - name: Setup dotnet uses: actions/setup-dotnet@v4 with: - dotnet-version: "8.0.x" + dotnet-version: "8.x" - name: Cache NuGet packages uses: actions/cache@v4 with: @@ -154,8 +150,7 @@ jobs: with: path: /tmp/.buildx-${{ matrix.image }}-cache key: buildx-${{ matrix.image }}-cache-${{ hashFiles(matrix.dockerfile) }} - restore-keys: | - buildx-${{ matrix.image }}-cache- + restore-keys: buildx-${{ matrix.image }}-cache- - name: Build Image uses: docker/build-push-action@v6 @@ -322,7 +317,7 @@ jobs: - name: Save Docker Logs if: failure() - run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.${{matrix.database}}.yml -f ./backbone/.ci/compose.test.capi.yml logs > logs.txt + run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.${{matrix.database}}.yml logs > logs.txt - name: Archive logs if: failure() @@ -332,7 +327,7 @@ jobs: path: logs.txt - name: Stop compose stack - run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.${{matrix.database}}.yml -f ./backbone/.ci/compose.test.capi.yml down + run: docker compose -f ./backbone/.ci/compose.test.${{matrix.database}}.yml -f ./backbone/.ci/compose.test.yml down build-helm-chart: name: Build Helm Chart From 9c106f5b07a8ba6b28deb6617684a731ef76c679 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 15:37:06 +0200 Subject: [PATCH 063/105] ci: change job names --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b19854e066..f27acd86be 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -180,7 +180,7 @@ jobs: mv /tmp/.buildx-${{ matrix.image }}-cache-new /tmp/.buildx-${{ matrix.image }}-cache integration-test: - name: Run ${{matrix.test-project.display-name}} integration tests on ${{matrix.database}} + name: Run ${{matrix.test-project.display-name}} Integration Tests (on ${{matrix.database}}) runs-on: ubuntu-latest strategy: fail-fast: false @@ -262,7 +262,7 @@ jobs: path: logs.txt transport-test: - name: Run transport tests on ${{matrix.database}} + name: Run transport Tests (on ${{matrix.database}}) runs-on: ubuntu-latest strategy: fail-fast: false From 94bc3cdfffc20d7d59ec3b6b7d446f0c23d5b6a7 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 15:41:13 +0200 Subject: [PATCH 064/105] test: formatting --- .../ActualDeletionWorkerTests.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Jobs/test/Job.IdentityDeletion.Tests.Integration/ActualDeletionWorkerTests.cs b/Jobs/test/Job.IdentityDeletion.Tests.Integration/ActualDeletionWorkerTests.cs index feec3cbfec..e8c60e4a87 100644 --- a/Jobs/test/Job.IdentityDeletion.Tests.Integration/ActualDeletionWorkerTests.cs +++ b/Jobs/test/Job.IdentityDeletion.Tests.Integration/ActualDeletionWorkerTests.cs @@ -143,12 +143,13 @@ public async Task Deletes_relationship_templates() templatesAfterAct.Should().BeEmpty(); } + #region Seeders + private async Task SeedDatabaseWithMessage(IdentityAddress from, IdentityAddress to) { var dbContext = GetService(); var recipient = new RecipientInformation(to, []); - var message = new Message(from, DeviceId.New(), [], [], [recipient]); await dbContext.SaveEntity(message); @@ -158,17 +159,21 @@ private async Task SeedDatabaseWithMessage(IdentityAddress from, Identi private async Task SeedDatabaseWithActiveRelationshipBetween(IdentityAddress from, IdentityAddress to) { + var dbContext = GetService(); + var template = new RelationshipTemplate(from, DeviceId.New(), null, null, []); var relationship = new Relationship(template, to, DeviceId.New(), [], []); relationship.Accept(from, DeviceId.New(), []); - var dbContext = GetService(); + await dbContext.SaveEntity(relationship); } private async Task SeedDatabaseWithRelationshipTemplateOf(IdentityAddress owner) { - var template = new RelationshipTemplate(owner, DeviceId.New(), null, null, []); var dbContext = GetService(); + + var template = new RelationshipTemplate(owner, DeviceId.New(), null, null, []); + await dbContext.SaveEntity(template); } @@ -190,6 +195,8 @@ private async Task SeedDatabaseWithIdentityWithRipeDeletionProcess() return identity; } + #endregion + private T GetService() where T : notnull { return _host.Services.CreateScope().ServiceProvider.GetRequiredService(); From 0599774e0e0dd902f334d80b6c9b56ca546fe22d Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 15:42:50 +0200 Subject: [PATCH 065/105] ci: remove redundant dependency from admin-cli to database-migrator --- .ci/compose.test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.ci/compose.test.yml b/.ci/compose.test.yml index be4201fc59..e8795784bf 100644 --- a/.ci/compose.test.yml +++ b/.ci/compose.test.yml @@ -105,8 +105,6 @@ services: container_name: admin-cli-test image: admin-cli:0.0.1 depends_on: - database-migrator: - condition: service_completed_successfully consumer-api: condition: service_healthy command: backbone client create --clientId test --clientSecret test --defaultTier Basic From 5d7e358b728cab42e1e14694114db607bad7ba8e Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 15:57:56 +0200 Subject: [PATCH 066/105] refactor: don't distinguish between _nonDeviceIdentityDeleters and _deviceIdentityDeleter anymore --- .../Workers/ActualDeletionWorker.cs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs b/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs index b8b22b2c55..461539b1a4 100644 --- a/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs +++ b/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs @@ -16,8 +16,7 @@ public class ActualDeletionWorker : IHostedService private readonly IPushNotificationSender _pushNotificationSender; private readonly ILogger _logger; private readonly IDeletionProcessLogger _deletionProcessLogger; - private readonly List _nonDeviceIdentityDeleters; - private readonly IIdentityDeleter? _deviceIdentityDeleter; + private readonly List _identityDeleters; public ActualDeletionWorker( IHostApplicationLifetime host, @@ -28,9 +27,7 @@ public ActualDeletionWorker( IDeletionProcessLogger deletionProcessLogger) { _host = host; - _nonDeviceIdentityDeleters = identityDeleters.ToList(); - _deviceIdentityDeleter = _nonDeviceIdentityDeleters.First(i => i.GetType() == typeof(Modules.Devices.Application.Identities.IdentityDeleter)); - _nonDeviceIdentityDeleters.Remove(_deviceIdentityDeleter); + _identityDeleters = identityDeleters.ToList(); _mediator = mediator; _pushNotificationSender = pushNotificationSender; _logger = logger; @@ -72,7 +69,6 @@ private async Task ExecuteDeletion(CancellationToken cancellationToken, Identity { await NotifyIdentityAboutStartingDeletion(cancellationToken, identityAddress); await Delete(identityAddress); - await DeleteDeviceIdentity(identityAddress); } private async Task NotifyIdentityAboutStartingDeletion(CancellationToken cancellationToken, IdentityAddress identityAddress) @@ -82,17 +78,12 @@ private async Task NotifyIdentityAboutStartingDeletion(CancellationToken cancell private async Task Delete(IdentityAddress identityAddress) { - foreach (var identityDeleter in _nonDeviceIdentityDeleters) + foreach (var identityDeleter in _identityDeleters) { await identityDeleter.Delete(identityAddress, _deletionProcessLogger); } } - private async Task DeleteDeviceIdentity(IdentityAddress identityAddress) - { - await _deviceIdentityDeleter!.Delete(identityAddress, _deletionProcessLogger); - } - private void LogErroringDeletionTriggers(IEnumerable>> erroringDeletionTriggers) { foreach (var erroringDeletion in erroringDeletionTriggers) From d268dae7d13742d00647d36e125390e409ccd71f Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 15:59:01 +0200 Subject: [PATCH 067/105] chore: remove redundant project properties --- .../Job.IdentityDeletion.Tests.Integration.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Jobs/test/Job.IdentityDeletion.Tests.Integration/Job.IdentityDeletion.Tests.Integration.csproj b/Jobs/test/Job.IdentityDeletion.Tests.Integration/Job.IdentityDeletion.Tests.Integration.csproj index 9e8921c3a1..75557f96ca 100644 --- a/Jobs/test/Job.IdentityDeletion.Tests.Integration/Job.IdentityDeletion.Tests.Integration.csproj +++ b/Jobs/test/Job.IdentityDeletion.Tests.Integration/Job.IdentityDeletion.Tests.Integration.csproj @@ -1,10 +1,6 @@ - net8.0 - enable - enable - false true From aa1672c76390d3139565a0e6849abbe9a17f8582 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 16:10:01 +0200 Subject: [PATCH 068/105] chore: add appsettings.override.json to identity deletion job tests --- .../Job.IdentityDeletion.Tests.Integration.csproj | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Jobs/test/Job.IdentityDeletion.Tests.Integration/Job.IdentityDeletion.Tests.Integration.csproj b/Jobs/test/Job.IdentityDeletion.Tests.Integration/Job.IdentityDeletion.Tests.Integration.csproj index 75557f96ca..e09b87b4cb 100644 --- a/Jobs/test/Job.IdentityDeletion.Tests.Integration/Job.IdentityDeletion.Tests.Integration.csproj +++ b/Jobs/test/Job.IdentityDeletion.Tests.Integration/Job.IdentityDeletion.Tests.Integration.csproj @@ -32,13 +32,7 @@ - - PreserveNewest - - - - - + PreserveNewest From 3a8e6cc83629a33e4af7e7264090587209de039b Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 16:10:18 +0200 Subject: [PATCH 069/105] chore: add appsettings.override.json to solution --- Backbone.sln | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Backbone.sln b/Backbone.sln index b9d0bc4f66..f1bcc24537 100644 --- a/Backbone.sln +++ b/Backbone.sln @@ -313,6 +313,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Challenges.Application.Test EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Job.IdentityDeletion.Tests.Integration", "Jobs\test\Job.IdentityDeletion.Tests.Integration\Job.IdentityDeletion.Tests.Integration.csproj", "{63BC08F3-5DA8-4AC5-877A-89B6ABA05F44}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Others", "Others", "{8B8EE965-0373-46D6-BB30-7C131EE524E4}" + ProjectSection(SolutionItems) = preProject + appsettings.override.json = appsettings.override.json + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU From 153aff0b13172c7f569922a7c0045f142c5fecdf Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 16:11:23 +0200 Subject: [PATCH 070/105] chore: add .editorconfig to solution --- Backbone.sln | 1 + 1 file changed, 1 insertion(+) diff --git a/Backbone.sln b/Backbone.sln index f1bcc24537..d6febc45aa 100644 --- a/Backbone.sln +++ b/Backbone.sln @@ -316,6 +316,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Others", "Others", "{8B8EE965-0373-46D6-BB30-7C131EE524E4}" ProjectSection(SolutionItems) = preProject appsettings.override.json = appsettings.override.json + .editorconfig = .editorconfig EndProjectSection EndProject Global From bc893f929c5a4175531efb5f34035ce87be3cb7e Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Fri, 5 Jul 2024 16:18:52 +0200 Subject: [PATCH 071/105] test: cleanup/simplify --- .../Tests/ActualDeletionWorkerTests.cs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs index 664b7da6af..a57ccc9535 100644 --- a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs +++ b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs @@ -3,7 +3,6 @@ using Backbone.BuildingBlocks.Domain.Errors; using Backbone.DevelopmentKit.Identity.ValueObjects; using Backbone.Job.IdentityDeletion.Workers; -using Backbone.Modules.Devices.Application.Identities; using Backbone.Modules.Devices.Application.Identities.Commands.TriggerRipeDeletionProcesses; using Backbone.Modules.Relationships.Application.Relationships.Commands.FindRelationshipsOfIdentity; using Backbone.Modules.Relationships.Domain.Aggregates.Relationships; @@ -27,10 +26,7 @@ public async Task Proxies_triggering_the_deletion_processes_to_command_handler() var mockMediator = A.Fake(); SetupRipeDeletionProcessesCommand(mockMediator); - var dummyDevicesIdentityDeleter = new IdentityDeleter(mockMediator); - var identityDeleters = new List { dummyDevicesIdentityDeleter }; - - var worker = CreateWorker(mediator: mockMediator, identityDeleters); + var worker = CreateWorker(mediator: mockMediator, []); // Act await worker.StartProcessing(CancellationToken.None); @@ -49,12 +45,9 @@ public async Task Calls_Deleters_For_Each_Identity() SetupRipeDeletionProcessesCommand(mockMediator, identityAddress1, identityAddress2); var mockIdentityDeleter = A.Fake(); - var dummyDevicesIdentityDeleter = new IdentityDeleter(mockMediator); var dummyIDeletionProcessLogger = A.Fake(); - var identityDeleters = new List { mockIdentityDeleter, dummyDevicesIdentityDeleter }; - - var worker = CreateWorker(mediator: mockMediator, identityDeleters, deletionProcessLogger: dummyIDeletionProcessLogger); + var worker = CreateWorker(mediator: mockMediator, [mockIdentityDeleter], deletionProcessLogger: dummyIDeletionProcessLogger); A.CallTo(() => mockMediator.Send(A._, A._)) .Returns(new FindRelationshipsOfIdentityResponse(new List())); @@ -78,11 +71,9 @@ public async Task Sends_push_notification_for_each_relationship_of_each_identity SetupRipeDeletionProcessesCommand(mockMediator, identityAddress1, identityAddress2, identityAddress3); A.CallTo(() => mockMediator.Send(A._, A._)).Returns(new FindRelationshipsOfIdentityResponse(new List())); - var mockPushNotificationSender = A.Dummy(); - var dummyDevicesIdentityDeleter = new IdentityDeleter(mockMediator); - var identityDeleters = new List { dummyDevicesIdentityDeleter }; + var mockPushNotificationSender = A.Fake(); - var worker = CreateWorker(mediator: mockMediator, identityDeleters, pushNotificationSender: mockPushNotificationSender); + var worker = CreateWorker(mediator: mockMediator, [], pushNotificationSender: mockPushNotificationSender); // Act await worker.StartProcessing(CancellationToken.None); From b262b105a477087c15205a393f2c3f28c09b40a5 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 8 Jul 2024 08:30:23 +0200 Subject: [PATCH 072/105] chore: extract into separate files --- .../Identities/AggregateType.cs | 17 ++++++++++++++ .../Identities/IDeletionProcessLogger.cs | 7 ++++++ .../Identities/IIdentityDeleter.cs | 22 ------------------- 3 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 BuildingBlocks/src/BuildingBlocks.Application/Identities/AggregateType.cs create mode 100644 BuildingBlocks/src/BuildingBlocks.Application/Identities/IDeletionProcessLogger.cs diff --git a/BuildingBlocks/src/BuildingBlocks.Application/Identities/AggregateType.cs b/BuildingBlocks/src/BuildingBlocks.Application/Identities/AggregateType.cs new file mode 100644 index 0000000000..277dd0a357 --- /dev/null +++ b/BuildingBlocks/src/BuildingBlocks.Application/Identities/AggregateType.cs @@ -0,0 +1,17 @@ +namespace Backbone.BuildingBlocks.Application.Identities; +public enum AggregateType +{ + Challenges, + PnsRegistrations, + Identities, + Files, + Messages, + QuotaIdentities, + Relationships, + RelationshipTemplates, + RelationshipTemplateAllocations, + ExternalEvents, + SyncRuns, + Datawallets, + Tokens +} diff --git a/BuildingBlocks/src/BuildingBlocks.Application/Identities/IDeletionProcessLogger.cs b/BuildingBlocks/src/BuildingBlocks.Application/Identities/IDeletionProcessLogger.cs new file mode 100644 index 0000000000..d619ab2efc --- /dev/null +++ b/BuildingBlocks/src/BuildingBlocks.Application/Identities/IDeletionProcessLogger.cs @@ -0,0 +1,7 @@ +using Backbone.DevelopmentKit.Identity.ValueObjects; + +namespace Backbone.BuildingBlocks.Application.Identities; +public interface IDeletionProcessLogger +{ + Task LogDeletion(IdentityAddress identityAddress, AggregateType aggregateType); +} diff --git a/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs b/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs index 55da605618..ba6afa6f45 100644 --- a/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs +++ b/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs @@ -5,25 +5,3 @@ public interface IIdentityDeleter { Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger); } - -public interface IDeletionProcessLogger -{ - Task LogDeletion(IdentityAddress identityAddress, AggregateType aggregateType); -} - -public enum AggregateType -{ - Challenges, - PnsRegistrations, - Identities, - Files, - Messages, - QuotaIdentities, - Relationships, - RelationshipTemplates, - RelationshipTemplateAllocations, - ExternalEvents, - SyncRuns, - Datawallets, - Tokens -} From ca51cebd52148b6dad365557a6b2b283b28856db Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 8 Jul 2024 09:01:40 +0200 Subject: [PATCH 073/105] chore: extract into separate file --- .../DeletionProcessLogger.cs | 20 +++++++++++++++++++ Jobs/src/Job.IdentityDeletion/Program.cs | 18 ----------------- 2 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 Jobs/src/Job.IdentityDeletion/DeletionProcessLogger.cs diff --git a/Jobs/src/Job.IdentityDeletion/DeletionProcessLogger.cs b/Jobs/src/Job.IdentityDeletion/DeletionProcessLogger.cs new file mode 100644 index 0000000000..cc221c72a0 --- /dev/null +++ b/Jobs/src/Job.IdentityDeletion/DeletionProcessLogger.cs @@ -0,0 +1,20 @@ +using Backbone.BuildingBlocks.Application.Identities; +using Backbone.DevelopmentKit.Identity.ValueObjects; +using Backbone.Modules.Devices.Application.Identities.Commands.LogDeletionProcess; +using MediatR; + +namespace Backbone.Job.IdentityDeletion; +public class DeletionProcessLogger : IDeletionProcessLogger +{ + private readonly IMediator _mediator; + + public DeletionProcessLogger(IMediator mediator) + { + _mediator = mediator; + } + + public async Task LogDeletion(IdentityAddress identityAddress, AggregateType aggregateType) + { + await _mediator.Send(new LogDeletionProcessCommand(identityAddress, aggregateType)); + } +} diff --git a/Jobs/src/Job.IdentityDeletion/Program.cs b/Jobs/src/Job.IdentityDeletion/Program.cs index f7f53d6cb3..ca31e3eaee 100644 --- a/Jobs/src/Job.IdentityDeletion/Program.cs +++ b/Jobs/src/Job.IdentityDeletion/Program.cs @@ -3,10 +3,8 @@ using Backbone.BuildingBlocks.API.Extensions; using Backbone.BuildingBlocks.Application.Identities; using Backbone.BuildingBlocks.Application.QuotaCheck; -using Backbone.DevelopmentKit.Identity.ValueObjects; using Backbone.Infrastructure.EventBus; using Backbone.Modules.Challenges.ConsumerApi; -using Backbone.Modules.Devices.Application.Identities.Commands.LogDeletionProcess; using Backbone.Modules.Devices.ConsumerApi; using Backbone.Modules.Devices.Infrastructure.PushNotifications; using Backbone.Modules.Files.ConsumerApi; @@ -16,7 +14,6 @@ using Backbone.Modules.Synchronization.ConsumerApi; using Backbone.Modules.Tokens.ConsumerApi; using FluentValidation.AspNetCore; -using MediatR; using Microsoft.Extensions.Options; using Serilog; using Serilog.Exceptions; @@ -133,18 +130,3 @@ public static IHostBuilder CreateHostBuilder(string[] args) ); } } - -public class DeletionProcessLogger : IDeletionProcessLogger -{ - private readonly IMediator _mediator; - - public DeletionProcessLogger(IMediator mediator) - { - _mediator = mediator; - } - - public async Task LogDeletion(IdentityAddress identityAddress, AggregateType aggregateType) - { - await _mediator.Send(new LogDeletionProcessCommand(identityAddress, aggregateType)); - } -} From fe2b1bec8310ce476fd69d2bb7198db77d24df6c Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 8 Jul 2024 11:38:24 +0200 Subject: [PATCH 074/105] chore: utilize A.Dummy for variables called dummy --- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- .../Tests/Identities/IdentityDeleterTests.cs | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 0d37b1d489..7eb6309bbe 100644 --- a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -17,7 +17,7 @@ public async Task Deleter_calls_correct_command() var mockMediator = A.Fake(); var deleter = new IdentityDeleter(mockMediator); var identityAddress = CreateRandomIdentityAddress(); - var dummyIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Dummy(); // Act await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); @@ -30,7 +30,7 @@ public async Task Deleter_calls_correct_command() public async Task Deleter_correctly_creates_audit_log() { // Arrange - var dummyMediator = A.Fake(); + var dummyMediator = A.Dummy(); var deleter = new IdentityDeleter(dummyMediator); var identityAddress = CreateRandomIdentityAddress(); var mockIDeletionProcessLogger = A.Fake(); diff --git a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index bd172b3610..6faf2581fa 100644 --- a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -18,7 +18,7 @@ public async Task Deleter_calls_correct_command() var mockMediator = A.Fake(); var deleter = new IdentityDeleter(mockMediator); var identityAddress = CreateRandomIdentityAddress(); - var dummyIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Dummy(); // Act await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); @@ -32,7 +32,7 @@ public async Task Deleter_calls_correct_command() public async Task Deleter_correctly_creates_audit_log() { // Arrange - var dummyMediator = A.Fake(); + var dummyMediator = A.Dummy(); var deleter = new IdentityDeleter(dummyMediator); var identityAddress = CreateRandomIdentityAddress(); var mockIDeletionProcessLogger = A.Fake(); diff --git a/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 8000ac1d32..8836f57a1d 100644 --- a/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -17,7 +17,7 @@ public async Task Deleter_calls_correct_command() var mockMediator = A.Fake(); var deleter = new IdentityDeleter(mockMediator); var identityAddress = CreateRandomIdentityAddress(); - var dummyIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Dummy(); // Act await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); @@ -30,7 +30,7 @@ public async Task Deleter_calls_correct_command() public async Task Deleter_correctly_creates_audit_log() { // Arrange - var dummyMediator = A.Fake(); + var dummyMediator = A.Dummy(); var deleter = new IdentityDeleter(dummyMediator); var identityAddress = CreateRandomIdentityAddress(); var mockIDeletionProcessLogger = A.Fake(); diff --git a/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 579e7f4629..a4f010c9c0 100644 --- a/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -17,7 +17,7 @@ public async Task Deleter_calls_correct_command() var mockMediator = A.Fake(); var deleter = new IdentityDeleter(mockMediator); var identityAddress = CreateRandomIdentityAddress(); - var dummyIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Dummy(); // Act await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); @@ -30,7 +30,7 @@ public async Task Deleter_calls_correct_command() public async Task Deleter_correctly_creates_audit_log() { // Arrange - var dummyMediator = A.Fake(); + var dummyMediator = A.Dummy(); var deleter = new IdentityDeleter(dummyMediator); var identityAddress = CreateRandomIdentityAddress(); var mockIDeletionProcessLogger = A.Fake(); diff --git a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 5e17e919dc..8b6dc12f92 100644 --- a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -17,7 +17,7 @@ public async Task Deleter_calls_correct_command() var mockMediator = A.Fake(); var deleter = new IdentityDeleter(mockMediator); var identityAddress = CreateRandomIdentityAddress(); - var dummyIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Dummy(); // Act await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); @@ -30,7 +30,7 @@ public async Task Deleter_calls_correct_command() public async Task Deleter_correctly_creates_audit_log() { // Arrange - var dummyMediator = A.Fake(); + var dummyMediator = A.Dummy(); var deleter = new IdentityDeleter(dummyMediator); var identityAddress = CreateRandomIdentityAddress(); var mockIDeletionProcessLogger = A.Fake(); diff --git a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 6a6cefea24..38db6445de 100644 --- a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -19,7 +19,7 @@ public async Task Deleter_calls_correct_command() var mockMediator = A.Fake(); var deleter = new IdentityDeleter(mockMediator); var identityAddress = CreateRandomIdentityAddress(); - var dummyIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Dummy(); // Act await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); @@ -41,7 +41,7 @@ public async Task Deleter_calls_correct_command() public async Task Deleter_correctly_creates_audit_log() { // Arrange - var dummyMediator = A.Fake(); + var dummyMediator = A.Dummy(); var deleter = new IdentityDeleter(dummyMediator); var identityAddress = CreateRandomIdentityAddress(); var mockIDeletionProcessLogger = A.Fake(); diff --git a/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 1c44499f49..89cc758cc6 100644 --- a/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -19,7 +19,7 @@ public async Task Deleter_calls_correct_command() var mockMediator = A.Fake(); var deleter = new IdentityDeleter(mockMediator); var identityAddress = CreateRandomIdentityAddress(); - var dummyIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Dummy(); // Act await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); @@ -34,7 +34,7 @@ public async Task Deleter_calls_correct_command() public async Task Deleter_correctly_creates_audit_log() { // Arrange - var dummyMediator = A.Fake(); + var dummyMediator = A.Dummy(); var deleter = new IdentityDeleter(dummyMediator); var identityAddress = CreateRandomIdentityAddress(); var mockIDeletionProcessLogger = A.Fake(); diff --git a/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 40983793ab..724304d5c0 100644 --- a/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -17,7 +17,7 @@ public async Task Deleter_calls_correct_command() var mockMediator = A.Fake(); var deleter = new IdentityDeleter(mockMediator); var identityAddress = CreateRandomIdentityAddress(); - var dummyIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Dummy(); // Act await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); @@ -30,7 +30,7 @@ public async Task Deleter_calls_correct_command() public async Task Deleter_correctly_creates_audit_log() { // Arrange - var dummyMediator = A.Fake(); + var dummyMediator = A.Dummy(); var deleter = new IdentityDeleter(dummyMediator); var identityAddress = CreateRandomIdentityAddress(); var mockIDeletionProcessLogger = A.Fake(); From c41155b8775f387e84de55a8b575ed479cf9f597 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 8 Jul 2024 11:55:01 +0200 Subject: [PATCH 075/105] chore: utilize A.Dummy for variable called dummy --- .../Tests/ActualDeletionWorkerTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs index a57ccc9535..634bf303e3 100644 --- a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs +++ b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs @@ -45,7 +45,7 @@ public async Task Calls_Deleters_For_Each_Identity() SetupRipeDeletionProcessesCommand(mockMediator, identityAddress1, identityAddress2); var mockIdentityDeleter = A.Fake(); - var dummyIDeletionProcessLogger = A.Fake(); + var dummyIDeletionProcessLogger = A.Dummy(); var worker = CreateWorker(mediator: mockMediator, [mockIdentityDeleter], deletionProcessLogger: dummyIDeletionProcessLogger); From 58e0fbfeecc6d0b9b0d7afd303377544565aa76d Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 8 Jul 2024 14:17:19 +0200 Subject: [PATCH 076/105] refactor: inject deletion progress logger into each deleter --- .../Identities/IIdentityDeleter.cs | 2 +- .../Workers/ActualDeletionWorker.cs | 7 ++----- .../Identities/IdentityDeleter.cs | 8 +++++--- .../Identities/IdentityDeleter.cs | 10 ++++++---- .../Files.Application/Identities/IdentityDeleter.cs | 8 +++++--- .../Identities/IdentityDeleter.cs | 8 +++++--- .../Quotas.Application/Identities/IdentityDeleter.cs | 8 +++++--- .../Identities/IdentityDeleter.cs | 12 +++++++----- .../Identities/IdentityDeleter.cs | 12 +++++++----- .../Tokens.Application/Identities/IdentityDeleter.cs | 8 +++++--- 10 files changed, 48 insertions(+), 35 deletions(-) diff --git a/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs b/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs index ba6afa6f45..1175d6d7b2 100644 --- a/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs +++ b/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs @@ -3,5 +3,5 @@ namespace Backbone.BuildingBlocks.Application.Identities; public interface IIdentityDeleter { - Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger); + Task Delete(IdentityAddress identityAddress); } diff --git a/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs b/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs index 461539b1a4..433eb3d0c2 100644 --- a/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs +++ b/Jobs/src/Job.IdentityDeletion/Workers/ActualDeletionWorker.cs @@ -15,7 +15,6 @@ public class ActualDeletionWorker : IHostedService private readonly IMediator _mediator; private readonly IPushNotificationSender _pushNotificationSender; private readonly ILogger _logger; - private readonly IDeletionProcessLogger _deletionProcessLogger; private readonly List _identityDeleters; public ActualDeletionWorker( @@ -23,15 +22,13 @@ public ActualDeletionWorker( IEnumerable identityDeleters, IMediator mediator, IPushNotificationSender pushNotificationSender, - ILogger logger, - IDeletionProcessLogger deletionProcessLogger) + ILogger logger) { _host = host; _identityDeleters = identityDeleters.ToList(); _mediator = mediator; _pushNotificationSender = pushNotificationSender; _logger = logger; - _deletionProcessLogger = deletionProcessLogger; } public async Task StartAsync(CancellationToken cancellationToken) @@ -80,7 +77,7 @@ private async Task Delete(IdentityAddress identityAddress) { foreach (var identityDeleter in _identityDeleters) { - await identityDeleter.Delete(identityAddress, _deletionProcessLogger); + await identityDeleter.Delete(identityAddress); } } diff --git a/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs b/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs index 3c741d5044..9e45090197 100644 --- a/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs +++ b/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs @@ -8,15 +8,17 @@ namespace Backbone.Modules.Challenges.Application.Identities; public class IdentityDeleter : IIdentityDeleter { private readonly IMediator _mediator; + private readonly IDeletionProcessLogger _deletionProcessLogger; - public IdentityDeleter(IMediator mediator) + public IdentityDeleter(IMediator mediator, IDeletionProcessLogger deletionProcessLogger) { _mediator = mediator; + _deletionProcessLogger = deletionProcessLogger; } - public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) + public async Task Delete(IdentityAddress identityAddress) { await _mediator.Send(new DeleteChallengesOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Challenges); + await _deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Challenges); } } diff --git a/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs b/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs index 4e56833629..f67073f481 100644 --- a/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs +++ b/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs @@ -9,17 +9,19 @@ namespace Backbone.Modules.Devices.Application.Identities; public class IdentityDeleter : IIdentityDeleter { private readonly IMediator _mediator; + private readonly IDeletionProcessLogger _deletionProcessLogger; - public IdentityDeleter(IMediator mediator) + public IdentityDeleter(IMediator mediator, IDeletionProcessLogger deletionProcessLogger) { _mediator = mediator; + _deletionProcessLogger = deletionProcessLogger; } - public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) + public async Task Delete(IdentityAddress identityAddress) { await _mediator.Send(new DeletePnsRegistrationsOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.PnsRegistrations); + await _deletionProcessLogger.LogDeletion(identityAddress, AggregateType.PnsRegistrations); await _mediator.Send(new DeleteIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Identities); + await _deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Identities); } } diff --git a/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs b/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs index 2d30500bb2..879df4c33e 100644 --- a/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs +++ b/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs @@ -8,15 +8,17 @@ namespace Backbone.Modules.Files.Application.Identities; public class IdentityDeleter : IIdentityDeleter { private readonly IMediator _mediator; + private readonly IDeletionProcessLogger _deletionProcessLogger; - public IdentityDeleter(IMediator mediator) + public IdentityDeleter(IMediator mediator, IDeletionProcessLogger deletionProcessLogger) { _mediator = mediator; + _deletionProcessLogger = deletionProcessLogger; } - public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) + public async Task Delete(IdentityAddress identityAddress) { await _mediator.Send(new DeleteFilesOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Files); + await _deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Files); } } diff --git a/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs b/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs index 8a36d34643..856e348900 100644 --- a/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs +++ b/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs @@ -8,15 +8,17 @@ namespace Backbone.Modules.Messages.Application.Identities; public class IdentityDeleter : IIdentityDeleter { private readonly IMediator _mediator; + private readonly IDeletionProcessLogger _deletionProcessLogger; - public IdentityDeleter(IMediator mediator) + public IdentityDeleter(IMediator mediator, IDeletionProcessLogger deletionProcessLogger) { _mediator = mediator; + _deletionProcessLogger = deletionProcessLogger; } - public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) + public async Task Delete(IdentityAddress identityAddress) { await _mediator.Send(new AnonymizeMessagesOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Messages); + await _deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Messages); } } diff --git a/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs b/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs index 9892063e53..f08cdeca8b 100644 --- a/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs +++ b/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs @@ -8,15 +8,17 @@ namespace Backbone.Modules.Quotas.Application.Identities; public class IdentityDeleter : IIdentityDeleter { private readonly IMediator _mediator; + private readonly IDeletionProcessLogger _deletionProcessLogger; - public IdentityDeleter(IMediator mediator) + public IdentityDeleter(IMediator mediator, IDeletionProcessLogger deletionProcessLogger) { _mediator = mediator; + _deletionProcessLogger = deletionProcessLogger; } - public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) + public async Task Delete(IdentityAddress identityAddress) { await _mediator.Send(new DeleteIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.QuotaIdentities); + await _deletionProcessLogger.LogDeletion(identityAddress, AggregateType.QuotaIdentities); } } diff --git a/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs b/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs index 79f4a35ceb..3478e1a097 100644 --- a/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs +++ b/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs @@ -10,19 +10,21 @@ namespace Backbone.Modules.Relationships.Application.Identities; public class IdentityDeleter : IIdentityDeleter { private readonly IMediator _mediator; + private readonly IDeletionProcessLogger _deletionProcessLogger; - public IdentityDeleter(IMediator mediator) + public IdentityDeleter(IMediator mediator, IDeletionProcessLogger deletionProcessLogger) { _mediator = mediator; + _deletionProcessLogger = deletionProcessLogger; } - public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) + public async Task Delete(IdentityAddress identityAddress) { await _mediator.Send(new DeleteRelationshipsOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Relationships); + await _deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Relationships); await _mediator.Send(new DeleteRelationshipTemplatesOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplates); + await _deletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplates); await _mediator.Send(new AnonymizeRelationshipTemplateAllocationsAllocatedByIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplateAllocations); + await _deletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplateAllocations); } } diff --git a/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs b/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs index 411245c9c8..0aa699be72 100644 --- a/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs +++ b/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs @@ -10,19 +10,21 @@ namespace Backbone.Modules.Synchronization.Application.Identities; public class IdentityDeleter : IIdentityDeleter { private readonly IMediator _mediator; + private readonly IDeletionProcessLogger _deletionProcessLogger; - public IdentityDeleter(IMediator mediator) + public IdentityDeleter(IMediator mediator, IDeletionProcessLogger deletionProcessLogger) { _mediator = mediator; + _deletionProcessLogger = deletionProcessLogger; } - public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) + public async Task Delete(IdentityAddress identityAddress) { await _mediator.Send(new DeleteExternalEventsOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.ExternalEvents); + await _deletionProcessLogger.LogDeletion(identityAddress, AggregateType.ExternalEvents); await _mediator.Send(new DeleteSyncRunsOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.SyncRuns); + await _deletionProcessLogger.LogDeletion(identityAddress, AggregateType.SyncRuns); await _mediator.Send(new DeleteDatawalletsOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Datawallets); + await _deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Datawallets); } } diff --git a/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs b/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs index 3c1b237ded..b0801ecfe8 100644 --- a/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs +++ b/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs @@ -8,15 +8,17 @@ namespace Backbone.Modules.Tokens.Application.Identities; public class IdentityDeleter : IIdentityDeleter { private readonly IMediator _mediator; + private readonly IDeletionProcessLogger _deletionProcessLogger; - public IdentityDeleter(IMediator mediator) + public IdentityDeleter(IMediator mediator, IDeletionProcessLogger deletionProcessLogger) { _mediator = mediator; + _deletionProcessLogger = deletionProcessLogger; } - public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) + public async Task Delete(IdentityAddress identityAddress) { await _mediator.Send(new DeleteTokensOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Tokens); + await _deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Tokens); } } From 7255f9d194dfcfb7af84db2349619abceeaa328c Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Mon, 8 Jul 2024 14:17:44 +0200 Subject: [PATCH 077/105] chore: add AccessControlAllowCredentials to appsettings.override.json --- appsettings.override.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/appsettings.override.json b/appsettings.override.json index 67c96a62c1..a9d9068ce8 100644 --- a/appsettings.override.json +++ b/appsettings.override.json @@ -7,7 +7,8 @@ }, "Cors": { "AllowedOrigins": "http://localhost:8080;https://localhost:8080", - "ExposedHeaders": "" + "ExposedHeaders": "", + "AccessControlAllowCredentials": true }, "SwaggerUi": { "TokenUrl": "http://localhost:5000/connect/token", From ce69a7edcc228f3458f63d166181f48c630996a2 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Mon, 8 Jul 2024 14:18:29 +0200 Subject: [PATCH 078/105] refactor: rename IdentityDeletionProcessAuditLogEntryDTO to IdentityDeletionProcessAuditLogEntry --- ...gEntryDTO.cs => IdentityDeletionProcessAuditLogEntry.cs} | 6 +++--- .../ListIdentityDeletionProcessAuditLogsResponse.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename AdminApi.Sdk/Endpoints/Identities/Types/{IdentityDeletionProcessAuditLogEntryDTO.cs => IdentityDeletionProcessAuditLogEntry.cs} (68%) diff --git a/AdminApi.Sdk/Endpoints/Identities/Types/IdentityDeletionProcessAuditLogEntryDTO.cs b/AdminApi.Sdk/Endpoints/Identities/Types/IdentityDeletionProcessAuditLogEntry.cs similarity index 68% rename from AdminApi.Sdk/Endpoints/Identities/Types/IdentityDeletionProcessAuditLogEntryDTO.cs rename to AdminApi.Sdk/Endpoints/Identities/Types/IdentityDeletionProcessAuditLogEntry.cs index 581398a193..4f5cc55a82 100644 --- a/AdminApi.Sdk/Endpoints/Identities/Types/IdentityDeletionProcessAuditLogEntryDTO.cs +++ b/AdminApi.Sdk/Endpoints/Identities/Types/IdentityDeletionProcessAuditLogEntry.cs @@ -1,10 +1,10 @@ -namespace Backbone.AdminApi.Sdk.Endpoints.Identities.Types; +namespace Backbone.AdminApi.Sdk.Endpoints.Identities.Types; -public class IdentityDeletionProcessAuditLogEntryDTO +public class IdentityDeletionProcessAuditLogEntry { public required string Id { get; set; } public required DateTime CreatedAt { get; set; } - public required string MessageKey { get; set; } public required string? OldStatus { get; set; } public required string NewStatus { get; set; } + public required string MessageKey { get; set; } } diff --git a/AdminApi.Sdk/Endpoints/Identities/Types/Responses/ListIdentityDeletionProcessAuditLogsResponse.cs b/AdminApi.Sdk/Endpoints/Identities/Types/Responses/ListIdentityDeletionProcessAuditLogsResponse.cs index a3c76e10d8..290cf111a0 100644 --- a/AdminApi.Sdk/Endpoints/Identities/Types/Responses/ListIdentityDeletionProcessAuditLogsResponse.cs +++ b/AdminApi.Sdk/Endpoints/Identities/Types/Responses/ListIdentityDeletionProcessAuditLogsResponse.cs @@ -2,4 +2,4 @@ namespace Backbone.AdminApi.Sdk.Endpoints.Identities.Types.Responses; -public class ListIdentityDeletionProcessAuditLogsResponse : EnumerableResponseBase; +public class ListIdentityDeletionProcessAuditLogsResponse : EnumerableResponseBase; From 955f48afb1f5001d5e6b02b7e94b2f8d9c4f37ed Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Mon, 8 Jul 2024 14:20:50 +0200 Subject: [PATCH 079/105] feat: add AdditionalData property to IdentityDeletionProcessAuditLogEntry --- .../IdentityDeletionProcessAuditLogEntry.cs | 3 +- .../DTOs/IdentityDeletionProcessDetailsDTO.cs | 6 +- .../IdentityDeletionProcessAuditLogEntry.cs | 6 +- ...tyDeletionProcessAuditLogEntry.Designer.cs | 915 +++++++++++++++++ ...aToIdentityDeletionProcessAuditLogEntry.cs | 30 + .../DevicesDbContextModelSnapshot.cs | 3 + ...tyDeletionProcessAuditLogEntry.Designer.cs | 920 ++++++++++++++++++ ...aToIdentityDeletionProcessAuditLogEntry.cs | 30 + .../DevicesDbContextModelSnapshot.cs | 3 + ...yDeletionProcessEntityTypeConfiguration.cs | 7 +- 10 files changed, 1917 insertions(+), 6 deletions(-) create mode 100644 Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/20240708114348_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry.Designer.cs create mode 100644 Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/20240708114348_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry.cs create mode 100644 Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/20240708114346_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry.Designer.cs create mode 100644 Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/20240708114346_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry.cs diff --git a/AdminApi.Sdk/Endpoints/Identities/Types/IdentityDeletionProcessAuditLogEntry.cs b/AdminApi.Sdk/Endpoints/Identities/Types/IdentityDeletionProcessAuditLogEntry.cs index 4f5cc55a82..5d705f93bb 100644 --- a/AdminApi.Sdk/Endpoints/Identities/Types/IdentityDeletionProcessAuditLogEntry.cs +++ b/AdminApi.Sdk/Endpoints/Identities/Types/IdentityDeletionProcessAuditLogEntry.cs @@ -1,4 +1,4 @@ -namespace Backbone.AdminApi.Sdk.Endpoints.Identities.Types; +namespace Backbone.AdminApi.Sdk.Endpoints.Identities.Types; public class IdentityDeletionProcessAuditLogEntry { @@ -7,4 +7,5 @@ public class IdentityDeletionProcessAuditLogEntry public required string? OldStatus { get; set; } public required string NewStatus { get; set; } public required string MessageKey { get; set; } + public required Dictionary AdditionalData { get; set; } } diff --git a/Modules/Devices/src/Devices.Application/DTOs/IdentityDeletionProcessDetailsDTO.cs b/Modules/Devices/src/Devices.Application/DTOs/IdentityDeletionProcessDetailsDTO.cs index 76b2f9ea0f..e99e5df897 100644 --- a/Modules/Devices/src/Devices.Application/DTOs/IdentityDeletionProcessDetailsDTO.cs +++ b/Modules/Devices/src/Devices.Application/DTOs/IdentityDeletionProcessDetailsDTO.cs @@ -58,14 +58,16 @@ public IdentityDeletionProcessAuditLogEntryDTO(IdentityDeletionProcessAuditLogEn { Id = entry.Id; CreatedAt = entry.CreatedAt; - MessageKey = entry.MessageKey; OldStatus = entry.OldStatus; NewStatus = entry.NewStatus; + MessageKey = entry.MessageKey; + AdditionalData = entry.AdditionalData ?? []; } public string Id { get; set; } public DateTime CreatedAt { get; set; } - public MessageKey MessageKey { get; set; } public DeletionProcessStatus? OldStatus { get; set; } public DeletionProcessStatus NewStatus { get; set; } + public Dictionary AdditionalData { get; set; } + public MessageKey MessageKey { get; set; } } diff --git a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs index e60d39c266..f295889ff3 100644 --- a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs +++ b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs @@ -1,4 +1,4 @@ -using Backbone.BuildingBlocks.Domain; +using Backbone.BuildingBlocks.Domain; using Backbone.DevelopmentKit.Identity.ValueObjects; using Backbone.Tooling; @@ -16,7 +16,7 @@ private IdentityDeletionProcessAuditLogEntry() } private IdentityDeletionProcessAuditLogEntry(IdentityDeletionProcessId? processId, MessageKey messageKey, byte[] identityAddressHash, byte[]? deviceIdHash, DeletionProcessStatus? oldStatus, - DeletionProcessStatus newStatus) + DeletionProcessStatus newStatus, Dictionary? additionalData = null) { Id = IdentityDeletionProcessAuditLogEntryId.Generate(); ProcessId = processId; @@ -26,6 +26,7 @@ private IdentityDeletionProcessAuditLogEntry(IdentityDeletionProcessId? processI DeviceIdHash = deviceIdHash; OldStatus = oldStatus; NewStatus = newStatus; + AdditionalData = additionalData; } public IdentityDeletionProcessAuditLogEntryId Id { get; } @@ -36,6 +37,7 @@ private IdentityDeletionProcessAuditLogEntry(IdentityDeletionProcessId? processI public byte[]? DeviceIdHash { get; } public DeletionProcessStatus? OldStatus { get; } public DeletionProcessStatus NewStatus { get; } + public Dictionary? AdditionalData { get; } public static IdentityDeletionProcessAuditLogEntry ProcessStartedByOwner(IdentityDeletionProcessId processId, IdentityAddress identityAddress, DeviceId deviceId) { diff --git a/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/20240708114348_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry.Designer.cs b/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/20240708114348_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry.Designer.cs new file mode 100644 index 0000000000..285b1f8a59 --- /dev/null +++ b/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/20240708114348_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry.Designer.cs @@ -0,0 +1,915 @@ +// +using System; +using Backbone.Modules.Devices.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Backbone.Modules.Devices.Infrastructure.Database.Postgres.Migrations +{ + [DbContext(typeof(DevicesDbContext))] + [Migration("20240708114348_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry")] + partial class AddAdditionalDataToIdentityDeletionProcessAuditLogEntry + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Devices") + .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Aggregates.PushNotifications.PnsRegistration", b => + { + b.Property("DeviceId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("AppId") + .IsRequired() + .HasColumnType("text"); + + b.Property("DevicePushIdentifier") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("Environment") + .HasColumnType("integer"); + + b.Property("Handle") + .IsRequired() + .HasMaxLength(200) + .IsUnicode(true) + .HasColumnType("character varying(200)") + .IsFixedLength(false); + + b.Property("IdentityAddress") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character varying(80)") + .IsFixedLength(false); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("DeviceId"); + + b.ToTable("PnsRegistrations", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Aggregates.Tier.Tier", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("CanBeManuallyAssigned") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("CanBeUsedAsDefaultForClient") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .IsUnicode(true) + .HasColumnType("character varying(30)") + .IsFixedLength(false); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Tiers", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Challenge", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Challenges", "Challenges", t => + { + t.ExcludeFromMigrations(); + }); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeviceId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("LastLoginAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("UserName") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("DeviceId") + .IsUnique(); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Device", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("CommunicationLanguage") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2) + .IsUnicode(false) + .HasColumnType("character(2)") + .HasDefaultValue("en") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("IdentityAddress") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character varying(80)") + .IsFixedLength(false); + + b.HasKey("Id"); + + b.HasIndex("IdentityAddress"); + + b.ToTable("Devices", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", b => + { + b.Property("Address") + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character varying(80)") + .IsFixedLength(false); + + b.Property("ClientId") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletionGracePeriodEndsAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IdentityVersion") + .HasColumnType("smallint"); + + b.Property("PublicKey") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TierId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("TierIdBeforeDeletion") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.HasKey("Address"); + + b.HasIndex("ClientId"); + + b.HasIndex("TierId"); + + b.ToTable("Identities", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcess", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("ApprovalReminder1SentAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovalReminder2SentAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovalReminder3SentAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovedByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("CancelledAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CancelledByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletionStartedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("GracePeriodEndsAt") + .HasColumnType("timestamp with time zone"); + + b.Property("GracePeriodReminder1SentAt") + .HasColumnType("timestamp with time zone"); + + b.Property("GracePeriodReminder2SentAt") + .HasColumnType("timestamp with time zone"); + + b.Property("GracePeriodReminder3SentAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IdentityAddress") + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character varying(80)") + .IsFixedLength(false); + + b.Property("RejectedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("RejectedByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("Status") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("IdentityAddress"); + + b.ToTable("IdentityDeletionProcesses", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcessAuditLogEntry", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("AdditionalData") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeviceIdHash") + .HasColumnType("bytea"); + + b.Property("IdentityAddressHash") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("IdentityDeletionProcessId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("MessageKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("NewStatus") + .HasColumnType("integer"); + + b.Property("OldStatus") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("IdentityDeletionProcessId"); + + b.ToTable("IdentityDeletionProcessAuditLog", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("ApplicationType") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ClientId") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("ClientSecret") + .HasColumnType("text"); + + b.Property("ClientType") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ConcurrencyToken") + .IsConcurrencyToken() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ConsentType") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DefaultTier") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("DisplayName") + .HasColumnType("text"); + + b.Property("DisplayNames") + .HasColumnType("text"); + + b.Property("JsonWebKeySet") + .HasColumnType("text"); + + b.Property("MaxIdentities") + .HasColumnType("integer"); + + b.Property("Permissions") + .HasColumnType("text"); + + b.Property("PostLogoutRedirectUris") + .HasColumnType("text"); + + b.Property("Properties") + .HasColumnType("text"); + + b.Property("RedirectUris") + .HasColumnType("text"); + + b.Property("Requirements") + .HasColumnType("text"); + + b.Property("Settings") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ClientId") + .IsUnique(); + + b.HasIndex("DefaultTier"); + + b.ToTable("OpenIddictApplications", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreAuthorization", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("ApplicationId") + .HasColumnType("text"); + + b.Property("ConcurrencyToken") + .IsConcurrencyToken() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("CreationDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Properties") + .HasColumnType("text"); + + b.Property("Scopes") + .HasColumnType("text"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Subject") + .HasMaxLength(400) + .HasColumnType("character varying(400)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationId", "Status", "Subject", "Type"); + + b.ToTable("OpenIddictAuthorizations", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreScope", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("ConcurrencyToken") + .IsConcurrencyToken() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Descriptions") + .HasColumnType("text"); + + b.Property("DisplayName") + .HasColumnType("text"); + + b.Property("DisplayNames") + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Properties") + .HasColumnType("text"); + + b.Property("Resources") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("OpenIddictScopes", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("ApplicationId") + .HasColumnType("text"); + + b.Property("AuthorizationId") + .HasColumnType("text"); + + b.Property("ConcurrencyToken") + .IsConcurrencyToken() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("CreationDate") + .HasColumnType("timestamp with time zone"); + + b.Property("ExpirationDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Payload") + .HasColumnType("text"); + + b.Property("Properties") + .HasColumnType("text"); + + b.Property("RedemptionDate") + .HasColumnType("timestamp with time zone"); + + b.Property("ReferenceId") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Subject") + .HasMaxLength(400) + .HasColumnType("character varying(400)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorizationId"); + + b.HasIndex("ReferenceId") + .IsUnique(); + + b.HasIndex("ApplicationId", "Status", "Subject", "Type"); + + b.ToTable("OpenIddictTokens", "Devices"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", "Devices"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", "Devices"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", "Devices"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", "Devices"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", "Devices"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.Device", "Device") + .WithOne("User") + .HasForeignKey("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", "DeviceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Device"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Device", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", "Identity") + .WithMany("Devices") + .HasForeignKey("IdentityAddress") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Identity"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcess", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", null) + .WithMany("DeletionProcesses") + .HasForeignKey("IdentityAddress") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcessAuditLogEntry", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcess", null) + .WithMany("AuditLog") + .HasForeignKey("IdentityDeletionProcessId") + .OnDelete(DeleteBehavior.SetNull); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Aggregates.Tier.Tier", null) + .WithMany() + .HasForeignKey("DefaultTier") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreAuthorization", b => + { + b.HasOne("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", "Application") + .WithMany("Authorizations") + .HasForeignKey("ApplicationId"); + + b.Navigation("Application"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreToken", b => + { + b.HasOne("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", "Application") + .WithMany("Tokens") + .HasForeignKey("ApplicationId"); + + b.HasOne("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreAuthorization", "Authorization") + .WithMany("Tokens") + .HasForeignKey("AuthorizationId"); + + b.Navigation("Application"); + + b.Navigation("Authorization"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Device", b => + { + b.Navigation("User") + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", b => + { + b.Navigation("DeletionProcesses"); + + b.Navigation("Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcess", b => + { + b.Navigation("AuditLog"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", b => + { + b.Navigation("Authorizations"); + + b.Navigation("Tokens"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreAuthorization", b => + { + b.Navigation("Tokens"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/20240708114348_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry.cs b/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/20240708114348_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry.cs new file mode 100644 index 0000000000..afebb4a4d7 --- /dev/null +++ b/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/20240708114348_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Devices.Infrastructure.Database.Postgres.Migrations +{ + /// + public partial class AddAdditionalDataToIdentityDeletionProcessAuditLogEntry : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "AdditionalData", + schema: "Devices", + table: "IdentityDeletionProcessAuditLog", + type: "text", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "AdditionalData", + schema: "Devices", + table: "IdentityDeletionProcessAuditLog"); + } + } +} diff --git a/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/DevicesDbContextModelSnapshot.cs b/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/DevicesDbContextModelSnapshot.cs index 87ea0b065b..56570b5c11 100644 --- a/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/DevicesDbContextModelSnapshot.cs +++ b/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/DevicesDbContextModelSnapshot.cs @@ -364,6 +364,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("character(20)") .IsFixedLength(); + b.Property("AdditionalData") + .HasColumnType("text"); + b.Property("CreatedAt") .HasColumnType("timestamp with time zone"); diff --git a/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/20240708114346_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry.Designer.cs b/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/20240708114346_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry.Designer.cs new file mode 100644 index 0000000000..d50cf0b4f6 --- /dev/null +++ b/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/20240708114346_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry.Designer.cs @@ -0,0 +1,920 @@ +// +using System; +using Backbone.Modules.Devices.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Backbone.Modules.Devices.Infrastructure.Database.SqlServer.Migrations +{ + [DbContext(typeof(DevicesDbContext))] + [Migration("20240708114346_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry")] + partial class AddAdditionalDataToIdentityDeletionProcessAuditLogEntry + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Devices") + .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Aggregates.PushNotifications.PnsRegistration", b => + { + b.Property("DeviceId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("AppId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DevicePushIdentifier") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("Environment") + .HasColumnType("int"); + + b.Property("Handle") + .IsRequired() + .HasMaxLength(200) + .IsUnicode(true) + .HasColumnType("nvarchar(200)") + .IsFixedLength(false); + + b.Property("IdentityAddress") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("varchar(80)") + .IsFixedLength(false); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("DeviceId"); + + b.ToTable("PnsRegistrations", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Aggregates.Tier.Tier", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("CanBeManuallyAssigned") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("CanBeUsedAsDefaultForClient") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .IsUnicode(true) + .HasColumnType("nvarchar(30)") + .IsFixedLength(false); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Tiers", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Challenge", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("Challenges", "Challenges", t => + { + t.ExcludeFromMigrations(); + }); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("DeviceId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("LastLoginAt") + .HasColumnType("datetime2"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("DeviceId") + .IsUnique(); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.ToTable("AspNetUsers", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Device", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("CommunicationLanguage") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2) + .IsUnicode(false) + .HasColumnType("char(2)") + .HasDefaultValue("en") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("DeletedAt") + .HasColumnType("datetime2"); + + b.Property("DeletedByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("IdentityAddress") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("varchar(80)") + .IsFixedLength(false); + + b.HasKey("Id"); + + b.HasIndex("IdentityAddress"); + + b.ToTable("Devices", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", b => + { + b.Property("Address") + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("varchar(80)") + .IsFixedLength(false); + + b.Property("ClientId") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("DeletionGracePeriodEndsAt") + .HasColumnType("datetime2"); + + b.Property("IdentityVersion") + .HasColumnType("tinyint"); + + b.Property("PublicKey") + .IsRequired() + .HasColumnType("varbinary(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TierId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("TierIdBeforeDeletion") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.HasKey("Address"); + + b.HasIndex("ClientId"); + + b.HasIndex("TierId"); + + b.ToTable("Identities", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcess", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("ApprovalReminder1SentAt") + .HasColumnType("datetime2"); + + b.Property("ApprovalReminder2SentAt") + .HasColumnType("datetime2"); + + b.Property("ApprovalReminder3SentAt") + .HasColumnType("datetime2"); + + b.Property("ApprovedAt") + .HasColumnType("datetime2"); + + b.Property("ApprovedByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("CancelledAt") + .HasColumnType("datetime2"); + + b.Property("CancelledByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("DeletionStartedAt") + .HasColumnType("datetime2"); + + b.Property("GracePeriodEndsAt") + .HasColumnType("datetime2"); + + b.Property("GracePeriodReminder1SentAt") + .HasColumnType("datetime2"); + + b.Property("GracePeriodReminder2SentAt") + .HasColumnType("datetime2"); + + b.Property("GracePeriodReminder3SentAt") + .HasColumnType("datetime2"); + + b.Property("IdentityAddress") + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("varchar(80)") + .IsFixedLength(false); + + b.Property("RejectedAt") + .HasColumnType("datetime2"); + + b.Property("RejectedByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IdentityAddress"); + + b.ToTable("IdentityDeletionProcesses", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcessAuditLogEntry", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("AdditionalData") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("DeviceIdHash") + .HasColumnType("varbinary(max)"); + + b.Property("IdentityAddressHash") + .IsRequired() + .HasColumnType("varbinary(max)"); + + b.Property("IdentityDeletionProcessId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("MessageKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NewStatus") + .HasColumnType("int"); + + b.Property("OldStatus") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IdentityDeletionProcessId"); + + b.ToTable("IdentityDeletionProcessAuditLog", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ApplicationType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ClientId") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ClientSecret") + .HasColumnType("nvarchar(max)"); + + b.Property("ClientType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ConcurrencyToken") + .IsConcurrencyToken() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ConsentType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("DefaultTier") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("DisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayNames") + .HasColumnType("nvarchar(max)"); + + b.Property("JsonWebKeySet") + .HasColumnType("nvarchar(max)"); + + b.Property("MaxIdentities") + .HasColumnType("int"); + + b.Property("Permissions") + .HasColumnType("nvarchar(max)"); + + b.Property("PostLogoutRedirectUris") + .HasColumnType("nvarchar(max)"); + + b.Property("Properties") + .HasColumnType("nvarchar(max)"); + + b.Property("RedirectUris") + .HasColumnType("nvarchar(max)"); + + b.Property("Requirements") + .HasColumnType("nvarchar(max)"); + + b.Property("Settings") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClientId") + .IsUnique() + .HasFilter("[ClientId] IS NOT NULL"); + + b.HasIndex("DefaultTier"); + + b.ToTable("OpenIddictApplications", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreAuthorization", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ApplicationId") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyToken") + .IsConcurrencyToken() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Properties") + .HasColumnType("nvarchar(max)"); + + b.Property("Scopes") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Subject") + .HasMaxLength(400) + .HasColumnType("nvarchar(400)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationId", "Status", "Subject", "Type"); + + b.ToTable("OpenIddictAuthorizations", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreScope", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyToken") + .IsConcurrencyToken() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Descriptions") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayNames") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Properties") + .HasColumnType("nvarchar(max)"); + + b.Property("Resources") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique() + .HasFilter("[Name] IS NOT NULL"); + + b.ToTable("OpenIddictScopes", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ApplicationId") + .HasColumnType("nvarchar(450)"); + + b.Property("AuthorizationId") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyToken") + .IsConcurrencyToken() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("ExpirationDate") + .HasColumnType("datetime2"); + + b.Property("Payload") + .HasColumnType("nvarchar(max)"); + + b.Property("Properties") + .HasColumnType("nvarchar(max)"); + + b.Property("RedemptionDate") + .HasColumnType("datetime2"); + + b.Property("ReferenceId") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Subject") + .HasMaxLength(400) + .HasColumnType("nvarchar(400)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorizationId"); + + b.HasIndex("ReferenceId") + .IsUnique() + .HasFilter("[ReferenceId] IS NOT NULL"); + + b.HasIndex("ApplicationId", "Status", "Subject", "Type"); + + b.ToTable("OpenIddictTokens", "Devices"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", "Devices"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", "Devices"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", "Devices"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", "Devices"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", "Devices"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", "Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.Device", "Device") + .WithOne("User") + .HasForeignKey("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", "DeviceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Device"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Device", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", "Identity") + .WithMany("Devices") + .HasForeignKey("IdentityAddress") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Identity"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcess", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", null) + .WithMany("DeletionProcesses") + .HasForeignKey("IdentityAddress") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcessAuditLogEntry", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcess", null) + .WithMany("AuditLog") + .HasForeignKey("IdentityDeletionProcessId") + .OnDelete(DeleteBehavior.SetNull); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Aggregates.Tier.Tier", null) + .WithMany() + .HasForeignKey("DefaultTier") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreAuthorization", b => + { + b.HasOne("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", "Application") + .WithMany("Authorizations") + .HasForeignKey("ApplicationId"); + + b.Navigation("Application"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreToken", b => + { + b.HasOne("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", "Application") + .WithMany("Tokens") + .HasForeignKey("ApplicationId"); + + b.HasOne("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreAuthorization", "Authorization") + .WithMany("Tokens") + .HasForeignKey("AuthorizationId"); + + b.Navigation("Application"); + + b.Navigation("Authorization"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Device", b => + { + b.Navigation("User") + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", b => + { + b.Navigation("DeletionProcesses"); + + b.Navigation("Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcess", b => + { + b.Navigation("AuditLog"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", b => + { + b.Navigation("Authorizations"); + + b.Navigation("Tokens"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreAuthorization", b => + { + b.Navigation("Tokens"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/20240708114346_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry.cs b/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/20240708114346_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry.cs new file mode 100644 index 0000000000..c6c93acffe --- /dev/null +++ b/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/20240708114346_AddAdditionalDataToIdentityDeletionProcessAuditLogEntry.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Devices.Infrastructure.Database.SqlServer.Migrations +{ + /// + public partial class AddAdditionalDataToIdentityDeletionProcessAuditLogEntry : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "AdditionalData", + schema: "Devices", + table: "IdentityDeletionProcessAuditLog", + type: "nvarchar(max)", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "AdditionalData", + schema: "Devices", + table: "IdentityDeletionProcessAuditLog"); + } + } +} diff --git a/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/DevicesDbContextModelSnapshot.cs b/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/DevicesDbContextModelSnapshot.cs index 15a262b5e3..2f11a773e1 100644 --- a/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/DevicesDbContextModelSnapshot.cs +++ b/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/DevicesDbContextModelSnapshot.cs @@ -365,6 +365,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("char(20)") .IsFixedLength(); + b.Property("AdditionalData") + .HasColumnType("nvarchar(max)"); + b.Property("CreatedAt") .HasColumnType("datetime2"); diff --git a/Modules/Devices/src/Devices.Infrastructure/Persistence/Database/EntityConfigurations/IdentityDeletionProcessEntityTypeConfiguration.cs b/Modules/Devices/src/Devices.Infrastructure/Persistence/Database/EntityConfigurations/IdentityDeletionProcessEntityTypeConfiguration.cs index 796bb3c047..d02dc04b32 100644 --- a/Modules/Devices/src/Devices.Infrastructure/Persistence/Database/EntityConfigurations/IdentityDeletionProcessEntityTypeConfiguration.cs +++ b/Modules/Devices/src/Devices.Infrastructure/Persistence/Database/EntityConfigurations/IdentityDeletionProcessEntityTypeConfiguration.cs @@ -1,4 +1,5 @@ -using Backbone.BuildingBlocks.Infrastructure.Persistence.Database.EntityTypeConfigurations; +using System.Text.Json; +using Backbone.BuildingBlocks.Infrastructure.Persistence.Database.EntityTypeConfigurations; using Backbone.Modules.Devices.Domain.Entities.Identities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; @@ -38,5 +39,9 @@ public override void Configure(EntityTypeBuilder x.NewStatus); builder.Property(x => x.OldStatus); builder.Property(x => x.MessageKey).HasConversion(); + builder.Property(x => x.AdditionalData).HasConversion( + v => JsonSerializer.Serialize(v, JsonSerializerOptions.Default), + v => JsonSerializer.Deserialize>(v, JsonSerializerOptions.Default) + ); } } From 8e811875957b1b6e6b8304606a37e0b82b4b2c23 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Mon, 8 Jul 2024 14:21:52 +0200 Subject: [PATCH 080/105] chore: update deletion process logger to use string instead of enum for aggregate type --- .../Identities/IIdentityDeleter.cs | 19 +------ Jobs/src/Job.IdentityDeletion/Program.cs | 2 +- .../ActualDeletionWorkerTests.cs | 39 +++++++++------ .../Identities/IdentityDeleter.cs | 2 +- .../LogDeletionProcessCommand.cs | 8 +-- .../Identities/IdentityDeleter.cs | 4 +- .../IdentityDeletionProcessAuditLogEntry.cs | 49 +++---------------- .../Identities/IdentityDeleter.cs | 2 +- .../Identities/IdentityDeleter.cs | 2 +- .../Identities/IdentityDeleter.cs | 2 +- .../Identities/IdentityDeleter.cs | 6 +-- .../Identities/IdentityDeleter.cs | 6 +-- .../Identities/IdentityDeleter.cs | 2 +- 13 files changed, 52 insertions(+), 91 deletions(-) diff --git a/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs b/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs index 55da605618..ef894552b7 100644 --- a/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs +++ b/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs @@ -8,22 +8,5 @@ public interface IIdentityDeleter public interface IDeletionProcessLogger { - Task LogDeletion(IdentityAddress identityAddress, AggregateType aggregateType); -} - -public enum AggregateType -{ - Challenges, - PnsRegistrations, - Identities, - Files, - Messages, - QuotaIdentities, - Relationships, - RelationshipTemplates, - RelationshipTemplateAllocations, - ExternalEvents, - SyncRuns, - Datawallets, - Tokens + Task LogDeletion(IdentityAddress identityAddress, string aggregateType); } diff --git a/Jobs/src/Job.IdentityDeletion/Program.cs b/Jobs/src/Job.IdentityDeletion/Program.cs index f7f53d6cb3..0d2af3d322 100644 --- a/Jobs/src/Job.IdentityDeletion/Program.cs +++ b/Jobs/src/Job.IdentityDeletion/Program.cs @@ -143,7 +143,7 @@ public DeletionProcessLogger(IMediator mediator) _mediator = mediator; } - public async Task LogDeletion(IdentityAddress identityAddress, AggregateType aggregateType) + public async Task LogDeletion(IdentityAddress identityAddress, string aggregateType) { await _mediator.Send(new LogDeletionProcessCommand(identityAddress, aggregateType)); } diff --git a/Jobs/test/Job.IdentityDeletion.Tests.Integration/ActualDeletionWorkerTests.cs b/Jobs/test/Job.IdentityDeletion.Tests.Integration/ActualDeletionWorkerTests.cs index e8c60e4a87..31e8771c12 100644 --- a/Jobs/test/Job.IdentityDeletion.Tests.Integration/ActualDeletionWorkerTests.cs +++ b/Jobs/test/Job.IdentityDeletion.Tests.Integration/ActualDeletionWorkerTests.cs @@ -42,20 +42,31 @@ public async Task Logs_that_data_was_deleted() var assertionContext = GetService(); var auditLogEntries = await assertionContext.IdentityDeletionProcessAuditLogs.Where(a => a.IdentityAddressHash == Hasher.HashUtf8(identity.Address)).ToListAsync(); - auditLogEntries.Should().HaveCount(14); - auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.ChallengesDeleted); - auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.PnsRegistrationsDeleted); - auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.IdentitiesDeleted); - auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.FilesDeleted); - auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.MessagesDeleted); - auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.QuotaIdentitiesDeleted); - auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.RelationshipsDeleted); - auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.RelationshipTemplatesDeleted); - auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.RelationshipTemplateAllocationsDeleted); - auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.ExternalEventsDeleted); - auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.SyncRunsDeleted); - auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.DatawalletsDeleted); - auditLogEntries.Should().Contain(a => a.MessageKey == MessageKey.TokensDeleted); + + var auditLogEntriesForDeletedData = auditLogEntries.Where(e => e.MessageKey == MessageKey.DataDeleted).ToList(); + + auditLogEntriesForDeletedData.Should().HaveCount(13); + + auditLogEntriesForDeletedData.Should().AllSatisfy(e => + { + e.AdditionalData.Should().HaveCount(1); + e.AdditionalData!.First().Key.Should().Be("aggregateType"); + }); + + var deletedAggregates = auditLogEntriesForDeletedData.SelectMany(e => e.AdditionalData!.Values).ToList(); + deletedAggregates.Should().Contain("Challenges"); + deletedAggregates.Should().Contain("PnsRegistrations"); + deletedAggregates.Should().Contain("Identities"); + deletedAggregates.Should().Contain("Files"); + deletedAggregates.Should().Contain("Messages"); + deletedAggregates.Should().Contain("QuotaIdentities"); + deletedAggregates.Should().Contain("Relationships"); + deletedAggregates.Should().Contain("RelationshipTemplates"); + deletedAggregates.Should().Contain("RelationshipTemplateAllocations"); + deletedAggregates.Should().Contain("ExternalEvents"); + deletedAggregates.Should().Contain("SyncRuns"); + deletedAggregates.Should().Contain("Datawallets"); + deletedAggregates.Should().Contain("Tokens"); } [Fact] diff --git a/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs b/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs index 3c741d5044..78bd2112cf 100644 --- a/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs +++ b/Modules/Challenges/src/Challenges.Application/Identities/IdentityDeleter.cs @@ -17,6 +17,6 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new DeleteChallengesOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Challenges); + await deletionProcessLogger.LogDeletion(identityAddress, "Challenges"); } } diff --git a/Modules/Devices/src/Devices.Application/Identities/Commands/LogDeletionProcess/LogDeletionProcessCommand.cs b/Modules/Devices/src/Devices.Application/Identities/Commands/LogDeletionProcess/LogDeletionProcessCommand.cs index 2aee6d0ccd..7b6f039405 100644 --- a/Modules/Devices/src/Devices.Application/Identities/Commands/LogDeletionProcess/LogDeletionProcessCommand.cs +++ b/Modules/Devices/src/Devices.Application/Identities/Commands/LogDeletionProcess/LogDeletionProcessCommand.cs @@ -1,16 +1,16 @@ -using Backbone.BuildingBlocks.Application.Identities; -using Backbone.DevelopmentKit.Identity.ValueObjects; +using Backbone.DevelopmentKit.Identity.ValueObjects; using MediatR; namespace Backbone.Modules.Devices.Application.Identities.Commands.LogDeletionProcess; + public class LogDeletionProcessCommand : IRequest { - public LogDeletionProcessCommand(IdentityAddress identityAddress, AggregateType aggregateType) + public LogDeletionProcessCommand(IdentityAddress identityAddress, string aggregateType) { IdentityAddress = identityAddress; AggregateType = aggregateType; } public string IdentityAddress { get; set; } - public AggregateType AggregateType { get; set; } + public string AggregateType { get; set; } } diff --git a/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs b/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs index 4e56833629..1dabb3ac7c 100644 --- a/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs +++ b/Modules/Devices/src/Devices.Application/Identities/IdentityDeleter.cs @@ -18,8 +18,8 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new DeletePnsRegistrationsOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.PnsRegistrations); + await deletionProcessLogger.LogDeletion(identityAddress, "PnsRegistrations"); await _mediator.Send(new DeleteIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Identities); + await deletionProcessLogger.LogDeletion(identityAddress, "Identities"); } } diff --git a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs index f295889ff3..23b3095389 100644 --- a/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs +++ b/Modules/Devices/src/Devices.Domain/Entities/Identities/IdentityDeletionProcessAuditLogEntry.cs @@ -1,4 +1,4 @@ -using Backbone.BuildingBlocks.Domain; +using Backbone.BuildingBlocks.Domain; using Backbone.DevelopmentKit.Identity.ValueObjects; using Backbone.Tooling; @@ -196,40 +196,19 @@ public static IdentityDeletionProcessAuditLogEntry GracePeriodReminder3Sent(Iden public static IdentityDeletionProcessAuditLogEntry DataDeleted(IdentityAddress identityAddress, string aggregateType) { - if (!TryGetMessageKey(aggregateType, out var messageKey)) - throw new ArgumentException("Invalid aggregateType", nameof(aggregateType)); - return new IdentityDeletionProcessAuditLogEntry( null, - messageKey, + MessageKey.DataDeleted, Hasher.HashUtf8(identityAddress.Value), null, DeletionProcessStatus.Deleting, - DeletionProcessStatus.Deleting + DeletionProcessStatus.Deleting, + new Dictionary + { + { "aggregateType", aggregateType } + } ); } - - private static bool TryGetMessageKey(string aggregateType, out MessageKey messageKey) - { - var messageKeyMappings = new Dictionary - { - { "Challenges", MessageKey.ChallengesDeleted }, - { "PnsRegistrations", MessageKey.PnsRegistrationsDeleted }, - { "Identities", MessageKey.IdentitiesDeleted }, - { "Files", MessageKey.FilesDeleted }, - { "Messages", MessageKey.MessagesDeleted }, - { "QuotaIdentities", MessageKey.QuotaIdentitiesDeleted }, - { "Relationships", MessageKey.RelationshipsDeleted }, - { "RelationshipTemplates", MessageKey.RelationshipTemplatesDeleted }, - { "RelationshipTemplateAllocations", MessageKey.RelationshipTemplateAllocationsDeleted }, - { "ExternalEvents", MessageKey.ExternalEventsDeleted }, - { "SyncRuns", MessageKey.SyncRunsDeleted }, - { "Datawallets", MessageKey.DatawalletsDeleted }, - { "Tokens", MessageKey.TokensDeleted } - }; - - return messageKeyMappings.TryGetValue(aggregateType, out messageKey); - } } public enum MessageKey @@ -247,17 +226,5 @@ public enum MessageKey GracePeriodReminder1Sent = 11, GracePeriodReminder2Sent = 12, GracePeriodReminder3Sent = 13, - ChallengesDeleted = 14, - PnsRegistrationsDeleted = 15, - IdentitiesDeleted = 16, - FilesDeleted = 17, - MessagesDeleted = 18, - QuotaIdentitiesDeleted = 19, - RelationshipsDeleted = 20, - RelationshipTemplatesDeleted = 21, - RelationshipTemplateAllocationsDeleted = 22, - ExternalEventsDeleted = 23, - SyncRunsDeleted = 24, - DatawalletsDeleted = 25, - TokensDeleted = 26 + DataDeleted = 14 } diff --git a/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs b/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs index 2d30500bb2..6863186a10 100644 --- a/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs +++ b/Modules/Files/src/Files.Application/Identities/IdentityDeleter.cs @@ -17,6 +17,6 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new DeleteFilesOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Files); + await deletionProcessLogger.LogDeletion(identityAddress, "Files"); } } diff --git a/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs b/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs index 8a36d34643..5ff6e3a477 100644 --- a/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs +++ b/Modules/Messages/src/Messages.Application/Identities/IdentityDeleter.cs @@ -17,6 +17,6 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new AnonymizeMessagesOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Messages); + await deletionProcessLogger.LogDeletion(identityAddress, "Messages"); } } diff --git a/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs b/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs index 9892063e53..3cd9eb42e2 100644 --- a/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs +++ b/Modules/Quotas/src/Quotas.Application/Identities/IdentityDeleter.cs @@ -17,6 +17,6 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new DeleteIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.QuotaIdentities); + await deletionProcessLogger.LogDeletion(identityAddress, "QuotaIdentities"); } } diff --git a/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs b/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs index 79f4a35ceb..a97f3b3e06 100644 --- a/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs +++ b/Modules/Relationships/src/Relationships.Application/Identities/IdentityDeleter.cs @@ -19,10 +19,10 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new DeleteRelationshipsOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Relationships); + await deletionProcessLogger.LogDeletion(identityAddress, "Relationships"); await _mediator.Send(new DeleteRelationshipTemplatesOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplates); + await deletionProcessLogger.LogDeletion(identityAddress, "RelationshipTemplates"); await _mediator.Send(new AnonymizeRelationshipTemplateAllocationsAllocatedByIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplateAllocations); + await deletionProcessLogger.LogDeletion(identityAddress, "RelationshipTemplateAllocations"); } } diff --git a/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs b/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs index 411245c9c8..459cc5cb2b 100644 --- a/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs +++ b/Modules/Synchronization/src/Synchronization.Application/Identities/IdentityDeleter.cs @@ -19,10 +19,10 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new DeleteExternalEventsOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.ExternalEvents); + await deletionProcessLogger.LogDeletion(identityAddress, "ExternalEvents"); await _mediator.Send(new DeleteSyncRunsOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.SyncRuns); + await deletionProcessLogger.LogDeletion(identityAddress, "SyncRuns"); await _mediator.Send(new DeleteDatawalletsOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Datawallets); + await deletionProcessLogger.LogDeletion(identityAddress, "Datawallets"); } } diff --git a/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs b/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs index 3c1b237ded..c75cdade66 100644 --- a/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs +++ b/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs @@ -17,6 +17,6 @@ public IdentityDeleter(IMediator mediator) public async Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger) { await _mediator.Send(new DeleteTokensOfIdentityCommand(identityAddress)); - await deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Tokens); + await deletionProcessLogger.LogDeletion(identityAddress, "Tokens"); } } From fe8bf89cec162b88e5e238acf4df9f6863fc4635 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Mon, 8 Jul 2024 15:15:08 +0200 Subject: [PATCH 081/105] fix: compiler errors --- .../Tests/Identities/IdentityDeleterTests.cs | 3 ++- .../Tests/Identities/IdentityDeleterTests.cs | 5 +++-- .../Tests/Identities/IdentityDeleterTests.cs | 3 ++- .../Tests/Identities/IdentityDeleterTests.cs | 3 ++- .../Tests/Identities/IdentityDeleterTests.cs | 3 ++- .../Tests/Identities/IdentityDeleterTests.cs | 7 ++++--- .../Tests/Identities/IdentityDeleterTests.cs | 7 ++++--- .../Tests/Identities/IdentityDeleterTests.cs | 3 ++- 8 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 0d37b1d489..23cb43d1da 100644 --- a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -8,6 +8,7 @@ using static Backbone.UnitTestTools.Data.TestDataGenerator; namespace Backbone.Modules.Challenges.Application.Tests.Tests.Identities; + public class IdentityDeleterTests : AbstractTestsBase { [Fact] @@ -39,6 +40,6 @@ public async Task Deleter_correctly_creates_audit_log() await deleter.Delete(identityAddress, mockIDeletionProcessLogger); // Assert - A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.Challenges)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "Challenges")).MustHaveHappenedOnceExactly(); } } diff --git a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index bd172b3610..f6c51a6373 100644 --- a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -9,6 +9,7 @@ using static Backbone.UnitTestTools.Data.TestDataGenerator; namespace Backbone.Modules.Devices.Application.Tests.Tests.Identities; + public class IdentityDeleterTests : AbstractTestsBase { [Fact] @@ -41,7 +42,7 @@ public async Task Deleter_correctly_creates_audit_log() await deleter.Delete(identityAddress, mockIDeletionProcessLogger); // Assert - A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.Identities)).MustHaveHappenedOnceExactly(); - A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.PnsRegistrations)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "Identities")).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "PnsRegistrations")).MustHaveHappenedOnceExactly(); } } diff --git a/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 8000ac1d32..95bd6719ea 100644 --- a/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -8,6 +8,7 @@ using static Backbone.UnitTestTools.Data.TestDataGenerator; namespace Backbone.Modules.Files.Application.Tests.Tests.Identities; + public class IdentityDeleterTests : AbstractTestsBase { [Fact] @@ -39,6 +40,6 @@ public async Task Deleter_correctly_creates_audit_log() await deleter.Delete(identityAddress, mockIDeletionProcessLogger); // Assert - A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.Files)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "Files")).MustHaveHappenedOnceExactly(); } } diff --git a/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 579e7f4629..72091c7374 100644 --- a/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -8,6 +8,7 @@ using static Backbone.UnitTestTools.Data.TestDataGenerator; namespace Backbone.Modules.Messages.Application.Tests.Tests.Identities; + public class IdentityDeleterTests : AbstractTestsBase { [Fact] @@ -39,6 +40,6 @@ public async Task Deleter_correctly_creates_audit_log() await deleter.Delete(identityAddress, mockIDeletionProcessLogger); // Assert - A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.Messages)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "Messages")).MustHaveHappenedOnceExactly(); } } diff --git a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 5e17e919dc..68a3d86d2c 100644 --- a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -8,6 +8,7 @@ using static Backbone.UnitTestTools.Data.TestDataGenerator; namespace Backbone.Modules.Quotas.Application.Tests.Tests.Identities; + public class IdentityDeleterTests : AbstractTestsBase { [Fact] @@ -39,6 +40,6 @@ public async Task Deleter_correctly_creates_audit_log() await deleter.Delete(identityAddress, mockIDeletionProcessLogger); // Assert - A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.QuotaIdentities)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "QuotaIdentities")).MustHaveHappenedOnceExactly(); } } diff --git a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 6a6cefea24..68cab255fd 100644 --- a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -10,6 +10,7 @@ using static Backbone.UnitTestTools.Data.TestDataGenerator; namespace Backbone.Modules.Relationships.Application.Tests.Tests.Identities; + public class IdentityDeleterTests : AbstractTestsBase { [Fact] @@ -50,8 +51,8 @@ public async Task Deleter_correctly_creates_audit_log() await deleter.Delete(identityAddress, mockIDeletionProcessLogger); // Assert - A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.Relationships)).MustHaveHappenedOnceExactly(); - A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplates)).MustHaveHappenedOnceExactly(); - A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.RelationshipTemplateAllocations)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "Relationships")).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "RelationshipTemplates")).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "RelationshipTemplateAllocations")).MustHaveHappenedOnceExactly(); } } diff --git a/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 1c44499f49..217eba53dc 100644 --- a/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -10,6 +10,7 @@ using static Backbone.UnitTestTools.Data.TestDataGenerator; namespace Backbone.Modules.Synchronization.Application.Tests.Tests.Identities; + public class IdentityDeleterTests : AbstractTestsBase { [Fact] @@ -43,8 +44,8 @@ public async Task Deleter_correctly_creates_audit_log() await deleter.Delete(identityAddress, mockIDeletionProcessLogger); // Assert - A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.ExternalEvents)).MustHaveHappenedOnceExactly(); - A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.SyncRuns)).MustHaveHappenedOnceExactly(); - A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.Datawallets)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "ExternalEvents")).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "SyncRuns")).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "Datawallets")).MustHaveHappenedOnceExactly(); } } diff --git a/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 40983793ab..c86759c6a6 100644 --- a/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -8,6 +8,7 @@ using static Backbone.UnitTestTools.Data.TestDataGenerator; namespace Backbone.Modules.Tokens.Application.Tests.Tests.Identities; + public class IdentityDeleterTests : AbstractTestsBase { [Fact] @@ -39,6 +40,6 @@ public async Task Deleter_correctly_creates_audit_log() await deleter.Delete(identityAddress, mockIDeletionProcessLogger); // Assert - A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, AggregateType.Tokens)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "Tokens")).MustHaveHappenedOnceExactly(); } } From aad77b2dac7a0fa7e4f6d7da60f8826d57ca4920 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Mon, 8 Jul 2024 15:16:56 +0200 Subject: [PATCH 082/105] chore: update packages of Challenges.Application.Tests.csproj --- .../Challenges.Application.Tests.csproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/Challenges/test/Challenges.Application.Tests/Challenges.Application.Tests.csproj b/Modules/Challenges/test/Challenges.Application.Tests/Challenges.Application.Tests.csproj index 274488c39b..f255a8fdcc 100644 --- a/Modules/Challenges/test/Challenges.Application.Tests/Challenges.Application.Tests.csproj +++ b/Modules/Challenges/test/Challenges.Application.Tests/Challenges.Application.Tests.csproj @@ -5,17 +5,17 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive From 5c0f6ee0d42a34a80110dccd51be8fd01e48a18b Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 8 Jul 2024 15:21:29 +0200 Subject: [PATCH 083/105] fix: adapt moved code to separate files --- .../Identities/IDeletionProcessLogger.cs | 2 +- .../Identities/IIdentityDeleter.cs | 76 +------------------ .../DeletionProcessLogger.cs | 2 +- Jobs/src/Job.IdentityDeletion/Program.cs | 15 ---- .../Identities/IdentityDeleter.cs | 2 +- 5 files changed, 4 insertions(+), 93 deletions(-) diff --git a/BuildingBlocks/src/BuildingBlocks.Application/Identities/IDeletionProcessLogger.cs b/BuildingBlocks/src/BuildingBlocks.Application/Identities/IDeletionProcessLogger.cs index d619ab2efc..9ad952a4c7 100644 --- a/BuildingBlocks/src/BuildingBlocks.Application/Identities/IDeletionProcessLogger.cs +++ b/BuildingBlocks/src/BuildingBlocks.Application/Identities/IDeletionProcessLogger.cs @@ -3,5 +3,5 @@ namespace Backbone.BuildingBlocks.Application.Identities; public interface IDeletionProcessLogger { - Task LogDeletion(IdentityAddress identityAddress, AggregateType aggregateType); + Task LogDeletion(IdentityAddress identityAddress, string aggregateType); } diff --git a/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs b/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs index 8bb5824140..1175d6d7b2 100644 --- a/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs +++ b/BuildingBlocks/src/BuildingBlocks.Application/Identities/IIdentityDeleter.cs @@ -3,79 +3,5 @@ namespace Backbone.BuildingBlocks.Application.Identities; public interface IIdentityDeleter { - Task Delete(IdentityAddress identityAddress, IDeletionProcessLogger deletionProcessLogger); -} - -public interface IDeletionProcessLogger -{ - Task LogDeletion(IdentityAddress identityAddress, string aggregateType); -} - -public enum AggregateType -{ - Challenges, - PnsRegistrations, - Identities, - Files, - Messages, - QuotaIdentities, - Relationships, - RelationshipTemplates, - RelationshipTemplateAllocations, - ExternalEvents, - SyncRuns, - Datawallets, - Tokens -} - -public enum AggregateType -{ - Challenges, - PnsRegistrations, - Identities, - Files, - Messages, - QuotaIdentities, - Relationships, - RelationshipTemplates, - RelationshipTemplateAllocations, - ExternalEvents, - SyncRuns, - Datawallets, - Tokens -} - -public enum AggregateType -{ - Challenges, - PnsRegistrations, - Identities, - Files, - Messages, - QuotaIdentities, - Relationships, - RelationshipTemplates, - RelationshipTemplateAllocations, - ExternalEvents, - SyncRuns, - Datawallets, - Tokens -} - - -public enum AggregateType -{ - Challenges, - PnsRegistrations, - Identities, - Files, - Messages, - QuotaIdentities, - Relationships, - RelationshipTemplates, - RelationshipTemplateAllocations, - ExternalEvents, - SyncRuns, - Datawallets, - Tokens + Task Delete(IdentityAddress identityAddress); } diff --git a/Jobs/src/Job.IdentityDeletion/DeletionProcessLogger.cs b/Jobs/src/Job.IdentityDeletion/DeletionProcessLogger.cs index cc221c72a0..65e9dd533b 100644 --- a/Jobs/src/Job.IdentityDeletion/DeletionProcessLogger.cs +++ b/Jobs/src/Job.IdentityDeletion/DeletionProcessLogger.cs @@ -13,7 +13,7 @@ public DeletionProcessLogger(IMediator mediator) _mediator = mediator; } - public async Task LogDeletion(IdentityAddress identityAddress, AggregateType aggregateType) + public async Task LogDeletion(IdentityAddress identityAddress, string aggregateType) { await _mediator.Send(new LogDeletionProcessCommand(identityAddress, aggregateType)); } diff --git a/Jobs/src/Job.IdentityDeletion/Program.cs b/Jobs/src/Job.IdentityDeletion/Program.cs index 073e7f7eb5..ca31e3eaee 100644 --- a/Jobs/src/Job.IdentityDeletion/Program.cs +++ b/Jobs/src/Job.IdentityDeletion/Program.cs @@ -130,18 +130,3 @@ public static IHostBuilder CreateHostBuilder(string[] args) ); } } - -public class DeletionProcessLogger : IDeletionProcessLogger -{ - private readonly IMediator _mediator; - - public DeletionProcessLogger(IMediator mediator) - { - _mediator = mediator; - } - - public async Task LogDeletion(IdentityAddress identityAddress, string aggregateType) - { - await _mediator.Send(new LogDeletionProcessCommand(identityAddress, aggregateType)); - } -} diff --git a/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs b/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs index b0801ecfe8..895709831b 100644 --- a/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs +++ b/Modules/Tokens/src/Tokens.Application/Identities/IdentityDeleter.cs @@ -19,6 +19,6 @@ public IdentityDeleter(IMediator mediator, IDeletionProcessLogger deletionProces public async Task Delete(IdentityAddress identityAddress) { await _mediator.Send(new DeleteTokensOfIdentityCommand(identityAddress)); - await _deletionProcessLogger.LogDeletion(identityAddress, AggregateType.Tokens); + await _deletionProcessLogger.LogDeletion(identityAddress, "Tokens"); } } From 2003f47364b522ed75e96705dc7b0988544520c7 Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 8 Jul 2024 15:38:20 +0200 Subject: [PATCH 084/105] test: fix tests --- .../Tests/Identities/IdentityDeleterTests.cs | 12 ++++++------ .../Tests/Identities/IdentityDeleterTests.cs | 12 ++++++------ .../Tests/Identities/IdentityDeleterTests.cs | 12 ++++++------ .../Tests/Identities/IdentityDeleterTests.cs | 12 ++++++------ .../Tests/Identities/IdentityDeleterTests.cs | 12 ++++++------ .../Tests/Identities/IdentityDeleterTests.cs | 12 ++++++------ .../Tests/Identities/IdentityDeleterTests.cs | 12 ++++++------ .../Tests/Identities/IdentityDeleterTests.cs | 12 ++++++------ 8 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 23bd6d7c68..bacad387a7 100644 --- a/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Challenges/test/Challenges.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -16,12 +16,12 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var deleter = new IdentityDeleter(mockMediator); - var identityAddress = CreateRandomIdentityAddress(); var dummyIDeletionProcessLogger = A.Dummy(); + var deleter = new IdentityDeleter(mockMediator, dummyIDeletionProcessLogger); + var identityAddress = CreateRandomIdentityAddress(); // Act - await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); + await deleter.Delete(identityAddress); // Assert A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); @@ -32,12 +32,12 @@ public async Task Deleter_correctly_creates_audit_log() { // Arrange var dummyMediator = A.Dummy(); - var deleter = new IdentityDeleter(dummyMediator); - var identityAddress = CreateRandomIdentityAddress(); var mockIDeletionProcessLogger = A.Fake(); + var deleter = new IdentityDeleter(dummyMediator, mockIDeletionProcessLogger); + var identityAddress = CreateRandomIdentityAddress(); // Act - await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + await deleter.Delete(identityAddress); // Assert A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "Challenges")).MustHaveHappenedOnceExactly(); diff --git a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index bccf8f8b04..eba5bac108 100644 --- a/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Devices/test/Devices.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -17,12 +17,12 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var deleter = new IdentityDeleter(mockMediator); - var identityAddress = CreateRandomIdentityAddress(); var dummyIDeletionProcessLogger = A.Dummy(); + var deleter = new IdentityDeleter(mockMediator, dummyIDeletionProcessLogger); + var identityAddress = CreateRandomIdentityAddress(); // Act - await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); + await deleter.Delete(identityAddress); // Assert A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); @@ -34,12 +34,12 @@ public async Task Deleter_correctly_creates_audit_log() { // Arrange var dummyMediator = A.Dummy(); - var deleter = new IdentityDeleter(dummyMediator); - var identityAddress = CreateRandomIdentityAddress(); var mockIDeletionProcessLogger = A.Fake(); + var deleter = new IdentityDeleter(dummyMediator, mockIDeletionProcessLogger); + var identityAddress = CreateRandomIdentityAddress(); // Act - await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + await deleter.Delete(identityAddress); // Assert A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "Identities")).MustHaveHappenedOnceExactly(); diff --git a/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 19a114b973..4ba7a63f3e 100644 --- a/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Files/test/Files.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -16,12 +16,12 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var deleter = new IdentityDeleter(mockMediator); - var identityAddress = CreateRandomIdentityAddress(); var dummyIDeletionProcessLogger = A.Dummy(); + var deleter = new IdentityDeleter(mockMediator, dummyIDeletionProcessLogger); + var identityAddress = CreateRandomIdentityAddress(); // Act - await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); + await deleter.Delete(identityAddress); // Assert A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); @@ -32,12 +32,12 @@ public async Task Deleter_correctly_creates_audit_log() { // Arrange var dummyMediator = A.Dummy(); - var deleter = new IdentityDeleter(dummyMediator); - var identityAddress = CreateRandomIdentityAddress(); var mockIDeletionProcessLogger = A.Fake(); + var deleter = new IdentityDeleter(dummyMediator, mockIDeletionProcessLogger); + var identityAddress = CreateRandomIdentityAddress(); // Act - await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + await deleter.Delete(identityAddress); // Assert A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "Files")).MustHaveHappenedOnceExactly(); diff --git a/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index e47191577d..00124ab1a6 100644 --- a/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Messages/test/Messages.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -16,12 +16,12 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var deleter = new IdentityDeleter(mockMediator); - var identityAddress = CreateRandomIdentityAddress(); var dummyIDeletionProcessLogger = A.Dummy(); + var deleter = new IdentityDeleter(mockMediator, dummyIDeletionProcessLogger); + var identityAddress = CreateRandomIdentityAddress(); // Act - await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); + await deleter.Delete(identityAddress); // Assert A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); @@ -32,12 +32,12 @@ public async Task Deleter_correctly_creates_audit_log() { // Arrange var dummyMediator = A.Dummy(); - var deleter = new IdentityDeleter(dummyMediator); - var identityAddress = CreateRandomIdentityAddress(); var mockIDeletionProcessLogger = A.Fake(); + var deleter = new IdentityDeleter(dummyMediator, mockIDeletionProcessLogger); + var identityAddress = CreateRandomIdentityAddress(); // Act - await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + await deleter.Delete(identityAddress); // Assert A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "Messages")).MustHaveHappenedOnceExactly(); diff --git a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 1427b424c6..5bb226742f 100644 --- a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -16,12 +16,12 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var deleter = new IdentityDeleter(mockMediator); - var identityAddress = CreateRandomIdentityAddress(); var dummyIDeletionProcessLogger = A.Dummy(); + var deleter = new IdentityDeleter(mockMediator, dummyIDeletionProcessLogger); + var identityAddress = CreateRandomIdentityAddress(); // Act - await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); + await deleter.Delete(identityAddress); // Assert A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); @@ -32,12 +32,12 @@ public async Task Deleter_correctly_creates_audit_log() { // Arrange var dummyMediator = A.Dummy(); - var deleter = new IdentityDeleter(dummyMediator); - var identityAddress = CreateRandomIdentityAddress(); var mockIDeletionProcessLogger = A.Fake(); + var deleter = new IdentityDeleter(dummyMediator, mockIDeletionProcessLogger); + var identityAddress = CreateRandomIdentityAddress(); // Act - await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + await deleter.Delete(identityAddress); // Assert A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "QuotaIdentities")).MustHaveHappenedOnceExactly(); diff --git a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index c36a0d10ad..f25896b4fb 100644 --- a/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Relationships/test/Relationships.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -18,12 +18,12 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var deleter = new IdentityDeleter(mockMediator); + var mockIDeletionProcessLogger = A.Fake(); + var deleter = new IdentityDeleter(mockMediator, mockIDeletionProcessLogger); var identityAddress = CreateRandomIdentityAddress(); - var dummyIDeletionProcessLogger = A.Dummy(); // Act - await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); + await deleter.Delete(identityAddress); // Assert A.CallTo(() => mockMediator.Send( @@ -43,12 +43,12 @@ public async Task Deleter_correctly_creates_audit_log() { // Arrange var dummyMediator = A.Dummy(); - var deleter = new IdentityDeleter(dummyMediator); - var identityAddress = CreateRandomIdentityAddress(); var mockIDeletionProcessLogger = A.Fake(); + var deleter = new IdentityDeleter(dummyMediator, mockIDeletionProcessLogger); + var identityAddress = CreateRandomIdentityAddress(); // Act - await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + await deleter.Delete(identityAddress); // Assert A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "Relationships")).MustHaveHappenedOnceExactly(); diff --git a/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index 5777fcee94..478497d83e 100644 --- a/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Synchronization/test/Synchronization.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -18,12 +18,12 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var deleter = new IdentityDeleter(mockMediator); - var identityAddress = CreateRandomIdentityAddress(); var dummyIDeletionProcessLogger = A.Dummy(); + var deleter = new IdentityDeleter(mockMediator, dummyIDeletionProcessLogger); + var identityAddress = CreateRandomIdentityAddress(); // Act - await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); + await deleter.Delete(identityAddress); // Assert A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); @@ -36,12 +36,12 @@ public async Task Deleter_correctly_creates_audit_log() { // Arrange var dummyMediator = A.Dummy(); - var deleter = new IdentityDeleter(dummyMediator); - var identityAddress = CreateRandomIdentityAddress(); var mockIDeletionProcessLogger = A.Fake(); + var deleter = new IdentityDeleter(dummyMediator, mockIDeletionProcessLogger); + var identityAddress = CreateRandomIdentityAddress(); // Act - await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + await deleter.Delete(identityAddress); // Assert A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "ExternalEvents")).MustHaveHappenedOnceExactly(); diff --git a/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs b/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs index a839ddb886..1716b5b1f1 100644 --- a/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs +++ b/Modules/Tokens/test/Tokens.Application.Tests/Tests/Identities/IdentityDeleterTests.cs @@ -16,12 +16,12 @@ public async Task Deleter_calls_correct_command() { // Arrange var mockMediator = A.Fake(); - var deleter = new IdentityDeleter(mockMediator); - var identityAddress = CreateRandomIdentityAddress(); var dummyIDeletionProcessLogger = A.Dummy(); + var deleter = new IdentityDeleter(mockMediator, dummyIDeletionProcessLogger); + var identityAddress = CreateRandomIdentityAddress(); // Act - await deleter.Delete(identityAddress, dummyIDeletionProcessLogger); + await deleter.Delete(identityAddress); // Assert A.CallTo(() => mockMediator.Send(A.That.Matches(command => command.IdentityAddress == identityAddress), A._)).MustHaveHappened(); @@ -32,12 +32,12 @@ public async Task Deleter_correctly_creates_audit_log() { // Arrange var dummyMediator = A.Dummy(); - var deleter = new IdentityDeleter(dummyMediator); - var identityAddress = CreateRandomIdentityAddress(); var mockIDeletionProcessLogger = A.Fake(); + var deleter = new IdentityDeleter(dummyMediator, mockIDeletionProcessLogger); + var identityAddress = CreateRandomIdentityAddress(); // Act - await deleter.Delete(identityAddress, mockIDeletionProcessLogger); + await deleter.Delete(identityAddress); // Assert A.CallTo(() => mockIDeletionProcessLogger.LogDeletion(identityAddress, "Tokens")).MustHaveHappenedOnceExactly(); From db1459cea2b95c4fe6b84bc9f83f46ff94a33500 Mon Sep 17 00:00:00 2001 From: Vladimir Vuckovic Date: Mon, 8 Jul 2024 16:01:28 +0200 Subject: [PATCH 085/105] feat: add support for data deleted --- .../dp-audit-logs-details.component.html | 2 +- .../dp-audit-logs-details.component.ts | 56 ++++++++++++++----- .../identity-service/identity.service.ts | 3 +- 3 files changed, 44 insertions(+), 17 deletions(-) diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.html b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.html index 50e7252684..b49b828881 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.html +++ b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.html @@ -35,7 +35,7 @@

{{ headerDeletionProcessAuditLog }}

Message - {{ replaceMessageKeyWithCorrespondingText(AuditLog.messageKey) }} + {{ getFormattedMessage(AuditLog.messageKey, AuditLog.additionalData) }} diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts index 60acca5ed4..9df9ef71f7 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts @@ -67,36 +67,62 @@ export class DeletionProcessAuditLogsDetailsComponent implements OnInit { return status; } - public replaceMessageKeyWithCorrespondingText(messageKey: string): string { + public getFormattedMessage(messageKey: string, additionalData: { [key: string]: string }): string { + let messageTemplate: string; + switch (messageKey) { case "StartedByOwner": - return "The deletion process was started by the owner. It was automatically approved."; + messageTemplate = "The deletion process was started by the owner. It was automatically approved."; + break; case "StartedBySupport": - return "The deletion process was started by support. It is now waiting for approval."; + messageTemplate = "The deletion process was started by support. It is now waiting for approval."; + break; case "Approved": - return "The deletion process was approved."; + messageTemplate = "The deletion process was approved."; + break; case "Rejected": - return "The deletion process was rejected."; + messageTemplate = "The deletion process was rejected."; + break; case "CancelledByOwner": - return "The deletion process was cancelled by the owner of the identity."; + messageTemplate = "The deletion process was cancelled by the owner of the identity."; + break; case "CancelledBySupport": - return "The deletion process was cancelled by a support employee."; + messageTemplate = "The deletion process was cancelled by a support employee."; + break; case "CancelledAutomatically": - return "The deletion process was cancelled automatically, because it wasn't approved by the owner within the approval period."; + messageTemplate = "The deletion process was cancelled automatically, because it wasn't approved by the owner within the approval period."; + break; case "ApprovalReminder1Sent": - return "The first approval reminder notification has been sent."; + messageTemplate = "The first approval reminder notification has been sent."; + break; case "ApprovalReminder2Sent": - return "The second approval reminder notification has been sent."; + messageTemplate = "The second approval reminder notification has been sent."; + break; case "ApprovalReminder3Sent": - return "The third approval reminder notification has been sent."; + messageTemplate = "The third approval reminder notification has been sent."; + break; case "GracePeriodReminder1Sent": - return "The first grace period reminder notification has been sent."; + messageTemplate = "The first grace period reminder notification has been sent."; + break; case "GracePeriodReminder2Sent": - return "The second grace period reminder notification has been sent."; + messageTemplate = "The second grace period reminder notification has been sent."; + break; case "GracePeriodReminder3Sent": - return "The third grace period reminder notification has been sent."; + messageTemplate = "The third grace period reminder notification has been sent."; + break; + case "DataDeleted": + const messages: string[] = []; + Object.keys(additionalData).forEach((key) => { + const message = `All ${additionalData[key]} have been deleted.`; + messages.push(message); + }); + messageTemplate = messages.join("\n"); + break; default: - return "Unknown message key."; + messageTemplate = "Unknown message key."; + break; } + + return messageTemplate; } } diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts index 87131af94d..72b7cdbedc 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts @@ -267,7 +267,8 @@ export interface UpdateTierRequest { export interface DeletionProcessAuditLog { id: string; createdAt: string; - message: string; + messageKey: string; + additionalData: { [key: string]: string }; oldStatus: number; newStatus: number; } From d580599b088413b8663c1081a26fc95d6f5df031 Mon Sep 17 00:00:00 2001 From: Vladimir Vuckovic Date: Mon, 8 Jul 2024 16:05:32 +0200 Subject: [PATCH 086/105] fix: replace indexed signature with record --- .../dp-audit-logs-details/dp-audit-logs-details.component.ts | 2 +- .../src/app/services/identity-service/identity.service.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts index 9df9ef71f7..9b877c23aa 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts @@ -67,7 +67,7 @@ export class DeletionProcessAuditLogsDetailsComponent implements OnInit { return status; } - public getFormattedMessage(messageKey: string, additionalData: { [key: string]: string }): string { + public getFormattedMessage(messageKey: string, additionalData: Record): string { let messageTemplate: string; switch (messageKey) { diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts index 72b7cdbedc..eb027c8fdd 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts @@ -268,7 +268,7 @@ export interface DeletionProcessAuditLog { id: string; createdAt: string; messageKey: string; - additionalData: { [key: string]: string }; + additionalData: Record; oldStatus: number; newStatus: number; } From 821232171aeed4268f0b768b0a3695720408f82d Mon Sep 17 00:00:00 2001 From: Hunor Tot-Bagi Date: Mon, 8 Jul 2024 16:06:43 +0200 Subject: [PATCH 087/105] tests: fix and improve job tests --- .../Tests/ActualDeletionWorkerTests.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs index 634bf303e3..a2a0814eab 100644 --- a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs +++ b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs @@ -26,7 +26,7 @@ public async Task Proxies_triggering_the_deletion_processes_to_command_handler() var mockMediator = A.Fake(); SetupRipeDeletionProcessesCommand(mockMediator); - var worker = CreateWorker(mediator: mockMediator, []); + var worker = CreateWorker(mockMediator, []); // Act await worker.StartProcessing(CancellationToken.None); @@ -45,9 +45,7 @@ public async Task Calls_Deleters_For_Each_Identity() SetupRipeDeletionProcessesCommand(mockMediator, identityAddress1, identityAddress2); var mockIdentityDeleter = A.Fake(); - var dummyIDeletionProcessLogger = A.Dummy(); - - var worker = CreateWorker(mediator: mockMediator, [mockIdentityDeleter], deletionProcessLogger: dummyIDeletionProcessLogger); + var worker = CreateWorker(mockMediator, [mockIdentityDeleter]); A.CallTo(() => mockMediator.Send(A._, A._)) .Returns(new FindRelationshipsOfIdentityResponse(new List())); @@ -56,8 +54,8 @@ public async Task Calls_Deleters_For_Each_Identity() await worker.StartProcessing(CancellationToken.None); // Assert - A.CallTo(() => mockIdentityDeleter.Delete(identityAddress1, dummyIDeletionProcessLogger)).MustHaveHappenedOnceExactly(); - A.CallTo(() => mockIdentityDeleter.Delete(identityAddress2, dummyIDeletionProcessLogger)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIdentityDeleter.Delete(identityAddress1)).MustHaveHappenedOnceExactly(); + A.CallTo(() => mockIdentityDeleter.Delete(identityAddress2)).MustHaveHappenedOnceExactly(); } [Fact] @@ -72,8 +70,7 @@ public async Task Sends_push_notification_for_each_relationship_of_each_identity A.CallTo(() => mockMediator.Send(A._, A._)).Returns(new FindRelationshipsOfIdentityResponse(new List())); var mockPushNotificationSender = A.Fake(); - - var worker = CreateWorker(mediator: mockMediator, [], pushNotificationSender: mockPushNotificationSender); + var worker = CreateWorker(mockMediator, [], mockPushNotificationSender); // Act await worker.StartProcessing(CancellationToken.None); @@ -93,14 +90,12 @@ private void SetupRipeDeletionProcessesCommand(IMediator mediator, params Identi private static ActualDeletionWorker CreateWorker(IMediator mediator, List? identityDeleters = null, - IPushNotificationSender? pushNotificationSender = null, - IDeletionProcessLogger? deletionProcessLogger = null) + IPushNotificationSender? pushNotificationSender = null) { var hostApplicationLifetime = A.Dummy(); identityDeleters ??= [A.Dummy()]; pushNotificationSender ??= A.Dummy(); var logger = A.Dummy>(); - deletionProcessLogger ??= A.Dummy(); - return new ActualDeletionWorker(hostApplicationLifetime, identityDeleters, mediator, pushNotificationSender, logger, deletionProcessLogger); + return new ActualDeletionWorker(hostApplicationLifetime, identityDeleters, mediator, pushNotificationSender, logger); } } From 52e06cb9881091c4f4e907f2d1e72b133aaf1ff0 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Tue, 9 Jul 2024 08:09:05 +0200 Subject: [PATCH 088/105] ci: use correct appsettings override file for identity deletion job integration tests --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2fd0c8c271..33eff63509 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -233,7 +233,7 @@ jobs: # The following two lines are for the identity deletion job only mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak - cp .ci/appsettings.override.${{matrix.database}}.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json + cp .ci/appsettings.override.${{matrix.database}}.docker.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json dotnet build --no-restore Backbone.sln } From e6516b640bc92a0c6ea34aa92b1145199c555505 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Tue, 9 Jul 2024 09:07:13 +0200 Subject: [PATCH 089/105] ci: replace appsettings.override.json from root directory instead of identity deletion job directory --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 33eff63509..e248490947 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -229,11 +229,11 @@ jobs: ./.ci/loadDockerImages.sh } & { - dotnet restore Backbone.sln - # The following two lines are for the identity deletion job only - mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak - cp .ci/appsettings.override.${{matrix.database}}.docker.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json + mv appsettings.override.json appsettings.override.json.bak + cp .ci/appsettings.override.${{matrix.database}}.docker.json appsettings.override.json + + dotnet restore Backbone.sln dotnet build --no-restore Backbone.sln } From 23b51310273dc43e7cb8a883d30dac39a459c270 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Tue, 9 Jul 2024 09:24:06 +0200 Subject: [PATCH 090/105] ci: use correct appsettings override file for identity deletion job integration tests --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e248490947..7c333d2605 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -231,7 +231,7 @@ jobs: { # The following two lines are for the identity deletion job only mv appsettings.override.json appsettings.override.json.bak - cp .ci/appsettings.override.${{matrix.database}}.docker.json appsettings.override.json + cp .ci/appsettings.override.${{matrix.database}}.local.json appsettings.override.json dotnet restore Backbone.sln From 3aa9c95b9e20816d6c39b6b7d879721de7c2e1a4 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Tue, 9 Jul 2024 11:44:20 +0200 Subject: [PATCH 091/105] chore: remove unnecessary AggregateType --- .../Identities/AggregateType.cs | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 BuildingBlocks/src/BuildingBlocks.Application/Identities/AggregateType.cs diff --git a/BuildingBlocks/src/BuildingBlocks.Application/Identities/AggregateType.cs b/BuildingBlocks/src/BuildingBlocks.Application/Identities/AggregateType.cs deleted file mode 100644 index 277dd0a357..0000000000 --- a/BuildingBlocks/src/BuildingBlocks.Application/Identities/AggregateType.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Backbone.BuildingBlocks.Application.Identities; -public enum AggregateType -{ - Challenges, - PnsRegistrations, - Identities, - Files, - Messages, - QuotaIdentities, - Relationships, - RelationshipTemplates, - RelationshipTemplateAllocations, - ExternalEvents, - SyncRuns, - Datawallets, - Tokens -} From c69bc04e549b221b1b324d49652aa620dd8781f4 Mon Sep 17 00:00:00 2001 From: Timo Notheisen Date: Tue, 9 Jul 2024 11:44:42 +0200 Subject: [PATCH 092/105] test: fix mock/fake naming --- .../Tests/ActualDeletionWorkerTests.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs index a2a0814eab..057f0730b2 100644 --- a/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs +++ b/Jobs/test/Job.IdentityDeletion.Tests/Tests/ActualDeletionWorkerTests.cs @@ -39,15 +39,15 @@ public async Task Proxies_triggering_the_deletion_processes_to_command_handler() public async Task Calls_Deleters_For_Each_Identity() { // Arrange - var mockMediator = A.Fake(); + var fakeMediator = A.Fake(); var identityAddress1 = TestDataGenerator.CreateRandomIdentityAddress(); var identityAddress2 = TestDataGenerator.CreateRandomIdentityAddress(); - SetupRipeDeletionProcessesCommand(mockMediator, identityAddress1, identityAddress2); + SetupRipeDeletionProcessesCommand(fakeMediator, identityAddress1, identityAddress2); var mockIdentityDeleter = A.Fake(); - var worker = CreateWorker(mockMediator, [mockIdentityDeleter]); + var worker = CreateWorker(fakeMediator, [mockIdentityDeleter]); - A.CallTo(() => mockMediator.Send(A._, A._)) + A.CallTo(() => fakeMediator.Send(A._, A._)) .Returns(new FindRelationshipsOfIdentityResponse(new List())); // Act @@ -59,18 +59,18 @@ public async Task Calls_Deleters_For_Each_Identity() } [Fact] - public async Task Sends_push_notification_for_each_relationship_of_each_identity() + public async Task Sends_push_notification_to_each_deleted_identity() { // Arrange - var mockMediator = A.Fake(); + var fakeMediator = A.Fake(); var identityAddress1 = TestDataGenerator.CreateRandomIdentityAddress(); var identityAddress2 = TestDataGenerator.CreateRandomIdentityAddress(); var identityAddress3 = TestDataGenerator.CreateRandomIdentityAddress(); - SetupRipeDeletionProcessesCommand(mockMediator, identityAddress1, identityAddress2, identityAddress3); - A.CallTo(() => mockMediator.Send(A._, A._)).Returns(new FindRelationshipsOfIdentityResponse(new List())); + SetupRipeDeletionProcessesCommand(fakeMediator, identityAddress1, identityAddress2, identityAddress3); + A.CallTo(() => fakeMediator.Send(A._, A._)).Returns(new FindRelationshipsOfIdentityResponse([])); var mockPushNotificationSender = A.Fake(); - var worker = CreateWorker(mockMediator, [], mockPushNotificationSender); + var worker = CreateWorker(fakeMediator, [], mockPushNotificationSender); // Act await worker.StartProcessing(CancellationToken.None); From 40d68f310b9505a483a29208e5fc3b1ae63f30d8 Mon Sep 17 00:00:00 2001 From: Vladimir Vuckovic Date: Tue, 9 Jul 2024 12:31:57 +0200 Subject: [PATCH 093/105] fix: make the replacement generic --- .../dp-audit-logs-details.component.ts | 77 ++++++------------- 1 file changed, 25 insertions(+), 52 deletions(-) diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts index 9b877c23aa..2a62f67b99 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts @@ -22,6 +22,23 @@ export class DeletionProcessAuditLogsDetailsComponent implements OnInit { public identityDeletionProcessAuditLogs: DeletionProcessAuditLog[] = []; + messageTemplates: Record = { + StartedByOwner: "The deletion process was started by the owner. It was automatically approved.", + StartedBySupport: "The deletion process was started by support. It is now waiting for approval.", + Approved: "The deletion process was approved.", + Rejected: "The deletion process was rejected.", + CancelledByOwner: "The deletion process was cancelled by the owner of the identity.", + CancelledBySupport: "The deletion process was cancelled by a support employee.", + CancelledAutomatically: "The deletion process was cancelled automatically, because it wasn't approved by the owner within the approval period.", + ApprovalReminder1Sent: "The first approval reminder notification has been sent.", + ApprovalReminder2Sent: "The second approval reminder notification has been sent.", + ApprovalReminder3Sent: "The third approval reminder notification has been sent.", + GracePeriodReminder1Sent: "The first grace period reminder notification has been sent.", + GracePeriodReminder2Sent: "The second grace period reminder notification has been sent.", + GracePeriodReminder3Sent: "The third grace period reminder notification has been sent.", + DataDeleted: "All {aggregateType} have been deleted." + }; + public constructor( private readonly identityService: IdentityService, private readonly snackBar: MatSnackBar, @@ -68,61 +85,17 @@ export class DeletionProcessAuditLogsDetailsComponent implements OnInit { } public getFormattedMessage(messageKey: string, additionalData: Record): string { - let messageTemplate: string; + let messageTemplate = this.messageTemplates[messageKey]; - switch (messageKey) { - case "StartedByOwner": - messageTemplate = "The deletion process was started by the owner. It was automatically approved."; - break; - case "StartedBySupport": - messageTemplate = "The deletion process was started by support. It is now waiting for approval."; - break; - case "Approved": - messageTemplate = "The deletion process was approved."; - break; - case "Rejected": - messageTemplate = "The deletion process was rejected."; - break; - case "CancelledByOwner": - messageTemplate = "The deletion process was cancelled by the owner of the identity."; - break; - case "CancelledBySupport": - messageTemplate = "The deletion process was cancelled by a support employee."; - break; - case "CancelledAutomatically": - messageTemplate = "The deletion process was cancelled automatically, because it wasn't approved by the owner within the approval period."; - break; - case "ApprovalReminder1Sent": - messageTemplate = "The first approval reminder notification has been sent."; - break; - case "ApprovalReminder2Sent": - messageTemplate = "The second approval reminder notification has been sent."; - break; - case "ApprovalReminder3Sent": - messageTemplate = "The third approval reminder notification has been sent."; - break; - case "GracePeriodReminder1Sent": - messageTemplate = "The first grace period reminder notification has been sent."; - break; - case "GracePeriodReminder2Sent": - messageTemplate = "The second grace period reminder notification has been sent."; - break; - case "GracePeriodReminder3Sent": - messageTemplate = "The third grace period reminder notification has been sent."; - break; - case "DataDeleted": - const messages: string[] = []; - Object.keys(additionalData).forEach((key) => { - const message = `All ${additionalData[key]} have been deleted.`; - messages.push(message); - }); - messageTemplate = messages.join("\n"); - break; - default: - messageTemplate = "Unknown message key."; - break; + if (!messageTemplate) { + return "Unknown message key."; } + Object.keys(additionalData).forEach((key) => { + const placeholder = `{${key}}`; + messageTemplate = messageTemplate.replace(new RegExp(placeholder, "g"), additionalData[key]); + }); + return messageTemplate; } } From b5527d4f1987a9ca5f94fa6965910eb3a68ec461 Mon Sep 17 00:00:00 2001 From: Vladimir Vuckovic Date: Tue, 9 Jul 2024 12:38:53 +0200 Subject: [PATCH 094/105] fix; add modifier --- .../dp-audit-logs-details/dp-audit-logs-details.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts index 2a62f67b99..acb3a22696 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts @@ -22,7 +22,7 @@ export class DeletionProcessAuditLogsDetailsComponent implements OnInit { public identityDeletionProcessAuditLogs: DeletionProcessAuditLog[] = []; - messageTemplates: Record = { + private messageTemplates: Record = { StartedByOwner: "The deletion process was started by the owner. It was automatically approved.", StartedBySupport: "The deletion process was started by support. It is now waiting for approval.", Approved: "The deletion process was approved.", From a64d46af200bf60f212f9ee32f07d183d3edde9f Mon Sep 17 00:00:00 2001 From: Vladimir Vuckovic Date: Tue, 9 Jul 2024 12:41:06 +0200 Subject: [PATCH 095/105] fix: add readonly --- .../dp-audit-logs-details/dp-audit-logs-details.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts index acb3a22696..cae0fe0791 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts @@ -22,7 +22,7 @@ export class DeletionProcessAuditLogsDetailsComponent implements OnInit { public identityDeletionProcessAuditLogs: DeletionProcessAuditLog[] = []; - private messageTemplates: Record = { + private readonly messageTemplates: Record = { StartedByOwner: "The deletion process was started by the owner. It was automatically approved.", StartedBySupport: "The deletion process was started by support. It is now waiting for approval.", Approved: "The deletion process was approved.", From 76155855ecdca7d0eec4fe1f87c406b51c56d985 Mon Sep 17 00:00:00 2001 From: Vladimir Vuckovic Date: Tue, 9 Jul 2024 12:51:34 +0200 Subject: [PATCH 096/105] fix: naming-convention --- .../dp-audit-logs-details.component.ts | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts index cae0fe0791..951e110364 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts @@ -23,20 +23,20 @@ export class DeletionProcessAuditLogsDetailsComponent implements OnInit { public identityDeletionProcessAuditLogs: DeletionProcessAuditLog[] = []; private readonly messageTemplates: Record = { - StartedByOwner: "The deletion process was started by the owner. It was automatically approved.", - StartedBySupport: "The deletion process was started by support. It is now waiting for approval.", - Approved: "The deletion process was approved.", - Rejected: "The deletion process was rejected.", - CancelledByOwner: "The deletion process was cancelled by the owner of the identity.", - CancelledBySupport: "The deletion process was cancelled by a support employee.", - CancelledAutomatically: "The deletion process was cancelled automatically, because it wasn't approved by the owner within the approval period.", - ApprovalReminder1Sent: "The first approval reminder notification has been sent.", - ApprovalReminder2Sent: "The second approval reminder notification has been sent.", - ApprovalReminder3Sent: "The third approval reminder notification has been sent.", - GracePeriodReminder1Sent: "The first grace period reminder notification has been sent.", - GracePeriodReminder2Sent: "The second grace period reminder notification has been sent.", - GracePeriodReminder3Sent: "The third grace period reminder notification has been sent.", - DataDeleted: "All {aggregateType} have been deleted." + startedByOwner: "The deletion process was started by the owner. It was automatically approved.", + startedBySupport: "The deletion process was started by support. It is now waiting for approval.", + approved: "The deletion process was approved.", + rejected: "The deletion process was rejected.", + cancelledByOwner: "The deletion process was cancelled by the owner of the identity.", + cancelledBySupport: "The deletion process was cancelled by a support employee.", + cancelledAutomatically: "The deletion process was cancelled automatically, because it wasn't approved by the owner within the approval period.", + approvalReminder1Sent: "The first approval reminder notification has been sent.", + approvalReminder2Sent: "The second approval reminder notification has been sent.", + approvalReminder3Sent: "The third approval reminder notification has been sent.", + gracePeriodReminder1Sent: "The first grace period reminder notification has been sent.", + gracePeriodReminder2Sent: "The second grace period reminder notification has been sent.", + gracePeriodReminder3Sent: "The third grace period reminder notification has been sent.", + dataDeleted: "All {aggregateType} have been deleted." }; public constructor( @@ -85,7 +85,9 @@ export class DeletionProcessAuditLogsDetailsComponent implements OnInit { } public getFormattedMessage(messageKey: string, additionalData: Record): string { - let messageTemplate = this.messageTemplates[messageKey]; + const camelCaseMessageKey = this.toCamelCase(messageKey); + console.log(camelCaseMessageKey); + let messageTemplate = this.messageTemplates[camelCaseMessageKey]; if (!messageTemplate) { return "Unknown message key."; @@ -98,4 +100,8 @@ export class DeletionProcessAuditLogsDetailsComponent implements OnInit { return messageTemplate; } + + private toCamelCase(str: string): string { + return str.charAt(0).toLowerCase() + str.slice(1).replace(/([-_][a-z])/gi, (match) => match.toUpperCase().replace("-", "").replace("_", "")); + } } From 18f5bdc903d35d9e0947cc24f41b671276d0e9d6 Mon Sep 17 00:00:00 2001 From: Vladimir Vuckovic Date: Tue, 9 Jul 2024 12:53:14 +0200 Subject: [PATCH 097/105] fix: remove console log --- .../dp-audit-logs-details/dp-audit-logs-details.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts index 951e110364..c256d6fbe9 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts @@ -86,7 +86,6 @@ export class DeletionProcessAuditLogsDetailsComponent implements OnInit { public getFormattedMessage(messageKey: string, additionalData: Record): string { const camelCaseMessageKey = this.toCamelCase(messageKey); - console.log(camelCaseMessageKey); let messageTemplate = this.messageTemplates[camelCaseMessageKey]; if (!messageTemplate) { From 7aad0b9d0f9315cf1d10d4c152810dfab87c96eb Mon Sep 17 00:00:00 2001 From: Vladimir Vuckovic Date: Tue, 9 Jul 2024 14:08:21 +0200 Subject: [PATCH 098/105] refactor: extract getFormattedMessage and messageTemplate into a service --- .../dp-audit-logs-details.component.ts | 35 +------------------ .../dp-details/dp-details.component.html | 2 +- .../dp-details/dp-details.component.ts | 33 ++--------------- .../identity-service/identity.service.ts | 33 +++++++++++++++++ 4 files changed, 37 insertions(+), 66 deletions(-) diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts index c256d6fbe9..68a8eeea88 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts @@ -22,23 +22,6 @@ export class DeletionProcessAuditLogsDetailsComponent implements OnInit { public identityDeletionProcessAuditLogs: DeletionProcessAuditLog[] = []; - private readonly messageTemplates: Record = { - startedByOwner: "The deletion process was started by the owner. It was automatically approved.", - startedBySupport: "The deletion process was started by support. It is now waiting for approval.", - approved: "The deletion process was approved.", - rejected: "The deletion process was rejected.", - cancelledByOwner: "The deletion process was cancelled by the owner of the identity.", - cancelledBySupport: "The deletion process was cancelled by a support employee.", - cancelledAutomatically: "The deletion process was cancelled automatically, because it wasn't approved by the owner within the approval period.", - approvalReminder1Sent: "The first approval reminder notification has been sent.", - approvalReminder2Sent: "The second approval reminder notification has been sent.", - approvalReminder3Sent: "The third approval reminder notification has been sent.", - gracePeriodReminder1Sent: "The first grace period reminder notification has been sent.", - gracePeriodReminder2Sent: "The second grace period reminder notification has been sent.", - gracePeriodReminder3Sent: "The third grace period reminder notification has been sent.", - dataDeleted: "All {aggregateType} have been deleted." - }; - public constructor( private readonly identityService: IdentityService, private readonly snackBar: MatSnackBar, @@ -85,22 +68,6 @@ export class DeletionProcessAuditLogsDetailsComponent implements OnInit { } public getFormattedMessage(messageKey: string, additionalData: Record): string { - const camelCaseMessageKey = this.toCamelCase(messageKey); - let messageTemplate = this.messageTemplates[camelCaseMessageKey]; - - if (!messageTemplate) { - return "Unknown message key."; - } - - Object.keys(additionalData).forEach((key) => { - const placeholder = `{${key}}`; - messageTemplate = messageTemplate.replace(new RegExp(placeholder, "g"), additionalData[key]); - }); - - return messageTemplate; - } - - private toCamelCase(str: string): string { - return str.charAt(0).toLowerCase() + str.slice(1).replace(/([-_][a-z])/gi, (match) => match.toUpperCase().replace("-", "").replace("_", "")); + return this.identityService.getFormattedMessage(messageKey, additionalData); } } diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-details/dp-details.component.html b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-details/dp-details.component.html index c20a965d11..ecf861ae54 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-details/dp-details.component.html +++ b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-details/dp-details.component.html @@ -62,7 +62,7 @@

{{ header }}

Message - {{ replaceMessageKeyWithCorrespondingText(AuditLog.messageKey) }} + {{ getFormattedMessage(AuditLog.messageKey, AuditLog.additionalData) }} diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-details/dp-details.component.ts b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-details/dp-details.component.ts index 8e84e7a872..dde005d616 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-details/dp-details.component.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-details/dp-details.component.ts @@ -111,36 +111,7 @@ export class DeletionProcessDetailsComponent { }); } - public replaceMessageKeyWithCorrespondingText(messageKey: string): string { - switch (messageKey) { - case "StartedByOwner": - return "The deletion process was started by the owner. It was automatically approved."; - case "StartedBySupport": - return "The deletion process was started by support. It is now waiting for approval."; - case "Approved": - return "The deletion process was approved."; - case "Rejected": - return "The deletion process was rejected."; - case "CancelledByOwner": - return "The deletion process was cancelled by the owner of the identity."; - case "CancelledBySupport": - return "The deletion process was cancelled by a support employee."; - case "CancelledAutomatically": - return "The deletion process was cancelled automatically, because it wasn't approved by the owner within the approval period."; - case "ApprovalReminder1Sent": - return "The first approval reminder notification has been sent."; - case "ApprovalReminder2Sent": - return "The second approval reminder notification has been sent."; - case "ApprovalReminder3Sent": - return "The third approval reminder notification has been sent."; - case "GracePeriodReminder1Sent": - return "The first grace period reminder notification has been sent."; - case "GracePeriodReminder2Sent": - return "The second grace period reminder notification has been sent."; - case "GracePeriodReminder3Sent": - return "The third grace period reminder notification has been sent."; - default: - return "Unknown message key."; - } + public getFormattedMessage(messageKey: string, additionalData: Record): string { + return this.identityService.getFormattedMessage(messageKey, additionalData); } } diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts index eb027c8fdd..7b1854c37e 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts @@ -26,6 +26,39 @@ export class IdentityService { this.odataUrl = `${environment.odataUrl}/Identities`; } + // eslint-disable-next-line + public readonly messageTemplates: Record = { + StartedByOwner: "The deletion process was started by the owner. It was automatically approved.", + StartedBySupport: "The deletion process was started by support. It is now waiting for approval.", + Approved: "The deletion process was approved.", + Rejected: "The deletion process was rejected.", + CancelledByOwner: "The deletion process was cancelled by the owner of the identity.", + CancelledBySupport: "The deletion process was cancelled by a support employee.", + CancelledAutomatically: "The deletion process was cancelled automatically, because it wasn't approved by the owner within the approval period.", + ApprovalReminder1Sent: "The first approval reminder notification has been sent.", + approvalReminder2Sent: "The second approval reminder notification has been sent.", + approvalReminder3Sent: "The third approval reminder notification has been sent.", + gracePeriodReminder1Sent: "The first grace period reminder notification has been sent.", + gracePeriodReminder2Sent: "The second grace period reminder notification has been sent.", + gracePeriodReminder3Sent: "The third grace period reminder notification has been sent.", + dataDeleted: "All {aggregateType} have been deleted." + }; + + public getFormattedMessage(messageKey: string, additionalData: Record): string { + let messageTemplate = this.messageTemplates[messageKey]; + + if (!messageTemplate) { + return "Unknown message key."; + } + + Object.keys(additionalData).forEach((key) => { + const placeholder = `{${key}}`; + messageTemplate = messageTemplate.replace(new RegExp(placeholder, "g"), additionalData[key]); + }); + + return messageTemplate; + } + public getIdentities(filter: IdentityOverviewFilter, pageNumber: number, pageSize: number): Observable> { const paginationFilter = `$top=${pageSize}&$skip=${pageNumber * pageSize}&$count=true`; return this.http.get(`${this.odataUrl}${this.buildODataFilter(filter, paginationFilter)}${this.buildODataExpand()}`).pipe( From 7f288c3bc01188b53186bf7528a5b06633609570 Mon Sep 17 00:00:00 2001 From: Vladimir Vuckovic Date: Tue, 9 Jul 2024 14:13:09 +0200 Subject: [PATCH 099/105] fix: revert the naming --- .../services/identity-service/identity.service.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts index 7b1854c37e..8091d369df 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts @@ -36,15 +36,16 @@ export class IdentityService { CancelledBySupport: "The deletion process was cancelled by a support employee.", CancelledAutomatically: "The deletion process was cancelled automatically, because it wasn't approved by the owner within the approval period.", ApprovalReminder1Sent: "The first approval reminder notification has been sent.", - approvalReminder2Sent: "The second approval reminder notification has been sent.", - approvalReminder3Sent: "The third approval reminder notification has been sent.", - gracePeriodReminder1Sent: "The first grace period reminder notification has been sent.", - gracePeriodReminder2Sent: "The second grace period reminder notification has been sent.", - gracePeriodReminder3Sent: "The third grace period reminder notification has been sent.", - dataDeleted: "All {aggregateType} have been deleted." + ApprovalReminder2Sent: "The second approval reminder notification has been sent.", + ApprovalReminder3Sent: "The third approval reminder notification has been sent.", + GracePeriodReminder1Sent: "The first grace period reminder notification has been sent.", + GracePeriodReminder2Sent: "The second grace period reminder notification has been sent.", + GracePeriodReminder3Sent: "The third grace period reminder notification has been sent.", + DataDeleted: "All {aggregateType} have been deleted." }; - public getFormattedMessage(messageKey: string, additionalData: Record): string { + public getFormattedMessage(messageKey: string, additionalData: Record): string { + console.log(messageKey); let messageTemplate = this.messageTemplates[messageKey]; if (!messageTemplate) { From f4ee73d83f6c39a13cef983d192c333dddd71fcb Mon Sep 17 00:00:00 2001 From: Vladimir Vuckovic Date: Tue, 9 Jul 2024 14:46:28 +0200 Subject: [PATCH 100/105] chore: change the rule --- .../src/app/services/identity-service/identity.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts index 8091d369df..1633d190d3 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts @@ -26,7 +26,7 @@ export class IdentityService { this.odataUrl = `${environment.odataUrl}/Identities`; } - // eslint-disable-next-line + /* eslint-disable @typescript-eslint/camelcase */ public readonly messageTemplates: Record = { StartedByOwner: "The deletion process was started by the owner. It was automatically approved.", StartedBySupport: "The deletion process was started by support. It is now waiting for approval.", From 329d62938a5557bed162b411b0eba527a7b2752a Mon Sep 17 00:00:00 2001 From: Vladimir Vuckovic Date: Tue, 9 Jul 2024 14:48:09 +0200 Subject: [PATCH 101/105] fix: rule --- .../src/app/services/identity-service/identity.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts index 1633d190d3..9eaa50de16 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts @@ -26,7 +26,7 @@ export class IdentityService { this.odataUrl = `${environment.odataUrl}/Identities`; } - /* eslint-disable @typescript-eslint/camelcase */ + /* eslint-disable @typescript-eslint/naming-convention */ public readonly messageTemplates: Record = { StartedByOwner: "The deletion process was started by the owner. It was automatically approved.", StartedBySupport: "The deletion process was started by support. It is now waiting for approval.", From 053164d161bfd740185647965b9c894e8aa71068 Mon Sep 17 00:00:00 2001 From: Vladimir Vuckovic Date: Tue, 9 Jul 2024 14:50:03 +0200 Subject: [PATCH 102/105] fix: remove console log --- .../src/app/services/identity-service/identity.service.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts index 9eaa50de16..b435b2c85e 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts @@ -45,7 +45,6 @@ export class IdentityService { }; public getFormattedMessage(messageKey: string, additionalData: Record): string { - console.log(messageKey); let messageTemplate = this.messageTemplates[messageKey]; if (!messageTemplate) { From f58307be9d2722cd280d49129ec15b5be4bce05b Mon Sep 17 00:00:00 2001 From: Vladimir Vuckovic Date: Tue, 9 Jul 2024 15:51:07 +0200 Subject: [PATCH 103/105] fix: add eslint-enable --- .../src/app/services/identity-service/identity.service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts index b435b2c85e..a11e6aef4c 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts @@ -27,7 +27,7 @@ export class IdentityService { } /* eslint-disable @typescript-eslint/naming-convention */ - public readonly messageTemplates: Record = { + private readonly messageTemplates: Record = { StartedByOwner: "The deletion process was started by the owner. It was automatically approved.", StartedBySupport: "The deletion process was started by support. It is now waiting for approval.", Approved: "The deletion process was approved.", @@ -43,6 +43,7 @@ export class IdentityService { GracePeriodReminder3Sent: "The third grace period reminder notification has been sent.", DataDeleted: "All {aggregateType} have been deleted." }; + /* eslint-enable @typescript-eslint/naming-convention */ public getFormattedMessage(messageKey: string, additionalData: Record): string { let messageTemplate = this.messageTemplates[messageKey]; From 75167463426c4d93af987e17692619b84da829e6 Mon Sep 17 00:00:00 2001 From: Vladimir Vuckovic Date: Tue, 9 Jul 2024 15:57:50 +0200 Subject: [PATCH 104/105] refactor: rename the method --- .../src/app/services/identity-service/identity.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts index a11e6aef4c..3099f75506 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/services/identity-service/identity.service.ts @@ -45,7 +45,7 @@ export class IdentityService { }; /* eslint-enable @typescript-eslint/naming-convention */ - public getFormattedMessage(messageKey: string, additionalData: Record): string { + public getMessageForDeletionProcessAuditLog(messageKey: string, additionalData: Record): string { let messageTemplate = this.messageTemplates[messageKey]; if (!messageTemplate) { From c35ff3028c9888886ae7f880994a40d434c9363a Mon Sep 17 00:00:00 2001 From: Vladimir Vuckovic Date: Tue, 9 Jul 2024 15:58:32 +0200 Subject: [PATCH 105/105] chore: change the method call --- .../dp-audit-logs-details/dp-audit-logs-details.component.ts | 2 +- .../deletion-processes/dp-details/dp-details.component.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts index 68a8eeea88..23cf1c7048 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-audit-logs/dp-audit-logs-details/dp-audit-logs-details/dp-audit-logs-details.component.ts @@ -68,6 +68,6 @@ export class DeletionProcessAuditLogsDetailsComponent implements OnInit { } public getFormattedMessage(messageKey: string, additionalData: Record): string { - return this.identityService.getFormattedMessage(messageKey, additionalData); + return this.identityService.getMessageForDeletionProcessAuditLog(messageKey, additionalData); } } diff --git a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-details/dp-details.component.ts b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-details/dp-details.component.ts index dde005d616..50c95730ea 100644 --- a/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-details/dp-details.component.ts +++ b/AdminApi/src/AdminApi/ClientApp/src/app/components/identity/identity-details/deletion-processes/dp-details/dp-details.component.ts @@ -112,6 +112,6 @@ export class DeletionProcessDetailsComponent { } public getFormattedMessage(messageKey: string, additionalData: Record): string { - return this.identityService.getFormattedMessage(messageKey, additionalData); + return this.identityService.getMessageForDeletionProcessAuditLog(messageKey, additionalData); } }