Skip to content

Commit

Permalink
SIGA-636 Generate values for SubjectDistinguishedName and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ivoMattus committed Nov 1, 2023
1 parent f6afd66 commit 7e8fcc4
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import io.restassured.response.Response;
import org.json.JSONException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.io.IOException;
Expand Down Expand Up @@ -54,9 +53,8 @@ void validateAsicContainer() throws JSONException, NoSuchAlgorithmException, Inv
assertThat(response.getBody().path(REPORT_SIGNATURES + "[0].signedBy"), equalTo("ŽÕRINÜWŠKY,MÄRÜ-LÖÖZ,11404176865"));
assertThat(response.getBody().path(REPORT_SIGNATURES + "[0].info.bestSignatureTime"), equalTo("2014-11-17T14:11:46Z"));

// TODO SIGA-636
// assertThat(response.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.commonName"), equalTo("ŽÕRINÜWŠKY,MÄRÜ-LÖÖZ,11404176865"));
// assertThat(response.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.serialNumber"), equalTo("11404176865"));
assertThat(response.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.commonName"), equalTo("ŽÕRINÜWŠKY,MÄRÜ-LÖÖZ,11404176865"));
assertThat(response.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.serialNumber"), equalTo("11404176865"));
}

@Test
Expand All @@ -67,9 +65,8 @@ void validateDDOCContainer() throws JSONException, NoSuchAlgorithmException, Inv
assertThat(response.getBody().path(REPORT_VALID_SIGNATURES_COUNT), equalTo(1));
assertThat(response.getBody().path(REPORT_SIGNATURES_COUNT), equalTo(1));

// TODO SIGA-636
// assertThat(response.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.commonName"), equalTo("ŽÕRINÜWŠKY,MÄRÜ-LÖÖZ,11404176865"));
// assertThat(response.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.serialNumber"), equalTo("11404176865"));
assertThat(response.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.commonName"), equalTo("ŽÕRINÜWŠKY,MÄRÜ-LÖÖZ,11404176865"));
assertThat(response.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.serialNumber"), equalTo("11404176865"));
}

@Test
Expand Down Expand Up @@ -102,13 +99,12 @@ void uploadAsicContainerAndValidateInSession() throws JSONException, NoSuchAlgor
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].signedBy"), equalTo("ŽÕRINÜWŠKY,MÄRÜ-LÖÖZ,11404176865"));
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].info.bestSignatureTime"), equalTo("2014-11-17T14:11:46Z"));

// TODO SIGA-636
// assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.commonName"), equalTo("ŽÕRINÜWŠKY,MÄRÜ-LÖÖZ,11404176865"));
// assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.serialNumber"), equalTo("11404176865"));
// assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[1].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
// assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[1].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
// assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[2].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
// assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[2].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.commonName"), equalTo("ŽÕRINÜWŠKY,MÄRÜ-LÖÖZ,11404176865"));
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.serialNumber"), equalTo("11404176865"));
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[1].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[1].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[2].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[2].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
}

@Test
Expand All @@ -121,9 +117,8 @@ void createAsicContainerSignRemotelyAndValidate() throws JSONException, NoSuchAl
assertThat(validationResponse.statusCode(), equalTo(200));
assertThat(validationResponse.getBody().path(REPORT_VALID_SIGNATURES_COUNT), equalTo(1));

// TODO SIGA-636
// assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
// assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
}

@Test
Expand Down Expand Up @@ -316,7 +311,6 @@ void patchToValidateAsicContainerInSession() throws NoSuchAlgorithmException, In
}

