Files
Stirling-PDF/testing/cucumber/features/redact.feature
T

144 lines
6.9 KiB
Gherkin

@security @redact
Feature: PDF redaction physically removes text
Target text must be gone from the extracted text layer, not just covered by a box.
Scenario: Auto-redact physically removes the target word
Given I generate a PDF file as "fileInput"
And the pdf pages all contain the text "PUBLIC alpha SECRET99 omega PUBLIC"
And the request data includes
| parameter | value |
| listOfText | SECRET99 |
When I send the API request to the endpoint "/api/v1/security/auto-redact"
Then the response status code should be 200
And the response content type should be "application/pdf"
And the response PDF should not contain the text "SECRET99"
And the response PDF should contain the text "omega"
Scenario: Auto-redact leaves substrings when whole-word search is on
Given I generate a PDF file as "fileInput"
And the pdf pages all contain the text "cat classification scatter"
And the request data includes
| parameter | value |
| listOfText | cat |
| wholeWordSearch | true |
When I send the API request to the endpoint "/api/v1/security/auto-redact"
Then the response status code should be 200
And the response PDF should contain the text "classification"
And the response PDF should contain the text "scatter"
Scenario: Auto-redact with a regex pattern removes matches
Given I generate a PDF file as "fileInput"
And the pdf pages all contain the text "call 123-45-6789 today"
And the request data includes
| parameter | value |
| listOfText | \d{3}-\d{2}-\d{4} |
| useRegex | true |
When I send the API request to the endpoint "/api/v1/security/auto-redact"
Then the response status code should be 200
And the response PDF should not contain the text "123-45-6789"
And the response PDF should contain the text "today"
Scenario: Auto-redact convert-to-image drops the entire text layer
Given I generate a PDF file as "fileInput"
And the pdf pages all contain the text "keep SECRET77 hidden"
And the request data includes
| parameter | value |
| listOfText | SECRET77 |
| convertPDFToImage | true |
When I send the API request to the endpoint "/api/v1/security/auto-redact"
Then the response status code should be 200
And the response PDF should not contain the text "SECRET77"
And the response PDF should not contain the text "keep"
Scenario: Auto-redact also scrubs the target from bookmark titles
Given I generate a PDF file as "fileInput"
And the pdf pages all contain the text "body SECRET55 text"
And the pdf has a bookmark titled "Chapter SECRET55 overview"
And the request data includes
| parameter | value |
| listOfText | SECRET55 |
When I send the API request to the endpoint "/api/v1/security/auto-redact"
Then the response status code should be 200
And the response PDF should not contain the text "SECRET55"
And the response PDF bookmarks should not contain "SECRET55"
Scenario: Manual whole-page redaction wipes every word on the page
Given I generate a PDF file as "fileInput"
And the pdf pages all contain the text "TOP SECRET material"
And the request data includes
| parameter | value |
| pageNumbers | 1 |
When I send the API request to the endpoint "/api/v1/security/redact"
Then the response status code should be 200
And the response PDF should not contain the text "SECRET"
Scenario: Auto-redact removes case variants of the target
Given I generate a PDF file as "fileInput"
And the pdf pages all contain the text "alpha Secret99x omega"
And the request data includes
| parameter | value |
| listOfText | SECRET99X |
When I send the API request to the endpoint "/api/v1/security/auto-redact"
Then the response status code should be 200
And the response PDF should not contain the text "Secret99x"
And the response PDF should contain the text "omega"
Scenario: Auto-redact only touches pages containing the target
Given I generate a PDF file as "fileInput"
And the pdf contains 3 pages
And the request data includes
| parameter | value |
| listOfText | Page 2 |
When I send the API request to the endpoint "/api/v1/security/auto-redact"
Then the response status code should be 200
And the response PDF should not contain the text "Page 2"
And the response PDF should contain the text "Page 1"
And the response PDF should contain the text "Page 3"
Scenario: Auto-redact handles a Type3 font PDF (glyphs as content streams)
Given I use an example file at "../crop_test.pdf" as parameter "fileInput"
And the request data includes
| parameter | value |
| listOfText | EXAMPLE |
When I send the API request to the endpoint "/api/v1/security/auto-redact"
Then the response status code should be 200
And the response PDF should not contain the text "EXAMPLE"
And the response PDF should contain the text "CROP"
Scenario: Auto-redact removes the target from an embedded TrueType font PDF
Given I generate a PDF file as "fileInput"
And the pdf pages all contain the text "keepA SECRET88 keepB" in an embedded font
And the request data includes
| parameter | value |
| listOfText | SECRET88 |
When I send the API request to the endpoint "/api/v1/security/auto-redact"
Then the response status code should be 200
And the response content type should be "application/pdf"
And the response PDF should not contain the text "SECRET88"
And the response PDF should contain the text "keepA"
And the response PDF should contain the text "keepB"
Scenario: Auto-redact with a regex pattern on an embedded-font PDF
Given I generate a PDF file as "fileInput"
And the pdf pages all contain the text "invoice 987-65-4321 total" in an embedded font
And the request data includes
| parameter | value |
| listOfText | \d{3}-\d{2}-\d{4} |
| useRegex | true |
When I send the API request to the endpoint "/api/v1/security/auto-redact"
Then the response status code should be 200
And the response PDF should not contain the text "987-65-4321"
And the response PDF should contain the text "invoice"
Scenario: Auto-redact convert-to-image on an embedded-font PDF drops the text layer
Given I generate a PDF file as "fileInput"
And the pdf pages all contain the text "keep SECRET66 hidden" in an embedded font
And the request data includes
| parameter | value |
| listOfText | SECRET66 |
| convertPDFToImage | true |
When I send the API request to the endpoint "/api/v1/security/auto-redact"
Then the response status code should be 200
And the response PDF should not contain the text "SECRET66"
And the response PDF should not contain the text "keep"