mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-07-02 00:17:40 +08:00
340 lines
18 KiB
Gherkin
340 lines
18 KiB
Gherkin
@pdfengines
|
|
@pdfengines-bookmarks
|
|
@bookmarks
|
|
Feature: /forms/pdfengines/bookmarks/{write|read}
|
|
|
|
Scenario: POST /forms/pdfengines/bookmarks/{write|read} (Single PDF & Bookmarks list)
|
|
Given I have a default Gotenberg container
|
|
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/bookmarks/write" endpoint with the following form data and header(s):
|
|
| files | testdata/page_1.pdf | file |
|
|
| bookmarks | [{"title":"Index","page":1,"children":[{"title":"Sub-index","page":1}]}] | field |
|
|
| Gotenberg-Output-Filename | foo | 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
|
|
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/bookmarks/read" endpoint with the following form data and header(s):
|
|
| files | teststore/foo.pdf | file |
|
|
Then the response status code should be 200
|
|
Then the response header "Content-Type" should be "application/json"
|
|
Then the response body should match JSON:
|
|
"""
|
|
{
|
|
"foo.pdf": [
|
|
{
|
|
"title": "Index",
|
|
"page": 1,
|
|
"children": [
|
|
{
|
|
"title": "Sub-index",
|
|
"page": 1
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
"""
|
|
|
|
Scenario: POST /forms/pdfengines/bookmarks/{write|read} (Single PDF & Bookmarks Map)
|
|
Given I have a default Gotenberg container
|
|
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/bookmarks/write" endpoint with the following form data and header(s):
|
|
| files | testdata/page_1.pdf | file |
|
|
| bookmarks | {"page_1.pdf":[{"title":"Index","page":1}]} | field |
|
|
| Gotenberg-Output-Filename | foo | 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
|
|
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/bookmarks/read" endpoint with the following form data and header(s):
|
|
| files | teststore/foo.pdf | file |
|
|
Then the response status code should be 200
|
|
Then the response header "Content-Type" should be "application/json"
|
|
Then the response body should match JSON:
|
|
"""
|
|
{
|
|
"foo.pdf": [
|
|
{
|
|
"title": "Index",
|
|
"page": 1
|
|
}
|
|
]
|
|
}
|
|
"""
|
|
|
|
Scenario: POST /forms/pdfengines/bookmarks/{write|read} (Many PDFs & Bookmarks List)
|
|
Given I have a default Gotenberg container
|
|
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/bookmarks/write" endpoint with the following form data and header(s):
|
|
| files. | testdata/page_1.pdf | file |
|
|
| files | testdata/page_2.pdf | file |
|
|
| bookmarks | [{"title":"Index","page":1}] | 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
|
|
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/bookmarks/read" endpoint with the following form data and header(s):
|
|
| files | teststore/page_1.pdf | file |
|
|
| files | teststore/page_2.pdf | file |
|
|
Then the response status code should be 200
|
|
Then the response header "Content-Type" should be "application/json"
|
|
Then the response body should match JSON:
|
|
"""
|
|
{
|
|
"page_1.pdf": [
|
|
{
|
|
"title": "Index",
|
|
"page": 1
|
|
}
|
|
],
|
|
"page_2.pdf": [
|
|
{
|
|
"title": "Index",
|
|
"page": 1
|
|
}
|
|
]
|
|
}
|
|
"""
|
|
|
|
Scenario: POST /forms/pdfengines/bookmarks/{write|read} (Many PDFs & Bookmarks Map)
|
|
Given I have a default Gotenberg container
|
|
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/bookmarks/write" endpoint with the following form data and header(s):
|
|
| files. | testdata/page_1.pdf | file |
|
|
| files | testdata/page_2.pdf | file |
|
|
| bookmarks | {"page_1.pdf":[{"title":"Index","page":1}],"page_2.pdf":[{"title":"Index","page":1}]} | 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
|
|
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/bookmarks/read" endpoint with the following form data and header(s):
|
|
| files | teststore/page_1.pdf | file |
|
|
| files | teststore/page_2.pdf | file |
|
|
Then the response status code should be 200
|
|
Then the response header "Content-Type" should be "application/json"
|
|
Then the response body should match JSON:
|
|
"""
|
|
{
|
|
"page_1.pdf": [
|
|
{
|
|
"title": "Index",
|
|
"page": 1
|
|
}
|
|
],
|
|
"page_2.pdf": [
|
|
{
|
|
"title": "Index",
|
|
"page": 1
|
|
}
|
|
]
|
|
}
|
|
"""
|
|
|
|
Scenario: POST /forms/pdfengines/bookmarks/read (Empty List)
|
|
Given I have a default Gotenberg container
|
|
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/bookmarks/read" endpoint with the following form data and header(s):
|
|
| files | testdata/page_1.pdf | file |
|
|
Then the response status code should be 200
|
|
Then the response header "Content-Type" should be "application/json"
|
|
Then the response body should match JSON:
|
|
"""
|
|
{
|
|
"page_1.pdf": []
|
|
}
|
|
"""
|
|
|
|
Scenario: POST /forms/pdfengines/bookmarks/write (Bad Request)
|
|
Given I have a default Gotenberg container
|
|
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/bookmarks/write" endpoint with the following form data and header(s):
|
|
| Gotenberg-Output-Filename | foo | header |
|
|
Then the response status code should be 400
|
|
Then the response header "Content-Type" should be "text/plain; charset=UTF-8"
|
|
Then the response body should match string:
|
|
"""
|
|
Invalid form data: form field 'bookmarks' is required; no form file found for extensions: [.pdf]
|
|
"""
|
|
Given I have a default Gotenberg container
|
|
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/bookmarks/write" endpoint with the following form data and header(s):
|
|
| files | testdata/page_1.pdf | file |
|
|
| bookmarks | foo | field |
|
|
Then the response status code should be 400
|
|
Then the response header "Content-Type" should be "text/plain; charset=UTF-8"
|
|
Then the response body should match string:
|
|
"""
|
|
Invalid form data: form field 'bookmarks' is invalid (got 'foo', resulting to unmarshal bookmarks: invalid character 'o' in literal false (expecting 'a'))
|
|
"""
|
|
|
|
Scenario: POST /forms/pdfengines/bookmarks/read (Bad Request)
|
|
Given I have a default Gotenberg container
|
|
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/bookmarks/read" endpoint with the following form data and header(s):
|
|
| Gotenberg-Output-Filename | foo | header |
|
|
Then the response status code should be 400
|
|
Then the response header "Content-Type" should be "text/plain; charset=UTF-8"
|
|
Then the response body should match string:
|
|
"""
|
|
Invalid form data: no form file found for extensions: [.pdf]
|
|
"""
|
|
|
|
Scenario: POST /forms/pdfengines/bookmarks/write (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/bookmarks/write" endpoint with the following form data and header(s):
|
|
| files | testdata/page_1.pdf | file |
|
|
| bookmarks | [{"title":"Index","page":1}] | field |
|
|
Then the response status code should be 404
|
|
|
|
Scenario: POST /forms/pdfengines/bookmarks/read (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/bookmarks/write" endpoint with the following form data and header(s):
|
|
| files | testdata/page_1.pdf | file |
|
|
Then the response status code should be 404
|
|
|
|
Scenario: POST /forms/pdfengines/bookmarks/write (Gotenberg Trace)
|
|
Given I have a default Gotenberg container
|
|
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/bookmarks/write" endpoint with the following form data and header(s):
|
|
| files | testdata/page_1.pdf | file |
|
|
| bookmarks | [{"title":"Index","page":1}] | field |
|
|
| Gotenberg-Trace | forms_pdfengines_bookmarks_write | 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_bookmarks_write"
|
|
Then the Gotenberg container should log the following entries:
|
|
| "correlation_id":"forms_pdfengines_bookmarks_write" |
|
|
|
|
Scenario: POST /forms/pdfengines/bookmarks/read (Gotenberg Trace)
|
|
Given I have a default Gotenberg container
|
|
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/bookmarks/read" endpoint with the following form data and header(s):
|
|
| files | testdata/page_1.pdf | file |
|
|
| Gotenberg-Trace | forms_pdfengines_bookmarks_read | header |
|
|
Then the response status code should be 200
|
|
Then the response header "Content-Type" should be "application/json"
|
|
Then the response header "Gotenberg-Trace" should be "forms_pdfengines_bookmarks_read"
|
|
Then the Gotenberg container should log the following entries:
|
|
| "correlation_id":"forms_pdfengines_bookmarks_read" |
|
|
|
|
@output-filename
|
|
Scenario: POST /forms/pdfengines/bookmarks/write (Output Filename - Single PDF)
|
|
Given I have a default Gotenberg container
|
|
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/bookmarks/write" endpoint with the following form data and header(s):
|
|
| files | testdata/page_1.pdf | file |
|
|
| bookmarks | [{"title":"Index","page":1}] | field |
|
|
| Gotenberg-Output-Filename | foo | header |
|
|
Then the response status code should be 200
|
|
Then the response header "Content-Type" should be "application/pdf"
|
|
Then there should be the following file(s) in the response:
|
|
| foo.pdf |
|
|
|
|
@output-filename
|
|
Scenario: POST /forms/pdfengines/bookmarks/write (Output Filename - Many PDFs)
|
|
Given I have a default Gotenberg container
|
|
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/bookmarks/write" endpoint with the following form data and header(s):
|
|
| files | testdata/page_1.pdf | file |
|
|
| files | testdata/page_2.pdf | file |
|
|
| bookmarks | [{"title":"Index","page":1}] | field |
|
|
| Gotenberg-Output-Filename | foo | 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:
|
|
| foo.zip |
|
|
| page_1.pdf |
|
|
| page_2.pdf |
|
|
|
|
@download-from
|
|
Scenario: POST /forms/pdfengines/bookmarks/write (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/bookmarks/write" endpoint with the following form data and header(s):
|
|
| bookmarks | [{"title":"Index","page":1}] | field |
|
|
| downloadFrom | [{"url":"http://host.docker.internal:%d/static/testdata/page_1.pdf","extraHttpHeaders":{"X-Foo":"bar"}}] | field |
|
|
| Gotenberg-Output-Filename | foo | header |
|
|
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"
|
|
|
|
@download-from
|
|
Scenario: POST /forms/pdfengines/bookmarks/read (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/bookmarks/read" 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 |
|
|
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/json"
|
|
|
|
@webhook
|
|
Scenario: POST /forms/pdfengines/bookmarks/write (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/bookmarks/write" endpoint with the following form data and header(s):
|
|
| files | testdata/page_1.pdf | file |
|
|
| bookmarks | [{"title":"Index","page":1}] | field |
|
|
| Gotenberg-Webhook-Url | http://host.docker.internal:%d/webhook | header |
|
|
| Gotenberg-Webhook-Error-Url | http://host.docker.internal:%d/webhook/error | header |
|
|
| Gotenberg-Output-Filename | foo | 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
|
|
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/bookmarks/read" endpoint with the following form data and header(s):
|
|
| files | teststore/foo.pdf | file |
|
|
Then the response status code should be 200
|
|
Then the response header "Content-Type" should be "application/json"
|
|
Then the response body should match JSON:
|
|
"""
|
|
{
|
|
"foo.pdf": [
|
|
{
|
|
"title": "Index",
|
|
"page": 1
|
|
}
|
|
]
|
|
}
|
|
"""
|
|
|
|
@webhook
|
|
Scenario: POST /forms/pdfengines/bookmarks/read (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/bookmarks/read" endpoint with the following form data and header(s):
|
|
| files | testdata/page_1.pdf | file |
|
|
| 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/json"
|
|
Then the webhook request body should match JSON:
|
|
"""
|
|
{
|
|
"status": 400,
|
|
"message": "The webhook middleware can only work with multipart/form-data routes that results in output files"
|
|
}
|
|
"""
|
|
|
|
Scenario: POST /forms/pdfengines/bookmarks/write (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/bookmarks/write" endpoint with the following form data and header(s):
|
|
| files | testdata/page_1.pdf | file |
|
|
| bookmarks | [{"title":"Index","page":1}] | field |
|
|
Then the response status code should be 401
|
|
|
|
Scenario: POST /forms/pdfengines/bookmarks/read (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/bookmarks/write" 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/bookmarks/{write|read} (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/bookmarks/write" endpoint with the following form data and header(s):
|
|
| files | testdata/page_1.pdf | file |
|
|
| bookmarks | [{"title":"Index","page":1}] | field |
|
|
| Gotenberg-Output-Filename | foo | header |
|
|
Then the response status code should be 200
|
|
Then the response header "Content-Type" should be "application/pdf"
|
|
When I make a "POST" request to Gotenberg at the "/foo/forms/pdfengines/bookmarks/read" endpoint with the following form data and header(s):
|
|
| files | teststore/foo.pdf | file |
|
|
Then the response status code should be 200
|
|
Then the response header "Content-Type" should be "application/json"
|