diff options
author | Matthew Newhook <matthew@zeroc.com> | 2006-04-25 07:25:18 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2006-04-25 07:25:18 +0000 |
commit | c746007cf0c259ebd13ad4bda358a1a810c87d91 (patch) | |
tree | 904eb34dcaf1e60a83f46825e0358b56aae6f4e8 /cpp/test/Glacier2/ssl/Client.cpp | |
parent | Remove link with IceStorm (diff) | |
download | ice-c746007cf0c259ebd13ad4bda358a1a810c87d91.tar.bz2 ice-c746007cf0c259ebd13ad4bda358a1a810c87d91.tar.xz ice-c746007cf0c259ebd13ad4bda358a1a810c87d91.zip |
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=959, plus added test.
Diffstat (limited to 'cpp/test/Glacier2/ssl/Client.cpp')
-rwxr-xr-x | cpp/test/Glacier2/ssl/Client.cpp | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/cpp/test/Glacier2/ssl/Client.cpp b/cpp/test/Glacier2/ssl/Client.cpp new file mode 100755 index 00000000000..90f9a56cff2 --- /dev/null +++ b/cpp/test/Glacier2/ssl/Client.cpp @@ -0,0 +1,119 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <Ice/Application.h> +#include <Glacier2/Router.h> +#include <TestCommon.h> + +using namespace std; +using namespace Ice; +//using namespace Test; + +class CallbackClient : public Application +{ +public: + + virtual int run(int, char*[]); +}; + +int +main(int argc, char* argv[]) +{ + // + // We must disable connection warnings, because we attempt to ping + // the router before session establishment, as well as after + // session destruction. Both will cause a ConnectionLostException. + // + Ice::PropertiesPtr properties = Ice::getDefaultProperties(argc, argv); + properties->setProperty("Ice.Warn.Connections", "0"); + + CallbackClient app; + return app.main(argc, argv); +} + +int +CallbackClient::run(int argc, char* argv[]) +{ + Glacier2::RouterPrx router = Glacier2::RouterPrx::uncheckedCast( + communicator()->stringToProxy("abc/def:tcp -h 127.0.0.1 -p 12347 -t 10000")); + communicator()->setDefaultRouter(router); + + // + // First try to create a non ssl sessions. + // + cout << "creating non-ssl session with tcp connection... "; + try + { + Glacier2::SessionPrx session = router->createSession("nossl", ""); + router->destroySession(); + } + catch(const Ice::ConnectionLostException&) + { + } + catch(const Glacier2::PermissionDeniedException&) + { + test(false); + } + cout << "ok" << endl; + cout << "creating ssl session with tcp connection... "; + try + { + Glacier2::SessionPrx session = router->createSession("ssl", ""); + test(false); + } + catch(const Glacier2::PermissionDeniedException&) + { + } + cout << "ok" << endl; + + // + // Switch to using the SSL router. First, clear the router. Then + // set a new SSL based router. + // + communicator()->setDefaultRouter(Glacier2::RouterPrx()); + router = Glacier2::RouterPrx::uncheckedCast( + communicator()->stringToProxy("abc/def:ssl -h 127.0.0.1 -p 12348 -t 10000")); + communicator()->setDefaultRouter(router); + + // + // Next try to create a non ssl session. This should succeed. + // + cout << "creating non-ssl session with ssl connection... "; + try + { + Glacier2::SessionPrx session = router->createSession("nossl", ""); + test(false); + } + catch(const Glacier2::PermissionDeniedException&) + { + } + cout << "ok" << endl; + + cout << "creating ssl session with ssl connection... "; + try + { + Glacier2::SessionPrx session = router->createSession("ssl", ""); + router->destroySession(); + } + catch(const Ice::ConnectionLostException&) + { + } + catch(const Glacier2::PermissionDeniedException&) + { + test(false); + } + cout << "ok" << endl; + + communicator()->setDefaultRouter(0); + Glacier2::AdminPrx admin = Glacier2::AdminPrx::checkedCast( + communicator()->stringToProxy("ABC/DEF:tcp -h 127.0.0.1 -p 12349 -t 10000")); + admin->shutdown(); + + return EXIT_SUCCESS; +} |