Add unit tests for PDF Packager converter functionality

- Implement tests for converter properties, ensuring correct input and output formats.
- Add tests for chip parsing, covering various image, pdf_image, and pdfa chip formats.
- Include tests for the isArchiveOutput and getOutputFileName functions.
- Mock execFile for testing the convert function, verifying command execution and output file creation.
- Ensure all chips are parseable and validate the completeness of chip categories.
This commit is contained in:
Your Name 2026-01-24 14:39:22 +08:00
parent 87bd318303
commit 944fe18b75
11 changed files with 2233 additions and 8 deletions

View file

@ -142,6 +142,7 @@ RUN echo "" && \
mupdf-tools \
poppler-utils \
potrace \
qpdf \
&& rm -rf /var/lib/apt/lists/* && \
echo "✅ 階段 2/11 完成:核心轉換工具已安裝"
@ -319,6 +320,7 @@ RUN echo "" && \
python3-numpy \
python3-tinycss2 \
python3-opencv \
python3-img2pdf \
pipx \
&& rm -rf /var/lib/apt/lists/* && \
echo "✅ 階段 11/11 完成Python 依賴已安裝" && \
@ -327,6 +329,35 @@ RUN echo "" && \
echo "✅ 所有 APT 套件安裝完成!" && \
echo "========================================"
# ==============================================================================
# 🔐 階段 11.1PDF Packager 預設簽章憑證(開箱即用)
# ==============================================================================
#
# 產生自簽憑證供 PDF Packager 簽章功能使用
# 此憑證僅供測試/展示用途,正式環境請替換為自己的憑證
# 📚 詳細說明請參考 docs/功能說明/PDF-Packager.md
#
# ==============================================================================
RUN echo "" && \
echo "========================================" && \
echo "🔐 階段 11.1:產生 PDF Packager 預設簽章憑證" && \
echo "========================================" && \
mkdir -p /app/certs && \
# 產生自簽憑證(有效期 10 年)
openssl req -x509 -newkey rsa:2048 \
-keyout /tmp/key.pem -out /tmp/cert.pem \
-days 3650 -nodes \
-subj "/CN=PDF Packager Default/O=ConvertX-CN/C=TW" && \
# 匯出為 PKCS12 格式(空密碼)
openssl pkcs12 -export \
-inkey /tmp/key.pem -in /tmp/cert.pem \
-out /app/certs/default.p12 \
-passout pass: && \
# 清理暫存檔案
rm -f /tmp/key.pem /tmp/cert.pem && \
chmod 644 /app/certs/default.p12 && \
echo "✅ 預設簽章憑證已產生: /app/certs/default.p12"
# ==============================================================================
# 🔥 階段 12-UNIFIEDPython 工具安裝 + 模型下載(單一 RUN 原則)
# ==============================================================================
@ -352,6 +383,15 @@ ENV PIP_NO_CACHE_DIR=1
# HuggingFace 環境變數(安裝時允許下載,安裝完成後設為離線)
ENV HF_HOME="/root/.cache/huggingface"
# ==============================================================================
# PDF Packager 簽章預設配置(開箱即用)
# ==============================================================================
ENV PDF_SIGN_P12_PATH="/app/certs/default.p12"
ENV PDF_SIGN_P12_PASSWORD=""
ENV PDF_SIGN_REASON="ConvertX-CN PDF Packager"
ENV PDF_SIGN_LOCATION="Taiwan"
ENV PDF_SIGN_CONTACT="convertx-cn@localhost"
RUN set -eux && \
echo "===========================================================" && \
echo "🚀 階段 12-UNIFIEDPython 工具 + 模型統一安裝" && \
@ -361,11 +401,11 @@ RUN set -eux && \
echo "===========================================================" && \
\
# ========================================
# [1/8] 安裝 huggingface_hub用於顯式模型下載
# [1/8] 安裝 huggingface_hub + endesive(用於顯式模型下載和 PDF 簽章
# ========================================
echo "" && \
echo "📦 [1/8] 安裝 huggingface_hub..." && \
pip3 install --no-cache-dir --break-system-packages huggingface_hub && \
echo "📦 [1/8] 安裝 huggingface_hub + endesivePDF 簽章)..." && \
pip3 install --no-cache-dir --break-system-packages huggingface_hub endesive && \
\
# ========================================
# [2/8] 安裝 markitdown文件轉換工具