From 0c9171761b355ac5446da5a56b6dfa9804b495d3 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Thu, 16 Dec 2004 17:33:15 +0000 Subject: [PATCH] removed session ID check from getSchedulerTime method --- .../scheduler/src/GetSchedulerTimeMethod.cxx | 25 +------ .../scheduler/src/GetSchedulerTimeMethod.h | 20 ++--- .../src/GetSchedulerTimeMethodTest.cxx | 75 +------------------ .../src/GetSchedulerTimeMethodTest.h | 33 +------- .../scheduler/src/RpcGetSchedulerTimeTest.cxx | 54 +------------ .../scheduler/src/RpcGetSchedulerTimeTest.h | 17 +---- 6 files changed, 18 insertions(+), 206 deletions(-) diff --git a/livesupport/products/scheduler/src/GetSchedulerTimeMethod.cxx b/livesupport/products/scheduler/src/GetSchedulerTimeMethod.cxx index 99689056a..21a236489 100644 --- a/livesupport/products/scheduler/src/GetSchedulerTimeMethod.cxx +++ b/livesupport/products/scheduler/src/GetSchedulerTimeMethod.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GetSchedulerTimeMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -100,28 +100,9 @@ GetSchedulerTimeMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) throw (XmlRpc::XmlRpcException) { - if (!rootParameter.valid() || rootParameter.size() != 1) { - XmlRpcTools::markError(errorId+1, "invalid argument format", - returnValue); - return; - } - XmlRpc::XmlRpcValue parameters = rootParameter[0]; - - Ptr::Ref sessionId; - try{ - sessionId = XmlRpcTools::extractSessionId(parameters); - } - catch (std::invalid_argument &e) { - XmlRpcTools::markError(errorId+20, - "missing session ID argument", - returnValue); - return; - } - - // TODO: check whether the session ID is valid - - Ptr::Ref schedulerPTime = TimeConversion::now(); + Ptr::Ref schedulerPTime = TimeConversion::now(); struct tm schedulerTime; TimeConversion::ptimeToTm(schedulerPTime, schedulerTime); returnValue["schedulerTime"] = & schedulerTime; } + diff --git a/livesupport/products/scheduler/src/GetSchedulerTimeMethod.h b/livesupport/products/scheduler/src/GetSchedulerTimeMethod.h index 25b4139ba..39181f377 100644 --- a/livesupport/products/scheduler/src/GetSchedulerTimeMethod.h +++ b/livesupport/products/scheduler/src/GetSchedulerTimeMethod.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GetSchedulerTimeMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -75,12 +75,7 @@ using namespace LiveSupport::Core; * The name of the method when called through XML-RPC is * "getSchedulerTime". * - * The expected parameter is an XML-RPC structure, with the following - * members: - *
    - *
  • sessionId - string - the session ID obtained via the login() - * method of the authentication client
  • - *
+ * No input parameters are expected. * * The XML-RPC function returns an XML-RPC structure containing a single * date/time field: @@ -88,15 +83,10 @@ using namespace LiveSupport::Core; *
  • schedulerTime - date/time - the local time on the scheduler
  • * * - * In case of an error, a standard XML-RPC fault response is generated, - * and a { faultCode, faultString } structure is returned. The - * possible errors are: - *
      - *
    • 1901 - invalid argument format
    • - *
    • 1920 - missing session ID argument
    • - *
    + * This method does not generate any fault responses. + * * @author $Author: fgerlits $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ class GetSchedulerTimeMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/GetSchedulerTimeMethodTest.cxx b/livesupport/products/scheduler/src/GetSchedulerTimeMethodTest.cxx index 461b5b33c..ea9bfde71 100644 --- a/livesupport/products/scheduler/src/GetSchedulerTimeMethodTest.cxx +++ b/livesupport/products/scheduler/src/GetSchedulerTimeMethodTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GetSchedulerTimeMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,14 +46,12 @@ #include #include "SchedulerDaemon.h" -#include "LiveSupport/Authentication/AuthenticationClientFactory.h" #include "GetSchedulerTimeMethodTest.h" using namespace std; using namespace XmlRpc; using namespace LiveSupport::Core; using namespace LiveSupport::Scheduler; -using namespace LiveSupport::Authentication; /* =================================================== local data structures */ @@ -63,58 +61,18 @@ using namespace LiveSupport::Authentication; CPPUNIT_TEST_SUITE_REGISTRATION(GetSchedulerTimeMethodTest); -/** - * The name of the configuration file for the authentication client factory. - */ -static const std::string authenticationClientConfigFileName = - "etc/authenticationClient.xml"; - /* =============================================== local function prototypes */ /* ============================================================= module code */ -/*------------------------------------------------------------------------------ - * Configure a Configurable with an XML file. - *----------------------------------------------------------------------------*/ -void -GetSchedulerTimeMethodTest :: configure( - Ptr::Ref configurable, - const std::string & fileName) - throw (std::invalid_argument, - xmlpp::exception) -{ - Ptr::Ref parser(new xmlpp::DomParser(fileName, true)); - const xmlpp::Document * document = parser->get_document(); - const xmlpp::Element * root = document->get_root_node(); - - configurable->configure(*root); -} - - /*------------------------------------------------------------------------------ * Set up the test environment *----------------------------------------------------------------------------*/ void GetSchedulerTimeMethodTest :: setUp(void) throw () { - try { - Ptr::Ref acf; - acf = AuthenticationClientFactory::getInstance(); - configure(acf, authenticationClientConfigFileName); - authentication = acf->getAuthenticationClient(); - } catch (std::invalid_argument &e) { - std::cerr << e.what() << std::endl; - CPPUNIT_FAIL("semantic error in authentication configuration file"); - } catch (xmlpp::exception &e) { - std::cerr << e.what() << std::endl; - CPPUNIT_FAIL("error parsing authentication configuration file"); - } - - if (!(sessionId = authentication->login("root", "q"))) { - CPPUNIT_FAIL("could not log in to authentication server"); - } } @@ -124,9 +82,6 @@ GetSchedulerTimeMethodTest :: setUp(void) throw () void GetSchedulerTimeMethodTest :: tearDown(void) throw () { - authentication->logout(sessionId); - sessionId.reset(); - authentication.reset(); } @@ -140,36 +95,12 @@ GetSchedulerTimeMethodTest :: simpleTest(void) Ptr::Ref getSchedulerTimeMethod(new GetSchedulerTimeMethod()); - XmlRpcValue parameters; +// XmlRpcValue parameters; XmlRpc::XmlRpcValue rootParameter; +// rootParameter[0] = parameters; XmlRpcValue result; struct tm time1, time2; - - result.clear(); - try { - getSchedulerTimeMethod->execute(rootParameter, result); - CPPUNIT_FAIL("failed to detect invalid parameter format"); - } - catch (XmlRpc::XmlRpcException &e) { - CPPUNIT_ASSERT(e.getCode() == 1901); - } - - rootParameter.setSize(1); - parameters["dummyParameter"] = "dummyValue"; - rootParameter[0] = parameters; - result.clear(); - try { - getSchedulerTimeMethod->execute(rootParameter, result); - CPPUNIT_FAIL("failed to detect missing session ID"); - } - catch (XmlRpc::XmlRpcException &e) { - CPPUNIT_ASSERT(e.getCode() == 1920); - } - - parameters.clear(); - parameters["sessionId"] = sessionId->getId(); - rootParameter[0] = parameters; result.clear(); try { getSchedulerTimeMethod->execute(rootParameter, result); diff --git a/livesupport/products/scheduler/src/GetSchedulerTimeMethodTest.h b/livesupport/products/scheduler/src/GetSchedulerTimeMethodTest.h index cd9534932..44e377987 100644 --- a/livesupport/products/scheduler/src/GetSchedulerTimeMethodTest.h +++ b/livesupport/products/scheduler/src/GetSchedulerTimeMethodTest.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/GetSchedulerTimeMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,15 +42,11 @@ #include -#include "LiveSupport/Authentication/AuthenticationClientInterface.h" -#include "LiveSupport/Core/SessionId.h" - namespace LiveSupport { namespace Scheduler { using namespace LiveSupport; using namespace LiveSupport::Core; -using namespace LiveSupport::Authentication; /* ================================================================ constants */ @@ -64,7 +60,7 @@ using namespace LiveSupport::Authentication; * Unit test to test the getSchedulerTime XML-RPC call. * * @author $Author: fgerlits $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * @see SchedulerDaemon */ class GetSchedulerTimeMethodTest : public CPPUNIT_NS::TestFixture @@ -73,31 +69,6 @@ class GetSchedulerTimeMethodTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST(simpleTest); CPPUNIT_TEST_SUITE_END(); - private: - /** - * An authentication client. - */ - Ptr::Ref authentication; - - /** - * A session ID from the authentication client login() method. - */ - Ptr::Ref sessionId; - - /** - * Configure a configurable with an XML file. - * - * @param configurable configure this - * @param fileName the name of the XML file to configure with. - * @exception std::invalid_argument on configuration errors. - * @exception xmlpp::exception on XML parsing errors. - */ - void - configure(Ptr::Ref configurable, - const std::string & fileName) - throw (std::invalid_argument, - xmlpp::exception); - protected: /** diff --git a/livesupport/products/scheduler/src/RpcGetSchedulerTimeTest.cxx b/livesupport/products/scheduler/src/RpcGetSchedulerTimeTest.cxx index 8c858bcc8..bf2475ba2 100644 --- a/livesupport/products/scheduler/src/RpcGetSchedulerTimeTest.cxx +++ b/livesupport/products/scheduler/src/RpcGetSchedulerTimeTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcGetSchedulerTimeTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -45,14 +45,12 @@ #include #include "SchedulerDaemon.h" -#include "LiveSupport/Authentication/AuthenticationClientFactory.h" #include "RpcGetSchedulerTimeTest.h" using namespace std; using namespace XmlRpc; using namespace LiveSupport::Core; using namespace LiveSupport::Scheduler; -using namespace LiveSupport::Authentication; /* =================================================== local data structures */ @@ -67,12 +65,6 @@ CPPUNIT_TEST_SUITE_REGISTRATION(RpcGetSchedulerTimeTest); */ static const std::string configFileName = "etc/scheduler.xml"; -/** - * The name of the configuration file for the authentication client factory. - */ -static const std::string authenticationClientConfigFileName = - "etc/authenticationClient.xml"; - /* =============================================== local function prototypes */ @@ -120,23 +112,6 @@ RpcGetSchedulerTimeTest :: setUp(void) throw () daemon->install(); // daemon->start(); // sleep(5); - - try { - Ptr::Ref acf; - acf = AuthenticationClientFactory::getInstance(); - configure(acf, authenticationClientConfigFileName); - authentication = acf->getAuthenticationClient(); - } catch (std::invalid_argument &e) { - std::cerr << e.what() << std::endl; - CPPUNIT_FAIL("semantic error in authentication configuration file"); - } catch (xmlpp::exception &e) { - std::cerr << e.what() << std::endl; - CPPUNIT_FAIL("error parsing authentication configuration file"); - } - - if (!(sessionId = authentication->login("root", "q"))) { - CPPUNIT_FAIL("could not log in to authentication server"); - } } @@ -150,10 +125,6 @@ RpcGetSchedulerTimeTest :: tearDown(void) throw () // daemon->stop(); daemon->uninstall(); - - authentication->logout(sessionId); - sessionId.reset(); - authentication.reset(); } @@ -171,32 +142,13 @@ RpcGetSchedulerTimeTest :: simpleTest(void) XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); - xmlRpcClient.execute("getSchedulerTime", parameters, result); - CPPUNIT_ASSERT(xmlRpcClient.isFault()); - CPPUNIT_ASSERT(result.hasMember("faultCode")); - CPPUNIT_ASSERT(int(result["faultCode"]) == 1901); - - parameters["dummyParameter"] = "dummyValue"; - xmlRpcClient.execute("getSchedulerTime", parameters, result); - CPPUNIT_ASSERT(xmlRpcClient.isFault()); - CPPUNIT_ASSERT(result.hasMember("faultCode")); - CPPUNIT_ASSERT(int(result["faultCode"]) == 1920); - -// doesn't work yet -// parameters.clear(); -// parameters["sessionId"] = badSessionId->getId(); -// xmlRpcClient.execute("getSchedulerTime", parameters, result); -// CPPUNIT_ASSERT(xmlRpcClient.isFault()); -// CPPUNIT_ASSERT(result.hasMember("faultCode")); -// CPPUNIT_ASSERT(int(result["faultCode"]) == NEW_ERROR_CODE); - - parameters.clear(); - parameters["sessionId"] = sessionId->getId(); + result.clear(); xmlRpcClient.execute("getSchedulerTime", parameters, result); CPPUNIT_ASSERT(!xmlRpcClient.isFault()); CPPUNIT_ASSERT(result.hasMember("schedulerTime")); time1 = result["schedulerTime"]; + result.clear(); xmlRpcClient.execute("getSchedulerTime", parameters, result); CPPUNIT_ASSERT(!xmlRpcClient.isFault()); CPPUNIT_ASSERT(result.hasMember("schedulerTime")); diff --git a/livesupport/products/scheduler/src/RpcGetSchedulerTimeTest.h b/livesupport/products/scheduler/src/RpcGetSchedulerTimeTest.h index cea6391b6..5e2c4ab7e 100644 --- a/livesupport/products/scheduler/src/RpcGetSchedulerTimeTest.h +++ b/livesupport/products/scheduler/src/RpcGetSchedulerTimeTest.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RpcGetSchedulerTimeTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,15 +42,11 @@ #include -#include "LiveSupport/Authentication/AuthenticationClientInterface.h" -#include "LiveSupport/Core/SessionId.h" - namespace LiveSupport { namespace Scheduler { using namespace LiveSupport; using namespace LiveSupport::Core; -using namespace LiveSupport::Authentication; /* ================================================================ constants */ @@ -64,7 +60,7 @@ using namespace LiveSupport::Authentication; * Unit test to test the getSchedulerTime XML-RPC call. * * @author $Author: fgerlits $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * @see SchedulerDaemon */ class RpcGetSchedulerTimeTest : public CPPUNIT_NS::TestFixture @@ -74,15 +70,6 @@ class RpcGetSchedulerTimeTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST_SUITE_END(); private: - /** - * An authentication client. - */ - Ptr::Ref authentication; - - /** - * A session ID from the authentication client login() method. - */ - Ptr::Ref sessionId; /** * Configure a configurable with an XML file.