diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-03-11 14:53:13 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-03-11 17:37:11 +0100 |
commit | 6c11778ee6919b0f16acb17a896f65d4021f3089 (patch) | |
tree | 3c1566ddff85966723e2cee72a6e7abe29a3c970 /xmlsecurity | |
parent | 69bb5e849825e32d9fe929519813ede56ca76997 (diff) |
CppunitTest_xmlsecurity_signing: add ODF verification testcases
Change-Id: I08734b7841fc83b327ebbf5c8ae43f7969e94e12
Diffstat (limited to 'xmlsecurity')
-rw-r--r-- | xmlsecurity/qa/unit/signing/data/bad.odt | bin | 0 -> 10920 bytes | |||
-rw-r--r-- | xmlsecurity/qa/unit/signing/data/good.odt | bin | 0 -> 10878 bytes | |||
-rw-r--r-- | xmlsecurity/qa/unit/signing/signing.cxx | 34 |
3 files changed, 34 insertions, 0 deletions
diff --git a/xmlsecurity/qa/unit/signing/data/bad.odt b/xmlsecurity/qa/unit/signing/data/bad.odt Binary files differnew file mode 100644 index 000000000000..75c39d5d8309 --- /dev/null +++ b/xmlsecurity/qa/unit/signing/data/bad.odt diff --git a/xmlsecurity/qa/unit/signing/data/good.odt b/xmlsecurity/qa/unit/signing/data/good.odt Binary files differnew file mode 100644 index 000000000000..8c6019d0acd9 --- /dev/null +++ b/xmlsecurity/qa/unit/signing/data/good.odt diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx index b576b3b060a3..2ee8e33bb0db 100644 --- a/xmlsecurity/qa/unit/signing/signing.cxx +++ b/xmlsecurity/qa/unit/signing/signing.cxx @@ -61,6 +61,10 @@ public: virtual void tearDown() override; void testDescription(); + /// Test a typical ODF where all streams are signed. + void testODFGood(); + /// Test a typical broken ODF signature where one stream is corrupted. + void testODFBroken(); /// Test a typical OOXML where a number of (but not all) streams are signed. void testOOXMLPartial(); /// Test a typical broken OOXML signature where one stream is corrupted. @@ -75,6 +79,9 @@ public: CPPUNIT_TEST_SUITE(SigningTest); CPPUNIT_TEST(testDescription); + CPPUNIT_TEST(testODFGood); + CPPUNIT_TEST(testODFBroken); + CPPUNIT_TEST(testODFBroken); CPPUNIT_TEST(testOOXMLPartial); CPPUNIT_TEST(testOOXMLBroken); CPPUNIT_TEST(testOOXMLDescription); @@ -301,6 +308,33 @@ void SigningTest::testOOXMLRemoveAll() })); } +void SigningTest::testODFGood() +{ + createDoc(m_directories.getURLFromSrc(DATA_DIRECTORY) + "good.odt"); + SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + CPPUNIT_ASSERT(pBaseModel); + SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell(); + CPPUNIT_ASSERT(pObjectShell); + // We expect NOTVALIDATED in case the root CA is not imported on the system, and OK otherwise, so accept both. + SignatureState nActual = pObjectShell->GetDocumentSignatureState(); + CPPUNIT_ASSERT_MESSAGE( + (OString::number( + static_cast<std::underlying_type<SignatureState>::type>(nActual)) + .getStr()), + (nActual == SignatureState::NOTVALIDATED + || nActual == SignatureState::PARTIAL_OK)); +} + +void SigningTest::testODFBroken() +{ + createDoc(m_directories.getURLFromSrc(DATA_DIRECTORY) + "bad.odt"); + SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); + CPPUNIT_ASSERT(pBaseModel); + SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell(); + CPPUNIT_ASSERT(pObjectShell); + CPPUNIT_ASSERT_EQUAL(static_cast<int>(SignatureState::BROKEN), static_cast<int>(pObjectShell->GetDocumentSignatureState())); +} + void SigningTest::testOOXMLPartial() { createDoc(m_directories.getURLFromSrc(DATA_DIRECTORY) + "partial.docx"); |