Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
georgetarazevich committed Jan 10, 2024
1 parent 86c6256 commit c9966b4
Show file tree
Hide file tree
Showing 51 changed files with 240 additions and 286 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Config option tests with build rest:dev
name: Options tests with build rest:dev

on:
schedule:
Expand All @@ -15,7 +15,7 @@ jobs:

- name: Build and run Docker Image
run: |
docker build --build-arg GH_CHECKOUT=integration -t ghcr.io/verapdf/rest:dev . && docker run --user root -d -p 8080:8080 -p 8081:8081 ghcr.io/verapdf/rest:dev
docker build --build-arg GH_CHECKOUT=integration -t ghcr.io/verapdf/rest:dev . && docker run --user root -d -p 8080:8080 -p 8081:8081 -e VERAPDF_MAX_FILE_SIZE=1 -v /tmp:/home/Res_tmp ghcr.io/verapdf/rest:dev
echo whoami: $(docker inspect $(docker ps -q) --format '{{.Config.User}} {{.Name}}')
- name: Check Docker Container
Expand Down Expand Up @@ -49,14 +49,15 @@ jobs:
./bats/bin/bats -v
- name: Config option ... running tests
- name: Running tests ... Options
working-directory: ./tests
run: |
echo pwd: $PWD
echo dir: $(ls ./)
./bats/bin/bats -r ./Options --show-output-of-passing-tests --print-output-on-failure --report-formatter junit --output ./results
- name: Generating report
if: always()
working-directory: ./tests/results
run: |
echo pwd: $PWD
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ verapdf/
*.log
*.html
*.css
*.code-workspace
7 changes: 6 additions & 1 deletion kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ spec:
labels:
project: verapdf-rest
spec:
terminationGracePeriodSeconds: 300
containers:
- name : verapdf-rest
image: ghcr.io/verapdf/rest:dev
lifecycle:
preStop:
exec:
command: ["/bin/sleep", "300"]
resources:
requests:
cpu: "250m"
limits:
cpu: "250m"
cpu: "2000m"
ports:
- containerPort: 8080
name : rest-api-port
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/verapdf/rest/resources/ProfileResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static Set<PDFAFlavour> getFlavours() {
/**
* @param profileId
* the String id of the Validation profile (1b, 1a, 2b, 2a, 2u,
* 3b, 3a, 3u, 4, 4e, 4f or ua1)
* 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)
* @return a validation profile selected by id
*/
@GET
Expand All @@ -108,15 +108,15 @@ public static Set<PDFAFlavour> getFlavours() {
)})})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public static ValidationProfile getProfile(@Parameter(description = "the String id of the Validation profile " +
"(1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f or ua1)")
"(1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)")
@PathParam("profileId") String profileId) {
return DIRECTORY.getValidationProfileById(profileId);
}

