test: Add PDF/A validation tests and manual testing guide
- Add unit tests for ValidatePdfAQueryHandler (4 tests) - Add integration tests for PDF/A validation endpoint (6 tests) - Fix FluentValidation: Add Base64 format validation to ValidatePdfAQueryValidator - Update AGENTS.md: Document 3-folder test structure rationale and test count (30 tests) - Add DocumentOperator.API/README.md: 16 manual test scenarios for all endpoints Test coverage: - Unit: ValidatePdfAQueryHandler (compliant, non-compliant, encrypted, exceptions) - Integration: PDF/A endpoint (multipart + Base64, validation, error handling) - Manual: Step-by-step Swagger UI testing guide for all features All 30 automated tests passing.
This commit is contained in:
@@ -14,5 +14,35 @@ public class ValidatePdfAQueryValidator : AbstractValidator<Queries.ValidatePdfA
|
||||
.Must(x => (x.PdfBytes != null && x.PdfBytes.Length > 0) ^
|
||||
!string.IsNullOrWhiteSpace(x.Base64Pdf))
|
||||
.WithMessage("Either PdfBytes or Base64Pdf must be provided, but not both");
|
||||
|
||||
When(x => !string.IsNullOrWhiteSpace(x.Base64Pdf), () =>
|
||||
{
|
||||
RuleFor(x => x.Base64Pdf!)
|
||||
.Must(BeValidBase64)
|
||||
.WithMessage("Base64Pdf must be a valid Base64 string");
|
||||
});
|
||||
|
||||
When(x => x.PdfBytes != null, () =>
|
||||
{
|
||||
RuleFor(x => x.PdfBytes!)
|
||||
.Must(bytes => bytes.Length > 0)
|
||||
.WithMessage("PdfBytes cannot be empty");
|
||||
});
|
||||
}
|
||||
|
||||
private static bool BeValidBase64(string base64)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(base64))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
Convert.FromBase64String(base64);
|
||||
return true;
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user