summaryrefslogtreecommitdiff
path: root/xmlsecurity/qa
diff options
context:
space:
mode:
authorTobias Krause <tkr@openoffice.org>2011-02-14 11:58:31 +0100
committerTobias Krause <tkr@openoffice.org>2011-02-14 11:58:31 +0100
commitbd9e36ca495160994d9f2cd786b3abc44c3859a1 (patch)
treea46a326d64cf8e1aa9cd8513f03775659e828d5a /xmlsecurity/qa
parent4b0358a8edfd003eaf054e1b333661b09213f708 (diff)
tkr38: #i112307# fix nss test run and clean up sources
Diffstat (limited to 'xmlsecurity/qa')
-rw-r--r--xmlsecurity/qa/certext/SanCertExt.cxx214
-rw-r--r--xmlsecurity/qa/certext/makefile.mk130
2 files changed, 146 insertions, 198 deletions
diff --git a/xmlsecurity/qa/certext/SanCertExt.cxx b/xmlsecurity/qa/certext/SanCertExt.cxx
index 6110f0f7645e..11d3fa62d5a5 100644
--- a/xmlsecurity/qa/certext/SanCertExt.cxx
+++ b/xmlsecurity/qa/certext/SanCertExt.cxx
@@ -27,15 +27,18 @@
#include "precompiled_xmlsecurity.hxx"
#include "sal/config.h"
+#include "test/officeconnection.hxx"
-#include "../../source/xmlsec/mscrypt/securityenvironment_mscryptimpl.hxx"
#include <com/sun/star/security/XSanExtension.hpp>
#include <com/sun/star/security/ExtAltNameType.hpp>
#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
+#include <com/sun/star/xml/crypto/XSEInitializer.hpp>
#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
#include <com/sun/star/security/XCertificate.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/uno/Reference.hxx"
#include "cppuhelper/bootstrap.hxx"
#include "cppunit/TestAssert.h"
@@ -49,49 +52,138 @@
#include <neon/ne_ssl.h>
using namespace com::sun::star;
-using ::com::sun::star::lang::XMultiServiceFactory;
#define OID_SUBJECT_ALTERNATIVE_NAME "2.5.29.17"
+#define SEINITIALIZER_COMPONENT "com.sun.star.xml.crypto.SEInitializer"
+
namespace {
-class Test: public CppUnit::TestFixture {
+ class Test: public CppUnit::TestFixture {
-private:
+ private:
+ static uno::Sequence< security::CertAltNameEntry > altNames;
+ static bool runOnce;
- static uno::Sequence< security::CertAltNameEntry > altNames;
+ uno::Reference< xml::crypto::XSecurityEnvironment > initUno();
+ void init();
+ rtl::OString getB64CertFromFile(const char filename[]);
+ test::OfficeConnection connection_;
- void init(){
- if (altNames.getLength() == 0){
- cppu::defaultBootstrap_InitialComponentContext();
- ne_ssl_certificate* cert = ne_ssl_cert_read("User_35_Root_11.crt");
- char* certExportB64 = ne_ssl_cert_export(cert);
+ public:
- uno::Reference< xml::crypto::XSecurityEnvironment > xSecurityEnv( new SecurityEnvironment_MSCryptImpl( uno::Reference< XMultiServiceFactory >() ) );
+ Test();
- uno::Reference< security::XCertificate > xCert = xSecurityEnv->createCertificateFromAscii(
- rtl::OStringToOUString( certExportB64, RTL_TEXTENCODING_ASCII_US ) );
+ ~Test();
- uno::Sequence< uno::Reference< security::XCertificateExtension > > extensions = xCert->getExtensions();
- for (sal_Int32 i = 0 ; i < extensions.getLength(); i++)
- {
- uno::Reference< security::XCertificateExtension >element = extensions[i];
+ virtual void setUp();
- rtl::OString aId ( (const sal_Char *)element->getExtensionId().getArray(), element->getExtensionId().getLength());
- if (aId.equals(OID_SUBJECT_ALTERNATIVE_NAME))
- {
- uno::Reference< security::XSanExtension > sanExtension ( element, uno::UNO_QUERY );
- altNames = sanExtension->getAlternativeNames();
- break;
- }
+ virtual void tearDown();
+
+ void test_Others();
+
+ void test_RFC822();
+
+ void test_DNS();
+
+ void test_Direcory();
+
+ void test_URI();
+
+ void test_IP();
+
+ void test_RID();
+
+ void test_EDI();
+
+ void test_X400();
+
+ CPPUNIT_TEST_SUITE(Test);
+ CPPUNIT_TEST(test_Others);
+ CPPUNIT_TEST(test_RFC822);
+ CPPUNIT_TEST(test_DNS);
+ CPPUNIT_TEST(test_Direcory);
+ CPPUNIT_TEST(test_URI);
+ CPPUNIT_TEST(test_IP);
+ CPPUNIT_TEST(test_RID);
+ CPPUNIT_TEST(test_EDI);
+ CPPUNIT_TEST(test_X400);
+ CPPUNIT_TEST_SUITE_END();
+ };
+
+ uno::Sequence< security::CertAltNameEntry > Test::altNames;
+ bool Test::runOnce = false;
+
+ CPPUNIT_TEST_SUITE_REGISTRATION(Test);
+
+ Test::Test()
+ {
+ if (runOnce)
+ return;
+ runOnce = true;
+ connection_.setUp();
+ init();
+ }
+
+ Test::~Test()
+ {
+ if (runOnce)
+ {
+ connection_.tearDown();
+ runOnce = false;
+ }
+ }
+
+
+ uno::Reference< xml::crypto::XSecurityEnvironment > Test::initUno()
+ {
+ uno::Reference< uno::XComponentContext > context(connection_.getComponentContext(), uno::UNO_QUERY_THROW);
+ uno::Reference< lang::XMultiServiceFactory > factory(context->getServiceManager(), uno::UNO_QUERY_THROW);
+ uno::Reference< xml::crypto::XSEInitializer > xSEInitializer(factory->createInstance(
+ rtl::OUString::createFromAscii( SEINITIALIZER_COMPONENT )), uno::UNO_QUERY_THROW);
+ uno::Reference< xml::crypto::XXMLSecurityContext > xSecurityContext(
+ xSEInitializer->createSecurityContext(rtl::OUString()));
+ return xSecurityContext->getSecurityEnvironment();
+ }
+
+
+ void Test::init()
+ {
+ uno::Reference< xml::crypto::XSecurityEnvironment > xSecurityEnv = initUno();
+ rtl::OString b64Cert(getB64CertFromFile("User_35_Root_11.crt"));
+ uno::Reference< security::XCertificate > xCert = xSecurityEnv->createCertificateFromAscii(
+ rtl::OStringToOUString( b64Cert, RTL_TEXTENCODING_ASCII_US ) );
+ uno::Sequence< uno::Reference< security::XCertificateExtension > > extensions = xCert->getExtensions();
+ for (sal_Int32 i = 0 ; i < extensions.getLength(); i++)
+ {
+ uno::Reference< security::XCertificateExtension >element = extensions[i];
+ rtl::OString aId ( (const sal_Char *)element->getExtensionId().getArray(), element->getExtensionId().getLength());
+ if (aId.equals(OID_SUBJECT_ALTERNATIVE_NAME))
+ {
+ uno::Reference< security::XSanExtension > sanExtension ( element, uno::UNO_QUERY );
+ altNames = sanExtension->getAlternativeNames();
+ break;
}
}
+ }
+ rtl::OString Test::getB64CertFromFile(const char filename[])
+ {
+ ne_ssl_certificate* cert = ne_ssl_cert_read(filename);
+ char* certExportB64 = ne_ssl_cert_export(cert);
+ rtl::OString certB64( certExportB64 );
+ return certB64;
}
-public:
- void test_Others() {
- init();
+
+ void Test::setUp() {
+ }
+
+ void Test::tearDown() {
+ }
+
+ void Test::test_Others() {
+ CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( altNames.getLength() > 0 ) );
for(int n = 1; n < altNames.getLength(); n++)
{
if (altNames[n].Type == security::ExtAltNameType_OTHER_NAME)
@@ -99,10 +191,7 @@ public:
::com::sun::star::beans::NamedValue otherNameProp;
if (altNames[n].Value >>= otherNameProp)
{
- //Name
CPPUNIT_ASSERT_EQUAL( rtl::OUString::createFromAscii("1.2.3.4"), otherNameProp.Name);
-
- //Value
uno::Sequence< sal_Int8 > ipAddress;
otherNameProp.Value >>= ipAddress;
CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( ipAddress.getLength() > 0 ) );
@@ -111,117 +200,82 @@ public:
}
}
- void test_RFC822() {
- init();
+ void Test::test_RFC822() {
+ CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( altNames.getLength() > 0 ) );
for(int n = 1; n < altNames.getLength(); n++)
{
if (altNames[n].Type == security::ExtAltNameType_RFC822_NAME)
{
rtl::OUString value;
altNames[n].Value >>= value;
- //Value
CPPUNIT_ASSERT_EQUAL( rtl::OUString::createFromAscii("my@other.address"), value);
}
}
}
- void test_DNS() {
- init();
+ void Test::test_DNS() {
+ CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( altNames.getLength() > 0 ) );
for(int n = 1; n < altNames.getLength(); n++)
{
if (altNames[n].Type == security::ExtAltNameType_DNS_NAME)
{
rtl::OUString value;
altNames[n].Value >>= value;
- //Value
CPPUNIT_ASSERT_EQUAL( rtl::OUString::createFromAscii("alt.openoffice.org"), value);
}
}
}
- void test_Direcory() {
- init();
- for(int n = 1; n < altNames.getLength(); n++)
- {
- if (altNames[n].Type == security::ExtAltNameType_DIRECTORY_NAME)
- {
- uno::Sequence< sal_Int8 > value;
- altNames[n].Value >>= value;
- //Value
- CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( value.getLength() > 0 ) );
- }
- }
+ void Test::test_Direcory() {
+ // Not implemented
}
- void test_URI() {
- init();
+ void Test::test_URI() {
+ CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( altNames.getLength() > 0 ) );
for(int n = 1; n < altNames.getLength(); n++)
{
if (altNames[n].Type == security::ExtAltNameType_URL)
{
rtl::OUString value;
altNames[n].Value >>= value;
- //Value
CPPUNIT_ASSERT_EQUAL( rtl::OUString::createFromAscii("http://my.url.here/"), value);
}
}
}
- void test_IP() {
- init();
+ void Test::test_IP() {
+ CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( altNames.getLength() > 0 ) );
for(int n = 1; n < altNames.getLength(); n++)
{
if (altNames[n].Type == security::ExtAltNameType_IP_ADDRESS)
{
uno::Sequence< sal_Int8 > ipAddress;
altNames[n].Value >>= ipAddress;
- //Value
CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( ipAddress.getLength() > 0 ) );
}
}
}
- void test_RID() {
- init();
+ void Test::test_RID() {
+ CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( altNames.getLength() > 0 ) );
for(int n = 1; n < altNames.getLength(); n++)
{
if (altNames[n].Type == security::ExtAltNameType_REGISTERED_ID)
{
rtl::OUString value;
altNames[n].Value >>= value;
- //Value
- CPPUNIT_ASSERT_EQUAL( rtl::OUString::createFromAscii("1.2.3.4"), value);
+ CPPUNIT_ASSERT( rtl::OUString::createFromAscii("1.2.3.4").equals(value));
}
}
-
}
- void test_EDI() {
+ void Test::test_EDI() {
// Not implemented
}
- void test_X400() {
+ void Test::test_X400() {
// Not implemented
}
-
- CPPUNIT_TEST_SUITE(Test);
- CPPUNIT_TEST(test_Others);
- CPPUNIT_TEST(test_RFC822);
- CPPUNIT_TEST(test_DNS);
- CPPUNIT_TEST(test_Direcory);
- CPPUNIT_TEST(test_URI);
- CPPUNIT_TEST(test_IP);
- CPPUNIT_TEST(test_RID);
- CPPUNIT_TEST(test_EDI);
- CPPUNIT_TEST(test_X400);
- CPPUNIT_TEST_SUITE_END();
-};
-
-uno::Sequence< security::CertAltNameEntry > Test::altNames;
-
-CPPUNIT_TEST_SUITE_REGISTRATION(Test);
-
}
-
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/xmlsecurity/qa/certext/makefile.mk b/xmlsecurity/qa/certext/makefile.mk
index 36ebb954914c..8cf90b4b4750 100644
--- a/xmlsecurity/qa/certext/makefile.mk
+++ b/xmlsecurity/qa/certext/makefile.mk
@@ -24,6 +24,9 @@
# for a copy of the LGPLv3 License.
#
#***********************************************************************/
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
PRJ = ../..
PRJNAME = xmlsecurity
@@ -31,85 +34,9 @@ TARGET = qa_certext
ENABLE_EXCEPTIONS = TRUE
-.IF "$(OS)" == "WNT"
-my_file = file:///
-.ELSE
-my_file = file://
-.END
-
-
.INCLUDE: settings.mk
.INCLUDE : $(PRJ)$/util$/target.pmk
-.IF "$(SYSTEM_LIBXML)" == "YES"
-CFLAGS+=-DSYSTEM_LIBXML $(LIBXML_CFLAGS)
-.ENDIF
-
-.IF "$(CRYPTO_ENGINE)" == "nss"
-
-.IF "$(WITH_MOZILLA)" == "NO" || "$(ENABLE_NSS_MODULE)"!="YES"
-.IF "$(SYSTEM_MOZILLA)" != "YES"
-@all:
- @echo "No mozilla -> no nss -> no libxmlsec -> no xmlsecurity/nss"
-.ENDIF
-.ENDIF
-
-.IF "$(SYSTEM_MOZILLA)" != "YES"
-MOZ_INC = $(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT)$/mozilla
-NSS_INC = $(MOZ_INC)$/nss
-NSPR_INC = $(MOZ_INC)$/nspr
-.ELSE
-# MOZ_INC already defined from environment
-NSS_INC = $(MOZ_NSS_CFLAGS)
-NSPR_INC = $(MOZ_INC)$/nspr
-.ENDIF
-
-.IF "$(GUI)"=="UNX"
-.IF "$(COMNAME)"=="sunpro5"
-CFLAGS += -features=tmplife
-#This flag is needed to build mozilla 1.7 code
-.ENDIF # "$(COMNAME)"=="sunpro5"
-.ENDIF
-
-.IF "$(GUI)" == "WNT"
-.IF "$(DBG_LEVEL)" == "0"
-INCPRE += \
--I$(MOZ_INC)$/profile \
--I$(MOZ_INC)$/string \
--I$(MOZ_INC)$/embed_base
-CFLAGS += -GR- -W3 -Gy -MD -UDEBUG
-.ELSE
-INCPRE += \
--I$(MOZ_INC)$/profile \
--I$(MOZ_INC)$/string \
--I$(MOZ_INC)$/embed_base
-CFLAGS += -Zi -GR- -W3 -Gy -MDd -UNDEBUG
-.ENDIF
-.ENDIF
-.IF "$(GUI)" == "UNX"
-INCPOST += \
-$(MOZ_INC)$/profile \
--I$(MOZ_INC)$/string \
--I$(MOZ_INC)$/embed_base
-.ENDIF
-
-CDEFS += -DXMLSEC_CRYPTO_NSS -DXMLSEC_NO_XSLT
-
-SOLARINC += \
- -I$(MOZ_INC) \
--I$(NSPR_INC) \
--I$(PRJ)$/source$/xmlsec
-
-.IF "$(SYSTEM_MOZILLA)" == "YES"
-SOLARINC += -DSYSTEM_MOZILLA $(NSS_INC)
-.ELSE
-SOLARINC += -I$(NSS_INC)
-.ENDIF
-.ENDIF
-
-
-
-
CFLAGSCXX += $(CPPUNIT_CFLAGS)
SHL1IMPLIB = i$(SHL1TARGET)
@@ -123,44 +50,8 @@ SHL1STDLIBS = $(CPPUNITLIB) \
$(CPPUHELPERLIB) \
$(SVLLIB) \
$(TOOLSLIB) \
- $(COMPHELPERLIB)
-
-
-
-.IF "$(OS)"=="SOLARIS"
-SHL1STDLIBS +=-ldl
-.ENDIF
-
-.IF "$(SYSTEM_MOZILLA)" == "YES"
-.IF "$(NSPR_LIB)" != ""
-SHL1STDLIBS += $(NSPR_LIB)
-.ENDIF
-.IF "$(NSS_LIB)" != ""
-SHL1STDLIBS += $(NSS_LIB)
-.ENDIF
-.ENDIF
-
-.IF "$(CRYPTO_ENGINE)" == "mscrypto"
-SHL1STDLIBS+= $(MSCRYPTOLIBS)
-.ELSE
-CDEFS += -DNSS_ENGINE
-SHL1STDLIBS+= $(NSSCRYPTOLIBS)
-.ENDIF
-
-.IF "$(ENABLE_NSS_MODULE)"=="YES" || "$(SYSTEM_MOZILLA)" == "YES"
-
-SHL1LIBS= \
- $(SLB)$/xs_comm.lib
-
-.IF "$(CRYPTO_ENGINE)" == "mscrypto"
-SHL1LIBS += \
- $(SLB)$/xs_mscrypt.lib
-.ELSE
-SHL1LIBS += \
- $(SLB)$/xs_nss.lib
-.ENDIF
-
-.ENDIF
+ $(COMPHELPERLIB) \
+ $(TESTLIB)
SHL1TARGET = qa_CertExt
SHL1VERSIONMAP = $(PRJ)/qa/certext/export.map
@@ -169,9 +60,12 @@ DEF1NAME = $(SHL1TARGET)
SLOFILES = $(SLO)/SanCertExt.obj
.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : cpptest
+
+cpptest : $(SHL1TARGETN)
-ALLTAR : test
+CPPTEST_LIBRARY = $(SHL1TARGETN)
-test .PHONY : $(SHL1TARGETN)
- $(CPPUNITTESTER) $(SHL1TARGETN) \
- -env:UNO_TYPES=$(my_file)$(SOLARBINDIR)/types.rdb
+.END \ No newline at end of file