From e46a2192ce160e0314819bb8f992730cb7328934 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Mon, 22 Nov 2004 13:14:45 +0000 Subject: [PATCH] added call to authentication server, as well as a new "sessionId" xml-rpc parameter, to *everything* --- .../products/scheduler/etc/Makefile.in | 30 +++++++-- .../src/AddAudioClipToPlaylistMethod.cxx | 17 ++++- .../src/AddAudioClipToPlaylistMethod.h | 7 ++- .../src/AddAudioClipToPlaylistMethodTest.cxx | 29 +++++++-- .../src/AddAudioClipToPlaylistMethodTest.h | 22 ++++++- .../scheduler/src/CreatePlaylistMethod.cxx | 24 ++++++- .../scheduler/src/CreatePlaylistMethod.h | 12 +++- .../src/CreatePlaylistMethodTest.cxx | 27 +++++++- .../scheduler/src/CreatePlaylistMethodTest.h | 22 ++++++- .../scheduler/src/DeletePlaylistMethod.cxx | 17 ++++- .../scheduler/src/DeletePlaylistMethod.h | 9 ++- .../src/DeletePlaylistMethodTest.cxx | 26 +++++++- .../scheduler/src/DeletePlaylistMethodTest.h | 22 ++++++- .../scheduler/src/DisplayAudioClipMethod.cxx | 15 ++++- .../scheduler/src/DisplayAudioClipMethod.h | 9 ++- .../src/DisplayAudioClipMethodTest.cxx | 26 +++++++- .../src/DisplayAudioClipMethodTest.h | 22 ++++++- .../scheduler/src/DisplayAudioClipsMethod.cxx | 30 +++++++-- .../scheduler/src/DisplayAudioClipsMethod.h | 27 +++++++- .../src/DisplayAudioClipsMethodTest.cxx | 32 +++++++++- .../src/DisplayAudioClipsMethodTest.h | 22 ++++++- .../scheduler/src/DisplayPlaylistMethod.cxx | 15 ++++- .../scheduler/src/DisplayPlaylistMethod.h | 9 ++- .../src/DisplayPlaylistMethodTest.cxx | 26 +++++++- .../scheduler/src/DisplayPlaylistMethodTest.h | 26 ++++++-- .../scheduler/src/DisplayPlaylistsMethod.cxx | 29 ++++++++- .../scheduler/src/DisplayPlaylistsMethod.h | 27 +++++++- .../src/DisplayPlaylistsMethodTest.cxx | 30 ++++++++- .../src/DisplayPlaylistsMethodTest.h | 22 ++++++- .../scheduler/src/DisplayScheduleMethod.cxx | 13 +++- .../scheduler/src/DisplayScheduleMethod.h | 9 ++- .../src/DisplayScheduleMethodTest.cxx | 43 +++++++++++-- .../scheduler/src/DisplayScheduleMethodTest.h | 26 ++++++-- .../src/GeneratePlayReportMethod.cxx | 13 +++- .../scheduler/src/GeneratePlayReportMethod.h | 9 ++- .../src/GeneratePlayReportMethodTest.cxx | 30 ++++++++- .../src/GeneratePlayReportMethodTest.h | 22 ++++++- .../src/OpenPlaylistForEditingMethod.cxx | 15 ++++- .../src/OpenPlaylistForEditingMethod.h | 9 ++- .../src/OpenPlaylistForEditingMethodTest.cxx | 26 +++++++- .../src/OpenPlaylistForEditingMethodTest.h | 22 ++++++- .../products/scheduler/src/PlaylistEvent.cxx | 13 ++-- .../products/scheduler/src/PlaylistEvent.h | 13 ++-- .../src/PlaylistEventContainerTest.cxx | 32 +++++++++- .../src/PlaylistEventContainerTest.h | 23 +++++-- .../src/RemoveAudioClipFromPlaylistMethod.cxx | 15 ++++- .../src/RemoveAudioClipFromPlaylistMethod.h | 7 ++- .../RemoveAudioClipFromPlaylistMethodTest.cxx | 28 ++++++++- .../RemoveAudioClipFromPlaylistMethodTest.h | 22 ++++++- .../src/RemoveFromScheduleMethod.cxx | 13 +++- .../scheduler/src/RemoveFromScheduleMethod.h | 11 ++-- .../src/RemoveFromScheduleMethodTest.cxx | 29 ++++++++- .../src/RemoveFromScheduleMethodTest.h | 26 ++++++-- .../scheduler/src/RescheduleMethod.cxx | 13 +++- .../products/scheduler/src/RescheduleMethod.h | 7 ++- .../scheduler/src/RescheduleMethodTest.cxx | 30 ++++++++- .../scheduler/src/RescheduleMethodTest.h | 26 ++++++-- .../src/RevertEditedPlaylistMethod.cxx | 15 ++++- .../src/RevertEditedPlaylistMethod.h | 9 ++- .../src/RevertEditedPlaylistMethodTest.cxx | 26 +++++++- .../src/RevertEditedPlaylistMethodTest.h | 22 ++++++- .../scheduler/src/SavePlaylistMethod.cxx | 15 ++++- .../scheduler/src/SavePlaylistMethod.h | 9 ++- .../scheduler/src/SavePlaylistMethodTest.cxx | 25 +++++++- .../scheduler/src/SavePlaylistMethodTest.h | 22 ++++++- .../SchedulerDaemonDisplayPlaylistTest.cxx | 63 ++++++++++++++++--- .../src/SchedulerDaemonDisplayPlaylistTest.h | 37 +++++++++-- .../SchedulerDaemonDisplayScheduleTest.cxx | 57 +++++++++++++++-- .../src/SchedulerDaemonDisplayScheduleTest.h | 37 +++++++++-- .../SchedulerDaemonRemoveFromScheduleTest.cxx | 59 +++++++++++++++-- .../SchedulerDaemonRemoveFromScheduleTest.h | 37 +++++++++-- .../src/SchedulerDaemonRescheduleTest.cxx | 61 ++++++++++++++++-- .../src/SchedulerDaemonRescheduleTest.h | 37 +++++++++-- .../src/SchedulerDaemonUploadTest.cxx | 58 +++++++++++++++-- .../scheduler/src/SchedulerDaemonUploadTest.h | 37 +++++++++-- .../src/UpdateFadeInFadeOutMethod.cxx | 15 ++++- .../scheduler/src/UpdateFadeInFadeOutMethod.h | 7 ++- .../src/UpdateFadeInFadeOutMethodTest.cxx | 24 ++++++- .../src/UpdateFadeInFadeOutMethodTest.h | 22 ++++++- .../scheduler/src/UploadPlaylistMethod.cxx | 15 ++++- .../scheduler/src/UploadPlaylistMethod.h | 7 ++- .../src/UploadPlaylistMethodTest.cxx | 32 +++++++++- .../scheduler/src/UploadPlaylistMethodTest.h | 26 ++++++-- .../scheduler/src/ValidatePlaylistMethod.cxx | 15 ++++- .../scheduler/src/ValidatePlaylistMethod.h | 9 ++- .../src/ValidatePlaylistMethodTest.cxx | 25 +++++++- .../src/ValidatePlaylistMethodTest.h | 22 ++++++- .../products/scheduler/src/XmlRpcTools.cxx | 25 +++++++- .../products/scheduler/src/XmlRpcTools.h | 24 ++++++- 89 files changed, 1825 insertions(+), 245 deletions(-) diff --git a/livesupport/products/scheduler/etc/Makefile.in b/livesupport/products/scheduler/etc/Makefile.in index 7ba3ca7a3..f54ba0a46 100644 --- a/livesupport/products/scheduler/etc/Makefile.in +++ b/livesupport/products/scheduler/etc/Makefile.in @@ -21,7 +21,7 @@ # # # Author : $Author: fgerlits $ -# Version : $Revision: 1.23 $ +# Version : $Revision: 1.24 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $ # # @configure_input@ @@ -70,6 +70,12 @@ CORE_LIB_DIR = ${CORE_DIR}/lib CORE_LIB = livesupport_core CORE_LIB_FILE = ${CORE_LIB_DIR}/lib${CORE_LIB}.a +AUTHENTICATION_DIR = ${MODULES_DIR}/authentication +AUTHENTICATION_INCLUDE_DIR = ${AUTHENTICATION_DIR}/include +AUTHENTICATION_LIB_DIR = ${AUTHENTICATION_DIR}/lib +AUTHENTICATION_LIB = livesupport_authentication +AUTHENTICATION_LIB_FILE = ${AUTHENTICATION_LIB_DIR}/lib${AUTHENTICATION_LIB}.a + DB_DIR = ${MODULES_DIR}/db DB_INCLUDE_DIR = ${DB_DIR}/include DB_LIB_DIR = ${DB_DIR}/lib @@ -82,6 +88,8 @@ STORAGE_LIB_DIR = ${STORAGE_DIR}/lib STORAGE_LIB = livesupport_storage STORAGE_LIB_FILE = ${STORAGE_LIB_DIR}/lib${STORAGE_LIB}.a +STORAGE_SERVER_DIR = ${MODULES_DIR}/storageServer + PLAYLIST_EXECUTOR_DIR = ${MODULES_DIR}/playlistExecutor PLAYLIST_EXECUTOR_INCLUDE_DIR = ${PLAYLIST_EXECUTOR_DIR}/include PLAYLIST_EXECUTOR_LIB_DIR = ${PLAYLIST_EXECUTOR_DIR}/lib @@ -115,6 +123,7 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ \ -I${BOOST_INCLUDE_DIR} \ -I${LIBXMLPP_INCLUDE_DIR} \ -I${CORE_INCLUDE_DIR} \ + -I${AUTHENTICATION_INCLUDE_DIR} \ -I${DB_INCLUDE_DIR} \ -I${STORAGE_INCLUDE_DIR} \ -I${PLAYLIST_EXECUTOR_INCLUDE_DIR} \ @@ -122,6 +131,7 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ \ -I${TMP_DIR} LDFLAGS = @LDFLAGS@ -L${USR_LIB_DIR} -L${HELIX_LIB_DIR} \ -L${CORE_LIB_DIR} \ + -L${AUTHENTICATION_LIB_DIR} \ -L${DB_LIB_DIR} \ -L${STORAGE_LIB_DIR} \ -L${PLAYLIST_EXECUTOR_LIB_DIR} \ @@ -164,7 +174,8 @@ SCHEDULER_OBJS = ${TMP_DIR}/SignalDispatcher.o \ SCHEDULER_EXE_OBJS = ${SCHEDULER_OBJS} \ ${TMP_DIR}/main.o SCHEDULER_EXE_LIBS = -l${EVENT_SCHEDULER_LIB} -l${PLAYLIST_EXECUTOR_LIB} \ - -l${STORAGE_LIB} -l${DB_LIB} -l${CORE_LIB} \ + -l${STORAGE_LIB} -l${DB_LIB} -l${AUTHENTICATION_LIB} \ + -l${CORE_LIB} \ ${HELIX_LIBS} \ -lodbc++ -lboost_date_time-gcc \ -lxmlrpc++ -lssl -lxml++-1.0 @@ -231,12 +242,13 @@ depclean: clean ${MAKE} -C ${PLAYLIST_EXECUTOR_DIR} clean ${MAKE} -C ${STORAGE_DIR} clean ${MAKE} -C ${DB_DIR} clean + ${MAKE} -C ${AUTHENTICATION_DIR} clean ${MAKE} -C ${CORE_DIR} clean distclean: clean docclean ${RMDIR} ${TMP_DIR}/config* ${TMP_DIR}/autom4te* -check: all ${TEST_RUNNER} start run_tests stop +check: all ${TEST_RUNNER} storage_server_init start run_tests stop run_tests: ${TEST_RUNNER} LD_LIBRARY_PATH=${USR_LIB_DIR} ${TEST_RUNNER} \ @@ -259,11 +271,15 @@ uninstall: ${SCHEDULER_EXE} LD_LIBRARY_PATH=${USR_LIB_DIR} ${SCHEDULER_EXE} -c ${SCHEDULER_CFG} \ uninstall +storage_server_init: + ${MAKE} -C ${STORAGE_SERVER_DIR} + #------------------------------------------------------------------------------- # Specific targets #------------------------------------------------------------------------------- -${SCHEDULER_EXE}: ${CORE_LIB_FILE} ${DB_LIB_FILE} ${STORAGE_LIB_FILE} \ +${SCHEDULER_EXE}: ${CORE_LIB_FILE} ${AUTHENTICATION_LIB_FILE} ${DB_LIB_FILE} \ + ${STORAGE_LIB_FILE} \ ${PLAYLIST_EXECUTOR_LIB_FILE} ${EVENT_SCHEDULER_LIB_FILE} \ ${SCHEDULER_EXE_OBJS} ${CXX} ${LDFLAGS} -o $@ $^ ${SCHEDULER_EXE_LIBS} @@ -274,7 +290,8 @@ ${TMP_DIR}: ${DOXYGEN_DIR}: ${MKDIR} ${DOXYGEN_DIR} -${TEST_RUNNER}: ${CORE_LIB_FILE} ${DB_LIB_FILE} ${STORAGE_LIB_FILE} \ +${TEST_RUNNER}: ${CORE_LIB_FILE} ${AUTHENTICATION_LIB_FILE} ${DB_LIB_FILE} \ + ${STORAGE_LIB_FILE} \ ${PLAYLIST_EXECUTOR_LIB_FILE} ${EVENT_SCHEDULER_LIB_FILE} \ ${TEST_RUNNER_OBJS} ${CXX} ${LDFLAGS} -o $@ ${TEST_RUNNER_OBJS} ${TEST_RUNNER_LIBS} @@ -282,6 +299,9 @@ ${TEST_RUNNER}: ${CORE_LIB_FILE} ${DB_LIB_FILE} ${STORAGE_LIB_FILE} \ ${CORE_LIB_FILE}: ${MAKE} -C ${CORE_DIR} +${AUTHENTICATION_LIB_FILE} : + ${MAKE} -C ${AUTHENTICATION_DIR} + ${DB_LIB_FILE}: ${MAKE} -C ${DB_DIR} diff --git a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx index 15951a934..4f20e61e2 100644 --- a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -107,6 +107,17 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, } XmlRpc::XmlRpcValue parameters = rootParameter[0]; + Ptr::Ref sessionId; + try{ + sessionId = XmlRpcTools::extractSessionId(parameters); + } + catch (std::invalid_argument &e) { + XmlRpcTools::markError(errorId+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref playlistId; try{ playlistId = XmlRpcTools::extractPlaylistId(parameters); @@ -144,7 +155,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, Ptr::Ref playlist; try { - playlist = storage->getPlaylist(playlistId); + playlist = storage->getPlaylist(sessionId, playlistId); } catch (std::invalid_argument &e) { XmlRpcTools::markError(errorId+5, "playlist not found", @@ -161,7 +172,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, Ptr::Ref audioClip; try { - audioClip = storage->getAudioClip(audioClipId); + audioClip = storage->getAudioClip(sessionId, audioClipId); } catch (std::invalid_argument &e) { XmlRpcTools::markError(errorId+7, "audio clip does not exist", diff --git a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.h b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.h index b7e7eb8c4..505c6ed97 100644 --- a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.h +++ b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -73,6 +73,8 @@ using namespace LiveSupport::Core; * 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
  • *
  • playlistId - int - the unique id of the playlist.
  • *
  • audioClipId - int - the unique id of the audio clip to * be added.
  • @@ -96,10 +98,11 @@ using namespace LiveSupport::Core; *
  • 306 - playlist has not been opened for editing
  • *
  • 307 - audio clip does not exist
  • *
  • 308 - two audio clips at the same relative offset
  • + *
  • 322 - missing session ID argument
  • *
