Kaydet (Commit) 193aa63a authored tarafından Samuel Mehrbrodt's avatar Samuel Mehrbrodt

tdf#65393 Test for signature line images

Change-Id: I6f37919da5fef0a90fad314019db19e4a5604169
Reviewed-on: https://gerrit.libreoffice.org/44220Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
üst b2e888a0
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include <com/sun/star/xml/crypto/SEInitializer.hpp> #include <com/sun/star/xml/crypto/SEInitializer.hpp>
#include <com/sun/star/io/TempFile.hpp> #include <com/sun/star/io/TempFile.hpp>
#include <com/sun/star/packages/manifest/ManifestReader.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/processfactory.hxx>
#include <comphelper/propertysequence.hxx> #include <comphelper/propertysequence.hxx>
...@@ -98,6 +100,8 @@ public: ...@@ -98,6 +100,8 @@ public:
void testXAdES(); void testXAdES();
/// Works with an existing good XAdES signature. /// Works with an existing good XAdES signature.
void testXAdESGood(); void testXAdESGood();
/// Test importing of signature line images
void testSignatureLineImages();
CPPUNIT_TEST_SUITE(SigningTest); CPPUNIT_TEST_SUITE(SigningTest);
CPPUNIT_TEST(testDescription); CPPUNIT_TEST(testDescription);
...@@ -120,6 +124,7 @@ public: ...@@ -120,6 +124,7 @@ public:
CPPUNIT_TEST(test96097Doc); CPPUNIT_TEST(test96097Doc);
CPPUNIT_TEST(testXAdES); CPPUNIT_TEST(testXAdES);
CPPUNIT_TEST(testXAdESGood); CPPUNIT_TEST(testXAdESGood);
CPPUNIT_TEST(testSignatureLineImages);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
...@@ -629,6 +634,29 @@ void SigningTest::testXAdESGood() ...@@ -629,6 +634,29 @@ void SigningTest::testXAdESGood()
(nActual == SignatureState::NOTVALIDATED (nActual == SignatureState::NOTVALIDATED
|| nActual == SignatureState::OK)); || 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) void SigningTest::registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx)
{ {
xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("odfds"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:digitalsignature:1.0")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("odfds"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:digitalsignature:1.0"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment