summaryrefslogtreecommitdiff
path: root/orbsvcs/tests/Security/Bug_1107_Regression/client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'orbsvcs/tests/Security/Bug_1107_Regression/client.cpp')
-rw-r--r--orbsvcs/tests/Security/Bug_1107_Regression/client.cpp84
1 files changed, 48 insertions, 36 deletions
diff --git a/orbsvcs/tests/Security/Bug_1107_Regression/client.cpp b/orbsvcs/tests/Security/Bug_1107_Regression/client.cpp
index 49e36cbd76e..6ac9c87c891 100644
--- a/orbsvcs/tests/Security/Bug_1107_Regression/client.cpp
+++ b/orbsvcs/tests/Security/Bug_1107_Regression/client.cpp
@@ -1,4 +1,5 @@
// -*- C++ -*-
+// $Id$
#include "ace/Get_Opt.h"
@@ -6,14 +7,10 @@
#include "orbsvcs/SecurityC.h"
#include "ace/SString.h"
-ACE_RCSID (Bug_1107_Regression,
- client,
- "$Id$")
-
const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
const char *cert_file = "cacert.pem";
-void
+int
insecure_invocation_test (CORBA::ORB_ptr orb,
CORBA::Object_ptr obj)
{
@@ -49,7 +46,7 @@ insecure_invocation_test (CORBA::ORB_ptr orb,
"nil.\n",
ior));
- throw CORBA::INTERNAL ();
+ return 1;
}
try
@@ -64,17 +61,17 @@ insecure_invocation_test (CORBA::ORB_ptr orb,
"(%P|%t) Received CORBA::NO_PERMISSION from "
"server, as expected.\n"));
- return;
+ return 0;
}
ACE_ERROR ((LM_ERROR,
"(%P|%t) ERROR: CORBA::NO_PERMISSION was not thrown.\n"
"(%P|%t) ERROR: It should have been thrown.\n"));
- throw CORBA::INTERNAL ();
+ return 1;
}
-void
+int
secure_invocation_test (CORBA::Object_ptr object)
{
Foo::Bar_var server =
@@ -87,13 +84,15 @@ secure_invocation_test (CORBA::Object_ptr object)
"nil.\n",
ior));
- throw CORBA::INTERNAL ();
+ return 1;
}
// This invocation should return successfully.
server->baz ();
server->shutdown ();
+
+ return 0;
}
int
@@ -114,18 +113,19 @@ parse_args (int argc, ACE_TCHAR *argv[])
default:
ACE_ERROR_RETURN ((LM_ERROR,
"Usage: %s "
- "-k <ior> "
+ "-k <ior>"
"\n",
argv [0]),
-1);
}
- // Indicates sucessful parsing of the command line
+ // Indicates successful parsing of the command line
return 0;
}
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
+ int status = 0;
bool set_cert_file = true;
try
{
@@ -165,42 +165,54 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
// then result in a CORBA::NO_PERMISSION exception.
//
// The server is not shutdown by this test.
- insecure_invocation_test (orb.in (), object.in ());
+ status = insecure_invocation_test (orb.in (), object.in ());
+ ACE_DEBUG ((LM_DEBUG,
+ "insecure_invocation_test returned <%d>\n",
+ status));
}
// This test uses the default secure SSLIOP settings to securely
// invoke a method on the server. No exception should occur.
//
// The server *is* shutdown by this test.
- if (!set_cert_file)
- ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR);
- secure_invocation_test (object.in ());
- if (!set_cert_file)
- ACE_LOG_MSG->set_flags (ACE_Log_Msg::STDERR);
+ try
+ {
+ status = secure_invocation_test (object.in ());
+ ACE_DEBUG ((LM_DEBUG,
+ "secure_invocation_test returned <%d>\n",
+ status));
+ }
+ catch (CORBA::Exception const &ex)
+ {
+ if (set_cert_file)
+ {
+ ex._tao_print_exception ("Caught unexpected exception "
+ "(probable failure):");
+ status = 1;
+ }
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Caught an exception as expected due "
+ "to the SSL_CERT_FILE environment "
+ "variable not being set.\n"));
+ }
+ }
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
- ACE_LOG_MSG->set_flags (ACE_Log_Msg::STDERR);
- if (set_cert_file)
- {
- ex._tao_print_exception ("Caught unexpected exception "
- "(probable failure):");
- return 1;
- }
- else
- {
- ACE_DEBUG ((LM_DEBUG, "Caught an excep. as expected due "
- "to the SSL_CERT_FILE environment "
- "variable\nnot being set.\n"));
- return 0;
- }
+ ex._tao_print_exception ("Exception in main:");
+ return 1;
}
- ACE_DEBUG ((LM_DEBUG,
- "\n"
- "Bug_1107_Regression test passed.\n"));
+ if (status == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "\n"
+ "Bug_1107_Regression test passed.\n"));
+ }
- return 0;
+ return status;
}