/**
* @param profileId
* the String id of the Validation profile (1b, 1a, 2b, 2a, 2u,
* 3b, 3a, 3u, 4, 4e, 4f or ua1)
* 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)
* @return the {@link java.util.Set} of
* {@link org.verapdf.pdfa.validation.profiles.RuleId}s for the selected
* Validation Profile
Expand All @@ -133,7 +133,7 @@ public static ValidationProfile getProfile(@Parameter(description = "the String
)})})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public static Set<RuleId> getProfileRules(@Parameter(description = "the String id of the Validation profile " +
"(1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f or ua1)")
"(1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)")
@PathParam("profileId") String profileId) {
SortedSet<RuleId> ids = new TreeSet<>(new Profiles.RuleIdComparator());
for (Rule rule : DIRECTORY.getValidationProfileById(profileId).getRules()) {
Expand All @@ -145,7 +145,7 @@ public static Set<RuleId> getProfileRules(@Parameter(description = "the String i
/**
* @param profileId
* the String id of the Validation profile (1b, 1a, 2b, 2a, 2u,
* 3b, 3a, 3u, 4, 4e, 4f or ua1)
* 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)
* @param clause
* a {@link java.lang.String} identifying the profile clause to
* return the Rules for
Expand All @@ -165,7 +165,7 @@ public static Set<RuleId> getProfileRules(@Parameter(description = "the String i
)})})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public static Set<Rule> getRulesForClause(@Parameter(description = "the String id of the Validation profile " +
"(1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f or ua1)")
"(1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)")
@PathParam("profileId") String profileId,
@Parameter(description = "a string identifying the profile clause to return the rules for")
@PathParam("clause") String clause) {
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/org/verapdf/rest/resources/ValidateResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static ComponentDetails getDetails() {
* @param profileId
* the String id of the Validation profile
* (auto, 1b, 1a, 2b, 2a, 2u,
* 3b, 3a, 3u, 4, 4e, 4f or ua1)
* 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)
* @param uploadedInputStream
* a {@link java.io.InputStream} to the PDF to
* be validated
Expand All @@ -108,7 +108,7 @@ public static ComponentDetails getDetails() {
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({MediaType.APPLICATION_XML})
public static InputStream validateXml(@Parameter(description = "the String id of the Validation profile " +
"(auto, 1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f or ua1)")
"(auto, 1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)")
@PathParam("profileId") String profileId,
@Parameter(name = "file", schema = @Schema(implementation = File.class),
style = ParameterStyle.FORM, description = "an InputStream of the PDF to be validated")
Expand All @@ -123,7 +123,7 @@ public static InputStream validateXml(@Parameter(description = "the String id of
* @param profileId
* the String id of the Validation profile
* (auto, 1b, 1a, 2b, 2a, 2u,
* 3b, 3a, 3u, 4, 4e, 4f or ua1)
* 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)
* @param sha1Hex
* the hex String representation of the file's
* SHA-1 hash
Expand All @@ -149,7 +149,7 @@ public static InputStream validateXml(@Parameter(description = "the String id of
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({MediaType.APPLICATION_XML})
public static InputStream validateXml(@Parameter(description = "the String id of the Validation profile " +
"(auto, 1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f or ua1)")
"(auto, 1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)")
@PathParam("profileId") String profileId,
@Parameter(description = "the hex String representation of the file's SHA-1 hash")
@FormDataParam("sha1Hex") String sha1Hex,
Expand Down Expand Up @@ -177,7 +177,7 @@ public static InputStream validateXml(@Parameter(description = "the String id of
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({MediaType.APPLICATION_XML})
public static InputStream validateXml(@Parameter(description = "the String id of the Validation profile " +
"(auto, 1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f or ua1)")
"(auto, 1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)")
@PathParam("profileId") String profileId,
@Parameter(description = "a URL of PDF to be validated")
@FormDataParam("url") String urlLink,
Expand All @@ -190,7 +190,7 @@ public static InputStream validateXml(@Parameter(description = "the String id of
* @param profileId
* the String id of the Validation profile
* (auto, 1b, 1a, 2b, 2a, 2u,
* 3b, 3a, 3u, 4, 4e, 4f or ua1)
* 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)
* @param uploadedInputStream
* a {@link java.io.InputStream} to the PDF to
* be validated
Expand All @@ -203,7 +203,7 @@ public static InputStream validateXml(@Parameter(description = "the String id of
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({MediaType.APPLICATION_JSON})
public static InputStream validateJson(@Parameter(description = "the String id of the Validation profile " +
"(auto, 1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f or ua1)")
"(auto, 1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)")
@PathParam("profileId") String profileId,
@Parameter(name = "file", schema = @Schema(implementation = File.class),
style = ParameterStyle.FORM, description = "an InputStream of the PDF to be validated")
Expand All @@ -218,7 +218,7 @@ public static InputStream validateJson(@Parameter(description = "the String id o
* @param profileId
* the String id of the Validation profile
* (auto, 1b, 1a, 2b, 2a, 2u,
* 3b, 3a, 3u, 4, 4e, 4f or ua1)
* 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)
* @param sha1Hex
* the hex String representation of the file's
* SHA-1 hash
Expand All @@ -234,7 +234,7 @@ public static InputStream validateJson(@Parameter(description = "the String id o
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({MediaType.APPLICATION_JSON})
public static InputStream validateJson(@Parameter(description = "the String id of the Validation profile " +
"(auto, 1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f or ua1)")
"(auto, 1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)")
@PathParam("profileId") String profileId,
@Parameter(description = "the hex String representation of the file's SHA-1 hash")
@FormDataParam("sha1Hex") String sha1Hex,
Expand All @@ -253,7 +253,7 @@ public static InputStream validateJson(@Parameter(description = "the String id o
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({MediaType.APPLICATION_JSON})
public static InputStream validateJson(@Parameter(description = "the String id of the Validation profile " +
"(auto, 1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f or ua1)")
"(auto, 1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)")
@PathParam("profileId") String profileId,
@Parameter(description = "a URL of PDF to be validated")
@FormDataParam("url") String urlLink,
Expand All @@ -266,7 +266,7 @@ public static InputStream validateJson(@Parameter(description = "the String id o
* @param profileId
* the String id of the Validation profile
* (auto, 1b, 1a, 2b, 2a, 2u,
* 3b, 3a, 3u, 4, 4e, 4f or ua1)
* 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)
* @param uploadedInputStream
* a {@link java.io.InputStream} to the PDF to
* be validated
Expand All @@ -291,7 +291,7 @@ public static InputStream validateHtml(@PathParam("profileId") String profileId,
* @param profileId
* the String id of the Validation profile
* (auto, 1b, 1a, 2b, 2a, 2u,
* 3b, 3a, 3u, 4, 4e, 4f or ua1)
* 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)
* @param sha1Hex
* the hex String representation of the file's
* SHA-1 hash
Expand Down Expand Up @@ -322,7 +322,7 @@ public static InputStream validateHtml(@PathParam("profileId") String profileId,
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({MediaType.TEXT_HTML})
public static InputStream validateHtml(@Parameter(description = "the String id of the Validation profile " +
"(auto, 1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f or ua1)")
"(auto, 1b, 1a, 2b, 2a, 2u, 3b, 3a, 3u, 4, 4e, 4f, ua1 or ua2)")
@PathParam("profileId") String profileId,
@Parameter(description = "a URL of PDF to be validated")
@FormDataParam("url") String urlLink,
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/org/verapdf/rest/views/restclient.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<option value="4e">PDF/A-4e Engineering</option>
<option value="4f">PDF/A-4f EmbeddedFiles</option>
<option value="ua1">PDF/UA-1</option>
<option value="ua2">PDF/UA-2</option>
</select>
</div>
<div class="form-group">
Expand Down Expand Up @@ -151,6 +152,9 @@
<li><a target="_blank" href="https://www.loc.gov/preservation/digital/formats/fdd/fdd000350.shtml">PDF/UA-1</a> |
<a href="/api/profiles/ua1" target="_blank">ua1</a>
</li>
<li><a target="_blank">PDF/UA-2</a> |
<a href="/api/profiles/ua2" target="_blank">ua2</a>
</li>
</ul>
</div>
<div id="footer">
Expand Down
27 changes: 0 additions & 27 deletions tests/Options/config/app/fixerFolder.bats

This file was deleted.

6 changes: 0 additions & 6 deletions tests/Options/config/app/fixerFolder/app.xml

This file was deleted.

21 changes: 14 additions & 7 deletions tests/Options/config/app/format.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,31 @@ setup() {
load "$PROJECT_ROOT/tools/test_helper/common-setup.bash"
_common_setup

remove_verapdf_config_files
prepare_fresh_verapdf_config_files

docker cp $BATS_TEST_DIRNAME/format/app.xml $DOCKER_CONTAINER:/opt/verapdf-rest/config/app.xml

}

teardown() {
docker cp $DOCKER_CONTAINER:/opt/verapdf-rest/config/app.xml $BATS_TEST_TMPDIR
cat $BATS_TEST_TMPDIR/app.xml >&3
cat $BATS_TEST_TMPDIR/app.xml >&3

echo -e "Done ..." >&3
}

@test "--format, Chooses the default reporting format, format=JSON" {
skip "Looks like it isn't ready to go yet"

run curl -F "file=@$PROJECT_ROOT/Resources/Mustang_505.pdf" localhost:8080/api/validate/1b
assert_output --partial "ICC profiles"
@test "--format, Chooses output format, the default format=XML" {

run curl -F "file=@$PROJECT_ROOT/Resources/Mustang_505.pdf" localhost:8080/api/validate/1b
assert_output --partial "<name>Mustang_505.pdf</name>"

[ "$status" -eq 0 ]
}

@test "--format, Chooses output format, format=JSON" {

run curl -F "file=@$PROJECT_ROOT/Resources/Mustang_505.pdf" localhost:8080/api/validate/1b -H 'accept: application/json'
assert_output --partial '"jobEndStatus" : "normal"'

[ "$status" -eq 0 ]
}
26 changes: 0 additions & 26 deletions tests/Options/config/app/isVerbose.bats

This file was deleted.

6 changes: 0 additions & 6 deletions tests/Options/config/app/isVerbose/app.xml

This file was deleted.

28 changes: 0 additions & 28 deletions tests/Options/config/app/policyFile.bats

This file was deleted.

6 changes: 0 additions & 6 deletions tests/Options/config/app/policyFile/app.xml

This file was deleted.

Loading

0 comments on commit c9966b4

Please sign in to comment.