removed session ID check from getSchedulerTime method
This commit is contained in:
parent
b700bb7932
commit
0c9171761b
@ -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<SessionId>::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<ptime>::Ref schedulerPTime = TimeConversion::now();
|
||||
Ptr<ptime>::Ref schedulerPTime = TimeConversion::now();
|
||||
struct tm schedulerTime;
|
||||
TimeConversion::ptimeToTm(schedulerPTime, schedulerTime);
|
||||
returnValue["schedulerTime"] = & schedulerTime;
|
||||
}
|
||||
|
||||
|
||||
@ -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:
|
||||
* <ul>
|
||||
* <li>sessionId - string - the session ID obtained via the login()
|
||||
* method of the authentication client </li>
|
||||
* </ul>
|
||||
* 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;
|
||||
* <li>schedulerTime - date/time - the local time on the scheduler</li>
|
||||
* </ul>
|
||||
*
|
||||
* In case of an error, a standard XML-RPC fault response is generated,
|
||||
* and a { faultCode, faultString } structure is returned. The
|
||||
* possible errors are:
|
||||
* <ul>
|
||||
* <li>1901 - invalid argument format </li>
|
||||
* <li>1920 - missing session ID argument </li>
|
||||
* </ul>
|
||||
* This method does not generate any fault responses.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
*/
|
||||
class GetSchedulerTimeMethod : public XmlRpc::XmlRpcServerMethod
|
||||
{
|
||||
|
||||
@ -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 <XmlRpcValue.h>
|
||||
|
||||
#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<Configurable>::Ref configurable,
|
||||
const std::string & fileName)
|
||||
throw (std::invalid_argument,
|
||||
xmlpp::exception)
|
||||
{
|
||||
Ptr<xmlpp::DomParser>::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<AuthenticationClientFactory>::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<GetSchedulerTimeMethod>::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);
|
||||
|
||||
@ -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 <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#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<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::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<Configurable>::Ref configurable,
|
||||
const std::string & fileName)
|
||||
throw (std::invalid_argument,
|
||||
xmlpp::exception);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
||||
@ -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 <XmlRpcValue.h>
|
||||
|
||||
#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<AuthenticationClientFactory>::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"));
|
||||
|
||||
@ -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 <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#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<AuthenticationClientInterface>::Ref authentication;
|
||||
|
||||
/**
|
||||
* A session ID from the authentication client login() method.
|
||||
*/
|
||||
Ptr<SessionId>::Ref sessionId;
|
||||
|
||||
/**
|
||||
* Configure a configurable with an XML file.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user