* * @author $Author: fgerlits $ - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ class AddAudioClipToPlaylistMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.cxx b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.cxx index 6a2bcc5e9..30787f0e0 100644 --- a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,17 +46,18 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" #include "XmlRpcTools.h" #include "OpenPlaylistForEditingMethod.h" #include "AddAudioClipToPlaylistMethod.h" #include "AddAudioClipToPlaylistMethodTest.h" - using namespace std; using namespace LiveSupport::Db; using namespace LiveSupport::Storage; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; /* =================================================== local data structures */ @@ -78,6 +79,12 @@ const std::string AddAudioClipToPlaylistMethodTest::storageClientConfig = const std::string AddAudioClipToPlaylistMethodTest::connectionManagerConfig = "etc/connectionManagerFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string AddAudioClipToPlaylistMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -108,15 +115,19 @@ AddAudioClipToPlaylistMethodTest :: configure( void AddAudioClipToPlaylistMethodTest :: setUp(void) throw () { + Ptr::Ref acf; try { Ptr::Ref scf - = StorageClientFactory::getInstance(); + = StorageClientFactory::getInstance(); configure(scf, storageClientConfig); Ptr::Ref cmf - = ConnectionManagerFactory::getInstance(); + = ConnectionManagerFactory::getInstance(); configure(cmf, connectionManagerConfig); + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -124,6 +135,11 @@ AddAudioClipToPlaylistMethodTest :: setUp(void) throw () } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + authentication = acf->getAuthenticationClient(); + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -133,6 +149,9 @@ AddAudioClipToPlaylistMethodTest :: setUp(void) throw () void AddAudioClipToPlaylistMethodTest :: tearDown(void) throw () { + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -152,6 +171,7 @@ AddAudioClipToPlaylistMethodTest :: firstTest(void) rootParameter.setSize(1); XmlRpc::XmlRpcValue result; + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; parameters["audioClipId"] = 10001; parameters["relativeOffset"] = 60*60; @@ -166,6 +186,7 @@ AddAudioClipToPlaylistMethodTest :: firstTest(void) CPPUNIT_ASSERT((int)(result["errorCode"]) == 308); parameters.clear(); + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; parameters["audioClipId"] = 10001; parameters["relativeOffset"] = 90*60; diff --git a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.h b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.h index 7a2438d6e..882a299d8 100644 --- a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.h +++ b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethodTest.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/AddAudioClipToPlaylistMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -61,7 +63,7 @@ using namespace LiveSupport::Core; * Unit test for the AddAudioClipToPlaylistMethod class. * * @author $Author: fgerlits $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @see AddAudioClipToPlaylistMethod */ class AddAudioClipToPlaylistMethodTest : public CPPUNIT_NS::TestFixture @@ -81,6 +83,22 @@ class AddAudioClipToPlaylistMethodTest : public CPPUNIT_NS::TestFixture */ static const std::string connectionManagerConfig; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx b/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx index 4819bcddb..abec21fd9 100644 --- a/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -95,17 +95,35 @@ CreatePlaylistMethod :: CreatePlaylistMethod ( * Execute the stop XML-RPC function call. *----------------------------------------------------------------------------*/ void -CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters, +CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) throw () { + 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+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref scf; Ptr::Ref storage; scf = StorageClientFactory::getInstance(); storage = scf->getStorageClient(); - Ptr::Ref playlist = storage->createPlaylist(); + Ptr::Ref playlist = storage->createPlaylist(sessionId); if (!playlist->setLockedForEditing(true)) { // this should never happen XmlRpcTools :: markError(errorId+1, diff --git a/livesupport/products/scheduler/src/CreatePlaylistMethod.h b/livesupport/products/scheduler/src/CreatePlaylistMethod.h index 1541f0725..702029fc9 100644 --- a/livesupport/products/scheduler/src/CreatePlaylistMethod.h +++ b/livesupport/products/scheduler/src/CreatePlaylistMethod.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -68,6 +68,13 @@ using namespace LiveSupport::Core; * * The name of the method when called through XML-RPC is "createPlaylist". * + * 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
  • + *
+ * * The XML-RPC function returns an XML-RPC structure, containing the following * fields: *
    @@ -84,10 +91,11 @@ using namespace LiveSupport::Core; * The possible error codes are: *
      *
    • 201 - could not open new playlist for editing
    • + *
    • 222 - missing session ID argument
    • *
    * * @author $Author: fgerlits $ - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx b/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx index aa1bcaa2b..0eda6b5de 100644 --- a/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.7 $ + Version : $Revision: 1.8 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,6 +46,8 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" + #include "CreatePlaylistMethod.h" #include "OpenPlaylistForEditingMethod.h" #include "CreatePlaylistMethodTest.h" @@ -55,6 +57,8 @@ using namespace XmlRpc; using namespace LiveSupport::Db; using namespace LiveSupport::Storage; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -75,6 +79,12 @@ const std::string CreatePlaylistMethodTest::storageClientConfig = const std::string CreatePlaylistMethodTest::connectionManagerConfig = "etc/connectionManagerFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string CreatePlaylistMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -105,6 +115,7 @@ CreatePlaylistMethodTest :: configure( void CreatePlaylistMethodTest :: setUp(void) throw () { + Ptr::Ref acf; try { Ptr::Ref scf = StorageClientFactory::getInstance(); @@ -114,6 +125,9 @@ CreatePlaylistMethodTest :: setUp(void) throw () = ConnectionManagerFactory::getInstance(); configure(cmf, connectionManagerConfig); + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -121,6 +135,11 @@ CreatePlaylistMethodTest :: setUp(void) throw () } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + authentication = acf->getAuthenticationClient(); + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -130,6 +149,9 @@ CreatePlaylistMethodTest :: setUp(void) throw () void CreatePlaylistMethodTest :: tearDown(void) throw () { + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -147,6 +169,8 @@ CreatePlaylistMethodTest :: firstTest(void) XmlRpc::XmlRpcValue result; result.clear(); + parameter["sessionId"] = sessionId->getId(); + rootParameter[0] = parameter; method->execute(rootParameter, result); CPPUNIT_ASSERT(result.hasMember("id")); CPPUNIT_ASSERT(((int) result["playlength"]) == 0); @@ -154,6 +178,7 @@ CreatePlaylistMethodTest :: firstTest(void) int playlistId = (int) result["id"]; method.reset(new OpenPlaylistForEditingMethod()); parameter.clear(); + parameter["sessionId"] = sessionId->getId(); parameter["playlistId"] = playlistId; rootParameter[0] = parameter; diff --git a/livesupport/products/scheduler/src/CreatePlaylistMethodTest.h b/livesupport/products/scheduler/src/CreatePlaylistMethodTest.h index 2f1eddbb5..f4d05a96d 100644 --- a/livesupport/products/scheduler/src/CreatePlaylistMethodTest.h +++ b/livesupport/products/scheduler/src/CreatePlaylistMethodTest.h @@ -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/CreatePlaylistMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -61,7 +63,7 @@ using namespace LiveSupport::Core; * Unit test for the CreatePlaylistMethod class. * * @author $Author: fgerlits $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @see CreatePlaylistMethod */ class CreatePlaylistMethodTest : public CPPUNIT_NS::TestFixture @@ -81,6 +83,22 @@ class CreatePlaylistMethodTest : public CPPUNIT_NS::TestFixture */ static const std::string connectionManagerConfig; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/DeletePlaylistMethod.cxx b/livesupport/products/scheduler/src/DeletePlaylistMethod.cxx index 9f7e0957b..0df1ebf0b 100644 --- a/livesupport/products/scheduler/src/DeletePlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/DeletePlaylistMethod.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -97,6 +97,17 @@ DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, } XmlRpc::XmlRpcValue parameters = rootParameter[0]; + Ptr::Ref sessionId; + try{ + sessionId = XmlRpcTools::extractSessionId(parameters); + } + catch (std::invalid_argument &e) { + XmlRpcTools::markError(errorId+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref playlistId; try{ playlistId = XmlRpcTools::extractPlaylistId(parameters); @@ -113,7 +124,7 @@ DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, = scf->getStorageClient(); Ptr::Ref playlist; try { - playlist = storage->getPlaylist(playlistId); + playlist = storage->getPlaylist(sessionId, playlistId); } catch (std::invalid_argument &e) { XmlRpcTools::markError(errorId+3, "playlist not found", @@ -128,7 +139,7 @@ DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, } try { - storage->deletePlaylist(playlistId); + storage->deletePlaylist(sessionId, playlistId); } catch (std::invalid_argument &e) { XmlRpcTools::markError(errorId+5, "playlist could not be deleted", diff --git a/livesupport/products/scheduler/src/DeletePlaylistMethod.h b/livesupport/products/scheduler/src/DeletePlaylistMethod.h index 78cad0a5e..2293150a5 100644 --- a/livesupport/products/scheduler/src/DeletePlaylistMethod.h +++ b/livesupport/products/scheduler/src/DeletePlaylistMethod.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -69,8 +69,10 @@ using namespace LiveSupport::Core; * The name of the method when called through XML-RPC is "deletePlaylist". * * The expected parameter is an XML-RPC structure, with the following - * member: + * members: *
      + *
    • sessionId - string - the session ID obtained via the login() + * method of the authentication client
    • *
    • playlistId - int - the unique id of the playlist * to be deleted.
    • *
    @@ -88,10 +90,11 @@ using namespace LiveSupport::Core; *
  • 903 - playlist not found
  • *
  • 904 - playlist is locked
  • *
  • 905 - playlist could not be deleted
  • + *
  • 922 - missing session ID argument
  • *
* * @author $Author: fgerlits $ - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ class DeletePlaylistMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/DeletePlaylistMethodTest.cxx b/livesupport/products/scheduler/src/DeletePlaylistMethodTest.cxx index 66f83bb9b..38385d7ec 100644 --- a/livesupport/products/scheduler/src/DeletePlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/DeletePlaylistMethodTest.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/Attic/DeletePlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,6 +46,8 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" + #include "OpenPlaylistForEditingMethod.h" #include "SavePlaylistMethod.h" @@ -56,6 +58,8 @@ using namespace LiveSupport::Db; using namespace LiveSupport::Storage; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -76,6 +80,12 @@ const std::string DeletePlaylistMethodTest::storageClientConfig = const std::string DeletePlaylistMethodTest::connectionManagerConfig = "etc/connectionManagerFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string DeletePlaylistMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -106,6 +116,7 @@ DeletePlaylistMethodTest :: configure( void DeletePlaylistMethodTest :: setUp(void) throw () { + Ptr::Ref acf; try { Ptr::Ref scf = StorageClientFactory::getInstance(); @@ -115,6 +126,9 @@ DeletePlaylistMethodTest :: setUp(void) throw () = ConnectionManagerFactory::getInstance(); configure(cmf, connectionManagerConfig); + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -122,6 +136,11 @@ DeletePlaylistMethodTest :: setUp(void) throw () } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + authentication = acf->getAuthenticationClient(); + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -131,6 +150,9 @@ DeletePlaylistMethodTest :: setUp(void) throw () void DeletePlaylistMethodTest :: tearDown(void) throw () { + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -153,6 +175,7 @@ DeletePlaylistMethodTest :: firstTest(void) XmlRpc::XmlRpcValue result; // set up a structure for the parameters + parameter["sessionId"] = sessionId->getId(); parameter["playlistId"] = 1; rootParameter[0] = parameter; @@ -189,6 +212,7 @@ DeletePlaylistMethodTest :: negativeTest(void) XmlRpc::XmlRpcValue result; // set up a structure for the parameters + parameter["sessionId"] = sessionId->getId(); parameter["playlistId"] = 9999; rootParameter[0] = parameter; diff --git a/livesupport/products/scheduler/src/DeletePlaylistMethodTest.h b/livesupport/products/scheduler/src/DeletePlaylistMethodTest.h index afa9dd737..2b6e3f2d8 100644 --- a/livesupport/products/scheduler/src/DeletePlaylistMethodTest.h +++ b/livesupport/products/scheduler/src/DeletePlaylistMethodTest.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/Attic/DeletePlaylistMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -62,7 +64,7 @@ using namespace LiveSupport::Core; * * @author $Author: maroy, fgerlits $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @see DeletePlaylistMethod */ class DeletePlaylistMethodTest : public CPPUNIT_NS::TestFixture @@ -83,6 +85,22 @@ class DeletePlaylistMethodTest : public CPPUNIT_NS::TestFixture */ static const std::string connectionManagerConfig; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/DisplayAudioClipMethod.cxx b/livesupport/products/scheduler/src/DisplayAudioClipMethod.cxx index a61cdffa9..8de0b2cb5 100644 --- a/livesupport/products/scheduler/src/DisplayAudioClipMethod.cxx +++ b/livesupport/products/scheduler/src/DisplayAudioClipMethod.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/DisplayAudioClipMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -106,6 +106,17 @@ DisplayAudioClipMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, } XmlRpc::XmlRpcValue parameters = rootParameter[0]; + Ptr::Ref sessionId; + try{ + sessionId = XmlRpcTools::extractSessionId(parameters); + } + catch (std::invalid_argument &e) { + XmlRpcTools::markError(errorId+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref id; try{ id = XmlRpcTools::extractAudioClipId(parameters); @@ -124,7 +135,7 @@ DisplayAudioClipMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, Ptr::Ref audioClip; try { - audioClip = storage->getAudioClip(id); + audioClip = storage->getAudioClip(sessionId, id); } catch (std::invalid_argument &e) { XmlRpcTools::markError(errorId+3, "audio clip not found", diff --git a/livesupport/products/scheduler/src/DisplayAudioClipMethod.h b/livesupport/products/scheduler/src/DisplayAudioClipMethod.h index 4b999f767..d51eab268 100644 --- a/livesupport/products/scheduler/src/DisplayAudioClipMethod.h +++ b/livesupport/products/scheduler/src/DisplayAudioClipMethod.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/DisplayAudioClipMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -70,8 +70,10 @@ using namespace LiveSupport::Core; * The name of the method when called through XML-RPC is "displayAudioClip". * * The expected parameter is an XML-RPC structure, with the following - * member: + * members: *
    + *
  • sessionId - string - the session ID obtained via the login() + * method of the authentication client
  • *
  • audioClipId - int - the unique id of the audio clip requested.
  • *
* @@ -94,10 +96,11 @@ using namespace LiveSupport::Core; *
  • 601 - invalid argument format
  • *
  • 602 - argument is not an audio clip ID
  • *
  • 603 - audio clip not found
  • + *
  • 622 - missing session ID argument
  • * * * @author $Author: fgerlits $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class DisplayAudioClipMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.cxx b/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.cxx index 3a15bd11e..deb6af902 100644 --- a/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.cxx +++ b/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.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/DisplayAudioClipMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,6 +46,8 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" + #include "DisplayAudioClipMethod.h" #include "DisplayAudioClipMethodTest.h" @@ -53,6 +55,8 @@ using namespace LiveSupport::Db; using namespace LiveSupport::Storage; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -73,6 +77,12 @@ const std::string DisplayAudioClipMethodTest::storageClientConfig = const std::string DisplayAudioClipMethodTest::connectionManagerConfig = "etc/connectionManagerFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string DisplayAudioClipMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -103,6 +113,7 @@ DisplayAudioClipMethodTest :: configure( void DisplayAudioClipMethodTest :: setUp(void) throw () { + Ptr::Ref acf; try { Ptr::Ref scf = StorageClientFactory::getInstance(); @@ -112,6 +123,9 @@ DisplayAudioClipMethodTest :: setUp(void) throw () = ConnectionManagerFactory::getInstance(); configure(cmf, connectionManagerConfig); + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -119,6 +133,11 @@ DisplayAudioClipMethodTest :: setUp(void) throw () } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + authentication = acf->getAuthenticationClient(); + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -128,6 +147,9 @@ DisplayAudioClipMethodTest :: setUp(void) throw () void DisplayAudioClipMethodTest :: tearDown(void) throw () { + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -145,6 +167,7 @@ DisplayAudioClipMethodTest :: firstTest(void) XmlRpc::XmlRpcValue result; // set up a structure for the parameter + parameter["sessionId"] = sessionId->getId(); parameter["audioClipId"] = 10001; rootParameter[0] = parameter; @@ -169,6 +192,7 @@ DisplayAudioClipMethodTest :: negativeTest(void) XmlRpc::XmlRpcValue result; // set up a structure for the parameter + parameter["sessionId"] = sessionId->getId(); parameter["audioClipId"] = 9999; rootParameter[0] = parameter; diff --git a/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.h b/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.h index bcf51b727..9eaed664c 100644 --- a/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.h +++ b/livesupport/products/scheduler/src/DisplayAudioClipMethodTest.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/DisplayAudioClipMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -61,7 +63,7 @@ using namespace LiveSupport::Core; * Unit test for the DisplayAudioClipMethod class. * * @author $Author: fgerlits $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @see DisplayAudioClipMethod */ class DisplayAudioClipMethodTest : public CPPUNIT_NS::TestFixture @@ -82,6 +84,22 @@ class DisplayAudioClipMethodTest : public CPPUNIT_NS::TestFixture */ static const std::string connectionManagerConfig; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/DisplayAudioClipsMethod.cxx b/livesupport/products/scheduler/src/DisplayAudioClipsMethod.cxx index e54374049..3ba897fdc 100644 --- a/livesupport/products/scheduler/src/DisplayAudioClipsMethod.cxx +++ b/livesupport/products/scheduler/src/DisplayAudioClipsMethod.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/DisplayAudioClipsMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -61,6 +61,11 @@ using namespace LiveSupport::Scheduler; *----------------------------------------------------------------------------*/ const std::string DisplayAudioClipsMethod::methodName = "displayAudioClips"; +/*------------------------------------------------------------------------------ + * The ID of this method for error reporting purposes. + *----------------------------------------------------------------------------*/ +const int DisplayAudioClipsMethod::errorId = 1800; + /* =============================================== local function prototypes */ @@ -76,15 +81,32 @@ DisplayAudioClipsMethod :: DisplayAudioClipsMethod ( { } - /*------------------------------------------------------------------------------ * Execute the stop XML-RPC function call. *----------------------------------------------------------------------------*/ void -DisplayAudioClipsMethod :: execute(XmlRpc::XmlRpcValue & parameters, +DisplayAudioClipsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) throw () { + 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+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref scf; Ptr::Ref storage; @@ -92,7 +114,7 @@ DisplayAudioClipsMethod :: execute(XmlRpc::XmlRpcValue & parameters, storage = scf->getStorageClient(); Ptr::Ref> >::Ref audioClipVector = - storage->getAllAudioClips(); + storage->getAllAudioClips(sessionId); XmlRpcTools::audioClipVectorToXmlRpcValue(audioClipVector, returnValue); } diff --git a/livesupport/products/scheduler/src/DisplayAudioClipsMethod.h b/livesupport/products/scheduler/src/DisplayAudioClipsMethod.h index 505e47569..97086098b 100644 --- a/livesupport/products/scheduler/src/DisplayAudioClipsMethod.h +++ b/livesupport/products/scheduler/src/DisplayAudioClipsMethod.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/DisplayAudioClipsMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -72,7 +72,12 @@ using namespace LiveSupport::Core; * * The name of the method when called through XML-RPC is "displayAudioClips". * - * No input parameters are expected. + * 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
    • + *
    * * The XML-RPC function returns an XML-RPC array, containing a structure * for each audio clip in the audio clip store. An array of size 0 means the @@ -83,8 +88,19 @@ using namespace LiveSupport::Core; * * * + * In case of an error, an XML-RPC structure is returned, with the following + * fields: + *
      + *
    • errorCode - int - the id of the error condition
    • + *
    • errorMessage - string - a description of the error
    • + *
    + * The possible error codes are: + *
      + *
    • 1822 - missing session ID argument
    • + *
    + * * @author $Author: fgerlits $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class DisplayAudioClipsMethod : public XmlRpc::XmlRpcServerMethod { @@ -95,6 +111,11 @@ class DisplayAudioClipsMethod : public XmlRpc::XmlRpcServerMethod */ static const std::string methodName; + /** + * The ID of this method for error reporting purposes. + */ + static const int errorId; + public: /** diff --git a/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.cxx b/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.cxx index eba298a6c..5147b8072 100644 --- a/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.cxx +++ b/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.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/DisplayAudioClipsMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -47,6 +47,8 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" + #include "DisplayAudioClipsMethod.h" #include "DisplayAudioClipsMethodTest.h" @@ -54,6 +56,8 @@ using namespace LiveSupport::Db; using namespace LiveSupport::Storage; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -74,6 +78,12 @@ const std::string DisplayAudioClipsMethodTest::storageClientConfig = const std::string DisplayAudioClipsMethodTest::connectionManagerConfig = "etc/connectionManagerFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string DisplayAudioClipsMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -104,6 +114,7 @@ DisplayAudioClipsMethodTest :: configure( void DisplayAudioClipsMethodTest :: setUp(void) throw () { + Ptr::Ref acf; try { Ptr::Ref scf = StorageClientFactory::getInstance(); @@ -113,6 +124,9 @@ DisplayAudioClipsMethodTest :: setUp(void) throw () = ConnectionManagerFactory::getInstance(); configure(cmf, connectionManagerConfig); + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -120,6 +134,11 @@ DisplayAudioClipsMethodTest :: setUp(void) throw () } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + authentication = acf->getAuthenticationClient(); + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -129,6 +148,9 @@ DisplayAudioClipsMethodTest :: setUp(void) throw () void DisplayAudioClipsMethodTest :: tearDown(void) throw () { + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -141,11 +163,15 @@ DisplayAudioClipsMethodTest :: firstTest(void) { Ptr::Ref method(new DisplayAudioClipsMethod()); XmlRpc::XmlRpcValue parameter; + XmlRpc::XmlRpcValue rootParameter; + rootParameter.setSize(1); XmlRpc::XmlRpcValue result; XmlRpc::XmlRpcValue audioClip; result.clear(); - method->execute(parameter, result); + parameter["sessionId"] = sessionId->getId(); + rootParameter[0] = parameter; + method->execute(rootParameter, result); CPPUNIT_ASSERT(result.size() == 2); audioClip = result[0]; @@ -155,5 +181,5 @@ DisplayAudioClipsMethodTest :: firstTest(void) audioClip = result[1]; CPPUNIT_ASSERT(int(audioClip["id"]) == 10002); CPPUNIT_ASSERT(int(audioClip["playlength"]) == 30 * 60); - } + diff --git a/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.h b/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.h index 1c5200d47..6d6465855 100644 --- a/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.h +++ b/livesupport/products/scheduler/src/DisplayAudioClipsMethodTest.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/DisplayAudioClipsMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -61,7 +63,7 @@ using namespace LiveSupport::Core; * Unit test for the DisplayAudioClipsMethod class. * * @author $Author: fgerlits $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @see DisplayAudioClipsMethod */ class DisplayAudioClipsMethodTest : public CPPUNIT_NS::TestFixture @@ -81,6 +83,22 @@ class DisplayAudioClipsMethodTest : public CPPUNIT_NS::TestFixture */ static const std::string connectionManagerConfig; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx b/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx index c3338c97d..ff0cd8342 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/DisplayPlaylistMethod.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/DisplayPlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -106,6 +106,17 @@ DisplayPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, } XmlRpc::XmlRpcValue parameters = rootParameter[0]; + Ptr::Ref sessionId; + try{ + sessionId = XmlRpcTools::extractSessionId(parameters); + } + catch (std::invalid_argument &e) { + XmlRpcTools::markError(errorId+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref id; try{ id = XmlRpcTools::extractPlaylistId(parameters); @@ -124,7 +135,7 @@ DisplayPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, Ptr::Ref playlist; try { - playlist = storage->getPlaylist(id); + playlist = storage->getPlaylist(sessionId, id); } catch (std::invalid_argument &e) { XmlRpcTools::markError(errorId+3, "playlist not found", diff --git a/livesupport/products/scheduler/src/DisplayPlaylistMethod.h b/livesupport/products/scheduler/src/DisplayPlaylistMethod.h index bc26a3889..2993f9340 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistMethod.h +++ b/livesupport/products/scheduler/src/DisplayPlaylistMethod.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -70,8 +70,10 @@ using namespace LiveSupport::Core; * The name of the method when called through XML-RPC is "displayPlaylist". * * The expected parameter is an XML-RPC structure, with the following - * member: + * members: *
      + *
    • sessionId - string - the session ID obtained via the login() + * method of the authentication client
    • *
    • playlistId - int - the unique id of the playlist requested.
    • *
    * @@ -94,10 +96,11 @@ using namespace LiveSupport::Core; *
  • 1001 - invalid argument format
  • *
  • 1002 - argument is not a playlist ID
  • *
  • 1003 - playlist not found
  • + *
  • 1022 - missing session ID argument
  • * * * @author $Author: fgerlits $ - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ class DisplayPlaylistMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx b/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx index 5cf2ea506..c93d3bcf0 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.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/DisplayPlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,6 +46,8 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" + #include "DisplayPlaylistMethod.h" #include "DisplayPlaylistMethodTest.h" @@ -53,6 +55,8 @@ using namespace LiveSupport::Db; using namespace LiveSupport::Storage; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -73,6 +77,12 @@ const std::string DisplayPlaylistMethodTest::storageClientConfig = const std::string DisplayPlaylistMethodTest::connectionManagerConfig = "etc/connectionManagerFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string DisplayPlaylistMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -103,6 +113,7 @@ DisplayPlaylistMethodTest :: configure( void DisplayPlaylistMethodTest :: setUp(void) throw () { + Ptr::Ref acf; try { Ptr::Ref scf = StorageClientFactory::getInstance(); @@ -112,6 +123,9 @@ DisplayPlaylistMethodTest :: setUp(void) throw () = ConnectionManagerFactory::getInstance(); configure(cmf, connectionManagerConfig); + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -119,6 +133,11 @@ DisplayPlaylistMethodTest :: setUp(void) throw () } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + authentication = acf->getAuthenticationClient(); + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -128,6 +147,9 @@ DisplayPlaylistMethodTest :: setUp(void) throw () void DisplayPlaylistMethodTest :: tearDown(void) throw () { + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -145,6 +167,7 @@ DisplayPlaylistMethodTest :: firstTest(void) XmlRpc::XmlRpcValue result; // set up a structure for the parameter + parameter["sessionId"] = sessionId->getId(); parameter["playlistId"] = 1; rootParameter[0] = parameter; @@ -169,6 +192,7 @@ DisplayPlaylistMethodTest :: negativeTest(void) XmlRpc::XmlRpcValue result; // set up a structure for the parameter + parameter["sessionId"] = sessionId->getId(); parameter["playlistId"] = 9999; rootParameter[0] = parameter; diff --git a/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.h b/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.h index a7539307e..77d806eb4 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.h +++ b/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -60,8 +62,8 @@ using namespace LiveSupport::Core; /** * Unit test for the DisplayPlaylistMethod class. * - * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.2 $ * @see DisplayPlaylistMethod */ class DisplayPlaylistMethodTest : public CPPUNIT_NS::TestFixture @@ -82,6 +84,22 @@ class DisplayPlaylistMethodTest : public CPPUNIT_NS::TestFixture */ static const std::string connectionManagerConfig; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx b/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx index 8164ab6f3..66927ad68 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistsMethod.cxx +++ b/livesupport/products/scheduler/src/DisplayPlaylistsMethod.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/DisplayPlaylistsMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -61,6 +61,11 @@ using namespace LiveSupport::Scheduler; *----------------------------------------------------------------------------*/ const std::string DisplayPlaylistsMethod::methodName = "displayPlaylists"; +/*------------------------------------------------------------------------------ + * The ID of this method for error reporting purposes. + *----------------------------------------------------------------------------*/ +const int DisplayPlaylistsMethod::errorId = 1700; + /* =============================================== local function prototypes */ @@ -81,10 +86,28 @@ DisplayPlaylistsMethod :: DisplayPlaylistsMethod ( * Execute the stop XML-RPC function call. *----------------------------------------------------------------------------*/ void -DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & parameters, +DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, XmlRpc::XmlRpcValue & returnValue) throw () { + 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+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref scf; Ptr::Ref storage; @@ -92,7 +115,7 @@ DisplayPlaylistsMethod :: execute(XmlRpc::XmlRpcValue & parameters, storage = scf->getStorageClient(); Ptr::Ref> >::Ref playlistVector = - storage->getAllPlaylists(); + storage->getAllPlaylists(sessionId); XmlRpcTools::playlistVectorToXmlRpcValue(playlistVector, returnValue); } diff --git a/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h b/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h index add83a8f5..69a64a249 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h +++ b/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -72,7 +72,12 @@ using namespace LiveSupport::Core; * * The name of the method when called through XML-RPC is "displayPlaylists". * - * No input parameters are expected. + * 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
    • + *
    * * The XML-RPC function returns an XML-RPC array, containing a structure * for each playlist in the playlist store. An array of size 0 means the @@ -83,8 +88,19 @@ using namespace LiveSupport::Core; * * * + * In case of an error, an XML-RPC structure is returned, with the following + * fields: + *
      + *
    • errorCode - int - the id of the error condition
    • + *
    • errorMessage - string - a description of the error
    • + *
    + * The possible error codes are: + *
      + *
    • 1722 - missing session ID argument
    • + *
    + * * @author $Author: fgerlits $ - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod { @@ -95,6 +111,11 @@ class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod */ static const std::string methodName; + /** + * The ID of this method for error reporting purposes. + */ + static const int errorId; + public: /** diff --git a/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx b/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx index 98e6c73da..b7a18fcaf 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx +++ b/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.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/DisplayPlaylistsMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -47,6 +47,8 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" + #include "DisplayPlaylistsMethod.h" #include "DisplayPlaylistsMethodTest.h" @@ -54,6 +56,8 @@ using namespace LiveSupport::Db; using namespace LiveSupport::Storage; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -74,6 +78,12 @@ const std::string DisplayPlaylistsMethodTest::storageClientConfig = const std::string DisplayPlaylistsMethodTest::connectionManagerConfig = "etc/connectionManagerFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string DisplayPlaylistsMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -104,6 +114,7 @@ DisplayPlaylistsMethodTest :: configure( void DisplayPlaylistsMethodTest :: setUp(void) throw () { + Ptr::Ref acf; try { Ptr::Ref scf = StorageClientFactory::getInstance(); @@ -113,6 +124,9 @@ DisplayPlaylistsMethodTest :: setUp(void) throw () = ConnectionManagerFactory::getInstance(); configure(cmf, connectionManagerConfig); + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -120,6 +134,11 @@ DisplayPlaylistsMethodTest :: setUp(void) throw () } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + authentication = acf->getAuthenticationClient(); + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -129,6 +148,9 @@ DisplayPlaylistsMethodTest :: setUp(void) throw () void DisplayPlaylistsMethodTest :: tearDown(void) throw () { + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -141,11 +163,15 @@ DisplayPlaylistsMethodTest :: firstTest(void) { Ptr::Ref method(new DisplayPlaylistsMethod()); XmlRpc::XmlRpcValue parameters; + XmlRpc::XmlRpcValue rootParameter; + rootParameter.setSize(1); XmlRpc::XmlRpcValue result; XmlRpc::XmlRpcValue playlist; result.clear(); - method->execute(parameters, result); + parameters["sessionId"] = sessionId->getId(); + rootParameter[0] = parameters; + method->execute(rootParameter, result); CPPUNIT_ASSERT(result.size() == 1); playlist = result[0]; diff --git a/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.h b/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.h index 947733ffd..6c4a12f30 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.h +++ b/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.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/DisplayPlaylistsMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -61,7 +63,7 @@ using namespace LiveSupport::Core; * Unit test for the DisplayPlaylistsMethod class. * * @author $Author: fgerlits $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @see DisplayPlaylistsMethod */ class DisplayPlaylistsMethodTest : public CPPUNIT_NS::TestFixture @@ -81,6 +83,22 @@ class DisplayPlaylistsMethodTest : public CPPUNIT_NS::TestFixture */ static const std::string connectionManagerConfig; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/DisplayScheduleMethod.cxx b/livesupport/products/scheduler/src/DisplayScheduleMethod.cxx index e2f6f29bd..2119e6f13 100644 --- a/livesupport/products/scheduler/src/DisplayScheduleMethod.cxx +++ b/livesupport/products/scheduler/src/DisplayScheduleMethod.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/DisplayScheduleMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -103,6 +103,17 @@ DisplayScheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, } XmlRpc::XmlRpcValue parameters = rootParameter[0]; + Ptr::Ref sessionId; + try{ + sessionId = XmlRpcTools::extractSessionId(parameters); + } + catch (std::invalid_argument &e) { + XmlRpcTools::markError(errorId+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref fromTime; try { fromTime = XmlRpcTools::extractFromTime(parameters); diff --git a/livesupport/products/scheduler/src/DisplayScheduleMethod.h b/livesupport/products/scheduler/src/DisplayScheduleMethod.h index 8b5344a07..84b17ead8 100644 --- a/livesupport/products/scheduler/src/DisplayScheduleMethod.h +++ b/livesupport/products/scheduler/src/DisplayScheduleMethod.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -74,8 +74,10 @@ using namespace LiveSupport::Core; * The name of the method when called through XML-RPC is "displaySchedule". * * The expected parameter is an XML-RPC structure, with the following - * member: + * members: *
      + *
    • sessionId - string - the session ID obtained via the login() + * method of the authentication client
    • *
    • from - datetime - the start of the interval to list schedule from, * inclusive.
    • *
    • to - datetime - the end of the interval to list schedule from, @@ -104,10 +106,11 @@ using namespace LiveSupport::Core; *
    • 1101 - invalid argument format
    • *
    • 1102 - missing or invalid 'from' argument
    • *
    • 1103 - missing or invalid 'to' argument
    • + *
    • 1122 - missing session ID argument
    • *
    * * @author $Author: fgerlits $ - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ class DisplayScheduleMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx b/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx index d7a37369b..81828e1d1 100644 --- a/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx +++ b/livesupport/products/scheduler/src/DisplayScheduleMethodTest.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/DisplayScheduleMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,6 +46,8 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" + #include "ScheduleFactory.h" #include "UploadPlaylistMethod.h" #include "DisplayScheduleMethod.h" @@ -56,6 +58,8 @@ using namespace std; using namespace LiveSupport::Db; using namespace LiveSupport::Storage; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -82,6 +86,12 @@ const std::string DisplayScheduleMethodTest::connectionManagerConfig = const std::string DisplayScheduleMethodTest::scheduleConfig = "etc/scheduleFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string DisplayScheduleMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -117,17 +127,21 @@ DisplayScheduleMethodTest :: setUp(void) throw () = StorageClientFactory::getInstance(); configure(scf, storageClientConfig); - Ptr::Ref cmf - = ConnectionManagerFactory::getInstance(); + Ptr::Ref + cmf = ConnectionManagerFactory::getInstance(); configure(cmf, connectionManagerConfig); - Ptr::Ref sf = ScheduleFactory::getInstance(); + Ptr::Ref + sf = ScheduleFactory::getInstance(); configure(sf, scheduleConfig); - schedule = sf->getSchedule(); schedule->install(); - insertEntries(); + Ptr::Ref + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + authentication = acf->getAuthenticationClient(); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -135,6 +149,12 @@ DisplayScheduleMethodTest :: setUp(void) throw () } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } + + insertEntries(); // this can only be called after sessionId is obtained } @@ -145,6 +165,10 @@ void DisplayScheduleMethodTest :: tearDown(void) throw () { schedule->uninstall(); + + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -163,6 +187,7 @@ DisplayScheduleMethodTest :: firstTest(void) struct tm time; // set up a structure for the parameters + parameters["sessionId"] = sessionId->getId(); time.tm_year = 2001; time.tm_mon = 11; time.tm_mday = 12; @@ -200,6 +225,7 @@ DisplayScheduleMethodTest :: insertEntries(void) struct tm time; // insert a playlist for 2004-07-31, at 10 o'clock + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; time.tm_year = 2004; time.tm_mon = 7; @@ -214,6 +240,7 @@ DisplayScheduleMethodTest :: insertEntries(void) method->execute(rootParameter, result); // insert a playlist for 2004-07-31, at 12 o'clock + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; time.tm_year = 2004; time.tm_mon = 7; @@ -228,6 +255,7 @@ DisplayScheduleMethodTest :: insertEntries(void) method->execute(rootParameter, result); // insert a playlist for 2004-07-31, at 14 o'clock + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; time.tm_year = 2004; time.tm_mon = 7; @@ -258,6 +286,7 @@ DisplayScheduleMethodTest :: intervalTest(void) struct tm time; // check for the interval 2004-07-31 between 9 and 11 o'clock + parameters["sessionId"] = sessionId->getId(); time.tm_year = 2004; time.tm_mon = 7; time.tm_mday = 31; @@ -296,6 +325,7 @@ DisplayScheduleMethodTest :: intervalTest(void) CPPUNIT_ASSERT(time.tm_sec == 0); // check for the interval 2004-07-31 between 9 and 13 o'clock + parameters["sessionId"] = sessionId->getId(); time.tm_year = 2004; time.tm_mon = 7; time.tm_mday = 31; @@ -350,6 +380,7 @@ DisplayScheduleMethodTest :: intervalTest(void) CPPUNIT_ASSERT(time.tm_sec == 0); // check for the interval 2004-07-31 between 8 and 9 o'clock + parameters["sessionId"] = sessionId->getId(); time.tm_year = 2004; time.tm_mon = 7; time.tm_mday = 31; diff --git a/livesupport/products/scheduler/src/DisplayScheduleMethodTest.h b/livesupport/products/scheduler/src/DisplayScheduleMethodTest.h index b08903945..d1515713c 100644 --- a/livesupport/products/scheduler/src/DisplayScheduleMethodTest.h +++ b/livesupport/products/scheduler/src/DisplayScheduleMethodTest.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -60,8 +62,8 @@ using namespace LiveSupport::Core; /** * Unit test for the DisplayScheduleMethod class. * - * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.2 $ * @see DisplayScheduleMethod */ class DisplayScheduleMethodTest : public CPPUNIT_NS::TestFixture @@ -92,6 +94,22 @@ class DisplayScheduleMethodTest : public CPPUNIT_NS::TestFixture */ Ptr::Ref schedule; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/GeneratePlayReportMethod.cxx b/livesupport/products/scheduler/src/GeneratePlayReportMethod.cxx index 81602563a..f171a7aeb 100644 --- a/livesupport/products/scheduler/src/GeneratePlayReportMethod.cxx +++ b/livesupport/products/scheduler/src/GeneratePlayReportMethod.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/GeneratePlayReportMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -103,6 +103,17 @@ GeneratePlayReportMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, } XmlRpc::XmlRpcValue parameters = rootParameter[0]; + Ptr::Ref sessionId; + try{ + sessionId = XmlRpcTools::extractSessionId(parameters); + } + catch (std::invalid_argument &e) { + XmlRpcTools::markError(errorId+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref fromTime; try { fromTime = XmlRpcTools::extractFromTime(parameters); diff --git a/livesupport/products/scheduler/src/GeneratePlayReportMethod.h b/livesupport/products/scheduler/src/GeneratePlayReportMethod.h index c686a8146..6e1f45269 100644 --- a/livesupport/products/scheduler/src/GeneratePlayReportMethod.h +++ b/livesupport/products/scheduler/src/GeneratePlayReportMethod.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/GeneratePlayReportMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -74,8 +74,10 @@ using namespace LiveSupport::Core; * The name of the method when called through XML-RPC is "generatePlayReport". * * The expected parameter is an XML-RPC structure, with the following - * member: + * members: *
      + *
    • sessionId - string - the session ID obtained via the login() + * method of the authentication client
    • *
    • from - datetime - the start of the interval to give the playlog * from, inclusive.
    • *
    • to - datetime - the end of the interval to give the playlog @@ -101,10 +103,11 @@ using namespace LiveSupport::Core; *
    • 1501 - invalid argument format
    • *
    • 1502 - missing or invalid 'from' argument
    • *
    • 1503 - missing or invalid 'to' argument
    • + *
    • 1522 - missing session ID argument
    • *
    * * @author $Author: fgerlits $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class GeneratePlayReportMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.cxx b/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.cxx index 6f39a3054..360ec2b98 100644 --- a/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.cxx +++ b/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.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/GeneratePlayReportMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,6 +46,8 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" + #include "PlayLogFactory.h" #include "UploadPlaylistMethod.h" #include "GeneratePlayReportMethod.h" @@ -56,6 +58,8 @@ using namespace std; using namespace LiveSupport::Db; using namespace LiveSupport::Storage; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -82,6 +86,12 @@ const std::string GeneratePlayReportMethodTest::connectionManagerConfig = const std::string GeneratePlayReportMethodTest::playLogConfig = "etc/playLogFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string GeneratePlayReportMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -112,6 +122,7 @@ GeneratePlayReportMethodTest :: configure( void GeneratePlayReportMethodTest :: setUp(void) throw () { + Ptr::Ref acf; try { Ptr::Ref scf = StorageClientFactory::getInstance(); @@ -129,6 +140,9 @@ GeneratePlayReportMethodTest :: setUp(void) throw () insertEntries(); + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -136,6 +150,11 @@ GeneratePlayReportMethodTest :: setUp(void) throw () } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + authentication = acf->getAuthenticationClient(); + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -146,6 +165,10 @@ void GeneratePlayReportMethodTest :: tearDown(void) throw () { playLog->uninstall(); + + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -164,6 +187,7 @@ GeneratePlayReportMethodTest :: firstTest(void) struct tm time; // set up a structure for the parameters + parameters["sessionId"] = sessionId->getId(); time.tm_year = 2001; time.tm_mon = 11; time.tm_mday = 12; @@ -223,6 +247,7 @@ GeneratePlayReportMethodTest :: intervalTest(void) struct tm time; // check for the interval 2004-10-26 between 13 and 15 o'clock + parameters["sessionId"] = sessionId->getId(); time.tm_year = 2004; time.tm_mon = 10; time.tm_mday = 26; @@ -255,6 +280,7 @@ GeneratePlayReportMethodTest :: intervalTest(void) // check for the interval 2004-10-26 between 14 o'clock and 15:30 + parameters["sessionId"] = sessionId->getId(); time.tm_year = 2004; time.tm_mon = 10; time.tm_mday = 26; @@ -287,6 +313,7 @@ GeneratePlayReportMethodTest :: intervalTest(void) // check for the interval 2004-10-26 15:00 to 2012-08-01 midnight + parameters["sessionId"] = sessionId->getId(); time.tm_year = 2004; time.tm_mon = 10; time.tm_mday = 26; @@ -328,6 +355,7 @@ GeneratePlayReportMethodTest :: intervalTest(void) // check for the interval 2004-10-26 16 o'clock to 2004-10-27 10 o'clock + parameters["sessionId"] = sessionId->getId(); time.tm_year = 2004; time.tm_mon = 10; time.tm_mday = 26; diff --git a/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.h b/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.h index 78ff3f978..7a632962e 100644 --- a/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.h +++ b/livesupport/products/scheduler/src/GeneratePlayReportMethodTest.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/GeneratePlayReportMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -61,7 +63,7 @@ using namespace LiveSupport::Core; * Unit test for the GeneratePlayReportMethod class. * * @author $Author: fgerlits $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @see GeneratePlayReportMethod */ class GeneratePlayReportMethodTest : public CPPUNIT_NS::TestFixture @@ -92,6 +94,22 @@ class GeneratePlayReportMethodTest : public CPPUNIT_NS::TestFixture */ Ptr::Ref playLog; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx index 7151490f5..10307d058 100644 --- a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx +++ b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.8 $ + Version : $Revision: 1.9 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -107,6 +107,17 @@ OpenPlaylistForEditingMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, } XmlRpc::XmlRpcValue parameters = rootParameter[0]; + Ptr::Ref sessionId; + try{ + sessionId = XmlRpcTools::extractSessionId(parameters); + } + catch (std::invalid_argument &e) { + XmlRpcTools::markError(errorId+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref id; try{ id = XmlRpcTools::extractPlaylistId(parameters); @@ -125,7 +136,7 @@ OpenPlaylistForEditingMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, Ptr::Ref playlist; try { - playlist = storage->getPlaylist(id); + playlist = storage->getPlaylist(sessionId, id); } catch (std::invalid_argument &e) { XmlRpcTools::markError(errorId+4, "playlist not found", diff --git a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h index 07ecf4ade..cefc97109 100644 --- a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h +++ b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -71,8 +71,10 @@ using namespace LiveSupport::Core; * "openPlaylistForEditing". * * The expected parameter is an XML-RPC structure, with the following - * member: + * members: *
      + *
    • sessionId - string - the session ID obtained via the login() + * method of the authentication client
    • *
    • playlistId - int - the unique id of the playlist requested.
    • *
    * @@ -95,9 +97,10 @@ using namespace LiveSupport::Core; *
  • 102 - argument is not a playlist ID
  • *
  • 104 - playlist not found
  • *
  • 105 - could not open playlist
  • + *
  • 122 - missing session ID argument
  • * * @author $Author: fgerlits $ - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ class OpenPlaylistForEditingMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx index 09f0d581f..53192e031 100644 --- a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx +++ b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.7 $ + Version : $Revision: 1.8 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,6 +46,7 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" #include "XmlRpcTools.h" #include "OpenPlaylistForEditingMethod.h" @@ -55,6 +56,8 @@ using namespace LiveSupport::Db; using namespace LiveSupport::Storage; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -75,6 +78,12 @@ const std::string OpenPlaylistForEditingMethodTest::storageClientConfig = const std::string OpenPlaylistForEditingMethodTest::connectionManagerConfig = "etc/connectionManagerFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string OpenPlaylistForEditingMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -105,6 +114,7 @@ OpenPlaylistForEditingMethodTest :: configure( void OpenPlaylistForEditingMethodTest :: setUp(void) throw () { + Ptr::Ref acf; try { Ptr::Ref scf = StorageClientFactory::getInstance(); @@ -114,6 +124,9 @@ OpenPlaylistForEditingMethodTest :: setUp(void) throw () = ConnectionManagerFactory::getInstance(); configure(cmf, connectionManagerConfig); + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -121,6 +134,11 @@ OpenPlaylistForEditingMethodTest :: setUp(void) throw () } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + authentication = acf->getAuthenticationClient(); + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -130,6 +148,9 @@ OpenPlaylistForEditingMethodTest :: setUp(void) throw () void OpenPlaylistForEditingMethodTest :: tearDown(void) throw () { + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -147,6 +168,7 @@ OpenPlaylistForEditingMethodTest :: firstTest(void) rootParameter.setSize(1); XmlRpc::XmlRpcValue result; + parameter["sessionId"] = sessionId->getId(); parameter["playlistId"] = 1; rootParameter[0] = parameter; @@ -156,6 +178,7 @@ OpenPlaylistForEditingMethodTest :: firstTest(void) CPPUNIT_ASSERT((int) result["playlength"] == (90 * 60)); parameter.clear(); + parameter["sessionId"] = sessionId->getId(); parameter["playlistId"] = 6376; rootParameter[0] = parameter; @@ -166,6 +189,7 @@ OpenPlaylistForEditingMethodTest :: firstTest(void) CPPUNIT_ASSERT((const std::string) result["errorMessage"] == "playlist not found"); parameter.clear(); + parameter["sessionId"] = sessionId->getId(); parameter["playlistId"] = 1; rootParameter[0] = parameter; diff --git a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.h b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.h index ec9a01f88..107539bfc 100644 --- a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.h +++ b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.h @@ -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/OpenPlaylistForEditingMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -61,7 +63,7 @@ using namespace LiveSupport::Core; * Unit test for the OpenPlaylistForEditingMethod class. * * @author $Author: fgerlits $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @see OpenPlaylistForEditingMethod */ class OpenPlaylistForEditingMethodTest : public CPPUNIT_NS::TestFixture @@ -81,6 +83,22 @@ class OpenPlaylistForEditingMethodTest : public CPPUNIT_NS::TestFixture */ static const std::string connectionManagerConfig; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/PlaylistEvent.cxx b/livesupport/products/scheduler/src/PlaylistEvent.cxx index 328a5ca20..8851bbaa6 100644 --- a/livesupport/products/scheduler/src/PlaylistEvent.cxx +++ b/livesupport/products/scheduler/src/PlaylistEvent.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.2 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEvent.cxx,v $ ------------------------------------------------------------------------------*/ @@ -40,6 +40,7 @@ #endif #include "LiveSupport/Core/TimeConversion.h" +#include "LiveSupport/Core/SessionId.h" #include "PlaylistEvent.h" @@ -70,6 +71,7 @@ PlaylistEvent :: PlaylistEvent( this->audioPlayer = audioPlayer; this->storage = storage; this->scheduleEntry = scheduleEntry; + this->sessionId.reset(new SessionId("dummy session ID")); } @@ -79,7 +81,10 @@ PlaylistEvent :: PlaylistEvent( void PlaylistEvent :: initialize(void) throw (std::exception) { - playlist = storage->acquirePlaylist(scheduleEntry->getPlaylistId()); + // some ugliness because getPlaylistId() returns a const pointer + Ptr::Ref playlistId(new UniqueId(scheduleEntry->getPlaylistId() + ->getId())); + playlist = storage->acquirePlaylist(sessionId, playlistId); } @@ -89,7 +94,7 @@ PlaylistEvent :: initialize(void) throw (std::exception) void PlaylistEvent :: deInitialize(void) throw () { - storage->releasePlaylist(playlist); + storage->releasePlaylist(sessionId, playlist); playlist.reset(); } diff --git a/livesupport/products/scheduler/src/PlaylistEvent.h b/livesupport/products/scheduler/src/PlaylistEvent.h index 2cdaef86a..d8c3adc7f 100644 --- a/livesupport/products/scheduler/src/PlaylistEvent.h +++ b/livesupport/products/scheduler/src/PlaylistEvent.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.2 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEvent.h,v $ ------------------------------------------------------------------------------*/ @@ -68,8 +68,8 @@ using namespace LiveSupport::Scheduler; /** * A scheduled event for playing a playlist. * - * @author $Author: maroy $ - * @version $Revision: 1.2 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.3 $ */ class PlaylistEvent : public virtual ScheduledEventInterface { @@ -99,6 +99,11 @@ class PlaylistEvent : public virtual ScheduledEventInterface */ Ptr::Ref playlist; + /** + * The session ID used for authentication at the storage server. + */ + Ptr::Ref sessionId; + public: /** diff --git a/livesupport/products/scheduler/src/PlaylistEventContainerTest.cxx b/livesupport/products/scheduler/src/PlaylistEventContainerTest.cxx index 9f385dcb0..536756303 100644 --- a/livesupport/products/scheduler/src/PlaylistEventContainerTest.cxx +++ b/livesupport/products/scheduler/src/PlaylistEventContainerTest.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEventContainerTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,6 +46,7 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" #include "LiveSupport/PlaylistExecutor/AudioPlayerFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" #include "PlaylistEventContainer.h" #include "PlaylistEventContainerTest.h" @@ -58,6 +59,8 @@ using namespace LiveSupport::Db; using namespace LiveSupport::Storage; using namespace LiveSupport::PlaylistExecutor; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -87,6 +90,12 @@ static const std::string storageClientConfigFileName = "etc/storageClient.xml"; */ static const std::string scheduleConfigFileName = "etc/scheduleFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +static const std::string authenticationClientConfigFileName = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -131,6 +140,14 @@ PlaylistEventContainerTest :: setUp(void) throw () schedule = scheduleFactory->getSchedule(); + // get an authentication client + Ptr::Ref acf; + acf = AuthenticationClientFactory::getInstance(); + parser.reset(new xmlpp::DomParser(authenticationClientConfigFileName, + true)); + acf->configure(*(parser->get_document()->get_root_node())); + authentication = acf->getAuthenticationClient(); + } catch (std::invalid_argument &e) { std::cerr << e.what() << std::endl; CPPUNIT_FAIL("semantic error in configuration file"); @@ -141,6 +158,10 @@ PlaylistEventContainerTest :: setUp(void) throw () scheduleFactory->install(); audioPlayer->initialize(); + + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -157,6 +178,10 @@ PlaylistEventContainerTest :: tearDown(void) throw () scheduleFactory.reset(); storage.reset(); audioPlayer.reset(); + + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -189,7 +214,8 @@ PlaylistEventContainerTest :: scheduleTest(void) // schedule playlist 1 at 10 seconds from now Ptr::Ref playlistId(new UniqueId(1)); - Ptr::Ref playlist = storage->getPlaylist(playlistId); + Ptr::Ref playlist = storage->getPlaylist(sessionId, + playlistId); CPPUNIT_ASSERT(playlist.get()); Ptr::Ref now = TimeConversion::now(); Ptr::Ref from(new ptime(*now + seconds(10))); diff --git a/livesupport/products/scheduler/src/PlaylistEventContainerTest.h b/livesupport/products/scheduler/src/PlaylistEventContainerTest.h index 1529400cf..57016b49e 100644 --- a/livesupport/products/scheduler/src/PlaylistEventContainerTest.h +++ b/livesupport/products/scheduler/src/PlaylistEventContainerTest.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlaylistEventContainerTest.h,v $ ------------------------------------------------------------------------------*/ @@ -40,14 +40,16 @@ #include "configure.h" #endif + #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" #include "LiveSupport/Core/StorageClientInterface.h" #include "LiveSupport/PlaylistExecutor/AudioPlayerInterface.h" #include "ScheduleInterface.h" #include "ScheduleFactory.h" - namespace LiveSupport { namespace Scheduler { @@ -58,6 +60,7 @@ using namespace LiveSupport::Core; using namespace LiveSupport::PlaylistExecutor; using namespace LiveSupport::Scheduler; + /* ================================================================ constants */ @@ -69,8 +72,8 @@ using namespace LiveSupport::Scheduler; /** * Unit test for the PlaylistEventContainer class * - * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.2 $ * @see PlaylistEventContainer */ class PlaylistEventContainerTest : public CPPUNIT_NS::TestFixture @@ -101,6 +104,16 @@ class PlaylistEventContainerTest : public CPPUNIT_NS::TestFixture */ Ptr::Ref schedule; + /** + * An authentication client. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + protected: diff --git a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx index 73639cf9d..9e6c0ec14 100644 --- a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.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/RemoveAudioClipFromPlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -108,6 +108,17 @@ RemoveAudioClipFromPlaylistMethod :: execute( } XmlRpc::XmlRpcValue parameters = rootParameter[0]; + Ptr::Ref sessionId; + try{ + sessionId = XmlRpcTools::extractSessionId(parameters); + } + catch (std::invalid_argument &e) { + XmlRpcTools::markError(errorId+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref playlistId; try{ playlistId = XmlRpcTools::extractPlaylistId(parameters); @@ -137,7 +148,7 @@ RemoveAudioClipFromPlaylistMethod :: execute( Ptr::Ref playlist; try { - playlist = storage->getPlaylist(playlistId); + playlist = storage->getPlaylist(sessionId, playlistId); } catch (std::invalid_argument &e) { XmlRpcTools::markError(errorId+4, "playlist does not exist", diff --git a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.h b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.h index 5bc7e1dee..af7bab612 100644 --- a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.h +++ b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.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/RemoveAudioClipFromPlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -73,6 +73,8 @@ using namespace LiveSupport::Core; * 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
    • *
    • playlistId - int - the unique id of the playlist.
    • *
    • relativeOffset - int - the number of seconds between the * start of the playlist and the start of the audio clip @@ -93,9 +95,10 @@ using namespace LiveSupport::Core; *
    • 404 - playlist does not exist
    • *
    • 405 - playlist has not been opened for editing
    • *
    • 406 - no audio clip at the specified relative offset
    • + *
    • 422 - missing session ID argument
    • *
    * @author $Author: fgerlits $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class RemoveAudioClipFromPlaylistMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.cxx b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.cxx index 61cc5ee46..3ca9e9022 100644 --- a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.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/RemoveAudioClipFromPlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,6 +46,7 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" #include "XmlRpcTools.h" #include "OpenPlaylistForEditingMethod.h" @@ -54,11 +55,11 @@ #include "RemoveAudioClipFromPlaylistMethodTest.h" - using namespace std; using namespace LiveSupport::Db; using namespace LiveSupport::Storage; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; /* =================================================== local data structures */ @@ -77,9 +78,17 @@ const std::string RemoveAudioClipFromPlaylistMethodTest::storageClientConfig = /** * The name of the configuration file for the connection manager factory. */ -const std::string RemoveAudioClipFromPlaylistMethodTest::connectionManagerConfig = +const std::string + RemoveAudioClipFromPlaylistMethodTest::connectionManagerConfig = "etc/connectionManagerFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string + RemoveAudioClipFromPlaylistMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -110,6 +119,7 @@ RemoveAudioClipFromPlaylistMethodTest :: configure( void RemoveAudioClipFromPlaylistMethodTest :: setUp(void) throw () { + Ptr::Ref acf; try { Ptr::Ref scf = StorageClientFactory::getInstance(); @@ -119,6 +129,9 @@ RemoveAudioClipFromPlaylistMethodTest :: setUp(void) thr = ConnectionManagerFactory::getInstance(); configure(cmf, connectionManagerConfig); + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -126,6 +139,11 @@ RemoveAudioClipFromPlaylistMethodTest :: setUp(void) thr } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + authentication = acf->getAuthenticationClient(); + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -135,6 +153,9 @@ RemoveAudioClipFromPlaylistMethodTest :: setUp(void) thr void RemoveAudioClipFromPlaylistMethodTest :: tearDown(void) throw () { + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -156,6 +177,7 @@ RemoveAudioClipFromPlaylistMethodTest :: firstTest(void) rootParameter.setSize(1); XmlRpc::XmlRpcValue result; + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; parameters["audioClipId"] = 10001; parameters["relativeOffset"] = 90*60; diff --git a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.h b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.h index d73c6d49b..aefbd709d 100644 --- a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.h +++ b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethodTest.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/RemoveAudioClipFromPlaylistMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -61,7 +63,7 @@ using namespace LiveSupport::Core; * Unit test for the RemoveAudioClipFromPlaylistMethod class. * * @author $Author: fgerlits $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @see RemoveAudioClipFromPlaylistMethod */ class RemoveAudioClipFromPlaylistMethodTest : public CPPUNIT_NS::TestFixture @@ -81,6 +83,22 @@ class RemoveAudioClipFromPlaylistMethodTest : public CPPUNIT_NS::TestFixture */ static const std::string connectionManagerConfig; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/RemoveFromScheduleMethod.cxx b/livesupport/products/scheduler/src/RemoveFromScheduleMethod.cxx index 46ff1b73c..287c9f6c0 100644 --- a/livesupport/products/scheduler/src/RemoveFromScheduleMethod.cxx +++ b/livesupport/products/scheduler/src/RemoveFromScheduleMethod.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/RemoveFromScheduleMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -100,6 +100,17 @@ RemoveFromScheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, } XmlRpc::XmlRpcValue parameters = rootParameter[0]; + Ptr::Ref sessionId; + try{ + sessionId = XmlRpcTools::extractSessionId(parameters); + } + catch (std::invalid_argument &e) { + XmlRpcTools::markError(errorId+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref entryId; try { entryId = XmlRpcTools::extractScheduleEntryId(parameters); diff --git a/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h b/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h index ebbc9b58b..60642efaf 100644 --- a/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h +++ b/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -72,6 +72,8 @@ using namespace LiveSupport::Core; * 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
    • *
    • scheduleEntryId - int - the id of the scheduled entry to remove
    • *
    * @@ -84,12 +86,13 @@ using namespace LiveSupport::Core; * The possible error codes are: *
      *
    • 1201 - invalid argument format
    • - *
    • 1202 - missing argument
    • - *
    • 1203 - not found
    • + *
    • 1202 - missing schedule entry ID argument
    • + *
    • 1203 - schedule entry not found
    • + *
    • 1222 - missing session ID argument
    • *
    * * @author $Author: fgerlits $ - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ class RemoveFromScheduleMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.cxx b/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.cxx index 5f2c40116..166c4f717 100644 --- a/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.cxx +++ b/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.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/RemoveFromScheduleMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -45,12 +45,16 @@ #include #include "ScheduleFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" + #include "UploadPlaylistMethod.h" #include "RemoveFromScheduleMethod.h" #include "RemoveFromScheduleMethodTest.h" using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -65,6 +69,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION(RemoveFromScheduleMethodTest); const std::string RemoveFromScheduleMethodTest::scheduleConfig = "etc/scheduleFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string RemoveFromScheduleMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -95,12 +105,17 @@ RemoveFromScheduleMethodTest :: configure( void RemoveFromScheduleMethodTest :: setUp(void) throw () { + Ptr::Ref acf; try { Ptr::Ref sf = ScheduleFactory::getInstance(); configure(sf, scheduleConfig); schedule = sf->getSchedule(); schedule->install(); + + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -108,6 +123,11 @@ RemoveFromScheduleMethodTest :: setUp(void) throw () } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + authentication = acf->getAuthenticationClient(); + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -118,6 +138,10 @@ void RemoveFromScheduleMethodTest :: tearDown(void) throw () { schedule->uninstall(); + + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -140,6 +164,7 @@ RemoveFromScheduleMethodTest :: firstTest(void) Ptr::Ref entryId; // first schedule (upload) a playlist + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; time.tm_year = 2001; time.tm_mon = 11; @@ -156,6 +181,7 @@ RemoveFromScheduleMethodTest :: firstTest(void) entryId.reset(new UniqueId(int(result["scheduleEntryId"]))); parameters.clear(); + parameters["sessionId"] = sessionId->getId(); parameters["scheduleEntryId"] = int(entryId->getId()); rootParameter[0] = parameters; @@ -180,6 +206,7 @@ RemoveFromScheduleMethodTest :: negativeTest(void) XmlRpc::XmlRpcValue result; Ptr::Ref entryId(new UniqueId(9999)); + parameters["sessionId"] = sessionId->getId(); parameters["scheduleEntryId"] = int(entryId->getId()); rootParameter[0] = parameters; diff --git a/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.h b/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.h index e56668c54..4fdf3c3ee 100644 --- a/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.h +++ b/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveFromScheduleMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -60,8 +62,8 @@ using namespace LiveSupport::Core; /** * Unit test for the RemoveFromScheduleMethod class. * - * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.2 $ * @see RemoveFromScheduleMethod */ class RemoveFromScheduleMethodTest : public CPPUNIT_NS::TestFixture @@ -81,6 +83,22 @@ class RemoveFromScheduleMethodTest : public CPPUNIT_NS::TestFixture */ Ptr::Ref schedule; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/RescheduleMethod.cxx b/livesupport/products/scheduler/src/RescheduleMethod.cxx index 0b9081d77..060aa2106 100644 --- a/livesupport/products/scheduler/src/RescheduleMethod.cxx +++ b/livesupport/products/scheduler/src/RescheduleMethod.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/RescheduleMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -103,6 +103,17 @@ RescheduleMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, } XmlRpc::XmlRpcValue parameters = rootParameter[0]; + Ptr::Ref sessionId; + try{ + sessionId = XmlRpcTools::extractSessionId(parameters); + } + catch (std::invalid_argument &e) { + XmlRpcTools::markError(errorId+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref entryId; try { entryId = XmlRpcTools::extractScheduleEntryId(parameters); diff --git a/livesupport/products/scheduler/src/RescheduleMethod.h b/livesupport/products/scheduler/src/RescheduleMethod.h index e04c3434c..6bbe6b1de 100644 --- a/livesupport/products/scheduler/src/RescheduleMethod.h +++ b/livesupport/products/scheduler/src/RescheduleMethod.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RescheduleMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -72,6 +72,8 @@ using namespace LiveSupport::Core; * 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
    • *
    • scheduleEntryId - int - the id of the schedule entry to reschedule *
    • *
    • playtime - datetime - the new playing time for the entry
    • @@ -90,10 +92,11 @@ using namespace LiveSupport::Core; *
    • 1303 - missing playtime argument
    • *
    • 1304 - schedule entry not found
    • *
    • 1305 - could not reschedule entry
    • + *
    • 1322 - missing session ID argument
    • *
    * * @author $Author: fgerlits $ - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ class RescheduleMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/RescheduleMethodTest.cxx b/livesupport/products/scheduler/src/RescheduleMethodTest.cxx index be6d07883..114c0e305 100644 --- a/livesupport/products/scheduler/src/RescheduleMethodTest.cxx +++ b/livesupport/products/scheduler/src/RescheduleMethodTest.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/RescheduleMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,14 +46,17 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" + #include "ScheduleFactory.h" #include "UploadPlaylistMethod.h" #include "RescheduleMethod.h" #include "RescheduleMethodTest.h" - using namespace LiveSupport::Db; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -68,6 +71,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION(RescheduleMethodTest); const std::string RescheduleMethodTest::scheduleConfig = "etc/scheduleFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string RescheduleMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -98,12 +107,17 @@ RescheduleMethodTest :: configure( void RescheduleMethodTest :: setUp(void) throw () { + Ptr::Ref acf; try { Ptr::Ref sf = ScheduleFactory::getInstance(); configure(sf, scheduleConfig); schedule = sf->getSchedule(); schedule->install(); + + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -111,6 +125,11 @@ RescheduleMethodTest :: setUp(void) throw () } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + authentication = acf->getAuthenticationClient(); + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -121,6 +140,10 @@ void RescheduleMethodTest :: tearDown(void) throw () { schedule->uninstall(); + + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -141,6 +164,7 @@ RescheduleMethodTest :: firstTest(void) Ptr::Ref entryId; // let's upload something so we can reschedule it + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; time.tm_year = 2001; time.tm_mon = 11; @@ -159,6 +183,7 @@ RescheduleMethodTest :: firstTest(void) // now let's reschedule it parameters.clear(); + parameters["sessionId"] = sessionId->getId(); parameters["scheduleEntryId"] = (int) entryId->getId(); time.tm_year = 2001; time.tm_mon = 11; @@ -175,6 +200,7 @@ RescheduleMethodTest :: firstTest(void) // now let's reschedule unto itself, should fail parameters.clear(); + parameters["sessionId"] = sessionId->getId(); parameters["scheduleEntryId"] = (int) entryId->getId(); time.tm_year = 2001; time.tm_mon = 11; diff --git a/livesupport/products/scheduler/src/RescheduleMethodTest.h b/livesupport/products/scheduler/src/RescheduleMethodTest.h index 7e854284a..c62b4c9af 100644 --- a/livesupport/products/scheduler/src/RescheduleMethodTest.h +++ b/livesupport/products/scheduler/src/RescheduleMethodTest.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RescheduleMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -60,8 +62,8 @@ using namespace LiveSupport::Core; /** * Unit test for the RescheduleMethod class. * - * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.2 $ * @see RescheduleMethod */ class RescheduleMethodTest : public CPPUNIT_NS::TestFixture @@ -80,6 +82,22 @@ class RescheduleMethodTest : public CPPUNIT_NS::TestFixture */ Ptr::Ref schedule; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.cxx b/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.cxx index 878477e55..243665187 100644 --- a/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.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/RevertEditedPlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -102,6 +102,17 @@ RevertEditedPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, } XmlRpc::XmlRpcValue parameters = rootParameter[0]; + Ptr::Ref sessionId; + try{ + sessionId = XmlRpcTools::extractSessionId(parameters); + } + catch (std::invalid_argument &e) { + XmlRpcTools::markError(errorId+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref id; try{ id = XmlRpcTools::extractPlaylistId(parameters); @@ -120,7 +131,7 @@ RevertEditedPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, Ptr::Ref playlist; try { - playlist = storage->getPlaylist(id); + playlist = storage->getPlaylist(sessionId, id); } catch (std::invalid_argument &e) { XmlRpcTools::markError(errorId+3, "playlist not found", diff --git a/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.h b/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.h index c81f974c4..8cf99329d 100644 --- a/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.h +++ b/livesupport/products/scheduler/src/RevertEditedPlaylistMethod.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/RevertEditedPlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -71,8 +71,10 @@ using namespace LiveSupport::Core; * "revertEditedPlaylist". * * The expected parameter is an XML-RPC structure, with the following - * member: + * members: *
      + *
    • sessionId - string - the session ID obtained via the login() + * method of the authentication client
    • *
    • playlistId - int - the unique id of the playlist requested.
    • *
    * @@ -88,9 +90,10 @@ using namespace LiveSupport::Core; *
  • 802 - argument is not a playlist ID
  • *
  • 803 - playlist not found
  • *
  • 804 - could not revert playlist
  • + *
  • 822 - missing session ID argument
  • * * @author $Author: fgerlits $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class RevertEditedPlaylistMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.cxx b/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.cxx index e1324584d..7ee5f58e9 100644 --- a/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.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/RevertEditedPlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,11 +46,12 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" + #include "OpenPlaylistForEditingMethod.h" #include "RemoveAudioClipFromPlaylistMethod.h" #include "SavePlaylistMethod.h" - #include "RevertEditedPlaylistMethod.h" #include "RevertEditedPlaylistMethodTest.h" @@ -58,6 +59,8 @@ using namespace std; using namespace LiveSupport::Db; using namespace LiveSupport::Storage; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -78,6 +81,12 @@ const std::string RevertEditedPlaylistMethodTest::storageClientConfig = const std::string RevertEditedPlaylistMethodTest::connectionManagerConfig = "etc/connectionManagerFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string RevertEditedPlaylistMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -108,6 +117,7 @@ RevertEditedPlaylistMethodTest :: configure( void RevertEditedPlaylistMethodTest :: setUp(void) throw () { + Ptr::Ref acf; try { Ptr::Ref scf = StorageClientFactory::getInstance(); @@ -117,6 +127,9 @@ RevertEditedPlaylistMethodTest :: setUp(void) throw () = ConnectionManagerFactory::getInstance(); configure(cmf, connectionManagerConfig); + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -124,6 +137,11 @@ RevertEditedPlaylistMethodTest :: setUp(void) throw () } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + authentication = acf->getAuthenticationClient(); + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -133,6 +151,9 @@ RevertEditedPlaylistMethodTest :: setUp(void) throw () void RevertEditedPlaylistMethodTest :: tearDown(void) throw () { + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -156,6 +177,7 @@ RevertEditedPlaylistMethodTest :: firstTest(void) rootParameter.setSize(1); XmlRpc::XmlRpcValue result; + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; parameters["relativeOffset"] = 0; rootParameter[0] = parameters; diff --git a/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.h b/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.h index fe681de74..442ce7bea 100644 --- a/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.h +++ b/livesupport/products/scheduler/src/RevertEditedPlaylistMethodTest.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/RevertEditedPlaylistMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -61,7 +63,7 @@ using namespace LiveSupport::Core; * Unit test for the RevertEditedPlaylistMethod class. * * @author $Author: fgerlits $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @see RevertEditedPlaylistMethod */ class RevertEditedPlaylistMethodTest : public CPPUNIT_NS::TestFixture @@ -81,6 +83,22 @@ class RevertEditedPlaylistMethodTest : public CPPUNIT_NS::TestFixture */ static const std::string connectionManagerConfig; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/SavePlaylistMethod.cxx b/livesupport/products/scheduler/src/SavePlaylistMethod.cxx index c3aa30235..d5ebf27c1 100644 --- a/livesupport/products/scheduler/src/SavePlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/SavePlaylistMethod.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/SavePlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -102,6 +102,17 @@ SavePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, } XmlRpc::XmlRpcValue parameters = rootParameter[0]; + Ptr::Ref sessionId; + try{ + sessionId = XmlRpcTools::extractSessionId(parameters); + } + catch (std::invalid_argument &e) { + XmlRpcTools::markError(errorId+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref id; try{ id = XmlRpcTools::extractPlaylistId(parameters); @@ -120,7 +131,7 @@ SavePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, Ptr::Ref playlist; try { - playlist = storage->getPlaylist(id); + playlist = storage->getPlaylist(sessionId, id); } catch (std::invalid_argument &e) { XmlRpcTools::markError(errorId+3, "playlist not found", diff --git a/livesupport/products/scheduler/src/SavePlaylistMethod.h b/livesupport/products/scheduler/src/SavePlaylistMethod.h index d61afa78d..181645dbf 100644 --- a/livesupport/products/scheduler/src/SavePlaylistMethod.h +++ b/livesupport/products/scheduler/src/SavePlaylistMethod.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/SavePlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -72,8 +72,10 @@ using namespace LiveSupport::Core; * "savePlaylist". * * The expected parameter is an XML-RPC structure, with the following - * member: + * members: *
      + *
    • sessionId - string - the session ID obtained via the login() + * method of the authentication client
    • *
    • playlistId - int - the unique id of the playlist to save.
    • *
    * @@ -89,9 +91,10 @@ using namespace LiveSupport::Core; *
  • 702 - argument is not a playlist ID
  • *
  • 703 - playlist not found
  • *
  • 704 - could not save playlist
  • + *
  • 722 - missing session ID argument
  • * * @author $Author: fgerlits $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class SavePlaylistMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/SavePlaylistMethodTest.cxx b/livesupport/products/scheduler/src/SavePlaylistMethodTest.cxx index f5682e859..61af6a756 100644 --- a/livesupport/products/scheduler/src/SavePlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/SavePlaylistMethodTest.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/SavePlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,16 +46,18 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" #include "OpenPlaylistForEditingMethod.h" #include "SavePlaylistMethod.h" #include "SavePlaylistMethodTest.h" - using namespace std; using namespace LiveSupport::Db; using namespace LiveSupport::Storage; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -76,6 +78,12 @@ const std::string SavePlaylistMethodTest::storageClientConfig = const std::string SavePlaylistMethodTest::connectionManagerConfig = "etc/connectionManagerFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string SavePlaylistMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -106,6 +114,7 @@ SavePlaylistMethodTest :: configure( void SavePlaylistMethodTest :: setUp(void) throw () { + Ptr::Ref acf; try { Ptr::Ref scf = StorageClientFactory::getInstance(); @@ -115,6 +124,9 @@ SavePlaylistMethodTest :: setUp(void) throw () = ConnectionManagerFactory::getInstance(); configure(cmf, connectionManagerConfig); + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -122,6 +134,11 @@ SavePlaylistMethodTest :: setUp(void) throw () } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + authentication = acf->getAuthenticationClient(); + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -131,6 +148,9 @@ SavePlaylistMethodTest :: setUp(void) throw () void SavePlaylistMethodTest :: tearDown(void) throw () { + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -149,6 +169,7 @@ SavePlaylistMethodTest :: firstTest(void) rootParameter.setSize(1); XmlRpc::XmlRpcValue result; + parameter["sessionId"] = sessionId->getId(); parameter["playlistId"] = 9999; rootParameter[0] = parameter; diff --git a/livesupport/products/scheduler/src/SavePlaylistMethodTest.h b/livesupport/products/scheduler/src/SavePlaylistMethodTest.h index d2daf4845..f9fb91ac8 100644 --- a/livesupport/products/scheduler/src/SavePlaylistMethodTest.h +++ b/livesupport/products/scheduler/src/SavePlaylistMethodTest.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/SavePlaylistMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -61,7 +63,7 @@ using namespace LiveSupport::Core; * Unit test for the SavePlaylistMethod class. * * @author $Author: fgerlits $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @see SavePlaylistMethod */ class SavePlaylistMethodTest : public CPPUNIT_NS::TestFixture @@ -81,6 +83,22 @@ class SavePlaylistMethodTest : public CPPUNIT_NS::TestFixture */ static const std::string connectionManagerConfig; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/SchedulerDaemonDisplayPlaylistTest.cxx b/livesupport/products/scheduler/src/SchedulerDaemonDisplayPlaylistTest.cxx index 6622f8fc2..fdd7bfc69 100644 --- a/livesupport/products/scheduler/src/SchedulerDaemonDisplayPlaylistTest.cxx +++ b/livesupport/products/scheduler/src/SchedulerDaemonDisplayPlaylistTest.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/Attic/SchedulerDaemonDisplayPlaylistTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -45,12 +45,15 @@ #include #include "SchedulerDaemon.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" #include "SchedulerDaemonDisplayPlaylistTest.h" - using namespace std; using namespace XmlRpc; +using namespace LiveSupport::Core; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -64,12 +67,36 @@ CPPUNIT_TEST_SUITE_REGISTRATION(SchedulerDaemonDisplayPlaylistTest); */ 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 */ /* ============================================================= module code */ +/*------------------------------------------------------------------------------ + * Configure a Configurable with an XML file. + *----------------------------------------------------------------------------*/ +void +SchedulerDaemonDisplayPlaylistTest :: 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 *----------------------------------------------------------------------------*/ @@ -80,22 +107,36 @@ SchedulerDaemonDisplayPlaylistTest :: setUp(void) throw ( if (!daemon->isConfigured()) { try { - std::auto_ptr - parser(new xmlpp::DomParser(configFileName, true)); - const xmlpp::Document * document = parser->get_document(); - daemon->configure(*(document->get_root_node())); + configure(daemon, configFileName); } catch (std::invalid_argument &e) { std::cerr << e.what() << std::endl; - CPPUNIT_FAIL("semantic error in configuration file"); + CPPUNIT_FAIL("semantic error in scheduler configuration file"); } catch (xmlpp::exception &e) { std::cerr << e.what() << std::endl; - CPPUNIT_FAIL("error parsing configuration file"); + CPPUNIT_FAIL("error parsing scheduler configuration file"); } } 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"); + } } @@ -109,6 +150,10 @@ SchedulerDaemonDisplayPlaylistTest :: tearDown(void) throw ( // daemon->stop(); daemon->uninstall(); + + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -124,6 +169,7 @@ SchedulerDaemonDisplayPlaylistTest :: simpleTest(void) XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; result.clear(); @@ -146,6 +192,7 @@ SchedulerDaemonDisplayPlaylistTest :: negativeTest(void) XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 9999; result.clear(); diff --git a/livesupport/products/scheduler/src/SchedulerDaemonDisplayPlaylistTest.h b/livesupport/products/scheduler/src/SchedulerDaemonDisplayPlaylistTest.h index b766b0b6c..1c1d4774b 100644 --- a/livesupport/products/scheduler/src/SchedulerDaemonDisplayPlaylistTest.h +++ b/livesupport/products/scheduler/src/SchedulerDaemonDisplayPlaylistTest.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonDisplayPlaylistTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,11 +42,15 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { using namespace LiveSupport; +using namespace LiveSupport::Core; + /* ================================================================ constants */ @@ -59,8 +63,8 @@ using namespace LiveSupport; /** * Unit test to test the displayPlaylist XML-RPC call. * - * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.2 $ * @see SchedulerDaemon */ class SchedulerDaemonDisplayPlaylistTest : public CPPUNIT_NS::TestFixture @@ -70,6 +74,31 @@ class SchedulerDaemonDisplayPlaylistTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST(negativeTest); 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/SchedulerDaemonDisplayScheduleTest.cxx b/livesupport/products/scheduler/src/SchedulerDaemonDisplayScheduleTest.cxx index 8a9243bf8..86167bba1 100644 --- a/livesupport/products/scheduler/src/SchedulerDaemonDisplayScheduleTest.cxx +++ b/livesupport/products/scheduler/src/SchedulerDaemonDisplayScheduleTest.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/Attic/SchedulerDaemonDisplayScheduleTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -45,11 +45,15 @@ #include #include "SchedulerDaemon.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" #include "SchedulerDaemonDisplayScheduleTest.h" using namespace std; using namespace XmlRpc; +using namespace LiveSupport::Core; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -63,12 +67,36 @@ CPPUNIT_TEST_SUITE_REGISTRATION(SchedulerDaemonDisplayScheduleTest); */ 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 */ /* ============================================================= module code */ +/*------------------------------------------------------------------------------ + * Configure a Configurable with an XML file. + *----------------------------------------------------------------------------*/ +void +SchedulerDaemonDisplayScheduleTest :: 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 *----------------------------------------------------------------------------*/ @@ -79,10 +107,7 @@ SchedulerDaemonDisplayScheduleTest :: setUp(void) throw ( if (!daemon->isConfigured()) { try { - std::auto_ptr - parser(new xmlpp::DomParser(configFileName, true)); - const xmlpp::Document * document = parser->get_document(); - daemon->configure(*(document->get_root_node())); + configure(daemon, configFileName); } catch (std::invalid_argument &e) { std::cerr << e.what() << std::endl; CPPUNIT_FAIL("semantic error in configuration file"); @@ -95,6 +120,23 @@ SchedulerDaemonDisplayScheduleTest :: 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"); + } } @@ -108,6 +150,10 @@ SchedulerDaemonDisplayScheduleTest :: tearDown(void) throw ( // daemon->stop(); daemon->uninstall(); + + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -126,6 +172,7 @@ SchedulerDaemonDisplayScheduleTest :: simpleTest(void) // list the schedules for an interval (as the database is empty, // it's going to return an empty result set) + parameters["sessionId"] = sessionId->getId(); time.tm_year = 2044; time.tm_mon = 11; time.tm_mday = 12; diff --git a/livesupport/products/scheduler/src/SchedulerDaemonDisplayScheduleTest.h b/livesupport/products/scheduler/src/SchedulerDaemonDisplayScheduleTest.h index 6aaaf21cd..f0be3cefc 100644 --- a/livesupport/products/scheduler/src/SchedulerDaemonDisplayScheduleTest.h +++ b/livesupport/products/scheduler/src/SchedulerDaemonDisplayScheduleTest.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonDisplayScheduleTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,11 +42,15 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { using namespace LiveSupport; +using namespace LiveSupport::Core; + /* ================================================================ constants */ @@ -59,8 +63,8 @@ using namespace LiveSupport; /** * Unit test to test the displaySchedule XML-RPC call. * - * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.2 $ * @see SchedulerDaemon */ class SchedulerDaemonDisplayScheduleTest : public CPPUNIT_NS::TestFixture @@ -69,6 +73,31 @@ class SchedulerDaemonDisplayScheduleTest : 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/SchedulerDaemonRemoveFromScheduleTest.cxx b/livesupport/products/scheduler/src/SchedulerDaemonRemoveFromScheduleTest.cxx index 5ff6f9302..7ca138b11 100644 --- a/livesupport/products/scheduler/src/SchedulerDaemonRemoveFromScheduleTest.cxx +++ b/livesupport/products/scheduler/src/SchedulerDaemonRemoveFromScheduleTest.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/Attic/SchedulerDaemonRemoveFromScheduleTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -45,12 +45,15 @@ #include #include "SchedulerDaemon.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" #include "SchedulerDaemonRemoveFromScheduleTest.h" - using namespace std; using namespace XmlRpc; +using namespace LiveSupport::Core; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -64,12 +67,36 @@ CPPUNIT_TEST_SUITE_REGISTRATION(SchedulerDaemonRemoveFromScheduleTest); */ 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 */ /* ============================================================= module code */ +/*------------------------------------------------------------------------------ + * Configure a Configurable with an XML file. + *----------------------------------------------------------------------------*/ +void +SchedulerDaemonRemoveFromScheduleTest :: 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 *----------------------------------------------------------------------------*/ @@ -80,10 +107,7 @@ SchedulerDaemonRemoveFromScheduleTest :: setUp(void) thro if (!daemon->isConfigured()) { try { - std::auto_ptr - parser(new xmlpp::DomParser(configFileName, true)); - const xmlpp::Document * document = parser->get_document(); - daemon->configure(*(document->get_root_node())); + configure(daemon, configFileName); } catch (std::invalid_argument &e) { std::cerr << e.what() << std::endl; CPPUNIT_FAIL("semantic error in configuration file"); @@ -96,6 +120,23 @@ SchedulerDaemonRemoveFromScheduleTest :: setUp(void) thro 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"); + } } @@ -109,6 +150,10 @@ SchedulerDaemonRemoveFromScheduleTest :: tearDown(void) thro // daemon->stop(); daemon->uninstall(); + + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -126,6 +171,7 @@ SchedulerDaemonRemoveFromScheduleTest :: simpleTest(void) XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); // first schedule a playlist, so that there is something to remove + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; time.tm_year = 2001; time.tm_mon = 11; @@ -161,6 +207,7 @@ SchedulerDaemonRemoveFromScheduleTest :: negativeTest(void) XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + parameters["sessionId"] = sessionId->getId(); parameters["scheduleEntryId"] = 9999; result.clear(); diff --git a/livesupport/products/scheduler/src/SchedulerDaemonRemoveFromScheduleTest.h b/livesupport/products/scheduler/src/SchedulerDaemonRemoveFromScheduleTest.h index 0b5218192..fa3f0d221 100644 --- a/livesupport/products/scheduler/src/SchedulerDaemonRemoveFromScheduleTest.h +++ b/livesupport/products/scheduler/src/SchedulerDaemonRemoveFromScheduleTest.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonRemoveFromScheduleTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,11 +42,15 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { using namespace LiveSupport; +using namespace LiveSupport::Core; + /* ================================================================ constants */ @@ -59,8 +63,8 @@ using namespace LiveSupport; /** * Unit test to test the removeFromSchedule XML-RPC call. * - * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.2 $ * @see SchedulerDaemon */ class SchedulerDaemonRemoveFromScheduleTest : public CPPUNIT_NS::TestFixture @@ -70,6 +74,31 @@ class SchedulerDaemonRemoveFromScheduleTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST(negativeTest); 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/SchedulerDaemonRescheduleTest.cxx b/livesupport/products/scheduler/src/SchedulerDaemonRescheduleTest.cxx index 61c82bec4..1252b2239 100644 --- a/livesupport/products/scheduler/src/SchedulerDaemonRescheduleTest.cxx +++ b/livesupport/products/scheduler/src/SchedulerDaemonRescheduleTest.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/Attic/SchedulerDaemonRescheduleTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -45,11 +45,14 @@ #include #include "SchedulerDaemon.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" #include "SchedulerDaemonRescheduleTest.h" - using namespace XmlRpc; +using namespace LiveSupport::Core; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -63,12 +66,36 @@ CPPUNIT_TEST_SUITE_REGISTRATION(SchedulerDaemonRescheduleTest); */ 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 */ /* ============================================================= module code */ +/*------------------------------------------------------------------------------ + * Configure a Configurable with an XML file. + *----------------------------------------------------------------------------*/ +void +SchedulerDaemonRescheduleTest :: 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 *----------------------------------------------------------------------------*/ @@ -79,10 +106,7 @@ SchedulerDaemonRescheduleTest :: setUp(void) throw () if (!daemon->isConfigured()) { try { - std::auto_ptr - parser(new xmlpp::DomParser(configFileName, true)); - const xmlpp::Document * document = parser->get_document(); - daemon->configure(*(document->get_root_node())); + configure(daemon, configFileName); } catch (std::invalid_argument &e) { std::cerr << e.what() << std::endl; CPPUNIT_FAIL("semantic error in configuration file"); @@ -95,6 +119,23 @@ SchedulerDaemonRescheduleTest :: 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"); + } } @@ -108,6 +149,10 @@ SchedulerDaemonRescheduleTest :: tearDown(void) throw () // daemon->stop(); daemon->uninstall(); + + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -125,6 +170,7 @@ SchedulerDaemonRescheduleTest :: simpleTest(void) XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); // first schedule a playlist, so that there is something to reschedule + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; time.tm_year = 2001; time.tm_mon = 11; @@ -140,6 +186,7 @@ SchedulerDaemonRescheduleTest :: simpleTest(void) Ptr::Ref entryId(new UniqueId(int(result["scheduleEntryId"]))); // now reschedule it + parameters["sessionId"] = sessionId->getId(); parameters["scheduleEntryId"] = (int) entryId->getId(); time.tm_year = 2001; time.tm_mon = 11; @@ -154,6 +201,7 @@ SchedulerDaemonRescheduleTest :: simpleTest(void) CPPUNIT_ASSERT(!result.hasMember("errorCode")); // now reschedule it unto itself, should fail + parameters["sessionId"] = sessionId->getId(); parameters["scheduleEntryId"] = (int) entryId->getId(); time.tm_year = 2001; time.tm_mon = 11; @@ -181,6 +229,7 @@ SchedulerDaemonRescheduleTest :: negativeTest(void) XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); + parameters["sessionId"] = sessionId->getId(); parameters["scheduleEntryId"] = 9999; result.clear(); diff --git a/livesupport/products/scheduler/src/SchedulerDaemonRescheduleTest.h b/livesupport/products/scheduler/src/SchedulerDaemonRescheduleTest.h index 5c57d6500..e5b96b4d0 100644 --- a/livesupport/products/scheduler/src/SchedulerDaemonRescheduleTest.h +++ b/livesupport/products/scheduler/src/SchedulerDaemonRescheduleTest.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonRescheduleTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,11 +42,15 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { using namespace LiveSupport; +using namespace LiveSupport::Core; + /* ================================================================ constants */ @@ -59,8 +63,8 @@ using namespace LiveSupport; /** * Unit test to test the removeFromSchedule XML-RPC call. * - * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.2 $ * @see SchedulerDaemon */ class SchedulerDaemonRescheduleTest : public CPPUNIT_NS::TestFixture @@ -70,6 +74,31 @@ class SchedulerDaemonRescheduleTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST(negativeTest); 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/SchedulerDaemonUploadTest.cxx b/livesupport/products/scheduler/src/SchedulerDaemonUploadTest.cxx index d91af77b1..a0485049e 100644 --- a/livesupport/products/scheduler/src/SchedulerDaemonUploadTest.cxx +++ b/livesupport/products/scheduler/src/SchedulerDaemonUploadTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonUploadTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -47,12 +47,15 @@ #include "XmlRpcTools.h" #include "LiveSupport/Core/UniqueId.h" #include "SchedulerDaemon.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" #include "SchedulerDaemonUploadTest.h" - using namespace std; using namespace XmlRpc; +using namespace LiveSupport::Core; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -66,12 +69,36 @@ CPPUNIT_TEST_SUITE_REGISTRATION(SchedulerDaemonUploadTest); */ 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 */ /* ============================================================= module code */ +/*------------------------------------------------------------------------------ + * Configure a Configurable with an XML file. + *----------------------------------------------------------------------------*/ +void +SchedulerDaemonUploadTest :: 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 *----------------------------------------------------------------------------*/ @@ -82,10 +109,7 @@ SchedulerDaemonUploadTest :: setUp(void) throw () if (!daemon->isConfigured()) { try { - std::auto_ptr - parser(new xmlpp::DomParser(configFileName, true)); - const xmlpp::Document * document = parser->get_document(); - daemon->configure(*(document->get_root_node())); + configure(daemon, configFileName); } catch (std::invalid_argument &e) { std::cerr << e.what() << std::endl; CPPUNIT_FAIL("semantic error in configuration file"); @@ -98,6 +122,23 @@ SchedulerDaemonUploadTest :: 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"); + } } @@ -111,6 +152,10 @@ SchedulerDaemonUploadTest :: tearDown(void) throw () // daemon->stop(); daemon->uninstall(); + + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -128,6 +173,7 @@ SchedulerDaemonUploadTest :: simpleTest(void) XmlRpcClient xmlRpcClient("localhost", 3344, "/RPC2", false); // try to schedule playlist #1 for the time below + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; time.tm_year = 2001; time.tm_mon = 11; diff --git a/livesupport/products/scheduler/src/SchedulerDaemonUploadTest.h b/livesupport/products/scheduler/src/SchedulerDaemonUploadTest.h index a44fb42fd..c596f1c9f 100644 --- a/livesupport/products/scheduler/src/SchedulerDaemonUploadTest.h +++ b/livesupport/products/scheduler/src/SchedulerDaemonUploadTest.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/SchedulerDaemonUploadTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,11 +42,15 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { using namespace LiveSupport; +using namespace LiveSupport::Core; + /* ================================================================ constants */ @@ -59,8 +63,8 @@ using namespace LiveSupport; /** * Unit test to test the uploadPlaylist XML-RPC call. * - * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.2 $ * @see SchedulerDaemon */ class SchedulerDaemonUploadTest : public CPPUNIT_NS::TestFixture @@ -69,6 +73,31 @@ class SchedulerDaemonUploadTest : 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/UpdateFadeInFadeOutMethod.cxx b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx index a9011a6f1..b5705c946 100644 --- a/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx +++ b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.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/UpdateFadeInFadeOutMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -110,6 +110,17 @@ UpdateFadeInFadeOutMethod :: execute( } XmlRpc::XmlRpcValue parameters = rootParameter[0]; + Ptr::Ref sessionId; + try{ + sessionId = XmlRpcTools::extractSessionId(parameters); + } + catch (std::invalid_argument &e) { + XmlRpcTools::markError(errorId+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref playlistId; try{ playlistId = XmlRpcTools::extractPlaylistId(parameters); @@ -161,7 +172,7 @@ UpdateFadeInFadeOutMethod :: execute( Ptr::Ref playlist; try { - playlist = storage->getPlaylist(playlistId); + playlist = storage->getPlaylist(sessionId, playlistId); } catch (std::invalid_argument &e) { XmlRpcTools::markError(errorId+6, "playlist does not exist", diff --git a/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.h b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.h index ae17ac9be..2ebbae7f4 100644 --- a/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.h +++ b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.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/UpdateFadeInFadeOutMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -73,6 +73,8 @@ using namespace LiveSupport::Core; * 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
    • *
    • playlistId - int - the unique id of the playlist.
    • *
    • relativeOffset - int - the number of seconds between the * start of the playlist and the start of the audio clip @@ -97,9 +99,10 @@ using namespace LiveSupport::Core; *
    • 1606 - playlist does not exist
    • *
    • 1607 - playlist has not been opened for editing
    • *
    • 1608 - no audio clip at the specified relative offset
    • + *
    • 1622 - missing session ID argument
    • *
    * @author $Author: fgerlits $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class UpdateFadeInFadeOutMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.cxx b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.cxx index 659677b73..d83327cb4 100644 --- a/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.cxx +++ b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.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/UpdateFadeInFadeOutMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,6 +46,7 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" #include "XmlRpcTools.h" #include "OpenPlaylistForEditingMethod.h" @@ -54,11 +55,11 @@ #include "UpdateFadeInFadeOutMethodTest.h" - using namespace std; using namespace LiveSupport::Db; using namespace LiveSupport::Storage; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; /* =================================================== local data structures */ @@ -80,6 +81,12 @@ const std::string UpdateFadeInFadeOutMethodTest::storageClientConfig = const std::string UpdateFadeInFadeOutMethodTest::connectionManagerConfig = "etc/connectionManagerFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string UpdateFadeInFadeOutMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -110,6 +117,7 @@ UpdateFadeInFadeOutMethodTest :: configure( void UpdateFadeInFadeOutMethodTest :: setUp(void) throw () { + Ptr::Ref acf; try { Ptr::Ref scf = StorageClientFactory::getInstance(); @@ -119,6 +127,9 @@ UpdateFadeInFadeOutMethodTest :: setUp(void) throw () = ConnectionManagerFactory::getInstance(); configure(cmf, connectionManagerConfig); + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -126,6 +137,11 @@ UpdateFadeInFadeOutMethodTest :: setUp(void) throw () } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + authentication = acf->getAuthenticationClient(); + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -135,6 +151,9 @@ UpdateFadeInFadeOutMethodTest :: setUp(void) throw () void UpdateFadeInFadeOutMethodTest :: tearDown(void) throw () { + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -154,6 +173,7 @@ UpdateFadeInFadeOutMethodTest :: firstTest(void) rootParameter.setSize(1); XmlRpc::XmlRpcValue result; + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; parameters["relativeOffset"] = 90*60; parameters["fadeIn"] = 0; diff --git a/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.h b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.h index c50217638..5ffabdc00 100644 --- a/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.h +++ b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethodTest.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/UpdateFadeInFadeOutMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -61,7 +63,7 @@ using namespace LiveSupport::Core; * Unit test for the UpdateFadeInFadeOutMethod class. * * @author $Author: fgerlits $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @see UpdateFadeInFadeOutMethod */ class UpdateFadeInFadeOutMethodTest : public CPPUNIT_NS::TestFixture @@ -81,6 +83,22 @@ class UpdateFadeInFadeOutMethodTest : public CPPUNIT_NS::TestFixture */ static const std::string connectionManagerConfig; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx b/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx index beb0afa08..44d468bef 100644 --- a/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -106,6 +106,17 @@ UploadPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, } XmlRpc::XmlRpcValue parameters = rootParameter[0]; + Ptr::Ref sessionId; + try{ + sessionId = XmlRpcTools::extractSessionId(parameters); + } + catch (std::invalid_argument &e) { + XmlRpcTools::markError(errorId+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref playlistId; try { playlistId = XmlRpcTools::extractPlaylistId(parameters); @@ -133,7 +144,7 @@ UploadPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, Ptr::Ref playlist; try { - playlist = storage->getPlaylist(playlistId); + playlist = storage->getPlaylist(sessionId, playlistId); } catch (std::invalid_argument &e) { XmlRpcTools::markError(errorId+4, "playlist not found", diff --git a/livesupport/products/scheduler/src/UploadPlaylistMethod.h b/livesupport/products/scheduler/src/UploadPlaylistMethod.h index b424bc130..b0e50f56c 100644 --- a/livesupport/products/scheduler/src/UploadPlaylistMethod.h +++ b/livesupport/products/scheduler/src/UploadPlaylistMethod.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.7 $ + Version : $Revision: 1.8 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -73,6 +73,8 @@ using namespace LiveSupport::Core; * 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
    • *
    • playlistId - int, the id of the playlist to upload
    • *
    • playtime - the time when the playlist should be scheduled, * an ISO 8601 DateTime field
    • @@ -99,10 +101,11 @@ using namespace LiveSupport::Core; *
    • 1404 - playlist not found
    • *
    • 1405 - timeframe not available
    • *
    • 1406 - could not schedule playlist
    • + *
    • 1422 - missing session ID argument
    • *
    * * @author $Author: fgerlits $ - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ */ class UploadPlaylistMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/UploadPlaylistMethodTest.cxx b/livesupport/products/scheduler/src/UploadPlaylistMethodTest.cxx index df5420f8a..d4e79e2c0 100644 --- a/livesupport/products/scheduler/src/UploadPlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/UploadPlaylistMethodTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,14 +46,17 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" #include "ScheduleFactory.h" + #include "UploadPlaylistMethod.h" #include "UploadPlaylistMethodTest.h" - using namespace LiveSupport::Db; using namespace LiveSupport::Storage; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; + /* =================================================== local data structures */ @@ -80,6 +83,12 @@ const std::string UploadPlaylistMethodTest::connectionManagerConfig = const std::string UploadPlaylistMethodTest::scheduleConfig = "etc/scheduleFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string UploadPlaylistMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -110,6 +119,7 @@ UploadPlaylistMethodTest :: configure( void UploadPlaylistMethodTest :: setUp(void) throw () { + Ptr::Ref acf; try { Ptr::Ref scf = StorageClientFactory::getInstance(); @@ -124,6 +134,10 @@ UploadPlaylistMethodTest :: setUp(void) throw () schedule = sf->getSchedule(); schedule->install(); + + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -131,6 +145,11 @@ UploadPlaylistMethodTest :: setUp(void) throw () } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + authentication = acf->getAuthenticationClient(); + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -141,6 +160,10 @@ void UploadPlaylistMethodTest :: tearDown(void) throw () { schedule->uninstall(); + + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -159,6 +182,7 @@ UploadPlaylistMethodTest :: firstTest(void) struct tm time; // set up a structure for the parameters + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; time.tm_year = 2001; time.tm_mon = 11; @@ -190,6 +214,7 @@ UploadPlaylistMethodTest :: overlappingPlaylists(void) struct tm time; // load the first playlist, this will succeed + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; time.tm_year = 2001; time.tm_mon = 11; @@ -206,6 +231,7 @@ UploadPlaylistMethodTest :: overlappingPlaylists(void) // try to load the same one, but in an overlapping time region // (we know that playlist with id 1 is 1 hour long) + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; time.tm_year = 2001; time.tm_mon = 11; @@ -222,6 +248,7 @@ UploadPlaylistMethodTest :: overlappingPlaylists(void) CPPUNIT_ASSERT(int(result["errorCode"]) == 1405); // timeframe not available // try to load the same one, but now in good timing + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; time.tm_year = 2001; time.tm_mon = 11; @@ -237,6 +264,7 @@ UploadPlaylistMethodTest :: overlappingPlaylists(void) CPPUNIT_ASSERT(result.hasMember("scheduleEntryId")); // try to load the same one, this time overlapping both previos instances + parameters["sessionId"] = sessionId->getId(); parameters["playlistId"] = 1; time.tm_year = 2001; time.tm_mon = 11; diff --git a/livesupport/products/scheduler/src/UploadPlaylistMethodTest.h b/livesupport/products/scheduler/src/UploadPlaylistMethodTest.h index ac58677f0..35126faf9 100644 --- a/livesupport/products/scheduler/src/UploadPlaylistMethodTest.h +++ b/livesupport/products/scheduler/src/UploadPlaylistMethodTest.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.2 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UploadPlaylistMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -60,8 +62,8 @@ using namespace LiveSupport::Core; /** * Unit test for the UploadPlaylistMethod class. * - * @author $Author: maroy $ - * @version $Revision: 1.2 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.3 $ * @see UploadPlaylistMethod */ class UploadPlaylistMethodTest : public CPPUNIT_NS::TestFixture @@ -92,6 +94,22 @@ class UploadPlaylistMethodTest : public CPPUNIT_NS::TestFixture */ Ptr::Ref schedule; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx b/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx index 7905885d5..21788e54f 100644 --- a/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx +++ b/livesupport/products/scheduler/src/ValidatePlaylistMethod.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/ValidatePlaylistMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -107,6 +107,17 @@ ValidatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, } XmlRpc::XmlRpcValue parameters = rootParameter[0]; + Ptr::Ref sessionId; + try{ + sessionId = XmlRpcTools::extractSessionId(parameters); + } + catch (std::invalid_argument &e) { + XmlRpcTools::markError(errorId+22, + "missing session ID argument", + returnValue); + return; + } + Ptr::Ref playlistId; try{ playlistId = XmlRpcTools::extractPlaylistId(parameters); @@ -125,7 +136,7 @@ ValidatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter, Ptr::Ref playlist; try { - playlist = storage->getPlaylist(playlistId); + playlist = storage->getPlaylist(sessionId, playlistId); } catch (std::invalid_argument &e) { XmlRpcTools::markError(errorId+3, "playlist does not exist", diff --git a/livesupport/products/scheduler/src/ValidatePlaylistMethod.h b/livesupport/products/scheduler/src/ValidatePlaylistMethod.h index cec371cf1..c0a1975c2 100644 --- a/livesupport/products/scheduler/src/ValidatePlaylistMethod.h +++ b/livesupport/products/scheduler/src/ValidatePlaylistMethod.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/ValidatePlaylistMethod.h,v $ ------------------------------------------------------------------------------*/ @@ -70,8 +70,10 @@ using namespace LiveSupport::Core; * "validatePlaylist". * * The expected parameter is an XML-RPC structure, with the following - * member: + * members: *
      + *
    • sessionId - string - the session ID obtained via the login() + * method of the authentication client
    • *
    • playlistId - int - the unique id of the playlist.
    • *
    * @@ -93,9 +95,10 @@ using namespace LiveSupport::Core; *
  • 502 - missing playlist ID argument
  • *
  • 503 - playlist does not exist
  • *
  • 504 - playlist has not been opened for editing
  • + *
  • 522 - missing session ID argument
  • * * @author $Author: fgerlits $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class ValidatePlaylistMethod : public XmlRpc::XmlRpcServerMethod { diff --git a/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.cxx b/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.cxx index 13ea512a8..35b664f1c 100644 --- a/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.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/ValidatePlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -46,6 +46,7 @@ #include "LiveSupport/Db/ConnectionManagerFactory.h" #include "LiveSupport/Storage/StorageClientFactory.h" +#include "LiveSupport/Authentication/AuthenticationClientFactory.h" #include "XmlRpcTools.h" #include "OpenPlaylistForEditingMethod.h" @@ -54,11 +55,11 @@ #include "ValidatePlaylistMethodTest.h" - using namespace std; using namespace LiveSupport::Db; using namespace LiveSupport::Storage; using namespace LiveSupport::Scheduler; +using namespace LiveSupport::Authentication; /* =================================================== local data structures */ @@ -80,6 +81,12 @@ const std::string ValidatePlaylistMethodTest::storageClientConfig = const std::string ValidatePlaylistMethodTest::connectionManagerConfig = "etc/connectionManagerFactory.xml"; +/** + * The name of the configuration file for the authentication client factory. + */ +const std::string ValidatePlaylistMethodTest::authenticationClientConfig = + "etc/authenticationClient.xml"; + /* =============================================== local function prototypes */ @@ -110,6 +117,7 @@ ValidatePlaylistMethodTest :: configure( void ValidatePlaylistMethodTest :: setUp(void) throw () { + Ptr::Ref acf; try { Ptr::Ref scf = StorageClientFactory::getInstance(); @@ -119,6 +127,9 @@ ValidatePlaylistMethodTest :: setUp(void) throw () = ConnectionManagerFactory::getInstance(); configure(cmf, connectionManagerConfig); + acf = AuthenticationClientFactory::getInstance(); + configure(acf, authenticationClientConfig); + } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { @@ -126,6 +137,11 @@ ValidatePlaylistMethodTest :: setUp(void) throw () } catch (std::exception &e) { CPPUNIT_FAIL(e.what()); } + + authentication = acf->getAuthenticationClient(); + if (!(sessionId = authentication->login("root", "q"))) { + CPPUNIT_FAIL("could not log in to authentication server"); + } } @@ -135,6 +151,9 @@ ValidatePlaylistMethodTest :: setUp(void) throw () void ValidatePlaylistMethodTest :: tearDown(void) throw () { + authentication->logout(sessionId); + sessionId.reset(); + authentication.reset(); } @@ -157,6 +176,7 @@ ValidatePlaylistMethodTest :: firstTest(void) XmlRpc::XmlRpcValue result; result.clear(); + parameter["sessionId"] = sessionId->getId(); parameter["playlistId"] = 275; rootParameter[0] = parameter; validatePlaylistMethod->execute(rootParameter, result); @@ -165,6 +185,7 @@ ValidatePlaylistMethodTest :: firstTest(void) result.clear(); parameter.clear(); + parameter["sessionId"] = sessionId->getId(); parameter["playlistId"] = 1; rootParameter[0] = parameter; openPlaylistMethod->execute(rootParameter, result); diff --git a/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.h b/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.h index 19abbb96f..13bc7e76b 100644 --- a/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.h +++ b/livesupport/products/scheduler/src/ValidatePlaylistMethodTest.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/ValidatePlaylistMethodTest.h,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #include +#include "LiveSupport/Core/AuthenticationClientInterface.h" +#include "LiveSupport/Core/SessionId.h" namespace LiveSupport { namespace Scheduler { @@ -61,7 +63,7 @@ using namespace LiveSupport::Core; * Unit test for the ValidatePlaylistMethod class. * * @author $Author: fgerlits $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @see ValidatePlaylistMethod */ class ValidatePlaylistMethodTest : public CPPUNIT_NS::TestFixture @@ -81,6 +83,22 @@ class ValidatePlaylistMethodTest : public CPPUNIT_NS::TestFixture */ static const std::string connectionManagerConfig; + /** + * The name of the configuration file for the authentication client + * factory. + */ + static const std::string authenticationClientConfig; + + /** + * The authentication client produced by the factory. + */ + Ptr::Ref authentication; + + /** + * A session ID from the authentication client login() method. + */ + Ptr::Ref sessionId; + /** * Configure a configurable with an XML file. * diff --git a/livesupport/products/scheduler/src/XmlRpcTools.cxx b/livesupport/products/scheduler/src/XmlRpcTools.cxx index 6b9e8f699..57ce2de36 100644 --- a/livesupport/products/scheduler/src/XmlRpcTools.cxx +++ b/livesupport/products/scheduler/src/XmlRpcTools.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.9 $ + Version : $Revision: 1.10 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/XmlRpcTools.cxx,v $ ------------------------------------------------------------------------------*/ @@ -107,6 +107,11 @@ const std::string XmlRpcTools::fadeInName = "fadeIn"; *----------------------------------------------------------------------------*/ const std::string XmlRpcTools::fadeOutName = "fadeOut"; +/*------------------------------------------------------------------------------ + * The name of the session ID member in the XML-RPC parameter structure + *----------------------------------------------------------------------------*/ +const std::string XmlRpcTools::sessionIdName = "sessionId"; + /* ================================================ local constants & macros */ @@ -504,3 +509,21 @@ XmlRpcTools :: playLogVectorToXmlRpcValue( ++it; } } + + +/*------------------------------------------------------------------------------ + * Extract the session ID from an XML-RPC function call parameter + *----------------------------------------------------------------------------*/ +Ptr::Ref +XmlRpcTools :: extractSessionId( + XmlRpc::XmlRpcValue & xmlRpcValue) + throw (std::invalid_argument) +{ + if (!xmlRpcValue.hasMember(sessionIdName)) { + throw std::invalid_argument("missing session ID argument"); + } + + Ptr::Ref id(new SessionId(xmlRpcValue[sessionIdName])); + return id; +} + diff --git a/livesupport/products/scheduler/src/XmlRpcTools.h b/livesupport/products/scheduler/src/XmlRpcTools.h index 1b92a2925..fb32d4e3f 100644 --- a/livesupport/products/scheduler/src/XmlRpcTools.h +++ b/livesupport/products/scheduler/src/XmlRpcTools.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.9 $ + Version : $Revision: 1.10 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/XmlRpcTools.h,v $ ------------------------------------------------------------------------------*/ @@ -47,6 +47,7 @@ #include #include "LiveSupport/Core/Ptr.h" +#include "LiveSupport/Core/SessionId.h" #include "LiveSupport/Core/Playlist.h" #include "PlayLogEntry.h" #include "ScheduleEntry.h" @@ -72,7 +73,7 @@ using namespace LiveSupport::Core; * in the Scheduler. * * @author $Author: fgerlits $ - * @version $Revision: 1.9 $ + * @version $Revision: 1.10 $ */ class XmlRpcTools { @@ -131,6 +132,12 @@ class XmlRpcTools */ static const std::string fadeOutName; + /** + * The name of the sessionId member in the XML-RPC parameter + * structure given as the input to an XmlRpcServerMethod. + */ + static const std::string sessionIdName; + /** * Convert a boost::posix_time::ptime to an XmlRpcValue * @@ -378,6 +385,19 @@ class XmlRpcTools XmlRpc::XmlRpcValue & returnValue) throw (); + /** + * Extract the session ID from the XML-RPC parameters. + * + * @param xmlRpcValue the XML-RPC parameter to extract from. + * @return a SessionId that was found in the XML-RPC parameter. + * @exception std::invalid_argument if there was no sessionId + * member in xmlRpcValue + */ + static Ptr::Ref + extractSessionId(XmlRpc::XmlRpcValue & xmlRpcValue) + throw (std::invalid_argument); + + }; /* ================================================= external data structures */