summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmlsecurity/qa/unit/signing/data/bad.odtbin0 -> 10920 bytes
-rw-r--r--xmlsecurity/qa/unit/signing/data/good.odtbin0 -> 10878 bytes
-rw-r--r--xmlsecurity/qa/unit/signing/signing.cxx34
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
new file mode 100644
index 000000000000..75c39d5d8309
--- /dev/null
+++ b/xmlsecurity/qa/unit/signing/data/bad.odt
Binary files differ
diff --git a/xmlsecurity/qa/unit/signing/data/good.odt b/xmlsecurity/qa/unit/signing/data/good.odt
new file mode 100644
index 000000000000..8c6019d0acd9
--- /dev/null
+++ b/xmlsecurity/qa/unit/signing/data/good.odt
Binary files differ
diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx
index 1894cb9cec62..d037eb9a35fb 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);
@@ -299,6 +306,33 @@ void SigningTest::testOOXMLRemoveAll()
}));
}
+void SigningTest::testODFGood()
+{
+ createDoc(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(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(getURLFromSrc(DATA_DIRECTORY) + "partial.docx");