Skip to content

Commit

Permalink
Merge branch 'integration' into EncryptDictIndirectRef
Browse files Browse the repository at this point in the history
  • Loading branch information
carlwilson authored Jan 11, 2023
2 parents 7f84e7b + 0a7d6f4 commit 2f22a39
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 78 deletions.
39 changes: 23 additions & 16 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
jhove:
- 'jhove-core/**'
- 'jhove-ext-modules/**'
- 'jhove-modules/**'
- 'jhove-apps/**'
- 'jhove-installer/**'
- 'pom.xml'
testing:
- 'jhove-bbt/scripts/**'
- 'test-root/corpora/**'
- name: JDK setup
uses: actions/setup-java@v3
with:
Expand All @@ -24,43 +38,36 @@ jobs:
- name: Build with Maven
run: mvn --batch-mode --update-snapshots install -DjacocoAgg
- name: Integration Tests
if: matrix.java-version == 8
if: (matrix.java-version == 8) && (steps.filter.outputs.jhove == 'true')
run: ./bbt-jhove
shell: bash
- name: Aggregate integration test results
if: matrix.java-version == 8
- name: Test with Maven
if: (matrix.java-version == 8)
run: mvn --batch-mode verify -DjacocoAgg
- name: Upload coverage report
if: matrix.java-version == 8
if: (matrix.java-version == 8)
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: jhove-apps/target/site/jacoco-aggregate/

coverage:
name: Quality Assurance
runs-on: ubuntu-20.04
needs: [ build ]

steps:
- uses: actions/checkout@v3
- name: Codacy analysis reporting
uses: codacy/codacy-analysis-cli-action@4.0.0
- name: Download coverage report
if: matrix.java-version == 8
uses: actions/download-artifact@v3
with:
name: coverage-report
path: core/target/site/jacoco/
path: jhove-apps/target/site/jacoco-aggregate/
- name: Codecov coverage reporting
if: matrix.java-version == 8
uses: codecov/codecov-action@v3
with:
files: jhove-apps/target/site/jacoco-aggregate/jacoco.xml
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
- name: Codacy coverage reporting
uses: codacy/codacy-coverage-reporter-action@v1
if: matrix.java-version == 8
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: jhove-apps/target/site/jacoco-aggregate/jacoco.xml
- name: Codacy analysis reporting
if: matrix.java-version == 8
uses: codacy/codacy-analysis-cli-action@4.0.0
22 changes: 20 additions & 2 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
codecov:
token: 8f43ae05-bde9-4f3d-9cc5-a49af1fed3e2
branch: integration
require_ci_to_pass: true
notify:
wait_for_ci: true

coverage:
precision: 2
round: down
range: "70...100"
status:
project:
default:
enabled: yes
target: 1
threshold: 0.5%
patch:
default:
enabled: yes
target: auto
threshold: 0%
ignore:
- doc
- .github
- .git
- test-root
- mac
14 changes: 14 additions & 0 deletions jhove-bbt/scripts/create-1.27-target.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,22 @@ echo "TEST BASELINE: Creating baseline"
echo " - copying ${baselineRoot} baseline to ${targetRoot}"
cp -R "${baselineRoot}" "${targetRoot}"

# Modification of output due to
# https://github.com/openpreserve/jhove/pull/804
find "${targetRoot}" -type f -name "6mp_soft.tif.jhove.xml" -exec sed -i 's/>DSC</>digital still camera</' {} \;

# Update release details for PDF module
find "${targetRoot}" -type f -name "*.pdf.jhove.xml" -exec sed -i 's/^ <reportingModule release="1.12.3" date="2022-04-22">PDF-hul<\/reportingModule>$/ <reportingModule release="1.12.4" date="2023-01-31">PDF-hul<\/reportingModule>/' {} \;
find "${targetRoot}" -type f -name "audit.jhove.xml" -exec sed -i 's/^ <module release="1.12.3">PDF-hul<\/module>$/ <module release="1.12.4">PDF-hul<\/module>/' {} \;
find "${targetRoot}" -type f -name "audit-PDF-hul.jhove.xml" -exec sed -i 's/^ <release>1.12.3<\/release>$/ <release>1.12.4<\/release>/' {} \;
find "${targetRoot}" -type f -name "audit-PDF-hul.jhove.xml" -exec sed -i 's/2022-04-22/2023-01-31/' {} \;

