feat: complete release readiness work
- consolidate API ownership and remove dead vendor code - add Stripe billing, learning paths, and public CV hardening - add migration, recovery, security, audit, and browser gates
This commit is contained in:
@@ -226,6 +226,74 @@ public sealed class ProfileCvControllerTests
|
||||
Assert.Null(user.ProfileCvText);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Background_processing_bypasses_the_http_user_filter_for_the_owned_run()
|
||||
{
|
||||
var user = new ApplicationUser { Id = "user-1", ProfileCvText = "# Ada Lovelace\n\n## Skills\nC#" };
|
||||
var userManager = CreateUserManager();
|
||||
userManager.Setup(x => x.FindByIdAsync(user.Id)).ReturnsAsync(user);
|
||||
var aiService = new Mock<ISummarizerService>();
|
||||
aiService.Setup(x => x.SummarizeSectionAsync(
|
||||
It.Is<string>(instruction => instruction.StartsWith("Rewrite this CV", StringComparison.Ordinal)),
|
||||
It.IsAny<string>(), 1800, 500))
|
||||
.ReturnsAsync(user.ProfileCvText);
|
||||
aiService.Setup(x => x.SummarizeSectionAsync(
|
||||
It.Is<string>(instruction => instruction.Contains("Extract this CV into structured JSON", StringComparison.Ordinal)),
|
||||
It.IsAny<string>(), 3200, 900))
|
||||
.ReturnsAsync("""
|
||||
{"version":"1","contact":{"fullName":"Ada Lovelace"},"summary":[],"jobs":[],"education":[],"skills":["C#"],"languages":[],"interests":[],"otherSections":[]}
|
||||
""");
|
||||
|
||||
await using var db = CreateDb(userId: null);
|
||||
var paths = CreatePaths();
|
||||
var orphanedPath = Path.Combine(paths.CvArtifactsRoot, "orphaned.pdf");
|
||||
await System.IO.File.WriteAllTextAsync(orphanedPath, "obsolete");
|
||||
var currentPath = Path.Combine(paths.CvArtifactsRoot, "current.pdf");
|
||||
await System.IO.File.WriteAllTextAsync(currentPath, "current");
|
||||
db.CvUploadArtifacts.Add(new CvUploadArtifact
|
||||
{
|
||||
OwnerUserId = user.Id,
|
||||
OriginalFileName = "orphaned.pdf",
|
||||
StoredFileName = "orphaned.pdf",
|
||||
MimeType = "application/pdf",
|
||||
ByteSize = 8,
|
||||
Sha256 = "orphaned",
|
||||
StoragePath = orphanedPath,
|
||||
});
|
||||
var currentArtifact = new CvUploadArtifact
|
||||
{
|
||||
OwnerUserId = user.Id,
|
||||
OriginalFileName = "current.pdf",
|
||||
StoredFileName = "current.pdf",
|
||||
MimeType = "application/pdf",
|
||||
ByteSize = 7,
|
||||
Sha256 = "current",
|
||||
StoragePath = currentPath,
|
||||
};
|
||||
db.CvUploadArtifacts.Add(currentArtifact);
|
||||
var run = new CvExtractionRun
|
||||
{
|
||||
OwnerUserId = user.Id,
|
||||
Trigger = "improve",
|
||||
ParserVersion = "test",
|
||||
NormalizerVersion = "test",
|
||||
LlmPromptVersion = "test",
|
||||
Status = "queued",
|
||||
};
|
||||
db.CvExtractionRuns.Add(run);
|
||||
await db.SaveChangesAsync();
|
||||
user.CurrentCvUploadArtifactId = currentArtifact.Id;
|
||||
|
||||
var controller = CreateController(userManager.Object, aiService.Object, db, paths);
|
||||
await controller.ProcessQueuedRunAsync(run.Id, CancellationToken.None);
|
||||
|
||||
Assert.Equal("pending_review", run.Status);
|
||||
Assert.NotNull(run.CompletedAtUtc);
|
||||
Assert.Equal(currentArtifact.Id, Assert.Single(await db.CvUploadArtifacts.IgnoreQueryFilters().ToListAsync()).Id);
|
||||
Assert.False(System.IO.File.Exists(orphanedPath));
|
||||
Assert.True(System.IO.File.Exists(currentPath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Upload_reconstructs_flattened_pdf_cv_before_save()
|
||||
{
|
||||
@@ -1255,7 +1323,7 @@ public sealed class ProfileCvControllerTests
|
||||
};
|
||||
}
|
||||
|
||||
private static JobTrackerContext CreateDb(string userId = "user-1")
|
||||
private static JobTrackerContext CreateDb(string? userId = "user-1")
|
||||
{
|
||||
return TestHostFactory.CreateInMemoryDb(userId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user