Skip to content

Commit

Permalink
Merge pull request #455 from slovensko-digital/revert/updated-fs-xdc
Browse files Browse the repository at this point in the history
Revert FS XDC identifier builder to former version within identifier
  • Loading branch information
celuchmarek authored Jun 12, 2024
2 parents 4d8fa3a + 38e43ad commit 8ff9d1a
Show file tree
Hide file tree
Showing 18 changed files with 12 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ private static String getFormUrlFromXdcIdentifier(String xdcIdentifier) {

r = getSlugAndVersion(xpath, parsed_meta_xml, "//" + ns + ":form[@xdcIdentifier=\"" + xdcIdentifier + "/1.0\"]");
if (r != null)
throw new EFormException("Nesprávny XDC identifikátor v podpísanom formulári", "XDC identifikátor v tomto konkrétnom podpísanom formulári by mal obsahovať ešte označenie verzie /1.0. Takto podpísaný formulár bude pravdepodobne odmietnutý informačným systémom Finančnej správy.");
return r;

r = getSlugAndVersion(xpath, parsed_meta_xml, "//" + ns + ":form[@xdcIdentifier=\"" + xdcIdentifier.replace("/1.0", "") + "\"]");
if (r != null)
throw new EFormException("Nesprávny XDC identifikátor v podpísanom formulári", "XDC identifikátor v tomto konkrétnom podpísanom formulári by nemal obsahovať označenie verzie /1.0. Takto podpísaný formulár bude pravdepodobne odmietnutý informačným systémom Finančnej správy.");
return r;

} catch (XPathExpressionException e) {
throw new UnrecognizedException(e);
Expand Down Expand Up @@ -175,6 +175,9 @@ public EFormAttributes getEformAttributes() {
}

public String getIdentifier() {
return xdcIdentifier;
if (xdcIdentifier.matches(".*/[v0-9.]+$"))
return xdcIdentifier;

return xdcIdentifier + "/1.0";
}
}
3 changes: 1 addition & 2 deletions src/test/java/digital/slovensko/autogram/AutogramTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class AutogramTests {
"digital.slovensko.autogram.TestMethodSources#orsrDocumentsProvider",
"digital.slovensko.autogram.TestMethodSources#validOtherDocumentsProvider",
"digital.slovensko.autogram.TestMethodSources#validXadesDocumentsProvider",
"digital.slovensko.autogram.TestMethodSources#fsDPFOProvider",
"digital.slovensko.autogram.TestMethodSources#fsUnmarkedXdcProvider"})
"digital.slovensko.autogram.TestMethodSources#fsDPFOProvider" })
void testSignAsiceXadesHappyScenario(InMemoryDocument document) {
var settings = new TestSettings();
var newUI = new FakeUI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,6 @@ void testThrowsOriginalDocumentNotFoundWithAsiceWithoutSignature(DSSDocument doc
() -> SigningParameters.buildForASiCWithXAdES(document, false, false, tspSource, true));
}

@ParameterizedTest
@MethodSource("digital.slovensko.autogram.TestMethodSources#fsWrongXdcIdentifierProvider")
void testThrowsEFormExceptionWithWrongFsXdcIdentifier(DSSDocument document) throws IOException {
Assertions.assertThrows(EFormException.class,
() -> SigningParameters.buildForASiCWithXAdES(document, false, false, tspSource, true));
}

@Test
void testThrowsExceptionWithAsiceWithEmptyXml() throws IOException {
var document = new InMemoryDocument(
Expand Down
12 changes: 0 additions & 12 deletions src/test/java/digital/slovensko/autogram/TestMethodSources.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,6 @@ public static Stream<DSSDocument> fsUnmarkedXdcProvider() throws IOException {
);
}

public static Stream<DSSDocument> fsWrongXdcIdentifierProvider() throws IOException {
var xdc = cls.getResourceAsStream("fs_forms/d_fs792_772_xdc_wrong_identifier.xml").readAllBytes();
var asice = cls.getResourceAsStream("fs_forms/signed_wrong_identifier.asice").readAllBytes();
var asiceMarked = cls.getResourceAsStream("fs_forms/d_fs792_772_xdc_wrong_identifier.asice").readAllBytes();

return Stream.of(
new InMemoryDocument(xdc, "d_fs792_772_xdc_wrong_identifier.xml", AutogramMimeType.XML_DATACONTAINER),
new InMemoryDocument(asice, "signed_wrong_identifier.asice", MimeTypeEnum.ASICE),
new InMemoryDocument(asiceMarked, "d_fs792_772_xdc_wrong_identifier.asice", MimeTypeEnum.ASICE)
);
}

public static Stream<DSSDocument> invalidXmlProvider() throws IOException {
var notAnXml = "not an xml".getBytes();
var invalidXml = "<invalidXml><foo><bar></foo></bar></invalidXml>".getBytes();
Expand Down
Binary file not shown.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xdc:XMLDataContainer xmlns:xdc="http://data.gov.sk/def/container/xmldatacontainer+xml/1.1">
<xdc:XMLData ContentType="application/xml; charset=UTF-8"
Identifier="https://ekr.financnasprava.sk/Formulare/xsd/dpfo_b2023.xsd" Version="1.0">
Identifier="https://ekr.financnasprava.sk/Formulare/xsd/dpfo_b2023.xsd/1.0" Version="1.0">
<dokument>
<hlavicka>
<dic>2120515056</dic>
Expand Down
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xdc:XMLDataContainer xmlns:xdc="http://data.gov.sk/def/container/xmldatacontainer+xml/1.1">
<xdc:XMLData ContentType="application/xml; charset=UTF-8"
Identifier="https://ekr.financnasprava.sk/Formulare/xsd/dpfo_b2023.xsd" Version="1.0">
Identifier="https://ekr.financnasprava.sk/Formulare/xsd/dpfo_b2023.xsd/1.0" Version="1.0">
<dokument>
<hlavicka>
<dic>2120515056</dic>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xdc:XMLDataContainer xmlns:xdc="http://data.gov.sk/def/container/xmldatacontainer+xml/1.1">
<xdc:XMLData ContentType="application/xml; charset=UTF-8"
Identifier="https://ekr.financnasprava.sk/Formulare/xsd/dpfo_b2023.xsd" Version="1.0">
Identifier="https://ekr.financnasprava.sk/Formulare/xsd/dpfo_b2023.xsd/1.0" Version="1.0">
<dokument>
<hlavicka>
<dic>2120515056</dic>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xdc:XMLDataContainer xmlns:xdc="http://data.gov.sk/def/container/xmldatacontainer+xml/1.1">
<xdc:XMLData ContentType="application/xml; charset=UTF-8"
Identifier="https://ekr.financnasprava.sk/Formulare/xsd/dpfo_b2023.xsd" Version="1.0">
Identifier="https://ekr.financnasprava.sk/Formulare/xsd/dpfo_b2023.xsd/1.0" Version="1.0">
<dokument>
<hlavicka>
<dic>2120515056</dic>
Expand Down

0 comments on commit 8ff9d1a

Please sign in to comment.