diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-03-04 15:41:35 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-03-04 16:01:34 +0100 |
commit | 3cefd33eb54d355d21f3541963ad1e89793c95f1 (patch) | |
tree | 6e79986ae8056f290ff75b1fa2b62c75fb431bf8 /xmlsecurity | |
parent | c30bf0284c643b6c574fcc5dabb840bb51174b30 (diff) |
CppunitTest_xmlsecurity_signing: add signature removal testcase
Fails with the previous commit reverted.
Change-Id: I050a03fa923980e46b31eff457d0b83f6c38ceaf
Diffstat (limited to 'xmlsecurity')
-rw-r--r-- | xmlsecurity/qa/unit/signing/data/multi.docx | bin | 0 -> 23767 bytes | |||
-rw-r--r-- | xmlsecurity/qa/unit/signing/signing.cxx | 28 |
2 files changed, 28 insertions, 0 deletions
diff --git a/xmlsecurity/qa/unit/signing/data/multi.docx b/xmlsecurity/qa/unit/signing/data/multi.docx Binary files differnew file mode 100644 index 000000000000..aba69508e253 --- /dev/null +++ b/xmlsecurity/qa/unit/signing/data/multi.docx diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx index 5d97d7114654..aa062d039d5c 100644 --- a/xmlsecurity/qa/unit/signing/signing.cxx +++ b/xmlsecurity/qa/unit/signing/signing.cxx @@ -66,6 +66,8 @@ public: void testOOXMLDescription(); /// Test appending a new signature next to an existing one. void testOOXMLAppend(); + /// Test removing a signature from existing ones. + void testOOXMLRemove(); CPPUNIT_TEST_SUITE(SigningTest); CPPUNIT_TEST(testDescription); @@ -73,6 +75,7 @@ public: CPPUNIT_TEST(testOOXMLBroken); CPPUNIT_TEST(testOOXMLDescription); CPPUNIT_TEST(testOOXMLAppend); + CPPUNIT_TEST(testOOXMLRemove); CPPUNIT_TEST_SUITE_END(); private: @@ -220,6 +223,31 @@ void SigningTest::testOOXMLAppend() CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rInformations.size()); } +void SigningTest::testOOXMLRemove() +{ + // Load the test document as a storage and read its signatures: purpose1 and purpose2. + DocumentSignatureManager aManager(mxComponentContext, SignatureModeDocumentContent); + CPPUNIT_ASSERT(aManager.maSignatureHelper.Init()); + OUString aURL = getURLFromSrc(DATA_DIRECTORY) + "multi.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>(2), rInformations.size()); + + // Then remove the last added signature. + uno::Reference<security::XCertificate> xCertificate = getCertificate(aManager.maSignatureHelper); + CPPUNIT_ASSERT(xCertificate.is()); + aManager.remove(0); + + // Read back the signatures and make sure that only purpose1 is left. + aManager.read(/*bUseTempStream=*/true); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rInformations.size()); + CPPUNIT_ASSERT_EQUAL(OUString("purpose1"), rInformations[0].ouDescription); +} + void SigningTest::testOOXMLPartial() { createDoc(getURLFromSrc(DATA_DIRECTORY) + "partial.docx"); |