ElyPDF: an OS permission error shows as an error, never a missing text key (P-01); component library f834f55

This commit is contained in:
ZacharyZhang-NY committed 2026-10-09 10:58:47 -04:00
1 parent ab85673eea
commit 943411fb1a
17 files changed
+90 -25

No files matched your search

+3 -2
View File
@@ -1,6 +1,6 @@
//! Images, text, optimized copies, printing leave, repaired files (C11.8).
use std::{io::ErrorKind, path::Path};
use std::path::Path;
use ely_pdf_engine::{
Doc, Lock, Optimizing, Worker,
@@ -89,7 +89,8 @@ fn printing_and_copying_need_leave() {
worker.protect(doc, &limited, Some(&Lock { user: String::new(), owner: "owner".into(), allow: may::EDIT })).expect("protects");
let (mut other, read) = opened(&limited);
for refused in [other.print_copy(read, &dir.path().join("p.pdf")), other.export_text(read, &dir.path().join("t.txt"))] {
assert_eq!(refused.expect_err("refused").kind(), ErrorKind::PermissionDenied);
let refused = refused.expect_err("refused");
assert!(ely_pdf_engine::refused(&refused).is_some(), "refused: {refused}");
}
worker.print_copy(doc, &dir.path().join("print.pdf")).expect("an unprotected file prints");
}
+4 -4
View File
@@ -1,6 +1,6 @@
//! Protected copies and what they allow (PDF-11).
use std::{io::ErrorKind, path::Path};
use std::path::Path;
use ely_pdf_engine::{
Doc, Lock, Worker,
@@ -43,7 +43,7 @@ fn a_protected_copy_asks_and_holds_its_limits() {
let allowed = worker.permissions(opened.doc).expect("reads");
assert_eq!(allowed & (may::PRINT | may::COPY | may::EDIT | may::OWNER), may::PRINT);
let refused = worker.rotate_pages(opened.doc, &[0], 90).expect_err("refused");
assert_eq!((refused.kind(), refused.to_string()), (ErrorKind::PermissionDenied, "assemble".to_string()));
assert_eq!(ely_pdf_engine::refused(&refused), Some("assemble"));
let text: String = worker.text(opened.doc, 0).expect("still reads").iter().map(|c| c.c).collect();
assert!(text.contains("Hello"));
}
@@ -72,7 +72,7 @@ fn changing_protection_needs_the_owner() {
worker.unlock(doc, "user").expect("unlocks");
let bare = dir.path().join("bare.pdf");
let refused = worker.protect(doc, &bare, None).expect_err("refused");
assert_eq!(refused.kind(), ErrorKind::PermissionDenied);
assert!(ely_pdf_engine::refused(&refused).is_some(), "refused: {refused}");
assert!(!bare.exists());
worker.owner(doc, "owner").expect("tries");
worker.protect(doc, &bare, None).expect("unprotects");
@@ -103,7 +103,7 @@ fn a_file_with_no_open_password_still_holds_limits() {
let opened = other.open(&out).expect("opens");
assert!(!opened.locked);
let refused = other.annotate(opened.doc, &[]).expect_err("refused");
assert_eq!((refused.kind(), refused.to_string()), (ErrorKind::PermissionDenied, "annotate".to_string()));
assert_eq!(ely_pdf_engine::refused(&refused), Some("annotate"));
}
#[test]
+2 -2
View File
@@ -1,6 +1,6 @@
//! Signing by update and checking what was signed (PDF-12, QA-15).
use std::{io::ErrorKind, path::{Path, PathBuf}};
use std::path::{Path, PathBuf};
use ely_pdf_engine::{
Digest, Doc, Lock, Signing, Worker,
@@ -128,7 +128,7 @@ fn a_new_field_needs_leave_to_change_the_page() {
worker.protect(doc, &limited, Some(&lock)).expect("protects");
let (mut other, read) = opened(&limited);
let refused = other.sign(read, &dir.path().join("signed.pdf"), &signing(None, "S", "ely")).expect_err("refused");
assert_eq!(refused.kind(), ErrorKind::PermissionDenied);
assert!(ely_pdf_engine::refused(&refused).is_some(), "refused: {refused}");
}
#[test]