Permalink
Browse files

#4 : Organized files under testFiles

Signed-off-by: Andrei <andrei.smirnov@cgi.com>
  • Loading branch information...
Andrei Smirnov
Andrei Smirnov committed Apr 25, 2017
1 parent 9a264b9 commit 7901fa27e0ef49de27564ef23450a838abfad82b
Showing with 541 additions and 426 deletions.
  1. +1 −1 src/org/digidoc4j/utils/TokenAlgorithmSupport.java
  2. +57 −58 test/org/digidoc4j/ConfigurationTest.java
  3. +5 −5 test/org/digidoc4j/ContainerBuilderTest.java
  4. +20 −2 test/org/digidoc4j/ContainerOpenerTest.java
  5. +30 −30 test/org/digidoc4j/ContainerTest.java
  6. +6 −4 test/org/digidoc4j/DataFileTest.java
  7. +4 −4 test/org/digidoc4j/FileWritingOperationsTest.java
  8. +5 −5 test/org/digidoc4j/LibraryInteroperabilityTest.java
  9. +1 −1 test/org/digidoc4j/PerformanceTest.java
  10. +11 −11 test/org/digidoc4j/SignatureBuilderTest.java
  11. +21 −21 test/org/digidoc4j/SignatureTest.java
  12. +1 −1 test/org/digidoc4j/SkDataLoaderTest.java
  13. +1 −1 test/org/digidoc4j/X509CertTest.java
  14. +71 −71 test/org/digidoc4j/impl/bdoc/BDocContainerTest.java
  15. +15 −15 test/org/digidoc4j/impl/bdoc/BDocSerializationTest.java
  16. +1 −1 test/org/digidoc4j/impl/bdoc/BDocSignatureOpenerTest.java
  17. +17 −17 test/org/digidoc4j/impl/bdoc/ExtendingBDocContainerTest.java
  18. +42 −42 test/org/digidoc4j/impl/bdoc/ValidationTests.java
  19. +6 −6 test/org/digidoc4j/impl/bdoc/asic/AsicContainerParserTest.java
  20. +1 −1 test/org/digidoc4j/impl/bdoc/manifest/ManifestTest.java
  21. +1 −1 test/org/digidoc4j/impl/bdoc/ocsp/SKOnlineOCSPSourceTest.java
  22. +8 −8 test/org/digidoc4j/impl/bdoc/report/ValidationReportTest.java
  23. +2 −2 test/org/digidoc4j/impl/bdoc/xades/XadesSignatureParserTest.java
  24. +3 −3 test/org/digidoc4j/impl/bdoc/xades/XadesSigningDssFacadeTest.java
  25. +1 −1 test/org/digidoc4j/impl/bdoc/xades/validation/ThreadPoolManagerTest.java
  26. +35 −35 test/org/digidoc4j/impl/ddoc/DDocFacadeTest.java
  27. +2 −2 test/org/digidoc4j/impl/ddoc/DDocSignatureTest.java
  28. +63 −63 test/org/digidoc4j/main/DigiDoc4JTest.java
  29. +1 −1 test/org/digidoc4j/signers/PKCS11SignatureTokenTest.java
  30. +1 −1 test/org/digidoc4j/signers/PKCS12SignatureTokenTest.java
  31. +1 −1 test/org/digidoc4j/testutils/TSLHelper.java
  32. +1 −1 test/org/digidoc4j/testutils/TestDataBuilder.java
  33. +2 −2 test/org/digidoc4j/testutils/TestSigningHelper.java
  34. +4 −3 test/org/digidoc4j/utils/HelperTest.java
  35. +1 −1 test/org/digidoc4j/utils/TokenAlgorithmSupportTest.java
  36. BIN testFiles/TS-05_23634_TS_unknown_TSA.asice
  37. BIN testFiles/ValidHashcode.bdoc
  38. BIN testFiles/ValidHashcodeUnsigned.bdoc
  39. 0 testFiles/{ → certs}/EE_Certification_Centre_Root_CA.pem.crt
  40. 0 testFiles/{ → certs}/ESTEID-SK_2011.pem.crt
  41. 0 testFiles/{ → certs}/Juur-SK.pem.crt
  42. 0 testFiles/{ → certs}/SK_OCSP_RESPONDER_2011.pem.cer
  43. 0 testFiles/{ → certs}/SK_TSA.pem.crt
  44. 0 testFiles/{ → certs}/signout.pem
  45. BIN testFiles/container_without_signatures.bdoc
  46. BIN testFiles/hashcode.bdoc
  47. BIN testFiles/hashcodeUnsigned.bdoc
  48. 0 testFiles/{ → helper-files}/test.txt
  49. 0 testFiles/{ → helper-files}/test.unknown_type
  50. +3 −3 testFiles/{ → helper-files}/test.xml
  51. BIN testFiles/{ → helper-files}/word_file.docx
  52. BIN testFiles/{ → invalid-containers}/22902_data_files_with_same_names.bdoc
  53. BIN testFiles/{ → invalid-containers}/22913_signatures_xml_double.bdoc
  54. BIN testFiles/{ → invalid-containers}/23200_weakdigest-wrong-nonce.asice
  55. BIN testFiles/{ → invalid-containers}/23608-bdoc21-no-ocsp.bdoc
  56. BIN testFiles/{ → invalid-containers}/23608_bdoc21-invalid-nonce-policy-oid.bdoc
  57. BIN testFiles/{ → invalid-containers}/23608_bdoc21-no-nonce-policy.bdoc
  58. BIN testFiles/{ → invalid-containers}/KS-19_IB-3721_bdoc21-TM-2fil-samename-1sig3.bdoc
  59. BIN testFiles/{ → invalid-containers}/Libdigidoc_created_tsa_signature_TS.bdoc
  60. BIN testFiles/{ → invalid-containers}/REF-03_bdoc21-TM-no-signedpropref.bdoc
  61. BIN testFiles/{ → invalid-containers}/REF-03_bdoc21-TS-no-signedpropref.asice
  62. BIN testFiles/{ → invalid-containers}/SP-03_bdoc21-bad-nonce-policy-oidasuri.bdoc
  63. BIN testFiles/{ → invalid-containers}/SP-06_bdoc21-no-uri.bdoc
  64. BIN testFiles/{ → invalid-containers}/TS-02_23634_TS_wrong_SignatureValue.asice
  65. BIN testFiles/{ → invalid-containers}/TS-06_23634_TS_missing_OCSP_adjusted.asice
  66. BIN testFiles/{ → invalid-containers}/TS-08_23634_TS_OCSP_before_TS.asice
  67. BIN testFiles/{ → invalid-containers}/TS_broken_TS.asice
  68. BIN testFiles/{ → invalid-containers}/asics_for_testing.bdoc
  69. BIN testFiles/{ → invalid-containers}/asics_without_signatures.bdoc
  70. BIN testFiles/{ → invalid-containers}/bdoc21-bad-nonce-content.bdoc
  71. 0 testFiles/{ → invalid-containers}/changed_digidoc_test.ddoc
  72. BIN testFiles/{ → invalid-containers}/corrupted_ocsp_data.asice
  73. 0 testFiles/{ → invalid-containers}/emptyFile.ddoc
  74. 0 testFiles/{ → invalid-containers}/empty_container_no_signature.ddoc
  75. 0 testFiles/{ → invalid-containers}/error75.ddoc
  76. BIN testFiles/{ → invalid-containers}/extra_file_in_container.asice
  77. BIN testFiles/{ → invalid-containers}/filename_mismatch_manifest.asice
  78. BIN testFiles/{ → invalid-containers}/filename_mismatch_second_signature.asice
  79. BIN testFiles/{ → invalid-containers}/filename_mismatch_signature.asice
  80. BIN testFiles/{ → invalid-containers}/incorrectMimetype.bdoc
  81. BIN testFiles/{ → invalid-containers}/invalid-data-file.bdoc
  82. +96 −0 testFiles/invalid-containers/invalid-file-format.ddoc
  83. BIN testFiles/{ → invalid-containers}/invalid_bdoc21-TS-old-cert.bdoc
  84. BIN testFiles/{ → invalid-containers}/invalid_bdoc_tm_old-sig-sigat-NOK-prodat-NOK.bdoc
  85. BIN testFiles/{ → invalid-containers}/invalid_bdoc_tm_old-sig-sigat-OK-prodat-NOK.bdoc
  86. BIN testFiles/{ → invalid-containers}/invalid_container.bdoc
  87. BIN testFiles/{ → invalid-containers}/manifest_validation_error.asice
  88. BIN testFiles/{ → invalid-containers}/mimetype_mismatch.asice
  89. BIN testFiles/{ → invalid-containers}/missing_manifest.asice
  90. BIN testFiles/{ → invalid-containers}/missing_mimetype_file.asice
  91. BIN testFiles/{ → invalid-containers}/multiple_signed_properties.asice
  92. 0 testFiles/{ → invalid-containers}/no_signed_doc_no_signature.ddoc
  93. BIN testFiles/{ → invalid-containers}/nonce-vale-sisu.bdoc
  94. BIN testFiles/{ → invalid-containers}/notABDoc.bdoc
  95. BIN testFiles/{ → invalid-containers}/ocsp_cert_is_not_in_tsl.bdoc
  96. BIN testFiles/{ → invalid-containers}/revocation_timestamp_delta_26h.asice
  97. 0 testFiles/{ → invalid-containers}/signature_without_last_certificate.ddoc
  98. BIN testFiles/{ → invalid-containers}/signed_properties_reference_not_found.asice
  99. 0 testFiles/{ → invalid-containers}/tooShortToVerifyIfIsZip.ddoc
  100. BIN testFiles/{ → invalid-containers}/two_signatures.bdoc
  101. BIN testFiles/{ → invalid-containers}/two_signatures_one_invalid.bdoc
  102. BIN testFiles/{ → invalid-containers}/warning.asice
  103. 0 testFiles/{ → invalid-containers}/warning.ddoc
  104. BIN testFiles/{ → invalid-containers}/zip_file_without_asics_extension.bdoc
  105. BIN testFiles/{ → invalid-containers}/zip_misses_file_which_is_in_manifest.asice
  106. 0 {resources → testFiles}/moved_constraint.xml
  107. BIN testFiles/{ → p12}/20167000013.p12
  108. BIN testFiles/{ → p12}/ec-digiid.p12
  109. BIN testFiles/{ → p12}/expired_signer.p12
  110. BIN testFiles/{ → p12}/ocsp_juurdepaasutoend.p12d
  111. BIN testFiles/{ → p12}/signout.p12
  112. +0 −1 testFiles/sub/test.txt
  113. BIN testFiles/{ → valid-containers}/DigiDocService_spec_est.pdf-TM-j.bdoc
  114. BIN testFiles/{ → valid-containers}/asics_testing_two_signatures.bdoc
  115. BIN testFiles/{ → valid-containers}/asics_with_one_signature.bdoc
  116. BIN testFiles/valid-containers/container_without_signatures.bdoc
  117. 0 testFiles/{ → valid-containers}/ddoc_for_testing.ddoc
  118. BIN testFiles/{ → valid-containers}/one_signature.bdoc
  119. BIN testFiles/{ → valid-containers}/test.asice
  120. BIN testFiles/{ → valid-containers}/valid_bdoc_tm_signed_with_valid_cert_expired_by_now.bdoc
  121. BIN testFiles/warning.bdoc
  122. 0 testFiles/{ → yaml-configurations}/digidoc4j_ForBDocWarningTest.yaml
  123. 0 testFiles/{ → yaml-configurations}/digidoc_test_all_optional_settings.yaml
  124. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf.yaml
  125. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_connection_timeout.yaml
  126. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_empty_ca.yaml
  127. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_invalid_datafile_hashcode_mode.yaml
  128. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_invalid_key_usage.yaml
  129. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_invalid_max_data_file_cached.yaml
  130. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_invalid_sign_ocsp_request.yaml
  131. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_invalid_use_local_tsl.yaml
  132. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_max_datafile_cached_invalid.yaml
  133. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_no_ca.yaml
  134. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_ocsps_empty.yaml
  135. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_ocsps_empty_certs_entry.yaml
  136. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_ocsps_empty_sub_entries.yaml
  137. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_ocsps_missing_certs_entry.yaml
  138. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_ocsps_missing_sub_entries.yaml
  139. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_ocsps_no_ca_cn.yaml
  140. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_ocsps_no_entry.yaml
  141. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_two_cas.yaml
  142. 0 testFiles/{ → yaml-configurations}/digidoc_test_conf_without_cache_dir.yaml
@@ -29,4 +29,4 @@ public static DigestAlgorithm determineSignatureDigestAlgorithm(X509Certificate
}
return DigestAlgorithm.SHA256;
}
}
}

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -45,8 +45,8 @@
public class ContainerBuilderTest extends DigiDoc4JTestHelper {
public static final Configuration TEST_CONFIGURATION = new Configuration(Configuration.Mode.TEST);
private static final String BDOC_TEST_FILE = "testFiles/one_signature.bdoc";
private static final String DDOC_TEST_FILE = "testFiles/ddoc_for_testing.ddoc";
private static final String BDOC_TEST_FILE = "testFiles/valid-containers/one_signature.bdoc";
private static final String DDOC_TEST_FILE = "testFiles/valid-containers/ddoc_for_testing.ddoc";
private File tempFolder;
@Rule
@@ -165,7 +165,7 @@ public void buildContainer_withInvalidMimeType_shouldThrowException() throws Exc
String mimeType = "application\\rtf";
ContainerBuilder.
aContainer().
withDataFile("testFiles/test.txt", mimeType).
withDataFile("testfiles/helper-files/test.txt", mimeType).
build();
}
@@ -512,7 +512,7 @@ public void openDDocContainerWithTempDirectory() throws Exception {
assertTrue(tempFolder.list().length == 0);
ContainerBuilder.
aContainer(DDOC_CONTAINER_TYPE).
fromExistingFile("testFiles/ddoc_for_testing.ddoc").
fromExistingFile("testFiles/valid-containers/ddoc_for_testing.ddoc").
usingTempDirectory(tempFolder.getPath()).
build();
assertTrue(tempFolder.list().length > 0);
@@ -523,7 +523,7 @@ public void openDDocContainerWithTempDirectoryAndConfiguration() throws Exceptio
assertTrue(tempFolder.list().length == 0);
ContainerBuilder.
aContainer(DDOC_CONTAINER_TYPE).
fromExistingFile("testFiles/ddoc_for_testing.ddoc").
fromExistingFile("testFiles/valid-containers/ddoc_for_testing.ddoc").
withConfiguration(TEST_CONFIGURATION).
usingTempDirectory(tempFolder.getPath()).
build();
@@ -17,13 +17,16 @@
import java.io.FileInputStream;
import org.apache.commons.io.FileUtils;
import org.digidoc4j.exceptions.DigiDoc4JException;
import org.digidoc4j.impl.DigiDoc4JTestHelper;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
public class ContainerOpenerTest extends DigiDoc4JTestHelper {
private static final String BDOC_TEST_FILE = "testFiles/one_signature.bdoc";
private static final String DDOC_TEST_FILE = "testFiles/ddoc_for_testing.ddoc";
private static final String BDOC_TEST_FILE = "testFiles/valid-containers/one_signature.bdoc";
private static final String DDOC_TEST_FILE = "testFiles/valid-containers/ddoc_for_testing.ddoc";
Configuration configuration = new Configuration(Configuration.Mode.TEST);
@Test
@@ -65,4 +68,19 @@ private void assertContainerOpened(Container container, String containerType) {
assertFalse(container.getDataFiles().isEmpty());
assertFalse(container.getSignatures().isEmpty());
}
@Test
@Ignore
public void validate(){
try {
Container container = ContainerBuilder.
aContainer().
fromExistingFile("testFiles/invalid-containers/invalid-file-format.ddoc").
build();
} catch (DigiDoc4JException e){
Assert.assertTrue( e.getMessage().contains("Invalid input file format."));
}
}
}
@@ -79,7 +79,7 @@
@Before
public void setUp() throws Exception {
PKCS12_SIGNER = new PKCS12SignatureToken("testFiles/signout.p12", "test".toCharArray());
PKCS12_SIGNER = new PKCS12SignatureToken("testFiles/p12/signout.p12", "test".toCharArray());
tempFile = testFolder.newFile("tempFile.txt");
}
@@ -121,18 +121,18 @@ public void createDDocContainer() {
@Test
public void openBDocContainerWhenTheFileIsAZipAndTheExtensionIsBDoc() {
assertTrue(ContainerOpener.open("testFiles/zip_file_without_asics_extension.bdoc") instanceof BDocContainer);
assertTrue(ContainerOpener.open("testFiles/invalid-containers/zip_file_without_asics_extension.bdoc") instanceof BDocContainer);
}
@Test
public void openDDocContainerForAllOtherFiles() {
assertTrue(ContainerOpener.open("testFiles/changed_digidoc_test.ddoc") instanceof DDocContainer);
assertTrue(ContainerOpener.open("testFiles/invalid-containers/changed_digidoc_test.ddoc") instanceof DDocContainer);
}
@Test
public void testAddOneFileToContainerForBDoc() throws Exception {
Container container = createContainer();
container.addDataFile("testFiles/test.txt", TEXT_MIME_TYPE);
container.addDataFile("testfiles/helper-files/test.txt", TEXT_MIME_TYPE);
List<DataFile> dataFiles = container.getDataFiles();
assertEquals(1, dataFiles.size());
assertEquals("test.txt", dataFiles.get(0).getName());
@@ -142,15 +142,15 @@ public void testAddOneFileToContainerForBDoc() throws Exception {
@Test
public void testRemovesOneFileFromContainerWhenFileExistsForBDoc() throws Exception {
Container bDocContainer = createContainer();
bDocContainer.addDataFile("testFiles/test.txt", TEXT_MIME_TYPE);
bDocContainer.addDataFile("testfiles/helper-files/test.txt", TEXT_MIME_TYPE);
bDocContainer.removeDataFile("test.txt");
assertEquals(0, bDocContainer.getDataFiles().size());
}
@Test
public void testCreateBDocContainerSpecifiedByDocumentTypeForBDoc() throws Exception {
Container asicContainer = createBDoc();
asicContainer.addDataFile("testFiles/test.txt", TEXT_MIME_TYPE);
asicContainer.addDataFile("testfiles/helper-files/test.txt", TEXT_MIME_TYPE);
TestDataBuilder.signContainer(asicContainer);
asicContainer.save("test.bdoc");
assertTrue(Helper.isZipFile(new File("test.bdoc")));
@@ -159,7 +159,7 @@ public void testCreateBDocContainerSpecifiedByDocumentTypeForBDoc() throws Excep
@Test
public void testCreateDDocContainer() throws Exception {
Container dDocContainer = createDDoc();
dDocContainer.addDataFile("testFiles/test.txt", TEXT_MIME_TYPE);
dDocContainer.addDataFile("testfiles/helper-files/test.txt", TEXT_MIME_TYPE);
dDocContainer.sign(PKCS12_SIGNER);
dDocContainer.save("testCreateDDocContainer.ddoc");
@@ -169,7 +169,7 @@ public void testCreateDDocContainer() throws Exception {
@Test
public void testAddOneFileToContainerForDDoc() throws Exception {
Container container = createDDoc();
container.addDataFile("testFiles/test.txt", TEXT_MIME_TYPE);
container.addDataFile("testfiles/helper-files/test.txt", TEXT_MIME_TYPE);
List<DataFile> dataFiles = container.getDataFiles();
assertEquals(1, dataFiles.size());
assertEquals("test.txt", dataFiles.get(0).getName());
@@ -179,11 +179,11 @@ public void testAddOneFileToContainerForDDoc() throws Exception {
@Test
public void testRemovesOneFileFromContainerWhenFileExistsForDDoc() throws Exception {
Container container = createDDoc();
container.addDataFile("testFiles/test.txt", TEXT_MIME_TYPE);
container.addDataFile("testfiles/helper-files/test.txt", TEXT_MIME_TYPE);
container.save("testRemovesOneFileFromContainerWhenFileExistsFor.ddoc");
Container container1 = ContainerOpener.open("testRemovesOneFileFromContainerWhenFileExistsFor.ddoc");
container1.removeDataFile("testFiles/test.txt");
container1.removeDataFile("testfiles/helper-files/test.txt");
assertEquals(0, container1.getDataFiles().size());
}
@@ -213,7 +213,7 @@ public void addLargeFileToDDoc() throws Exception {
@Test
public void testOpenCreatedDDocFile() throws Exception {
Container container = createDDoc();
container.addDataFile("testFiles/test.txt", TEXT_MIME_TYPE);
container.addDataFile("testfiles/helper-files/test.txt", TEXT_MIME_TYPE);
container.save("testOpenCreatedDDocFile.ddoc");
Container containerForReading = ContainerOpener.open("testOpenCreatedDDocFile.ddoc");
assertEquals(DDOC, containerForReading.getDocumentType());
@@ -223,12 +223,12 @@ public void testOpenCreatedDDocFile() throws Exception {
@Test(expected = DigiDoc4JException.class)
public void testOpenInvalidFileReturnsError() {
ContainerOpener.open("testFiles/test.txt");
ContainerOpener.open("testfiles/helper-files/test.txt");
}
@Test
public void testValidateDDoc() throws Exception {
Container dDocContainer = ContainerOpener.open("testFiles/ddoc_for_testing.ddoc");
Container dDocContainer = ContainerOpener.open("testFiles/valid-containers/ddoc_for_testing.ddoc");
assertFalse(dDocContainer.validate().hasErrors());
assertFalse(dDocContainer.validate().hasWarnings());
}
@@ -240,18 +240,18 @@ public void testOpenNotExistingFileThrowsException() {
@Test(expected = DigiDoc4JException.class)
public void testOpenEmptyFileThrowsException() {
ContainerOpener.open("emptyFile.ddoc");
ContainerOpener.open("testFiles/invalid-containers/emptyFile.ddoc");
}
@Test(expected = DigiDoc4JException.class)
public void testFileTooShortToVerifyIfItIsZipFileThrowsException() {
ContainerOpener.open("testFiles/tooShortToVerifyIfIsZip.ddoc");
ContainerOpener.open("testFiles/invalid-containers/tooShortToVerifyIfIsZip.ddoc");
}
@Test(expected = DigiDoc4JException.class)
public void testOpenFromStreamTooShortToVerifyIfIsZip() {
try {
FileInputStream stream = new FileInputStream(new File("testFiles/tooShortToVerifyIfIsZip.ddoc"));
FileInputStream stream = new FileInputStream(new File("testFiles/invalid-containers/tooShortToVerifyIfIsZip.ddoc"));
ContainerOpener.open(stream, true);
IOUtils.closeQuietly(stream);
} catch (FileNotFoundException e) {
@@ -273,7 +273,7 @@ public void testAddFileFromStreamToDDoc() throws IOException {
@Test
public void openContainerFromStreamAsBDoc() throws IOException {
Container container = createContainer();
container.addDataFile("testFiles/test.txt", "text/plain");
container.addDataFile("testfiles/helper-files/test.txt", "text/plain");
Signature signature = SignatureBuilder.
aSignature(container).
withSignatureToken(PKCS12_SIGNER).
@@ -291,7 +291,7 @@ public void openContainerFromStreamAsBDoc() throws IOException {
@Test
public void openContainerFromStreamAsDDoc() throws IOException {
FileInputStream stream = new FileInputStream("testFiles/ddoc_for_testing.ddoc");
FileInputStream stream = new FileInputStream("testFiles/valid-containers/ddoc_for_testing.ddoc");
Container container = ContainerOpener.open(stream, false);
stream.close();
@@ -301,7 +301,7 @@ public void openContainerFromStreamAsDDoc() throws IOException {
@Test
public void testGetSignatureFromDDoc() {
Container container = createDDoc();
container.addDataFile("testFiles/test.txt", TEXT_MIME_TYPE);
container.addDataFile("testfiles/helper-files/test.txt", TEXT_MIME_TYPE);
container.sign(PKCS12_SIGNER);
List<Signature> signatures = container.getSignatures();
@@ -317,7 +317,7 @@ public void testAddRawSignatureThrowsException() {
@Test
public void testAddRawSignatureAsByteArrayForDDoc() throws CertificateEncodingException, IOException, SAXException {
Container container = createDDoc();
container.addDataFile("testFiles/test.txt", TEXT_MIME_TYPE);
container.addDataFile("testfiles/helper-files/test.txt", TEXT_MIME_TYPE);
container.sign(PKCS12_SIGNER);
byte[] signatureBytes = FileUtils.readFileToByteArray(new File(("testFiles/xades/test-bdoc-tm.xml")));
container.addRawSignature(signatureBytes);
@@ -340,7 +340,7 @@ public void throwsErrorWhenCreatesDDOCContainerWithConfiguration() throws Except
@Test
public void testExtendToForBDOC() {
Container container = createContainer();
container.addDataFile("testFiles/test.txt", "text/plain");
container.addDataFile("testfiles/helper-files/test.txt", "text/plain");
Signature signature = SignatureBuilder.
aSignature(container).
withSignatureProfile(B_BES).
@@ -356,7 +356,7 @@ public void testExtendToForBDOC() {
@Test
public void testExtendToForDDOC() {
Container container = createDDoc();
container.addDataFile("testFiles/test.txt", "text/plain");
container.addDataFile("testfiles/helper-files/test.txt", "text/plain");
container.setSignatureProfile(B_BES);
container.sign(PKCS12_SIGNER);
@@ -368,7 +368,7 @@ public void testExtendToForDDOC() {
@Test
public void addRawSignatureToBDocContainer() throws Exception {
Container container = createBDoc();
container.addDataFile("testFiles/test.txt", TEXT_MIME_TYPE);
container.addDataFile("testfiles/helper-files/test.txt", TEXT_MIME_TYPE);
byte[] signatureBytes = FileUtils.readFileToByteArray(new File("testFiles/xades/valid-bdoc-tm.xml"));
container.addRawSignature(signatureBytes);
String containerPath = testFolder.newFile("test-container.bdoc").getPath();
@@ -380,7 +380,7 @@ public void addRawSignatureToBDocContainer() throws Exception {
@Test
public void addRawSignatureToExistingBDocContainer() throws Exception {
Container container = TestDataBuilder.createContainerWithFile("testFiles/test.txt");
Container container = TestDataBuilder.createContainerWithFile("testfiles/helper-files/test.txt");
TestDataBuilder.signContainer(container);
byte[] signatureBytes = FileUtils.readFileToByteArray(new File("testFiles/xades/valid-bdoc-tm.xml"));
container.addRawSignature(signatureBytes);
@@ -394,7 +394,7 @@ public void addRawSignatureToExistingBDocContainer() throws Exception {
@Test(expected = InvalidSignatureException.class)
public void testAddRawSignatureAsByteArrayForBDoc() throws CertificateEncodingException, IOException, SAXException {
Container container = createBDoc();
container.addDataFile("testFiles/test.txt", TEXT_MIME_TYPE);
container.addDataFile("testfiles/helper-files/test.txt", TEXT_MIME_TYPE);
TestDataBuilder.signContainer(container);
container.addRawSignature(Base64.decodeBase64("fo4aA1PVI//1agzBm2Vcxj7sk9pYQJt+9a7xLFSkfF10RocvGjVPBI65RMqyxGIsje" +
"LoeDERfTcjHdNojoK/gEdKtme4z6kvkZzjMjDuJu7krK/3DHBtW3XZleIaWZSWySahUiPNNIuk5ykACUolh+K/UK2aWL3Nh64EWvC8aznLV0" +
@@ -405,7 +405,7 @@ public void testAddRawSignatureAsByteArrayForBDoc() throws CertificateEncodingEx
@Test
public void testAddRawSignatureAsStreamArray() throws CertificateEncodingException, IOException {
Container container = createDDoc();
container.addDataFile("testFiles/test.txt", TEXT_MIME_TYPE);
container.addDataFile("testfiles/helper-files/test.txt", TEXT_MIME_TYPE);
FileInputStream fileInputStream = new FileInputStream("testFiles/xades/test-bdoc-tm.xml");
container.addRawSignature(fileInputStream);
@@ -422,7 +422,7 @@ public void testAddRawSignatureAsStreamArray() throws CertificateEncodingExcepti
@Ignore("jDigidoc fails to save a container after a raw signature has been added")
public void testRemoveSignature() throws IOException {
Container container = createDDoc();
container.addDataFile("testFiles/test.txt", TEXT_MIME_TYPE);
container.addDataFile("testfiles/helper-files/test.txt", TEXT_MIME_TYPE);
container.sign(PKCS12_SIGNER);
FileInputStream fileInputStream = new FileInputStream("testFiles/xades/test-bdoc-tm.xml");
container.addRawSignature(fileInputStream);
@@ -445,7 +445,7 @@ public void testRemovingNotExistingSignatureThrowsException() {
@Test
public void testSigningWithSignerInfo() throws Exception {
Container container = createContainer();
container.addDataFile("testFiles/test.txt", TEXT_MIME_TYPE);
container.addDataFile("testfiles/helper-files/test.txt", TEXT_MIME_TYPE);
Signature signature = SignatureBuilder.
aSignature(container).
withCity("myCity").
@@ -472,7 +472,7 @@ public void testSetConfigurationForBDoc() throws Exception {
Container container = ContainerBuilder.
aContainer(BDOC_CONTAINER_TYPE).
withConfiguration(conf).
withDataFile("testFiles/test.txt", TEXT_MIME_TYPE).
withDataFile("testfiles/helper-files/test.txt", TEXT_MIME_TYPE).
build();
SignatureBuilder.
aSignature(container).
@@ -483,7 +483,7 @@ public void testSetConfigurationForBDoc() throws Exception {
@Test
public void mustBePossibleToCreateAndVerifyContainerWhereDigestAlgorithmIsSHA224() throws Exception {
Container container = createContainer();
container.addDataFile("testFiles/test.txt", "text/plain");
container.addDataFile("testfiles/helper-files/test.txt", "text/plain");
Signature signature = SignatureBuilder.
aSignature(container).
withSignatureDigestAlgorithm(DigestAlgorithm.SHA224).
@@ -15,7 +15,9 @@
import org.digidoc4j.exceptions.DigiDoc4JException;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -36,7 +38,7 @@
@Before
public void setUp() throws Exception {
dataFile = new DataFile("testFiles/test.txt", "text/plain");
dataFile = new DataFile("testfiles/helper-files/test.txt", "text/plain");
}
@Test
@@ -82,7 +84,7 @@ public void testSaveToFile() throws IOException {
dataFile.saveAs(fileName);
assertTrue(new File(fileName).exists());
byte[] testFileContent = FileUtils.readFileToByteArray(new File("testFiles/test.txt"));
byte[] testFileContent = FileUtils.readFileToByteArray(new File("testfiles/helper-files/test.txt"));
byte[] savedFileContent = FileUtils.readFileToByteArray(new File(fileName));
assertArrayEquals(testFileContent, savedFileContent);
@@ -102,12 +104,12 @@ public void testSaveToOutputStream() throws IOException {
@Test(expected = DigiDoc4JException.class)
public void incorrectMimeType() {
dataFile = new DataFile("testFiles/test.txt", "incorrect");
dataFile = new DataFile("testfiles/helper-files/test.txt", "incorrect");
}
@Test(expected = DigiDoc4JException.class)
public void incorrectMimeTypeByteArrayConstructor() {
dataFile = new DataFile(new byte[]{0x041}, "testFiles/test.txt", "incorrect");
dataFile = new DataFile(new byte[]{0x041}, "testfiles/helper-files/test.txt", "incorrect");
}
@Test(expected = DigiDoc4JException.class)
Oops, something went wrong.

0 comments on commit 7901fa2

Please sign in to comment.