chore: slight improvement of the encrypt feature to be more in line with others features

This commit is contained in:
Julien Neuhart
2025-05-28 15:21:41 +02:00
parent 99307befdd
commit ba944f9dc2
19 changed files with 318 additions and 797 deletions
@@ -815,6 +815,28 @@ Feature: /forms/chromium/convert/html
Then there should be 1 PDF(s) in the response
Then the response PDF(s) should be flatten
Scenario: POST /forms/chromium/convert/html (Encrypt - user password only)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/html" endpoint with the following form data and header(s):
| files | testdata/page-1-html/index.html | file |
| userPassword | foo | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the response PDF(s) should be encrypted
Scenario: POST /forms/chromium/convert/html (Encrypt - both user and owner passwords)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/html" endpoint with the following form data and header(s):
| files | testdata/page-1-html/index.html | file |
| userPassword | foo | field |
| ownerPassword | bar | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the response PDF(s) should be encrypted
# FIXME: once decrypt is done, add encrypt and check after the content of the PDF.
Scenario: POST /forms/chromium/convert/html (PDF/A-1b & PDF/UA-1 & Metadata & Flatten)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/html" endpoint with the following form data and header(s):
@@ -920,75 +942,3 @@ Feature: /forms/chromium/convert/html
| files | testdata/page-1-html/index.html | file |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Scenario: POST /forms/chromium/convert/html with encryption (user password only)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/html" endpoint with the following form data and header(s):
| files | testdata/page-1-html/index.html | file |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should have 1 page(s)
Scenario: POST /forms/chromium/convert/html with encryption (user and owner passwords)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/html" endpoint with the following form data and header(s):
| files | testdata/page-1-html/index.html | file |
| userPassword | user123 | field |
| ownerPassword | owner456 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should have 1 page(s)
Scenario: POST /forms/chromium/convert/html with encryption and PDF/A conversion
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/html" endpoint with the following form data and header(s):
| files | testdata/page-1-html/index.html | file |
| userPassword | test123 | field |
| pdfa | PDF/A-1a | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should have 1 page(s)
Scenario: POST /forms/chromium/convert/html with encryption and page splitting
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/html" endpoint with the following form data and header(s):
| files | testdata/pages-12-html/index.html | file |
| userPassword | test123 | field |
| splitMode | intervals | field |
| splitSpan | 5 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/zip"
Then there should be the following file(s) in the response:
| encrypted.zip |
Then the "encrypted.zip" archive should contain encrypted PDF file(s)
Scenario: POST /forms/chromium/convert/html without encryption (empty password)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/html" endpoint with the following form data and header(s):
| files | testdata/page-1-html/index.html | file |
| userPassword | | field |
| Gotenberg-Output-Filename | unencrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| unencrypted.pdf |
Then the "unencrypted.pdf" PDF should NOT be encrypted
Then the "unencrypted.pdf" PDF should have 1 page(s)
@@ -939,6 +939,30 @@ Feature: /forms/chromium/convert/markdown
Then there should be 1 PDF(s) in the response
Then the response PDF(s) should be flatten
Scenario: POST /forms/chromium/convert/markdown (Encrypt - user password only)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/markdown" endpoint with the following form data and header(s):
| files | testdata/page-1-markdown/index.html | file |
| files | testdata/page-1-markdown/page_1.md | file |
| userPassword | foo | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the response PDF(s) should be encrypted
Scenario: POST /forms/chromium/convert/markdown (Encrypt - both user and owner passwords)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/markdown" endpoint with the following form data and header(s):
| files | testdata/page-1-markdown/index.html | file |
| files | testdata/page-1-markdown/page_1.md | file |
| userPassword | foo | field |
| ownerPassword | bar | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the response PDF(s) should be encrypted
# FIXME: once decrypt is done, add encrypt and check after the content of the PDF.
Scenario: POST /forms/chromium/convert/markdown (PDF/A-1b & PDF/UA-1 & Metadata & Flatten)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/markdown" endpoint with the following form data and header(s):
@@ -1051,81 +1075,3 @@ Feature: /forms/chromium/convert/markdown
| files | testdata/page-1-markdown/page_1.md | file |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Scenario: POST /forms/chromium/convert/markdown with encryption (user password only)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/markdown" endpoint with the following form data and header(s):
| files | testdata/page-1-markdown/index.html | file |
| files | testdata/page-1-markdown/page_1.md | file |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should have 1 page(s)
Scenario: POST /forms/chromium/convert/markdown with encryption (user and owner passwords)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/markdown" endpoint with the following form data and header(s):
| files | testdata/page-1-markdown/index.html | file |
| files | testdata/page-1-markdown/page_1.md | file |
| userPassword | user123 | field |
| ownerPassword | owner456 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should have 1 page(s)
Scenario: POST /forms/chromium/convert/markdown with encryption and PDF/A conversion
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/markdown" endpoint with the following form data and header(s):
| files | testdata/page-1-markdown/index.html | file |
| files | testdata/page-1-markdown/page_1.md | file |
| userPassword | test123 | field |
| pdfa | PDF/A-1a | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should have 1 page(s)
Scenario: POST /forms/chromium/convert/markdown with encryption and page splitting
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/markdown" endpoint with the following form data and header(s):
| files | testdata/pages-12-markdown/index.html | file |
| files | testdata/pages-12-markdown/page_1.md | file |
| files | testdata/pages-12-markdown/page_2.md | file |
| userPassword | test123 | field |
| splitMode | intervals | field |
| splitSpan | 5 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/zip"
Then there should be the following file(s) in the response:
| encrypted.zip |
Then the "encrypted.zip" archive should contain encrypted PDF file(s)
Scenario: POST /forms/chromium/convert/markdown without encryption (empty password)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/markdown" endpoint with the following form data and header(s):
| files | testdata/page-1-markdown/index.html | file |
| files | testdata/page-1-markdown/page_1.md | file |
| userPassword | | field |
| Gotenberg-Output-Filename | unencrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| unencrypted.pdf |
Then the "unencrypted.pdf" PDF should NOT be encrypted
Then the "unencrypted.pdf" PDF should have 1 page(s)
@@ -898,6 +898,30 @@ Feature: /forms/chromium/convert/url
Then there should be 1 PDF(s) in the response
Then the response PDF(s) should be flatten
Scenario: POST /forms/chromium/convert/url (Encrypt - user password only)
Given I have a default Gotenberg container
Given I have a static server
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/url" endpoint with the following form data and header(s):
| url | http://host.docker.internal:%d/html/testdata/page-1-html/index.html | field |
| userPassword | foo | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the response PDF(s) should be encrypted
Scenario: POST /forms/chromium/convert/url (Encrypt - both user and owner passwords)
Given I have a default Gotenberg container
Given I have a static server
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/url" endpoint with the following form data and header(s):
| url | http://host.docker.internal:%d/html/testdata/page-1-html/index.html | field |
| userPassword | foo | field |
| ownerPassword | bar | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the response PDF(s) should be encrypted
# FIXME: once decrypt is done, add encrypt and check after the content of the PDF.
Scenario: POST /forms/chromium/convert/url (PDF/A-1b & PDF/UA-1 & Metadata & Flatten)
Given I have a default Gotenberg container
Given I have a static server
@@ -999,80 +1023,3 @@ Feature: /forms/chromium/convert/url
| url | http://host.docker.internal:%d/html/testdata/page-1-html/index.html | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Scenario: POST /forms/chromium/convert/url with encryption (user password only)
Given I have a default Gotenberg container
Given I have a static server
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/url" endpoint with the following form data and header(s):
| url | http://host.docker.internal:%d/html/testdata/page-1-html/index.html | field |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should have 1 page(s)
Scenario: POST /forms/chromium/convert/url with encryption (user and owner passwords)
Given I have a default Gotenberg container
Given I have a static server
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/url" endpoint with the following form data and header(s):
| url | http://host.docker.internal:%d/html/testdata/page-1-html/index.html | field |
| userPassword | user123 | field |
| ownerPassword | owner456 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should have 1 page(s)
Scenario: POST /forms/chromium/convert/url with encryption and PDF/A conversion
Given I have a default Gotenberg container
Given I have a static server
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/url" endpoint with the following form data and header(s):
| url | http://host.docker.internal:%d/html/testdata/page-1-html/index.html | field |
| userPassword | test123 | field |
| pdfa | PDF/A-1a | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should have 1 page(s)
Scenario: POST /forms/chromium/convert/url with encryption and page splitting
Given I have a default Gotenberg container
Given I have a static server
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/url" endpoint with the following form data and header(s):
| url | http://host.docker.internal:%d/html/testdata/pages-12-html/index.html | field |
| userPassword | test123 | field |
| splitMode | intervals | field |
| splitSpan | 5 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/zip"
Then there should be the following file(s) in the response:
| encrypted.zip |
Then the "encrypted.zip" archive should contain encrypted PDF file(s)
Scenario: POST /forms/chromium/convert/url without encryption (empty password)
Given I have a default Gotenberg container
Given I have a static server
When I make a "POST" request to Gotenberg at the "/forms/chromium/convert/url" endpoint with the following form data and header(s):
| url | http://host.docker.internal:%d/html/testdata/page-1-html/index.html | field |
| userPassword | | field |
| Gotenberg-Output-Filename | unencrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| unencrypted.pdf |
Then the "unencrypted.pdf" PDF should NOT be encrypted
Then the "unencrypted.pdf" PDF should have 1 page(s)
@@ -526,6 +526,28 @@ Feature: /forms/libreoffice/convert
Then there should be 1 PDF(s) in the response
Then the response PDF(s) should be flatten
Scenario: POST /forms/libreoffice/convert (Encrypt - user password only)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/libreoffice/convert" endpoint with the following form data and header(s):
| files | testdata/page_1.docx | file |
| userPassword | foo | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the response PDF(s) should be encrypted
Scenario: POST /forms/libreoffice/convert (Encrypt - both user and owner passwords)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/libreoffice/convert" endpoint with the following form data and header(s):
| files | testdata/page_1.docx | file |
| userPassword | foo | field |
| ownerPassword | bar | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the response PDF(s) should be encrypted
# FIXME: once decrypt is done, add encrypt and check after the content of the PDF.
Scenario: POST /forms/libreoffice/convert (PDF/A-1b & PDF/UA-1 & Metadata & Flatten)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/libreoffice/convert" endpoint with the following form data and header(s):
@@ -533,7 +555,6 @@ Feature: /forms/libreoffice/convert
| pdfa | PDF/A-1b | field |
| pdfua | true | field |
| metadata | {"Author":"Julien Neuhart","Copyright":"Julien Neuhart","CreateDate":"2006-09-18T16:27:50-04:00","Creator":"Gotenberg","Keywords":["first","second"],"Marked":true,"ModDate":"2006-09-18T16:27:50-04:00","PDFVersion":1.7,"Producer":"Gotenberg","Subject":"Sample","Title":"Sample","Trapped":"Unknown"} | field |
| flatten | true | field |
| Gotenberg-Output-Filename | foo | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
@@ -631,90 +652,3 @@ Feature: /forms/libreoffice/convert
| files | testdata/page_1.docx | file |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Scenario: POST /forms/libreoffice/convert with encryption (user password only)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/libreoffice/convert" endpoint with the following form data and header(s):
| files | testdata/page_1.docx | file |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should have 1 page(s)
Scenario: POST /forms/libreoffice/convert with encryption (user and owner passwords)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/libreoffice/convert" endpoint with the following form data and header(s):
| files | testdata/page_1.docx | file |
| userPassword | user123 | field |
| ownerPassword | owner456 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should have 1 page(s)
Scenario: POST /forms/libreoffice/convert with encryption and PDF/A conversion
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/libreoffice/convert" endpoint with the following form data and header(s):
| files | testdata/page_1.docx | file |
| userPassword | test123 | field |
| pdfa | PDF/A-1a | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should have 1 page(s)
Scenario: POST /forms/libreoffice/convert with encryption (multiple files)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/libreoffice/convert" endpoint with the following form data and header(s):
| files | testdata/page_1.docx | file |
| files | testdata/page_2.docx | file |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/zip"
Then there should be the following file(s) in the response:
| encrypted.zip |
Then the response PDF(s) should be encrypted
Then the "encrypted.zip" archive should contain encrypted PDF file(s)
Scenario: POST /forms/libreoffice/convert with encryption and flattening
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/libreoffice/convert" endpoint with the following form data and header(s):
| files | testdata/page_1.docx | file |
| userPassword | test123 | field |
| flatten | true | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should have 1 page(s)
Scenario: POST /forms/libreoffice/convert without encryption (empty password)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/libreoffice/convert" endpoint with the following form data and header(s):
| files | testdata/page_1.docx | file |
| userPassword | | field |
| Gotenberg-Output-Filename | unencrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| unencrypted.pdf |
Then the "unencrypted.pdf" PDF should NOT be encrypted
Then the "unencrypted.pdf" PDF should have 1 page(s)
@@ -183,78 +183,3 @@ Feature: /forms/pdfengines/convert
| pdfa | PDF/A-1b | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Scenario: POST /forms/pdfengines/convert with encryption (user password only)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/convert" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| pdfa | PDF/A-1b | field |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should be valid "PDF/A-1b" with a tolerance of 1 failed rule(s)
Scenario: POST /forms/pdfengines/convert with encryption (user and owner passwords)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/convert" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| pdfa | PDF/A-1b | field |
| userPassword | user123 | field |
| ownerPassword | owner456 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should be valid "PDF/A-1b" with a tolerance of 1 failed rule(s)
Scenario: POST /forms/pdfengines/convert with encryption (multiple files)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/convert" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| files | testdata/page_2.pdf | file |
| pdfa | PDF/A-1b | field |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/zip"
Then there should be the following file(s) in the response:
| encrypted.zip |
Then the response PDF(s) should be encrypted
Then the "encrypted.zip" archive should contain encrypted PDF file(s)
Scenario: POST /forms/pdfengines/convert with encryption and PDF/UA
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/convert" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| pdfua | true | field |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Scenario: POST /forms/pdfengines/convert without encryption (empty password)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/convert" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| pdfa | PDF/A-1b | field |
| userPassword | | field |
| Gotenberg-Output-Filename | unencrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| unencrypted.pdf |
Then the "unencrypted.pdf" PDF should NOT be encrypted
Then the "unencrypted.pdf" PDF should be valid "PDF/A-1b" with a tolerance of 1 failed rule(s)
@@ -1,129 +1,152 @@
Feature: /forms/pdfengines/encrypt
Scenario: POST /forms/pdfengines/encrypt (default - QPDF)
Scenario: POST /forms/pdfengines/encrypt (default - QPDF - user password only)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/encrypt" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | protected | header |
| files | testdata/page_1.pdf | file |
| userPassword | foo | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| protected.pdf |
Then the "protected.pdf" PDF should be encrypted
Then the response PDF(s) should be encrypted
Scenario: POST /forms/pdfengines/encrypt with user and owner passwords (QPDF)
Scenario: POST /forms/pdfengines/encrypt (default - QPDF - both user and owner passwords)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/encrypt" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| userPassword | user123 | field |
| ownerPassword | owner456 | field |
| Gotenberg-Output-Filename | protected | header |
| files | testdata/page_1.pdf | file |
| userPassword | foo | field |
| ownerPassword | bar | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| protected.pdf |
Then the "protected.pdf" PDF should be encrypted
Then the response PDF(s) should be encrypted
Scenario: POST /forms/pdfengines/encrypt (PDFtk)
Scenario: POST /forms/pdfengines/encrypt (PDFtk - user password only)
Given I have a Gotenberg container with the following environment variable(s):
| PDFENGINES_PASSWORD_ENGINES | pdftk |
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/encrypt" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | protected | header |
| files | testdata/page_1.pdf | file |
| userPassword | foo | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| protected.pdf |
Then the "protected.pdf" PDF should be encrypted
Then the response PDF(s) should be encrypted
Scenario: POST /forms/pdfengines/encrypt (pdfcpu)
Scenario: POST /forms/pdfengines/encrypt (PDFtk - both user and owner passwords)
Given I have a Gotenberg container with the following environment variable(s):
| PDFENGINES_PASSWORD_ENGINES | pdftk |
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/encrypt" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| userPassword | foo | field |
| ownerPassword | bar | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the response PDF(s) should be encrypted
Scenario: POST /forms/pdfengines/encrypt (pdfcpu - user password only)
Given I have a Gotenberg container with the following environment variable(s):
| PDFENGINES_PASSWORD_ENGINES | pdfcpu |
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/encrypt" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | protected | header |
| files | testdata/page_1.pdf | file |
| userPassword | foo | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| protected.pdf |
Then the "protected.pdf" PDF should be encrypted
Then the response PDF(s) should be encrypted
Scenario: POST /forms/pdfengines/encrypt with multiple files
Scenario: POST /forms/pdfengines/encrypt (pdfcpu - both user and owner passwords)
Given I have a Gotenberg container with the following environment variable(s):
| PDFENGINES_PASSWORD_ENGINES | pdfcpu |
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/encrypt" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| userPassword | foo | field |
| ownerPassword | bar | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the response PDF(s) should be encrypted
Scenario: POST /forms/pdfengines/encrypt (Many PDFs)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/encrypt" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| files | testdata/page_2.pdf | file |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | protected | header |
| files | testdata/page_1.pdf | file |
| files | testdata/page_2.pdf | file |
| userPassword | foo | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/zip"
Then there should be the following file(s) in the response:
| protected.zip |
Then the "protected.zip" archive should contain 2 file(s)
Then the "protected.zip" archive should contain encrypted PDF file(s)
Then there should be 2 PDF(s) in the response
Then the response PDF(s) should be encrypted
Scenario: POST /forms/pdfengines/encrypt without required userPassword field
Scenario: POST /forms/pdfengines/encrypt (Bad Request)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/encrypt" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| Gotenberg-Output-Filename | protected | header |
| files | testdata/page_1.pdf | file |
Then the response status code should be 400
Then the response body should contain "userPassword"
Scenario: POST /forms/pdfengines/encrypt with password engines that don't support password protection
Given I have a Gotenberg container with the following environment variable(s):
| PDFENGINES_PASSWORD_ENGINES | exiftool |
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/encrypt" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | protected | header |
Then the response status code should be 500
Then the response body should contain "password protection not supported"
Scenario: POST /forms/pdfengines/encrypt (Download From)
Given I have a default Gotenberg container
Given I have a static server
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/encrypt" endpoint with the following form data and header(s):
| downloadFrom | [{"url":"http://host.docker.internal:%d/static/testdata/page_1.pdf","extraHttpHeaders":{"X-Foo":"bar"}}] | field |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | protected | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| protected.pdf |
Then the "protected.pdf" PDF should be encrypted
Scenario: POST /forms/pdfengines/encrypt (Webhook)
Given I have a default Gotenberg container
Given I have a webhook server
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/encrypt" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| Gotenberg-Output-Filename | foo | header |
| Gotenberg-Webhook-Url | http://host.docker.internal:%d/webhook | header |
| Gotenberg-Webhook-Error-Url | http://host.docker.internal:%d/webhook/error | header |
Then the response status code should be 204
When I wait for the asynchronous request to the webhook
Then the webhook request header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the webhook request
Then there should be the following file(s) in the webhook request:
| foo.pdf |
Then the "foo.pdf" PDF should have 1 page(s)
Then the "foo.pdf" PDF should have the following content at page 1:
Then the response body should match string:
"""
Page 1
Invalid form data: form field 'userPassword' is required
"""
Scenario: POST /forms/pdfengines/encrypt (Routes Disabled)
Given I have a Gotenberg container with the following environment variable(s):
| PDFENGINES_DISABLE_ROUTES | true |
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/encrypt" endpoint with the following form data and header(s):
| files | testdata/pages_3.pdf | file |
| files | testdata/page_1.pdf | file |
Then the response status code should be 404
Scenario: POST /forms/pdfengines/encrypt (Gotenberg Trace)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/encrypt" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| userPassword | foo | field |
| Gotenberg-Trace | forms_pdfengines_encrypt | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then the response header "Gotenberg-Trace" should be "forms_pdfengines_encrypt"
Then the Gotenberg container should log the following entries:
| "trace":"forms_pdfengines_encrypt" |
Scenario: POST /forms/pdfengines/encrypt (Download From)
Given I have a default Gotenberg container
Given I have a static server
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/encrypt" endpoint with the following form data and header(s):
| downloadFrom | [{"url":"http://host.docker.internal:%d/static/testdata/page_1.pdf","extraHttpHeaders":{"X-Foo":"bar"}}] | field |
| userPassword | foo | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the response PDF(s) should be encrypted
Scenario: POST /forms/pdfengines/encrypt (Webhook)
Given I have a default Gotenberg container
Given I have a webhook server
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/encrypt" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| userPassword | foo | field |
| Gotenberg-Webhook-Url | http://host.docker.internal:%d/webhook | header |
| Gotenberg-Webhook-Error-Url | http://host.docker.internal:%d/webhook/error | header |
Then the response status code should be 204
When I wait for the asynchronous request to the webhook
Then the webhook request header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the webhook request
Then the response PDF(s) should be encrypted
Scenario: POST /forms/pdfengines/encrypt (Basic Auth)
Given I have a Gotenberg container with the following environment variable(s):
| API_ENABLE_BASIC_AUTH | true |
| GOTENBERG_API_BASIC_AUTH_USERNAME | foo |
| GOTENBERG_API_BASIC_AUTH_PASSWORD | bar |
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/encrypt" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
Then the response status code should be 401
Scenario: POST /foo/forms/pdfengines/encrypt (Root Path)
Given I have a Gotenberg container with the following environment variable(s):
| API_ENABLE_DEBUG_ROUTE | true |
| API_ROOT_PATH | /foo/ |
When I make a "POST" request to Gotenberg at the "/foo/forms/pdfengines/encrypt" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| userPassword | foo | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
@@ -79,6 +79,7 @@ Feature: /forms/pdfengines/flatten
Then the file request header "X-Foo" should be "bar"
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then the response PDF(s) should be flatten
Scenario: POST /forms/pdfengines/flatten (Webhook)
Given I have a default Gotenberg container
@@ -199,6 +199,30 @@ Feature: /forms/pdfengines/merge
"""
Then the response PDF(s) should be flatten
Scenario: POST /forms/pdfengines/merge (Encrypt - user password only)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/merge" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| files | testdata/page_2.pdf | file |
| userPassword | foo | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the response PDF(s) should be encrypted
Scenario: POST /forms/pdfengines/merge (Encrypt - both user and owner passwords)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/merge" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| files | testdata/page_2.pdf | file |
| userPassword | foo | field |
| ownerPassword | bar | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then the response PDF(s) should be encrypted
# FIXME: once decrypt is done, add encrypt and check after the content of the PDF.
Scenario: POST /forms/pdfengines/merge (PDF/A-1b & PDF/UA-1 & Metadata & Flatten)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/merge" endpoint with the following form data and header(s):
@@ -322,81 +346,3 @@ Feature: /forms/pdfengines/merge
| files | testdata/page_2.pdf | file |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Scenario: POST /forms/pdfengines/merge with encryption (user password only)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/merge" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| files | testdata/page_2.pdf | file |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should have 2 page(s)
Scenario: POST /forms/pdfengines/merge with encryption (user and owner passwords)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/merge" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| files | testdata/page_2.pdf | file |
| userPassword | user123 | field |
| ownerPassword | owner456 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should have 2 page(s)
Scenario: POST /forms/pdfengines/merge with encryption and PDF/A conversion
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/merge" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| files | testdata/page_2.pdf | file |
| userPassword | test123 | field |
| pdfa | PDF/A-1a | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should have 2 page(s)
Scenario: POST /forms/pdfengines/merge with encryption and flattening
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/merge" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| files | testdata/page_2.pdf | file |
| userPassword | test123 | field |
| flatten | true | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Then the "encrypted.pdf" PDF should have 2 page(s)
Scenario: POST /forms/pdfengines/merge without encryption (empty password)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/merge" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| files | testdata/page_2.pdf | file |
| userPassword | | field |
| Gotenberg-Output-Filename | unencrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| unencrypted.pdf |
Then the "unencrypted.pdf" PDF should NOT be encrypted
Then the "unencrypted.pdf" PDF should have 2 page(s)
@@ -284,61 +284,3 @@ Feature: /forms/pdfengines/{write|read}
| files | teststore/foo.pdf | file |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/json"
Scenario: POST /forms/pdfengines/metadata/write with encryption (user password only)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/metadata/write" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| metadata | {"Title":"Encrypted Sample","Author":"Test Author","Subject":"Test Subject"} | field |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Scenario: POST /forms/pdfengines/metadata/write with encryption (user and owner passwords)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/metadata/write" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| metadata | {"Title":"Encrypted Sample","Author":"Test Author","Subject":"Test Subject"} | field |
| userPassword | user123 | field |
| ownerPassword | owner456 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.pdf |
Then the "encrypted.pdf" PDF should be encrypted
Scenario: POST /forms/pdfengines/metadata/write with encryption (multiple files)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/metadata/write" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| files | testdata/page_2.pdf | file |
| metadata | {"Title":"Encrypted Sample","Author":"Test Author","Subject":"Test Subject"} | field |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/zip"
Then there should be the following file(s) in the response:
| encrypted.zip |
Then the response PDF(s) should be encrypted
Then the "encrypted.zip" archive should contain encrypted PDF file(s)
Scenario: POST /forms/pdfengines/metadata/write without encryption (empty password)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/metadata/write" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| metadata | {"Title":"Unencrypted Sample","Author":"Test Author","Subject":"Test Subject"} | field |
| userPassword | | field |
| Gotenberg-Output-Filename | unencrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| unencrypted.pdf |
Then the "unencrypted.pdf" PDF should NOT be encrypted
@@ -365,6 +365,32 @@ Feature: /forms/pdfengines/split
"""
Then the response PDF(s) should be flatten
Scenario: POST /forms/pdfengines/split (Encrypt - user password only)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/split" endpoint with the following form data and header(s):
| files | testdata/pages_3.pdf | file |
| splitMode | intervals | field |
| splitSpan | 2 | field |
| userPassword | foo | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/zip"
Then there should be 2 PDF(s) in the response
Then the response PDF(s) should be encrypted
Scenario: POST /forms/pdfengines/split (Encrypt - both user and owner passwords)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/split" endpoint with the following form data and header(s):
| files | testdata/pages_3.pdf | file |
| splitMode | intervals | field |
| splitSpan | 2 | field |
| userPassword | foo | field |
| ownerPassword | bar | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/zip"
Then there should be 2 PDF(s) in the response
Then the response PDF(s) should be encrypted
# FIXME: once decrypt is done, add encrypt and check after the content of the PDFs.
Scenario: POST /forms/pdfengines/split (PDF/A-1b & PDF/UA-1 & Metadata & Flatten)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/split" endpoint with the following form data and header(s):
@@ -549,69 +575,3 @@ Feature: /forms/pdfengines/split
| splitSpan | 2 | field |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/zip"
Scenario: POST /forms/pdfengines/split with encryption (intervals)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/split" endpoint with the following form data and header(s):
| files | testdata/pages_3.pdf | file |
| splitMode | intervals | field |
| splitSpan | 2 | field |
| userPassword | test123 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/zip"
Then there should be 2 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.zip |
Then the response PDF(s) should be encrypted
Then the "encrypted.zip" archive should contain encrypted PDF file(s)
Scenario: POST /forms/pdfengines/split with encryption (pages)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/split" endpoint with the following form data and header(s):
| files | testdata/pages_3.pdf | file |
| splitMode | pages | field |
| splitSpan | 2- | field |
| userPassword | user123 | field |
| ownerPassword | owner456 | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/zip"
Then there should be 2 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.zip |
Then the response PDF(s) should be encrypted
Then the "encrypted.zip" archive should contain encrypted PDF file(s)
Scenario: POST /forms/pdfengines/split with encryption and PDF/A conversion
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/split" endpoint with the following form data and header(s):
| files | testdata/pages_3.pdf | file |
| splitMode | intervals | field |
| splitSpan | 2 | field |
| userPassword | test123 | field |
| pdfa | PDF/A-1a | field |
| Gotenberg-Output-Filename | encrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/zip"
Then there should be 2 PDF(s) in the response
Then there should be the following file(s) in the response:
| encrypted.zip |
Then the response PDF(s) should be encrypted
Then the "encrypted.zip" archive should contain encrypted PDF file(s)
Scenario: POST /forms/pdfengines/split without encryption (empty password)
Given I have a default Gotenberg container
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/split" endpoint with the following form data and header(s):
| files | testdata/pages_3.pdf | file |
| splitMode | intervals | field |
| splitSpan | 2 | field |
| userPassword | | field |
| Gotenberg-Output-Filename | unencrypted | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/zip"
Then there should be 2 PDF(s) in the response
Then there should be the following file(s) in the response:
| unencrypted.zip |
Then the "unencrypted.zip" archive should contain 2 file(s)
Then the "unencrypted.zip" archive should NOT contain encrypted PDF file(s)
+41 -82
View File
@@ -580,6 +580,7 @@ func (s *scenario) thePdfsShouldBeValidWithAToleranceOf(ctx context.Context, kin
return fmt.Errorf("unknown %q", validate)
}
re := regexp.MustCompile(`failedRules="(\d+)"`)
for _, path := range paths {
cmd := []string{
"verapdf",
@@ -593,9 +594,7 @@ func (s *scenario) thePdfsShouldBeValidWithAToleranceOf(ctx context.Context, kin
return fmt.Errorf("exec %q: %w", cmd, err)
}
re := regexp.MustCompile(`failedRules="(\d+)"`)
matches := re.FindStringSubmatch(output)
if len(matches) < 2 {
return errors.New("expected failed rules")
}
@@ -812,6 +811,8 @@ func (s *scenario) thePdfsShouldBeFlatten(ctx context.Context, kind, should stri
return fmt.Errorf("walk %q: %w", s.workdir, err)
}
invert := should == "should NOT"
for _, path := range paths {
cmd := []string{
"verapdf",
@@ -826,7 +827,6 @@ func (s *scenario) thePdfsShouldBeFlatten(ctx context.Context, kind, should stri
return fmt.Errorf("exec %q: %w", cmd, err)
}
invert := should == "should NOT"
if invert && strings.Contains(output, "<featuresReport></featuresReport>") {
return fmt.Errorf("PDF %q is flatten", path)
}
@@ -839,93 +839,53 @@ func (s *scenario) thePdfsShouldBeFlatten(ctx context.Context, kind, should stri
return nil
}
// thePdfShouldBeEncrypted checks if a PDF file is encrypted or not encrypted based on condition.
func (s *scenario) thePdfShouldBeEncrypted(ctx context.Context, filename, should string) error {
filePath := fmt.Sprintf("%s/%s", s.workdir, filename)
func (s *scenario) thePdfsShouldBeEncrypted(ctx context.Context, kind string, should string) error {
dirPath := fmt.Sprintf("%s/%s", s.workdir, s.resp.Header().Get("Gotenberg-Trace"))
cmd := []string{
"qpdf",
"--check",
filepath.Base(filePath),
_, err := os.Stat(dirPath)
if os.IsNotExist(err) {
return fmt.Errorf("directory %q does not exist", dirPath)
}
output, err := execCommandInIntegrationToolsContainer(ctx, cmd, filePath)
invert := should == "should NOT"
isEncrypted := err != nil && (strings.Contains(output, "password") || strings.Contains(output, "encrypted"))
if invert && isEncrypted {
return fmt.Errorf("expected PDF %s to not be encrypted, but it is encrypted", filename)
}
if !invert && !isEncrypted {
return fmt.Errorf("expected PDF %s to be encrypted, but it is not", filename)
}
return nil
}
// theArchiveShouldContainEncryptedPdfFiles checks if a zip archive contains encrypted PDF files based on condition.
func (s *scenario) theArchiveShouldContainEncryptedPdfFiles(ctx context.Context, archiveFilename, should string) error {
archivePath := fmt.Sprintf("%s/%s", s.workdir, archiveFilename)
// First, extract the archive inside the container
extractCmd := []string{
"sh",
"-c",
fmt.Sprintf("mkdir -p /tmp/extract && unzip -o %s -d /tmp/extract", filepath.Base(archivePath)),
}
_, err := execCommandInIntegrationToolsContainer(ctx, extractCmd, archivePath)
if err != nil {
return fmt.Errorf("extract archive in container: %w", err)
}
// List PDF files in the extracted directory
listCmd := []string{
"sh",
"-c",
"find /tmp/extract -name '*.pdf' -type f",
}
output, err := execCommandInIntegrationToolsContainer(ctx, listCmd, archivePath)
if err != nil {
return fmt.Errorf("list PDFs in container: %w", err)
}
// No PDFs found
if output == "" {
return fmt.Errorf("no PDF files found in archive %s", archiveFilename)
}
// Check each PDF for password protection
pdfPaths := strings.Split(strings.TrimSpace(output), "\n")
foundProtectedPdf := false
for _, pdfPath := range pdfPaths {
checkCmd := []string{
"qpdf",
"--check",
pdfPath,
var paths []string
err = filepath.Walk(dirPath, func(path string, info os.FileInfo, pathErr error) error {
if pathErr != nil {
return pathErr
}
checkOutput, err := execCommandInIntegrationToolsContainer(ctx, checkCmd, archivePath)
// If we get a password error, we found a protected PDF
if err != nil && (strings.Contains(checkOutput, "password") || strings.Contains(checkOutput, "encrypted")) {
foundProtectedPdf = true
break
if strings.EqualFold(filepath.Ext(info.Name()), ".pdf") {
paths = append(paths, path)
}
return nil
})
if err != nil {
return fmt.Errorf("walk %q: %w", dirPath, err)
}
invert := should == "should NOT"
re := regexp.MustCompile(`CommandLineError:Incorrectpassword`)
if invert && foundProtectedPdf {
return fmt.Errorf("found encrypted PDF files in archive %s, but expected none", archiveFilename)
}
for _, path := range paths {
cmd := []string{
"pdfinfo",
filepath.Base(path),
}
if !invert && !foundProtectedPdf {
return fmt.Errorf("no encrypted PDF files found in archive %s", archiveFilename)
output, err := execCommandInIntegrationToolsContainer(ctx, cmd, path)
if err != nil {
return fmt.Errorf("exec %q: %w", cmd, err)
}
output = strings.ReplaceAll(output, " ", "")
output = strings.ReplaceAll(output, "\n", "")
matches := re.FindStringSubmatch(output)
isEncrypted := len(matches) >= 1 && matches[0] == "CommandLineError:Incorrectpassword"
if invert && isEncrypted {
return fmt.Errorf("PDF %q is encrypted", path)
}
if !invert && !isEncrypted {
return fmt.Errorf("PDF %q is not encrypted: %q", path, output)
}
}
return nil
@@ -963,11 +923,10 @@ func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.Then(`^there should be the following file\(s\) in the (response|webhook request):$`, s.thereShouldBeTheFollowingFiles)
ctx.Then(`^the (response|webhook request) PDF\(s\) should be valid "([^"]*)" with a tolerance of (\d+) failed rule\(s\)$`, s.thePdfsShouldBeValidWithAToleranceOf)
ctx.Then(`^the (response|webhook request) PDF\(s\) (should|should NOT) be flatten$`, s.thePdfsShouldBeFlatten)
ctx.Then(`^the (response|webhook request) PDF\(s\) (should|should NOT) be encrypted`, s.thePdfsShouldBeEncrypted)
ctx.Then(`^the "([^"]*)" PDF should have (\d+) page\(s\)$`, s.thePdfShouldHavePages)
ctx.Then(`^the "([^"]*)" PDF (should|should NOT) be set to landscape orientation$`, s.thePdfShouldBeSetToLandscapeOrientation)
ctx.Then(`^the "([^"]*)" PDF (should|should NOT) have the following content at page (\d+):$`, s.thePdfShouldHaveTheFollowingContentAtPage)
ctx.Then(`^the "([^"]*)" PDF (should|should NOT) be encrypted$`, s.thePdfShouldBeEncrypted)
ctx.Then(`^the "([^"]*)" archive (should|should NOT) contain encrypted PDF file\(s\)$`, s.theArchiveShouldContainEncryptedPdfFiles)
ctx.After(func(ctx context.Context, sc *godog.Scenario, err error) (context.Context, error) {
if s.gotenbergContainer != nil {
errTerminate := s.gotenbergContainer.Terminate(ctx, testcontainers.StopTimeout(0))