summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorAnthony Neal <aneal@zeroc.com>2002-03-25 16:26:26 +0000
committerAnthony Neal <aneal@zeroc.com>2002-03-25 16:26:26 +0000
commit9eee89455e844cddcfe825cc32e62e60320b3227 (patch)
tree640972a987e99f6291cd2e5f71bad0f35cd91af1 /cpp
parentUpdates as part of a rename of configuration.cpp to Configuration.cpp. (diff)
downloadice-9eee89455e844cddcfe825cc32e62e60320b3227.tar.bz2
ice-9eee89455e844cddcfe825cc32e62e60320b3227.tar.xz
ice-9eee89455e844cddcfe825cc32e62e60320b3227.zip
Removed as part of a rename.
Diffstat (limited to 'cpp')
-rw-r--r--cpp/test/IceSSL/configuration/configuration.cpp222
-rw-r--r--cpp/test/IceSSL/loadPEM/loadPEM.cpp248
2 files changed, 0 insertions, 470 deletions
diff --git a/cpp/test/IceSSL/configuration/configuration.cpp b/cpp/test/IceSSL/configuration/configuration.cpp
deleted file mode 100644
index 3707d31d85d..00000000000
--- a/cpp/test/IceSSL/configuration/configuration.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2002
-// MutableRealms, Inc.
-// Huntsville, AL, USA
-//
-// All Rights Reserved
-//
-// **********************************************************************
-
-#include <Ice/Ice.h>
-#include <TestCommon.h>
-#include <Ice/SslException.h>
-#include <Ice/System.h>
-
-// Note: This test must have a valid Ice.SSL.Client.CertPath
-// and Ice.SSL.Server.CertPath specified.
-
-using namespace std;
-using namespace Ice;
-
-void testContextWithConfig(const Ice::CommunicatorPtr&, IceSSL::ContextType, const std::string&,
- const std::string&, bool expectFailure = true);
-
-void
-testContextNoConfig(const Ice::CommunicatorPtr& communicator, IceSSL::ContextType contextType)
-{
- testContextWithConfig(communicator, contextType, "", "");
-}
-
-void
-testContextWithConfig(const Ice::CommunicatorPtr& communicator,
- IceSSL::ContextType contextType,
- const std::string& clientFile,
- const std::string& serverFile,
- bool expectFailure)
-{
- PropertiesPtr properties = communicator->getProperties();
- IceSSL::SystemPtr sslSystem = communicator->getSslSystem();
-
- std::string contextString;
-
- std::string clientPropertyString = "Ice.SSL.Client.Config";
- std::string serverPropertyString = "Ice.SSL.Server.Config";
-
- switch (contextType)
- {
- case IceSSL::Client:
- {
- contextString = "Client";
- break;
- }
-
- case IceSSL::Server:
- {
- contextString = "Server";
- break;
- }
-
- case IceSSL::ClientServer:
- {
- contextString = "ClientServer";
- break;
- }
- }
-
- std::string configFileDesc = "";
-
- if (!clientFile.empty() && !serverFile.empty())
- {
- configFileDesc = "client and server configuration files";
- }
- else if (!clientFile.empty())
- {
- configFileDesc = "client configuration file";
- }
- else if (!serverFile.empty())
- {
- configFileDesc = "server configuration file";
- }
- else
- {
- configFileDesc = "no configuration file";
- }
-
- std::cout << contextString << " with " << configFileDesc << "... " << std::flush;
-
- try
- {
- properties->setProperty(clientPropertyString, clientFile);
- properties->setProperty(serverPropertyString, serverFile);
- sslSystem->configure(contextType);
-
- if (expectFailure)
- {
- test(false);
- }
- else
- {
- std::cout << "ok" << std::endl;
- }
- }
- catch (const IceSSL::ConfigurationLoadingException&)
- {
- //
- // Depending on the context type, and if we supplied
- // a configuration file, this might be a valid response.
- //
-
- switch (contextType)
- {
- case IceSSL::Client:
- {
- if (clientFile.empty())
- {
- std::cout << "ok" << std::endl;
- }
- else
- {
- test(false);
- }
- break;
- }
-
- case IceSSL::Server:
- {
- if (serverFile.empty())
- {
- std::cout << "ok" << std::endl;
- }
- else
- {
- test(false);
- }
- break;
- }
-
- case IceSSL::ClientServer:
- {
- if (clientFile.empty() || serverFile.empty())
- {
- std::cout << "ok" << std::endl;
- }
- else
- {
- test(false);
- }
- break;
- }
- }
- }
- catch (const LocalException&)
- {
- //
- // Any other exception is bad.
- //
-
- test(false);
- }
- catch (...)
- {
- //
- // Unknown exceptions are always bad.
- //
-
- test(false);
- }
-}
-
-int
-run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
-{
- // Testing Client context.
- testContextNoConfig(communicator, IceSSL::Client);
- testContextWithConfig(communicator, IceSSL::Client,"client_sslconfig.xml","", false);
-
- // Testing Server context.
- testContextNoConfig(communicator, IceSSL::Server);
- testContextWithConfig(communicator, IceSSL::Server,"","server_sslconfig.xml", false);
-
- // Testing ClientServer context.
- testContextNoConfig(communicator, IceSSL::ClientServer);
- testContextWithConfig(communicator, IceSSL::ClientServer, "client_sslconfig.xml", "");
- testContextWithConfig(communicator, IceSSL::ClientServer, "", "server_sslconfig.xml");
- testContextWithConfig(communicator, IceSSL::ClientServer, "client_sslconfig.xml", "server_sslconfig.xml", false);
- testContextWithConfig(communicator, IceSSL::ClientServer, "sslconfig.xml", "sslconfig.xml", false);
-
- return EXIT_SUCCESS;
-}
-
-int
-main(int argc, char* argv[])
-{
- int status;
- Ice::CommunicatorPtr communicator;
-
- try
- {
- communicator = Ice::initialize(argc, argv);
- status = run(argc, argv, communicator);
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
-
- if (communicator)
- {
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
- }
-
- return status;
-}
diff --git a/cpp/test/IceSSL/loadPEM/loadPEM.cpp b/cpp/test/IceSSL/loadPEM/loadPEM.cpp
deleted file mode 100644
index 6995edd53ab..00000000000
--- a/cpp/test/IceSSL/loadPEM/loadPEM.cpp
+++ /dev/null
@@ -1,248 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2002
-// MutableRealms, Inc.
-// Huntsville, AL, USA
-//
-// All Rights Reserved
-//
-// **********************************************************************
-
-#include <Ice/Ice.h>
-#include <TestCommon.h>
-#include <Ice/SslException.h>
-#include <Ice/System.h>
-
-using namespace std;
-using namespace Ice;
-
-void
-testExpectCertificateAndPrivateKeyLoadException(const Ice::CommunicatorPtr& communicator,
- const std::string& configFile)
-{
- PropertiesPtr properties = communicator->getProperties();
- IceSSL::SystemPtr system = communicator->getSslSystem();
-
- try
- {
- properties->setProperty("Ice.SSL.Client.Config", configFile);
- system->configure(IceSSL::Client);
- test(false);
- }
- catch (const IceSSL::OpenSSL::CertificateLoadException&)
- {
- std::cout << "ok" << std::endl;
- }
- catch (const IceSSL::OpenSSL::PrivateKeyLoadException&)
- {
- std::cout << "ok" << std::endl;
- }
- catch (const LocalException&)
- {
- //
- // Any other exception is bad.
- //
-
- test(false);
- }
- catch (...)
- {
- //
- // Unknown exceptions are always bad.
- //
-
- test(false);
- }
-}
-
-void
-testExpectPrivateKeyLoadException(const Ice::CommunicatorPtr& communicator, const std::string& configFile)
-{
- PropertiesPtr properties = communicator->getProperties();
- IceSSL::SystemPtr system = communicator->getSslSystem();
-
- try
- {
- properties->setProperty("Ice.SSL.Client.Config", configFile);
- system->configure(IceSSL::Client);
- test(false);
- }
- catch (const IceSSL::OpenSSL::PrivateKeyLoadException&)
- {
- std::cout << "ok" << std::endl;
- }
- catch (const LocalException&)
- {
- //
- // Any other exception is bad.
- //
-
- test(false);
- }
- catch (...)
- {
- //
- // Unknown exceptions are always bad.
- //
-
- test(false);
- }
-}
-
-void
-testExpectCertificateLoadException(const Ice::CommunicatorPtr& communicator, const std::string& configFile)
-{
- PropertiesPtr properties = communicator->getProperties();
- IceSSL::SystemPtr system = communicator->getSslSystem();
-
- try
- {
- properties->setProperty("Ice.SSL.Client.Config", configFile);
- system->configure(IceSSL::Client);
- test(false);
- }
- catch (const IceSSL::OpenSSL::CertificateLoadException&)
- {
- std::cout << "ok" << std::endl;
- }
- catch (const LocalException&)
- {
- //
- // Any other exception is bad.
- //
-
- test(false);
- }
- catch (...)
- {
- //
- // Unknown exceptions are always bad.
- //
-
- test(false);
- }
-}
-
-void
-testExpectCertificateKeyMatchException(const Ice::CommunicatorPtr& communicator, const std::string& configFile)
-{
- PropertiesPtr properties = communicator->getProperties();
- IceSSL::SystemPtr system = communicator->getSslSystem();
-
- try
- {
- properties->setProperty("Ice.SSL.Client.Config", configFile);
- system->configure(IceSSL::Client);
- test(false);
- }
- catch (const IceSSL::OpenSSL::CertificateKeyMatchException&)
- {
- std::cout << "ok" << std::endl;
- }
- catch (const LocalException&)
- {
- //
- // Any other exception is bad.
- //
-
- test(false);
- }
- catch (...)
- {
- //
- // Unknown exceptions are always bad.
- //
-
- test(false);
- }
-}
-
-void
-testNoException(const Ice::CommunicatorPtr& communicator, const std::string& configFile)
-{
- PropertiesPtr properties = communicator->getProperties();
- IceSSL::SystemPtr system = communicator->getSslSystem();
-
- try
- {
- properties->setProperty("Ice.SSL.Client.Config", configFile);
- system->configure(IceSSL::Client);
- std::cout << "ok" << std::endl;
- }
- catch (const LocalException&)
- {
- //
- // Any other exception is bad.
- //
-
- test(false);
- }
- catch (...)
- {
- //
- // Unknown exceptions are always bad.
- //
-
- test(false);
- }
-}
-
-int
-run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
-{
- PropertiesPtr properties = communicator->getProperties();
- properties->setProperty("Ice.SSL.Client.CertPath", "../certs");
-
- std::cout << "Bad private key and certificate... " << std::flush;
- testExpectCertificateAndPrivateKeyLoadException(communicator, "sslconfig_1.xml");
-
- std::cout << "Bad private key and good certificate 1... " << std::flush;
- testExpectPrivateKeyLoadException(communicator, "sslconfig_2.xml");
-
- std::cout << "Good private key 1 and bad certificate... " << std::flush;
- testExpectCertificateLoadException(communicator, "sslconfig_3.xml");
-
- std::cout << "Good private key 1 and good certificate 2, mismatched... " << std::flush;
- testExpectCertificateKeyMatchException(communicator, "sslconfig_4.xml");
-
- std::cout << "Good private key 2 and good certificate 1, mismatched (again)... " << std::flush;
- testExpectCertificateKeyMatchException(communicator, "sslconfig_5.xml");
-
- std::cout << "Good matched private key and certificate... " << std::flush;
- testNoException(communicator, "sslconfig_6.xml");
-
- return EXIT_SUCCESS;
-}
-
-int
-main(int argc, char* argv[])
-{
- int status;
- Ice::CommunicatorPtr communicator;
-
- try
- {
- communicator = Ice::initialize(argc, argv);
- status = run(argc, argv, communicator);
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
-
- if (communicator)
- {
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
- }
-
- return status;
-}