test(bf-1h5og): add test utility and error handling imports

Add comprehensive test utility and error handling imports to encryption test files:

- Added std::error::Error and std::io for error handling
- Expanded pdftract_core::diagnostics imports to include Diagnostic, DiagnosticsCollector, and ObjRef
- Ensured both test_encryption_errors.rs and test_encryption_unsupported.rs have consistent imports

All imports verified against actual crate structure and compile successfully.

Closes bf-1h5og. Verification: notes/bf-1h5og.md.
This commit is contained in:
jedarden 2026-07-05 19:01:12 -04:00
parent d603e324a4
commit b6d01ae85f
3 changed files with 60 additions and 2 deletions

View file

@ -19,13 +19,17 @@
//! - Plan line 1132: RC4 and AES-128/256 decryption implementation
//! - Plan line 1149: Encrypted file with unknown handler error handling
use std::error::Error;
use std::fs;
use std::io;
use std::path::{Path, PathBuf};
use std::process::Command;
// CLI module imports for encryption testing
use pdftract_cli::password;
use pdftract_core::diagnostics::{DiagCode, DiagInfo, Severity, DIAGNOSTIC_CATALOG};
use pdftract_core::diagnostics::{
DiagCode, DiagInfo, Diagnostic, DiagnosticsCollector, ObjRef, Severity, DIAGNOSTIC_CATALOG,
};
/// Get the workspace root directory
fn workspace_root() -> PathBuf {

View file

@ -4,11 +4,15 @@
//! and exits with code 3 when run on an owner-password-only encrypted PDF
//! (or a PDF with an unsupported encryption handler like Adobe LiveCycle).
use std::error::Error;
use std::io;
use std::process::Command;
// CLI module imports for encryption testing
use pdftract_cli::password;
use pdftract_core::diagnostics::{DiagCode, DiagInfo, Severity, DIAGNOSTIC_CATALOG};
use pdftract_core::diagnostics::{
DiagCode, DiagInfo, Diagnostic, DiagnosticsCollector, ObjRef, Severity, DIAGNOSTIC_CATALOG,
};
#[test]
fn test_livecycle_pdf_emits_encryption_unsupported() {

50
notes/bf-1h5og.md Normal file
View file

@ -0,0 +1,50 @@
# Verification Note: bf-1h5og - Add test utility and error handling imports
## Summary
Added comprehensive test utility and error handling imports to both encryption test files.
## Changes Made
### 1. Enhanced test_encryption_errors.rs imports
Added imports:
- `std::error::Error` - for error handling patterns
- `std::io` - for I/O operations
- `Diagnostic`, `DiagnosticsCollector`, `ObjRef` from `pdftract_core::diagnostics` - for detailed diagnostic testing
### 2. Enhanced test_encryption_unsupported.rs imports
Added the same comprehensive imports for consistency:
- `std::error::Error` - for error handling patterns
- `std::io` - for I/O operations
- `Diagnostic`, `DiagnosticsCollector`, `ObjRef` from `pdftract_core::diagnostics` - for detailed diagnostic testing
## Verification
### Compilation Status
✅ PASS - Both test files compile successfully with `cargo test --test test_encryption_errors --test test_encryption_unsupported --no-run`
### Imports Match Actual Crate Structure
✅ PASS - All imports verified against actual exports:
- `pdftract_core::diagnostics` exports: `DiagCode`, `DiagInfo`, `Diagnostic`, `DiagnosticsCollector`, `ObjRef`, `Severity`, `DIAGNOSTIC_CATALOG`
- `pdftract_cli::password` - confirmed as public module
- Standard library imports: `std::error::Error`, `std::io`, `std::fs`, `std::path`, `std::process::Command`
### Test Utility Imports
✅ PASS - Test utilities now include:
- Error handling types (`Error`, `io`)
- Comprehensive diagnostic types for advanced testing
- All necessary CLI and core imports
### Files Modified
- `/home/coding/pdftract/crates/pdftract-cli/tests/test_encryption_errors.rs`
- `/home/coding/pdftract/crates/pdftract-cli/tests/test_encryption_unsupported.rs`
## Acceptance Criteria Status
- ✅ Test utility imports added
- ✅ Error handling type imports added
- ✅ Imports compile successfully
- ✅ Imports match actual crate structure
## References
- Parent bead: bf-2nl4x
- Plan line 258, Failure Mode Taxonomy: ENCRYPTION_UNSUPPORTED