Commit c1e01c96 authored by Lefebvre, Jordan's avatar Lefebvre, Jordan
Browse files

Added additional SessionWorker documentation. Started on SessionController.

parent b494459a
Pipeline #86903 failed
......@@ -2,9 +2,11 @@ TRIBITS_SUBPACKAGE(core)
SET(HEADERS
sessionworker.hh
sessioncontroller.hh
)
SET(SOURCES
sessionworker.cc
sessioncontroller.cc
)
QT5_WRAP_CPP(MOC_FILES
......
#include "rsmcore/sessioncontroller.hh"
#include "rsmcore/sessionworker.hh"
#include <QThread>
namespace rsm
{
class SessionControllerImpl
{
public:
SessionWorker* worker;
QThread* thread;
SessionControllerImpl()
{
worker = new SessionWorker();
thread = new QThread();
worker->moveToThread(thread);
} // SessionControllerImpl constructor
~SessionControllerImpl()
{
if (worker != nullptr)
{
delete worker;
}
if (thread != nullptr)
{
if (thread->isRunning())
{
thread->quit();
thread->wait();
delete thread;
}
}
} // SessionControllerImpl destructor
}; // class SessionControllerImpl
} // namespace rsm
\ No newline at end of file
#ifndef RSM_RSMCORE_SESSIONCONTROLLER_HH_
#define RSM_RSMCORE_SESSIONCONTROLLER_HH_
#include <QObject>
#include "rsmcore/declspec.hh"
namespace rsm
{
/** Forward declaration of private implementation */
class SessionControllerImpl;
class RSM_PUBLIC SessionController : public QObject
{
Q_OBJECT
private:
// Private implementation
SessionControllerImpl* p;
public:
SessionController(QObject* parent = nullptr);
~SessionController();
}; // class SessionController
} // namespace rsm
#endif /* RSM_RSMCORE_SESSIONCONTROLLER_HH_ */
......@@ -7,6 +7,7 @@
namespace rsm
{
/** Forward declaration of private implementation */
class SessionWorkerImpl;
class RSM_PUBLIC SessionWorker : public QObject
{
......@@ -99,18 +100,86 @@ class RSM_PUBLIC SessionWorker : public QObject
void requestExec(QString command);
signals:
/**
* @brief getServerPublicKeyFailed
* Signal is emitted when the remote host does not have or provide a public
* key. Recommended to disconnect from session
*/
void getServerPublicKeyFailed();
/**
* @brief hostUnknown
* Signal is emitted when the remote host's public key is not in known_hosts
* on this client. Recommend prompt for user action/acceptance of host.
* @param host_hash
*/
void hostUnknown(QString host_hash);
/**
* @brief hostPublicKeyChanged
* Signal is emitted when the host is known, but the key differs from that in
* known_hosts. This could be a man-in-the-middle attack. Recommended
* disconnect from session.
* @param host_hash
*/
void hostPublicKeyChanged(QString host_hash);
/**
* @brief hostPublicKeyUnavailable
* Signal is emitted when the remote host does not have a public key.
* Recommended to disconnect from session.
*/
void hostPublicKeyUnavailable();
/**
* @brief knownHostError
* This signal is emitted when an unknown error occurs retrieving known_hosts.
* @param message
*/
void knownHostError(QString message);
/**
* @brief updateKnownHostsFailed
* Signal is emitted upon accepting public key update that fails to update
* client known_hosts.
*/
void updateKnownHostsFailed();
/**
* @brief authenticationError
* Signal is emitted when the user's authentication method password/pubkey
* fails.
* @param message
*/
void authenticationError(QString message);
/**
* @brief authenticationSucceeded
* Signal is emitted indicating successful authentication again remote host.
*/
void authenticationSucceeded();
/**
* @brief passwordRequested
* Signal is emitted when public key authentication fails and password is
* asked for. Recommend prompt user for password and
* authenticateWithPassword().
*/
void passwordRequested();
/**
* @brief loginBannerIssued
* Signal is emitted after authentication has succeeded and if a banner is
* available on the remote host.
* @param message
*/
void loginBannerIssued(QString message);
/**
* @brief execOutputReady
* Signal is emitted if a requestExec was performed with standard output.
*/
void execOutputReady();
/**
* @brief execFailed
* Signal is emitted if requestExec fails in someway.
* @param message
*/
void execFailed(QString message);
/**
* @brief execFinished
* Signal is emitted when requestExec() has completed.
*/
void execFinished();
}; // class SessionWorker
......
......@@ -3,7 +3,7 @@
#include "rsmcore/sessionworker.hh"
using namespace rsm;
TEST(RSM, Session)
TEST(RSM, SessionWorker)
{
SessionWorker session("apollo");
session.setLogVerbosity(SessionWorker::Verbosity::None);
......@@ -12,6 +12,7 @@ TEST(RSM, Session)
session.connect(); // 1) hand-shake with host
session.verifyKnownHost(); // 2) verify host is known/acceptable
session.authenticate(); // 3) process authentication
session.requestExec("ls -la");
QByteArray ls_la = session.readExecOutput();
session.requestExec("ls modulefiles");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment