diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-03-04 11:18:17 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-03-04 11:48:48 +0100 |
commit | 78a209b951d2f6e6bb3001b45c242a85fcf9ebb0 (patch) | |
tree | d57d2cbb76f50a7c53e3850d879b7e7f78d00623 /xmlsecurity | |
parent | e89610dad647ea5c77805ff06af1ea9870ae9f15 (diff) |
CppunitTest_xmlsecurity_signing: add signature append testcase
Fails with e.g. commit 963264a417ce807201f0021fc6000ce7d6cf0245
(xmlsecurity OOXML export: don't loose old signatures when adding a new
one, 2016-03-03) reverted.
Change-Id: Ia2b0f3d8914bca14075481f5ac8cd4c0033d26c1
Diffstat (limited to 'xmlsecurity')
-rw-r--r-- | xmlsecurity/qa/unit/signing/signing.cxx | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx index d9aec730472e..5d97d7114654 100644 --- a/xmlsecurity/qa/unit/signing/signing.cxx +++ b/xmlsecurity/qa/unit/signing/signing.cxx @@ -64,12 +64,15 @@ public: /// Test a typical broken OOXML signature where one stream is corrupted. void testOOXMLBroken(); void testOOXMLDescription(); + /// Test appending a new signature next to an existing one. + void testOOXMLAppend(); CPPUNIT_TEST_SUITE(SigningTest); CPPUNIT_TEST(testDescription); CPPUNIT_TEST(testOOXMLPartial); CPPUNIT_TEST(testOOXMLBroken); CPPUNIT_TEST(testOOXMLDescription); + CPPUNIT_TEST(testOOXMLAppend); CPPUNIT_TEST_SUITE_END(); private: @@ -177,7 +180,7 @@ void SigningTest::testOOXMLDescription() aManager.mxStore = xStorage; aManager.maSignatureHelper.SetStorage(xStorage, "1.2"); - // Then add a signature document. + // Then add a document signature. uno::Reference<security::XCertificate> xCertificate = getCertificate(aManager.maSignatureHelper); CPPUNIT_ASSERT(xCertificate.is()); OUString aDescription("SigningTest::testDescription"); @@ -191,6 +194,32 @@ void SigningTest::testOOXMLDescription() CPPUNIT_ASSERT_EQUAL(aDescription, rInformations[0].ouDescription); } +void SigningTest::testOOXMLAppend() +{ + // Load the test document as a storage and read its single signature. + DocumentSignatureManager aManager(mxComponentContext, SignatureModeDocumentContent); + CPPUNIT_ASSERT(aManager.maSignatureHelper.Init()); + OUString aURL = getURLFromSrc(DATA_DIRECTORY) + "partial.docx"; + uno::Reference <embed::XStorage> xStorage = comphelper::OStorageHelper::GetStorageOfFormatFromURL(ZIP_STORAGE_FORMAT_STRING, aURL, embed::ElementModes::READWRITE); + CPPUNIT_ASSERT(xStorage.is()); + aManager.mxStore = xStorage; + aManager.maSignatureHelper.SetStorage(xStorage, "1.2"); + aManager.read(/*bUseTempStream=*/false); + std::vector<SignatureInformation>& rInformations = aManager.maCurrentSignatureInformations; + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rInformations.size()); + + // Then add a second document signature. + uno::Reference<security::XCertificate> xCertificate = getCertificate(aManager.maSignatureHelper); + CPPUNIT_ASSERT(xCertificate.is()); + sal_Int32 nSecurityId; + aManager.add(xCertificate, OUString(), nSecurityId); + + // Read back the signatures and make sure that we have the expected amount. + aManager.read(/*bUseTempStream=*/true); + // This was 1: the original signature was lost. + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rInformations.size()); +} + void SigningTest::testOOXMLPartial() { createDoc(getURLFromSrc(DATA_DIRECTORY) + "partial.docx"); |