# Copy examples for encrypted dictionaries
if [[ -f "${candidateRoot}/errors/modules/PDF-hul/issue6010_1.pdf.jhove.xml" ]]; then
echo " - First example for non reference encryption dictionaries."
cp "${candidateRoot}/errors/modules/PDF-hul/issue6010_1.pdf.jhove.xml" "${targetRoot}/errors/modules/PDF-hul/issue6010_1.pdf.jhove.xml"
fi
if [[ -f "${candidateRoot}/errors/modules/PDF-hul/issue6010_2.pdf.jhove.xml" ]]; then
echo " - Second example for non reference encryption dictionaries."
cp "${candidateRoot}/errors/modules/PDF-hul/issue6010_2.pdf.jhove.xml" "${targetRoot}/errors/modules/PDF-hul/issue6010_2.pdf.jhove.xml"
fi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.logging.Logger;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* Encapsulation of the NISO Z39.87-2002 / AIIM 20-2002 Data Dictionary --
Expand Down Expand Up @@ -1466,9 +1467,9 @@ public void setCompressionScheme (int scheme)
* TIFF dates get converted to ISO 8601 format.
* @param date Date/time created
*/
public void setDateTimeCreated (String date)
public void setDateTimeCreated(String date)
{
_dateTimeCreated = make8601Valid (date);
_dateTimeCreated = make8601Valid(date);
}

/** Set 9.1.1 DateTimeProcessed.
Expand All @@ -1477,7 +1478,7 @@ public void setDateTimeCreated (String date)
*/
public void setDateTimeProcessed (String date)
{
_dateTimeProcessed = make8601Valid (date);
_dateTimeProcessed = make8601Valid(date);
}

/** Set 7.5 Device source.
Expand Down Expand Up @@ -2229,32 +2230,26 @@ public void setViewerData (Property viewerData)
_viewerData = viewerData;
}

/* Canonicizes (canonizes? whatever) a date to ISO
/* Normalizes a date to ISO
* 8601 format. Returns null if it can't make sense of
* it. Returns the date unchanged if it's already
* canonical. Initially this converts TIFF dates to ISO.
*/
private String make8601Valid (String date)
{
try {
if (date.charAt (4) == ':') {
// It's a TIFF date, or a good imitation of one.
// TIFF dates have exact offsets, making things easy.
String yr = date.substring (0, 4);
String mo = date.substring (5, 7);
String da = date.substring (8, 10);
String hr = date.substring (11, 13);
String mi = date.substring (14, 16);
String se = date.substring (17, 19);
return yr + "-" + mo + "-" + da + "T" +
hr + TIME_SEP + mi + TIME_SEP + se;
}
return date; // default
* in ISO format. Initially this converts TIFF dates to ISO.
*/
protected static String make8601Valid(String date) {
final Pattern pIsoDate = Pattern.compile("(\\d{4})\\-([01]\\d)\\-([0-3]\\d)T([0-2]\\d):([0-5]\\d):([0-5]\\d)");
final Pattern pTiffDate = Pattern.compile("(\\d{4}).([01]\\d).([0-3]\\d).([0-2]\\d).([0-5]\\d).([0-5]\\d)");
if (pIsoDate.matcher(date).matches()) {
return date;
}
catch (Exception e) {
// Malformed date
return null;
Matcher m = pTiffDate.matcher(date);
if (m.matches()) {
String isoDate = String.format("%s-%s-%sT%s:%s:%s",
m.group(1), m.group(2), m.group(3), m.group(4), m.group(5), m.group(6));
if (pIsoDate.matcher(isoDate).matches()) {
return isoDate;
}
}
return null;
}

public static String extractIccProfileDescription(byte[] data) throws IllegalArgumentException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
public class NisoImageMetadataTest {
private final static String ERROR_TEST = "Not a icc profile ";

@Test
public void testMake8601Valid() {
assertEquals("2020-10-20T23:58:45", NisoImageMetadata.make8601Valid("2020-10-20T23:58:45"));
assertEquals("2020-10-20T23:58:45", NisoImageMetadata.make8601Valid("2020:10:20 23:58:45"));
assertEquals("2020-10-20T23:58:45", NisoImageMetadata.make8601Valid("2020.10.20 23.58.45"));
assertNull(NisoImageMetadata.make8601Valid("2020:10:20 23:58:73"));
assertNull(NisoImageMetadata.make8601Valid("2020:10:20"));
}

@Test
public void testExtractIccProfileDescriptionBad() {
final byte ANY_BYTE_1 = (byte) 0xFF;
Expand Down
Loading

0 comments on commit 2f22a39

Please sign in to comment.