summaryrefslogtreecommitdiff
path: root/xmlsecurity/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-02-15 17:51:00 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-02-15 17:52:04 +0000
commitd3f83ffa0e85a697af2cbf50a55dd7308609cf56 (patch)
treeae931888272a9abcfd924f0f56c8c68c9994184d /xmlsecurity/qa
parentb4f182b31c8dc5ba872d30ac26da65904e1dd827 (diff)
CppunitTest_xmlsecurity_signing: add OOXML description roundtrip test
Fails when the relevant part of XSecController::exportOOXMLSignature() is commented out, i.e. the member function just writes a <Signature> XML element, no child elements. Change-Id: I526c1170c8ada71f111a1ad56d74af1a4102dbce Reviewed-on: https://gerrit.libreoffice.org/22375 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'xmlsecurity/qa')
-rw-r--r--xmlsecurity/qa/unit/signing/signing.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx
index 6f2249cc2543..ce69d2701b05 100644
--- a/xmlsecurity/qa/unit/signing/signing.cxx
+++ b/xmlsecurity/qa/unit/signing/signing.cxx
@@ -59,11 +59,13 @@ public:
void testOOXMLPartial();
/// Test a typical broken OOXML signature where one stream is corrupted.
void testOOXMLBroken();
+ void testOOXMLDescription();
CPPUNIT_TEST_SUITE(SigningTest);
CPPUNIT_TEST(testDescription);
CPPUNIT_TEST(testOOXMLPartial);
CPPUNIT_TEST(testOOXMLBroken);
+ CPPUNIT_TEST(testOOXMLDescription);
CPPUNIT_TEST_SUITE_END();
private:
@@ -152,6 +154,39 @@ void SigningTest::testDescription()
CPPUNIT_ASSERT_EQUAL(aDescription, rInformations[0].ouDescription);
}
+void SigningTest::testOOXMLDescription()
+{
+ // Create an empty document and store it to a tempfile, finally load it as a storage.
+ createDoc();
+
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= OUString("MS Word 2007 XML");
+ xStorable->storeAsURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+
+ DocumentSignatureManager aManager(mxComponentContext, SignatureModeDocumentContent);
+ CPPUNIT_ASSERT(aManager.maSignatureHelper.Init());
+ uno::Reference <embed::XStorage> xStorage = comphelper::OStorageHelper::GetStorageOfFormatFromURL(ZIP_STORAGE_FORMAT_STRING, aTempFile.GetURL(), embed::ElementModes::READWRITE);
+ CPPUNIT_ASSERT(xStorage.is());
+ aManager.mxStore = xStorage;
+ aManager.maSignatureHelper.SetStorage(xStorage, "1.2");
+
+ // Then add a signature document.
+ uno::Reference<security::XCertificate> xCertificate = getCertificate(aManager.maSignatureHelper);
+ CPPUNIT_ASSERT(xCertificate.is());
+ OUString aDescription("SigningTest::testDescription");
+ sal_Int32 nSecurityId;
+ aManager.add(xCertificate, aDescription, nSecurityId);
+
+ // Read back the signature and make sure that the description survives the roundtrip.
+ aManager.read(/*bUseTempStream=*/true);
+ std::vector<SignatureInformation>& rInformations = aManager.maCurrentSignatureInformations;
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rInformations.size());
+ CPPUNIT_ASSERT_EQUAL(aDescription, rInformations[0].ouDescription);
+}
+
void SigningTest::testOOXMLPartial()
{
createDoc(getURLFromSrc(DATA_DIRECTORY) + "partial.docx");