feat(email): export send attempt metadata
CI and Deploy / test (pull_request) Failing after 4m32s
CI and Deploy / deploy (pull_request) Has been skipped

Add content-free provider delivery history to encrypted and daily owner exports, exclude payload hashes, and lock in tenant-safe hard-delete cascades.
This commit is contained in:
cesnimda
2026-08-10 00:48:32 +02:00
parent 14f8d4e928
commit aff34cc645
6 changed files with 120 additions and 2 deletions
+24 -1
View File
@@ -35,7 +35,22 @@ public sealed class BackupControllerTests
{
await using var db = CreateDb();
db.Companies.Add(new Company { Name = "Acme", OwnerUserId = "user-1" });
db.JobApplications.Add(new JobApplication { JobTitle = "Backend Developer", OwnerUserId = "user-1" });
var job = new JobApplication { JobTitle = "Backend Developer", OwnerUserId = "user-1" };
db.JobApplications.Add(job);
await db.SaveChangesAsync();
db.EmailSendAttempts.Add(new EmailSendAttempt
{
Id = Guid.NewGuid(),
OwnerUserId = "user-1",
JobApplicationId = job.Id,
Provider = "gmail",
ClientRequestId = Guid.NewGuid().ToString(),
PayloadHash = new string('a', 64),
Status = EmailSendStatuses.Sent,
ProviderMessageId = "synthetic-message-id",
CreatedAtUtc = DateTime.UtcNow,
CompletedAtUtc = DateTime.UtcNow,
});
await db.SaveChangesAsync();
var provider = DataProtectionProvider.Create(new DirectoryInfo(Path.Combine(Path.GetTempPath(), $"jobtracker-tests-{Guid.NewGuid():N}")));
@@ -47,6 +62,14 @@ public sealed class BackupControllerTests
Assert.Equal("application/octet-stream", file.ContentType);
Assert.EndsWith(".jtbackup", file.FileDownloadName);
Assert.NotEmpty(file.FileContents);
var protectedText = System.Text.Encoding.UTF8.GetString(file.FileContents);
var json = Convert.FromBase64String(provider.CreateProtector("JobTrackerApi.Backup.v1").Unprotect(protectedText));
using var document = System.Text.Json.JsonDocument.Parse(json);
var attempt = Assert.Single(document.RootElement.GetProperty("Data").GetProperty("EmailSendAttempts").EnumerateArray());
Assert.Equal("gmail", attempt.GetProperty("Provider").GetString());
Assert.Equal("sent", attempt.GetProperty("Status").GetString());
Assert.False(attempt.TryGetProperty("PayloadHash", out _));
}
private static JobTrackerContext CreateDb()