diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2017-11-02 15:47:32 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2017-11-06 12:17:14 +0100 |
commit | 193aa63a2aa697e3689eedd63775afffb6ed9ef1 (patch) | |
tree | b45d024e9c5b7e6242934d0fd43ef100c344279c /xmlsecurity | |
parent | b2e888a0cd9dc272348b7293a2e8b083f7277cea (diff) |
tdf#65393 Test for signature line images
Change-Id: I6f37919da5fef0a90fad314019db19e4a5604169
Reviewed-on: https://gerrit.libreoffice.org/44220
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'xmlsecurity')
-rw-r--r-- | xmlsecurity/qa/unit/signing/data/signatureline.docx | bin | 0 -> 22877 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/signatureline.docx b/xmlsecurity/qa/unit/signing/data/signatureline.docx Binary files differnew file mode 100644 index 000000000000..e1dae66989d3 --- /dev/null +++ b/xmlsecurity/qa/unit/signing/data/signatureline.docx diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx index e17ccff09ef4..4724f56f234a 100644 --- a/xmlsecurity/qa/unit/signing/signing.cxx +++ b/xmlsecurity/qa/unit/signing/signing.cxx @@ -25,6 +25,8 @@ #include <com/sun/star/xml/crypto/SEInitializer.hpp> #include <com/sun/star/io/TempFile.hpp> #include <com/sun/star/packages/manifest/ManifestReader.hpp> +#include <com/sun/star/security/DocumentDigitalSignatures.hpp> +#include <com/sun/star/security/XDocumentDigitalSignatures.hpp> #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> @@ -98,6 +100,8 @@ public: void testXAdES(); /// Works with an existing good XAdES signature. void testXAdESGood(); + /// Test importing of signature line images + void testSignatureLineImages(); CPPUNIT_TEST_SUITE(SigningTest); CPPUNIT_TEST(testDescription); @@ -120,6 +124,7 @@ public: CPPUNIT_TEST(test96097Doc); CPPUNIT_TEST(testXAdES); CPPUNIT_TEST(testXAdESGood); + CPPUNIT_TEST(testSignatureLineImages); CPPUNIT_TEST_SUITE_END(); private: @@ -629,6 +634,29 @@ void SigningTest::testXAdESGood() (nActual == SignatureState::NOTVALIDATED || nActual == SignatureState::OK)); } + +void SigningTest::testSignatureLineImages() +{ + // Given: A document (docx) with a signature line and a valid signature + uno::Reference< security::XDocumentDigitalSignatures > xSignatures( + security::DocumentDigitalSignatures::createWithVersion( + comphelper::getProcessComponentContext(), "1.2" ) ); + + uno::Reference<embed::XStorage> xStorage = comphelper::OStorageHelper::GetStorageOfFormatFromURL( + ZIP_STORAGE_FORMAT_STRING, m_directories.getURLFromSrc(DATA_DIRECTORY) + "signatureline.docx", + embed::ElementModes::READ); + CPPUNIT_ASSERT(xStorage.is()); + + uno::Sequence< security::DocumentSignatureInformation > xSignatureInfo = + xSignatures->verifyScriptingContentSignatures(xStorage, uno::Reference< io::XInputStream >()); + + // The signature should have a valid signature, and signature line with two valid images + CPPUNIT_ASSERT(xSignatureInfo[0].SignatureIsValid); + CPPUNIT_ASSERT_EQUAL(OUString("{DEE0514B-13E8-4674-A831-46E3CDB18BB4}"), xSignatureInfo[0].SignatureLineId); + CPPUNIT_ASSERT(xSignatureInfo[0].ValidSignatureLineImage.is()); + CPPUNIT_ASSERT(xSignatureInfo[0].InvalidSignatureLineImage.is()); +} + void SigningTest::registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) { xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("odfds"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:digitalsignature:1.0")); |