Kaydet (Commit) 6c11778e authored tarafından Miklos Vajna's avatar Miklos Vajna

CppunitTest_xmlsecurity_signing: add ODF verification testcases

Change-Id: I08734b7841fc83b327ebbf5c8ae43f7969e94e12
üst 69bb5e84
...@@ -61,6 +61,10 @@ public: ...@@ -61,6 +61,10 @@ public:
virtual void tearDown() override; virtual void tearDown() override;
void testDescription(); 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. /// Test a typical OOXML where a number of (but not all) streams are signed.
void testOOXMLPartial(); void testOOXMLPartial();
/// Test a typical broken OOXML signature where one stream is corrupted. /// Test a typical broken OOXML signature where one stream is corrupted.
...@@ -75,6 +79,9 @@ public: ...@@ -75,6 +79,9 @@ public:
CPPUNIT_TEST_SUITE(SigningTest); CPPUNIT_TEST_SUITE(SigningTest);
CPPUNIT_TEST(testDescription); CPPUNIT_TEST(testDescription);
CPPUNIT_TEST(testODFGood);
CPPUNIT_TEST(testODFBroken);
CPPUNIT_TEST(testODFBroken);
CPPUNIT_TEST(testOOXMLPartial); CPPUNIT_TEST(testOOXMLPartial);
CPPUNIT_TEST(testOOXMLBroken); CPPUNIT_TEST(testOOXMLBroken);
CPPUNIT_TEST(testOOXMLDescription); CPPUNIT_TEST(testOOXMLDescription);
...@@ -301,6 +308,33 @@ void SigningTest::testOOXMLRemoveAll() ...@@ -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() void SigningTest::testOOXMLPartial()
{ {
createDoc(m_directories.getURLFromSrc(DATA_DIRECTORY) + "partial.docx"); createDoc(m_directories.getURLFromSrc(DATA_DIRECTORY) + "partial.docx");
......
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