@Test
@Disabled("SIGA-636")
void validatePadesContainerSubjectDistinguishedName() throws JSONException, NoSuchAlgorithmException, InvalidKeyException, IOException {
Response response = postContainerValidationReport(flow, asicContainerRequestFromFile("pdfSingleTestSignature.pdf"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import io.restassured.response.Response;
import org.json.JSONException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.io.IOException;
Expand Down Expand Up @@ -39,13 +38,12 @@ void validateHashcodeContainer() throws JSONException, NoSuchAlgorithmException,
assertThat(response.getBody().path(REPORT_SIGNATURES + "[0].signedBy"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
assertThat(response.getBody().path(REPORT_SIGNATURES + "[0].info.bestSignatureTime"), equalTo("2019-02-22T11:04:25Z"));

// TODO SIGA-636
// assertThat(response.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
// assertThat(response.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
// assertThat(response.getBody().path(REPORT_SIGNATURES + "[1].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
// assertThat(response.getBody().path(REPORT_SIGNATURES + "[1].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
// assertThat(response.getBody().path(REPORT_SIGNATURES + "[2].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
// assertThat(response.getBody().path(REPORT_SIGNATURES + "[2].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
assertThat(response.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
assertThat(response.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
assertThat(response.getBody().path(REPORT_SIGNATURES + "[1].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
assertThat(response.getBody().path(REPORT_SIGNATURES + "[1].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
assertThat(response.getBody().path(REPORT_SIGNATURES + "[2].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
assertThat(response.getBody().path(REPORT_SIGNATURES + "[2].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
}

@Test
Expand Down Expand Up @@ -83,9 +81,8 @@ void uploadHashcodeContainerAndValidateInSession() throws JSONException, NoSuchA
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].signedBy"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].info.bestSignatureTime"), equalTo("2019-02-22T11:04:25Z"));

// TODO SIGA-636
// assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
// assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
}

@Test
Expand All @@ -98,9 +95,8 @@ void createHashcodeContainerSignRemotelyAndValidate() throws JSONException, NoSu
assertThat(validationResponse.statusCode(), equalTo(200));
assertThat(validationResponse.getBody().path(REPORT_VALID_SIGNATURES_COUNT), equalTo(1));

// TODO SIGA-636
// assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
// assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
}

@Test
Expand Down Expand Up @@ -134,9 +130,8 @@ void validateHashcodeContainerWithZeroFileSizeDataFiles() throws Exception {
assertThat(validationResponse.getBody().path("validationConclusion.signatures[0].warnings.content"), everyItem(not(containsString("data-file-3.txt"))));
assertThat(validationResponse.getBody().path("validationConclusion.signatures[0].warnings.content"), everyItem(not(containsString("data-file-5.txt"))));

// TODO SIGA-636
// assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
// assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.commonName"), equalTo("JÕEORG,JAAK-KRISTJAN,38001085718"));
assertThat(validationResponse.getBody().path(REPORT_SIGNATURES + "[0].subjectDistinguishedName.serialNumber"), equalTo("PNOEE-38001085718"));
}

@Test
Expand Down Expand Up @@ -233,7 +228,6 @@ void headToValidateHashcodeContainerInSession() throws NoSuchAlgorithmException,
}

@Test
@Disabled("SIGA-636")
void validateDDOCHashcodeContainerSubjectDistinguishedName() throws JSONException, NoSuchAlgorithmException, InvalidKeyException, IOException {
Response response = postContainerValidationReport(flow, hashcodeContainerRequestFromFile("hashcodeDdocTest.ddoc"));

Expand Down
16 changes: 7 additions & 9 deletions siga-webapp/src/main/resources/static/siga.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,7 @@
<xs:element name="signatureFormat" type="xs:string"/>
<xs:element name="signatureLevel" minOccurs="0" type="xs:string"/>
<xs:element name="signedBy" type="xs:string"/>
<!-- TODO SIGA-636 -->
<!-- <xs:element name="subjectDistinguishedName" minOccurs="0" type="tns:subjectDistinguishedName"/>-->
<xs:element name="subjectDistinguishedName" minOccurs="0" type="tns:subjectDistinguishedName"/>
<xs:element name="indication" type="xs:string"/>
<xs:element name="subIndication" minOccurs="0" type="xs:string"/>
<xs:element name="errors" minOccurs="0" maxOccurs="unbounded" type="tns:error"/>
Expand Down Expand Up @@ -528,11 +527,10 @@
<xs:element name="fileContent" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<!-- TODO SIGA-636 -->
<!-- <xs:complexType name="subjectDistinguishedName">-->
<!-- <xs:sequence>-->
<!-- <xs:element name="serialNumber" type="xs:string"/>-->
<!-- <xs:element name="commonName" type="xs:string"/>-->
<!-- </xs:sequence>-->
<!-- </xs:complexType>-->
<xs:complexType name="subjectDistinguishedName">
<xs:sequence>
<xs:element name="serialNumber" type="xs:string"/>
<xs:element name="commonName" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ee.openeid.siga.service.signature.hashcode.HashcodeContainer;
import ee.openeid.siga.webapp.json.HashcodeDataFile;
import ee.openeid.siga.webapp.json.Signature;
import ee.openeid.siga.webapp.json.ValidationConclusion;
import org.junit.jupiter.api.Test;

import java.util.List;
Expand All @@ -24,10 +25,9 @@ public void mobileIdHashcodeSigningFlow() throws Exception {
List<HashcodeDataFile> dataFiles = getHashcodeDataFiles(containerId);
assertEquals(2, dataFiles.size());
assertEquals("RnKZobNWVy8u92sDL4S2j1BUzMT5qTgt6hm90TfAGRo=", dataFiles.get(0).getFileHashSha256());
// TODO SIGA-636
// ValidationConclusion validationConclusion = getHashcodeValidationConclusion(containerId);
// assertEquals("JÃ\u0095EORG,JAAK-KRISTJAN,38001085718", validationConclusion.getSignatures().get(0).getSubjectDistinguishedName().getCommonName());
// assertEquals("PNOEE-38001085718", validationConclusion.getSignatures().get(0).getSubjectDistinguishedName().getSerialNumber());
ValidationConclusion validationConclusion = getHashcodeValidationConclusion(containerId);
assertEquals("JÃ\u0095EORG,JAAK-KRISTJAN,38001085718", validationConclusion.getSignatures().get(0).getSubjectDistinguishedName().getCommonName());
assertEquals("PNOEE-38001085718", validationConclusion.getSignatures().get(0).getSubjectDistinguishedName().getSerialNumber());

String signatureId = startHashcodeMobileSigning(containerId);
String mobileFirstStatus = getHashcodeMobileIdStatus(containerId, signatureId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ee.openeid.siga.service.signature.hashcode.HashcodeContainer;
import ee.openeid.siga.webapp.json.HashcodeDataFile;
import ee.openeid.siga.webapp.json.Signature;
import ee.openeid.siga.webapp.json.ValidationConclusion;
import org.junit.jupiter.api.Test;

import java.util.List;
Expand All @@ -25,10 +26,9 @@ public void smartIdHashcodeFlowWihCertificateChoice() throws Exception {
assertEquals(2, originalContainer.getDataFiles().size());
List<HashcodeDataFile> dataFiles = getHashcodeDataFiles(containerId);
assertEquals(2, dataFiles.size());
// TODO SIGA-636
// ValidationConclusion validationConclusion = getHashcodeValidationConclusion(containerId);
// assertEquals("JÃ\u0095EORG,JAAK-KRISTJAN,38001085718", validationConclusion.getSignatures().get(0).getSubjectDistinguishedName().getCommonName());
// assertEquals("PNOEE-38001085718", validationConclusion.getSignatures().get(0).getSubjectDistinguishedName().getSerialNumber());
ValidationConclusion validationConclusion = getHashcodeValidationConclusion(containerId);
assertEquals("JÃ\u0095EORG,JAAK-KRISTJAN,38001085718", validationConclusion.getSignatures().get(0).getSubjectDistinguishedName().getCommonName());
assertEquals("PNOEE-38001085718", validationConclusion.getSignatures().get(0).getSubjectDistinguishedName().getSerialNumber());

String certificateId = startHashcodeSmartIdCertificateChoice(containerId);
AtomicReference<CertificateStatus> certificateStatusHolder = new AtomicReference<>();
Expand Down

0 comments on commit 7e8fcc4

Please sign in to comment.