CppunitTest_xmlsecurity_signing: add invalid OOXML testcase

Test the case when the manifest reference has invalid hash: this is the
more complex situation. A simple situation is when a direct
(non-manifest) reference is broken.

Change-Id: Iaea139abc460050768cfbc236cacb1fd94418b36
This commit is contained in:
Miklos Vajna
2016-02-04 10:02:36 +01:00
parent 50d4306476
commit d165f035d2
2 changed files with 14 additions and 0 deletions
Binary file not shown.
+14
View File
@@ -55,10 +55,13 @@ public:
void testDescription();
/// 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.
void testOOXMLBroken();
CPPUNIT_TEST_SUITE(SigningTest);
CPPUNIT_TEST(testDescription);
CPPUNIT_TEST(testOOXMLPartial);
CPPUNIT_TEST(testOOXMLBroken);
CPPUNIT_TEST_SUITE_END();
private:
@@ -206,6 +209,17 @@ void SigningTest::testOOXMLPartial()
CPPUNIT_ASSERT(nActual == static_cast<int>(SignatureState::NOTVALIDATED) || nActual == static_cast<int>(SignatureState::PARTIAL_OK));
}
void SigningTest::testOOXMLBroken()
{
createDoc(getURLFromSrc(DATA_DIRECTORY) + "bad.docx");
SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
CPPUNIT_ASSERT(pBaseModel);
SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell();
CPPUNIT_ASSERT(pObjectShell);
// This was SignatureState::NOTVALIDATED/PARTIAL_OK as we did not validate manifest references.
CPPUNIT_ASSERT_EQUAL(static_cast<int>(SignatureState::BROKEN), static_cast<int>(pObjectShell->GetDocumentSignatureState()));
}
CPPUNIT_TEST_SUITE_REGISTRATION(SigningTest);
CPPUNIT_PLUGIN_IMPLEMENT();