Skip to content
Snippets Groups Projects
Commit ac7ddba0 authored by Zdravko Iliev's avatar Zdravko Iliev
Browse files

fix signature parsing by stopping part of the verification process

parent 23a5e9b9
No related branches found
No related tags found
No related merge requests found
Showing
with 14 additions and 1690 deletions
node_modules node_modules
.idea .idea
yarn-error.log yarn-error.log
__tests__/outputs/**
...@@ -7,17 +7,19 @@ import { AppError } from "../src/lib/errors"; ...@@ -7,17 +7,19 @@ import { AppError } from "../src/lib/errors";
describe("PDF parser", () => { describe("PDF parser", () => {
it("should return pdf document metadata including signatures", async () => { it("should return pdf document metadata including signatures", async () => {
const file = fs.readFileSync( const file = fs.readFileSync(
path.resolve(__dirname, "./abacus-two-signatures.pdf") path.resolve(__dirname, "./source/loremipsum-advanced-1-signee.pdf")
); );
const parser = new PDFparser(file); const parser = new PDFparser(file);
const actual = await parser.getPDFMeta(); const actual = await parser.getPDFMeta();
expect(actual.pages).toEqual(2); expect(actual.pages).toEqual(1);
}); });
it("should return pdf document metadata without signatures", async () => { it("should return pdf document metadata without signatures", async () => {
const file = fs.readFileSync(path.resolve(__dirname, "./example.pdf")); const file = fs.readFileSync(
path.resolve(__dirname, "./source/example.pdf")
);
const parser = new PDFparser(file); const parser = new PDFparser(file);
...@@ -29,7 +31,7 @@ describe("PDF parser", () => { ...@@ -29,7 +31,7 @@ describe("PDF parser", () => {
it("should throw error without file", async () => { it("should throw error without file", async () => {
try { try {
const parser = new PDFparser(null); const parser = new PDFparser(undefined);
const actual = await parser.getPDFMeta(); const actual = await parser.getPDFMeta();
} catch (error) { } catch (error) {
expect(error).toBeInstanceOf(AppError); expect(error).toBeInstanceOf(AppError);
...@@ -37,7 +39,7 @@ describe("PDF parser", () => { ...@@ -37,7 +39,7 @@ describe("PDF parser", () => {
}); });
it("should throw error if file type is different then pdf", async () => { it("should throw error if file type is different then pdf", async () => {
const file = fs.readFileSync(path.resolve(__dirname, "./test.txt")); const file = fs.readFileSync(path.resolve(__dirname, "./source/test.txt"));
try { try {
const parser = new PDFparser(file); const parser = new PDFparser(file);
...@@ -54,7 +56,7 @@ type SealCoords = { ...@@ -54,7 +56,7 @@ type SealCoords = {
}; };
describe("PDF insert", () => { describe("PDF insert", () => {
it.only("should insert qrcode into the pdf without breaking the signature", async () => { it("should insert qrcode into the pdf without breaking the signature", async () => {
// Signed-linux-libreOfficeWriterTest-v1.6-signed-pades-baseline-b // Signed-linux-libreOfficeWriterTest-v1.6-signed-pades-baseline-b
// Signed-linux-OpenOfficeWriter-v1.4-signed-pades-baseline-b // Signed-linux-OpenOfficeWriter-v1.4-signed-pades-baseline-b
// Signed-mac-Adobe-1.3-signed-pades-baseline-b // Signed-mac-Adobe-1.3-signed-pades-baseline-b
...@@ -65,10 +67,13 @@ describe("PDF insert", () => { ...@@ -65,10 +67,13 @@ describe("PDF insert", () => {
); );
const qrcode = fs.readFileSync(path.resolve(__dirname, "./qrcode.png")); const qrcode = fs.readFileSync(path.resolve(__dirname, "./qrcode.png"));
const cert = fs.readFileSync(path.resolve(__dirname, "./cert.cer"));
const parser = new PDFparser(file); const parser = new PDFparser(file);
await parser.initialize(
"demo:1652778685773:7b893c000300000000b9c455b21b7b47780dc82f9ef63ddc54ce5c282b"
);
const sealCoords: SealCoords = { const sealCoords: SealCoords = {
"1": { x: "261.6", y: "384.84" }, "1": { x: "261.6", y: "384.84" },
"2": { x: "261.6", y: "384.84" }, "2": { x: "261.6", y: "384.84" },
...@@ -80,7 +85,7 @@ describe("PDF insert", () => { ...@@ -80,7 +85,7 @@ describe("PDF insert", () => {
sealCoords, sealCoords,
0.25, 0.25,
"demo:1652778685773:7b893c000300000000b9c455b21b7b47780dc82f9ef63ddc54ce5c282b", "demo:1652778685773:7b893c000300000000b9c455b21b7b47780dc82f9ef63ddc54ce5c282b",
cert, path.resolve(__dirname, "./cert.cer"),
"http://rfc3161timestamp.globalsign.com/advanced" "http://rfc3161timestamp.globalsign.com/advanced"
); );
......
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File added
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment