xmlsecurity/qa/unit/signing/data/certificate.crt | 27 ----------------- xmlsecurity/qa/unit/signing/data/key3.db |binary xmlsecurity/qa/unit/signing/signing.cxx | 36 +++++++++++------------ 3 files changed, 18 insertions(+), 45 deletions(-)
New commits: commit 748f778d0f42f2cbb78a7ca7e013bfbd77cdf2b7 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Nov 24 13:42:14 2016 +0100 CppunitTest_xmlsecurity_signing: don't assume we always have a signing cert This makes this suite in sync with CppunitTest_xmlsecurity_pdfsigning. A signing certificate is available on 64bit NSS platforms, as there we provide a pre-created NSS db, but on other platforms by default there is just no signing certificate. The certificate.crt I added earlier is not enough, that's just the certificate, but it doesn't provide a private key. Change-Id: Ie09d70fc9bc7ab752382eef96659bedb414553f5 diff --git a/xmlsecurity/qa/unit/signing/data/certificate.crt b/xmlsecurity/qa/unit/signing/data/certificate.crt deleted file mode 100644 index f3f34b7..0000000 --- a/xmlsecurity/qa/unit/signing/data/certificate.crt +++ /dev/null @@ -1,27 +0,0 @@ -MIIE7jCCAtagAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwVzELMAkGA1UEBhMCVUsx -EDAOBgNVBAgMB0VuZ2xhbmQxEjAQBgNVBAoMCVRTQ1AgVGVzdDEiMCAGA1UEAwwZ -VFNDUCBJbnRlcm1lZGlhdGUgUm9vdCBDQTAeFw0xNTEyMTgwNzU4MTlaFw0xNjEy -MjcwNzU4MTlaMFUxCzAJBgNVBAYTAlVLMRAwDgYDVQQIDAdFbmdsYW5kMRIwEAYD -VQQKDAlUU0NQIFRlc3QxIDAeBgNVBAMMF1RTQ1AgVGVzdCBleGFtcGxlIEFsaWNl -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3m2YNdX+nc1LkhlrNrcI -PI3yCWnv0/0k9zDKpKiwjMH4vjWM46M6ptAiupxVpAMW5ojnhEyxaNHvZNsCwddY -E6778hut2SJvz0szSBuHUuedcALI2EhVwdM0yLqfGo6WGeO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7Rdu9jDFP9oNizC7kQfA5QVRTfBFcWH7jml69RmVgfM+X+wdQgen9hJAILhBz -mDfeteJ5ZEaoEYtw3isOGkpSyg7odjgYq7I+bOiN1toDg07vzfIkvF9KxlkDeRLX -bmcFIvQsqFeF6cUwlZQYLOHA diff --git a/xmlsecurity/qa/unit/signing/data/key3.db b/xmlsecurity/qa/unit/signing/data/key3.db new file mode 100644 index 0000000..8ab32c2 Binary files /dev/null and b/xmlsecurity/qa/unit/signing/data/key3.db differ diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx index 51e5366..4e6c20e 100644 --- a/xmlsecurity/qa/unit/signing/signing.cxx +++ b/xmlsecurity/qa/unit/signing/signing.cxx @@ -132,6 +132,7 @@ void SigningTest::setUp() OUString aTargetDir = m_directories.getURLFromWorkdir( "/CppunitTest/xmlsecurity_signing.test.user/"); osl::File::copy(aSourceDir + "cert8.db", aTargetDir + "cert8.db"); + osl::File::copy(aSourceDir + "key3.db", aTargetDir + "key3.db"); OUString aTargetPath; osl::FileBase::getSystemPathFromFileURL(aTargetDir, aTargetPath); setenv("MOZILLA_CERTIFICATE_FOLDER", aTargetPath.toUtf8().getStr(), 1); @@ -168,20 +169,14 @@ void SigningTest::createCalc(const OUString& rURL) uno::Reference<security::XCertificate> SigningTest::getCertificate(DocumentSignatureManager& rSignatureManager) { + uno::Reference<security::XCertificate> xCertificate; + uno::Reference<xml::crypto::XSecurityEnvironment> xSecurityEnvironment = rSignatureManager.getSecurityEnvironment(); - OUString aCertificate; - { - SvFileStream aStream(m_directories.getURLFromSrc(DATA_DIRECTORY) + "certificate.crt", StreamMode::READ); - OString aLine; - bool bMore = aStream.ReadLine(aLine); - while (bMore) - { - aCertificate += OUString::fromUtf8(aLine); - aCertificate += "\n"; - bMore = aStream.ReadLine(aLine); - } - } - return xSecurityEnvironment->createCertificateFromAscii(aCertificate); + uno::Sequence<uno::Reference<security::XCertificate>> aCertificates = xSecurityEnvironment->getPersonalCertificates(); + if (!aCertificates.hasElements()) + return xCertificate; + + return aCertificates[0]; } void SigningTest::testDescription() @@ -205,7 +200,8 @@ void SigningTest::testDescription() // Then add a signature document. uno::Reference<security::XCertificate> xCertificate = getCertificate(aManager); - CPPUNIT_ASSERT(xCertificate.is()); + if (!xCertificate.is()) + return; OUString aDescription("SigningTest::testDescription"); sal_Int32 nSecurityId; aManager.add(xCertificate, aDescription, nSecurityId, false); @@ -238,7 +234,8 @@ void SigningTest::testOOXMLDescription() // Then add a document signature. uno::Reference<security::XCertificate> xCertificate = getCertificate(aManager); - CPPUNIT_ASSERT(xCertificate.is()); + if (!xCertificate.is()) + return; OUString aDescription("SigningTest::testDescription"); sal_Int32 nSecurityId; aManager.add(xCertificate, aDescription, nSecurityId, false); @@ -271,7 +268,8 @@ void SigningTest::testOOXMLAppend() // Then add a second document signature. uno::Reference<security::XCertificate> xCertificate = getCertificate(aManager); - CPPUNIT_ASSERT(xCertificate.is()); + if (!xCertificate.is()) + return; sal_Int32 nSecurityId; aManager.add(xCertificate, OUString(), nSecurityId, false); @@ -297,7 +295,8 @@ void SigningTest::testOOXMLRemove() // Then remove the last added signature. uno::Reference<security::XCertificate> xCertificate = getCertificate(aManager); - CPPUNIT_ASSERT(xCertificate.is()); + if (!xCertificate.is()) + return; aManager.remove(0); // Read back the signatures and make sure that only purpose1 is left. @@ -327,7 +326,8 @@ void SigningTest::testOOXMLRemoveAll() // Then remove the only signature in the document. uno::Reference<security::XCertificate> xCertificate = getCertificate(aManager); - CPPUNIT_ASSERT(xCertificate.is()); + if (!xCertificate.is()) + return; aManager.remove(0); aManager.read(/*bUseTempStream=*/true); aManager.write(/*bXAdESCompliantIfODF=*/false); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits