Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable support for HTTP communication between components ECFLOW-1957 #121

Draft
wants to merge 24 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
55d8417
Refactor DefaultServer class template
marcosbento Feb 20, 2024
b006066
Enable HTTP connection between Client/Server
marcosbento Feb 21, 2024
39562c0
Enable UI to use HTTP connection
marcosbento Jun 20, 2024
780eef2
Enable REST/UDP proxies to use HTTP connection
marcosbento Sep 4, 2024
981b615
Enable ecFlow REST API tests using HTTP backend
marcosbento Oct 2, 2024
bda467c
Improve TestFixture by extracting ScratchDir
marcosbento Oct 10, 2024
252f2e5
Improve TestFixture by extracting LocalServerLauncher
marcosbento Oct 11, 2024
3265be6
Enable s_test with HTTP backend
marcosbento Oct 11, 2024
d7580b6
Simplify tests AbortCmd and WaitCmd
marcosbento Oct 11, 2024
8e24563
Correct typo in source code comment
marcosbento Oct 11, 2024
ff85a00
Replace deprecated use of BOOST_GLOBAL_FIXTURE
marcosbento Oct 11, 2024
b44cf5c
Allow REST API tests to run in parallel
marcosbento Oct 15, 2024
ed2c9f6
Remove the use of std::filesystem
marcosbento Oct 15, 2024
032a0b2
Ensure parallel s_test* do not use same port or directory
marcosbento Oct 16, 2024
2a63791
Test ecFlow Python using HTTP ecFlow server
marcosbento Oct 17, 2024
e5ac47e
Enable HTTPS on the Client side
marcosbento Oct 18, 2024
0611701
Use notion of selected Protocol
marcosbento Oct 18, 2024
4aaeecb
Move test methods in ClientInvoker to SCPort
marcosbento Oct 21, 2024
b18ef39
Use notion of selected Protocol
marcosbento Oct 21, 2024
9720d5e
Add description to HttpServer
marcosbento Oct 21, 2024
7b12105
Correct #include guards
marcosbento Oct 21, 2024
2c80e24
Correct outstanding compilation warnings
marcosbento Oct 21, 2024
acd85f1
Update default HTTP connection timeouts
marcosbento Oct 24, 2024
99a3689
Replace use of io.post() with boost::asio::post
marcosbento Jan 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Viewer/ecflowUI/src/OverviewProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ void OverviewProvider::serverInfo(VInfoServer* info, std::stringstream& f) {
f << inc << "Host : " << server->host() << "\n";
f << inc << "Port : " << server->port() << "\n";

if (server->isSsl()) {
f << inc << "SSL : enabled\n";
}
f << inc << "Protocol : " << ecf::to_ui_designation(server->protocol()) << " : enabled\n";

if (!server->user().empty()) {
f << inc << "Custom user : " << server->user() << "\n";
Expand Down
60 changes: 31 additions & 29 deletions Viewer/ecflowUI/src/ServerAddDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>294</width>
<height>225</height>
<height>358</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -20,7 +20,7 @@
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -85,23 +85,41 @@
<widget class="QLineEdit" name="userEdit"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="protocolLabel">
<property name="text">
<string>Use &amp;SSL:</string>
</property>
<property name="buddy">
<cstring>sslCb</cstring>
<string>Protocol:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="sslCb">
<widget class="QRadioButton" name="protocolPlain">
<property name="text">
<string/>
<string>TCP/IP</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QRadioButton" name="protocolSsl">
<property name="text">
<string>TCP/IP with SSL</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QRadioButton" name="protocolHttp">
<property name="text">
<string>HTTP</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QRadioButton" name="protocolHttps">
<property name="text">
<string>HTTPS</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="MessageLabel" name="sslMessageLabel" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
Expand All @@ -111,22 +129,6 @@
</property>
</widget>
</item>
<item row="8" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
Expand All @@ -142,10 +144,10 @@
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -158,10 +160,10 @@
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
Expand Down
32 changes: 25 additions & 7 deletions Viewer/ecflowUI/src/ServerEditDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,41 @@
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="sslLabel">
<widget class="QLabel" name="protocolLabel">
<property name="text">
<string>Use &amp;SSL:</string>
</property>
<property name="buddy">
<cstring>sslCh</cstring>
<string>Protocol:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="sslCh">
<widget class="QRadioButton" name="protocolPlain">
<property name="text">
<string/>
<string>TCP/IP</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QRadioButton" name="protocolSsl">
<property name="text">
<string>TCP/IP with SSL</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QRadioButton" name="protocolHttp">
<property name="text">
<string>HTTP</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QRadioButton" name="protocolHttps">
<property name="text">
<string>HTTPS</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="MessageLabel" name="sslMessageLabel" native="true"/>
</item>
</layout>
Expand Down
40 changes: 29 additions & 11 deletions Viewer/ecflowUI/src/ServerHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ ServerHandler::ServerHandler(const std::string& name,
const std::string& host,
const std::string& port,
const std::string& user,
bool ssl)
ecf::Protocol protocol)
: name_(name),
host_(host),
port_(port),
user_(user),
ssl_(ssl),
protocol_(protocol),
client_(nullptr),
updating_(false),
communicating_(false),
Expand Down Expand Up @@ -184,10 +184,11 @@ void ServerHandler::createClient(bool init) {

bool ssl_enabled = false;
std::string ssl_error;
std::string http_error;

if (client_) {
#ifdef ECF_OPENSSL
if (ssl_) {
if (isSsl()) {
try {
client_->enable_ssl();
ssl_enabled = true;
Expand All @@ -203,6 +204,23 @@ void ServerHandler::createClient(bool init) {
client_->disable_ssl();
}
#endif
if (isHttp()) {
try {
client_->enable_http();
}
catch (std::exception& e) {
http_error = std::string(e.what());
}
}

if (isHttps()) {
try {
client_->enable_https();
}
catch (std::exception& e) {
http_error = std::string(e.what());
}
}

if (!init || !user_.empty()) {
try {
Expand Down Expand Up @@ -249,7 +267,7 @@ void ServerHandler::createClient(bool init) {
}

#ifdef ECF_OPENSSL
if (ssl_ && !ssl_enabled) {
if (isSsl() && !ssl_enabled) {
sslCertificateError(ssl_error);
return;
}
Expand Down Expand Up @@ -304,9 +322,9 @@ void ServerHandler::recreateClient() {
createClient(false);
}

void ServerHandler::setSsl(bool ssl) {
if (ssl != ssl_) {
ssl_ = ssl;
void ServerHandler::setProtocol(ecf::Protocol protocol) {
if (protocol != protocol_) {
protocol_ = protocol;

if (connectState_->state() != ConnectState::VersionIncompatible &&
connectState_->state() != ConnectState::FailedClient) {
Expand Down Expand Up @@ -528,8 +546,8 @@ ServerHandler* ServerHandler::addServer(const std::string& name,
const std::string& host,
const std::string& port,
const std::string& user,
bool ssl) {
auto* sh = new ServerHandler(name, host, port, user, ssl);
ecf::Protocol protocol) {
auto* sh = new ServerHandler(name, host, port, user, protocol);
return sh;
}

Expand Down Expand Up @@ -1394,7 +1412,7 @@ void ServerHandler::sslIncompatibleServer(const std::string& msg) {
connectState_->state(ConnectState::SslIncompatible);
std::string errStr = "Cannot communicate to server.";
#if ECF_OPENSSL
if (ssl_) {
if (isSsl()) {
errStr += " Server is marked as SSL in the UI. Please check if the server is really SSL-enabled! Also check "
"settings in Manage servers dialogue!";
}
Expand All @@ -1412,7 +1430,7 @@ void ServerHandler::sslIncompatibleServer(const std::string& msg) {

void ServerHandler::sslCertificateError(const std::string& msg) {
#if ECF_OPENSSL
assert(ssl_);
assert(isSsl());
compatibility_ = Incompatible;
stopRefreshTimer();
comQueue_->disable();
Expand Down
29 changes: 16 additions & 13 deletions Viewer/ecflowUI/src/ServerHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
#include "VReply.hpp"
#include "VServerSettings.hpp"
#include "VTask.hpp"
#include "ecflow/base/ServerProtocol.hpp"
#include "ecflow/node/Defs.hpp"

class ClientInvoker;
class ServerReply;

class ConnectState;
class NodeObserver;
class ServerHandler;
class ServerComQueue;
class ServerObserver;
class ServerComObserver;
Expand Down Expand Up @@ -58,9 +58,12 @@ class ServerHandler : public QObject {
const std::string& longName() const { return longName_; }
const std::string& fullLongName() const { return fullLongName_; }
const std::string& port() const { return port_; }
bool isSsl() const { return ssl_; }
bool isSsl() const { return protocol_ == ecf::Protocol::Ssl; }
bool isHttp() const { return protocol_ == ecf::Protocol::Http; }
bool isHttps() const { return protocol_ == ecf::Protocol::Https; }
ecf::Protocol protocol() const { return protocol_; }
const std::string& user() { return user_; }
void setSsl(bool);
void setProtocol(ecf::Protocol protocol);
void setUser(const std::string& user);

Activity activity() const { return activity_; }
Expand Down Expand Up @@ -118,7 +121,7 @@ class ServerHandler : public QObject {
const std::string& host,
const std::string& port,
const std::string& user,
bool ssl);
ecf::Protocol protocol);
static void removeServer(ServerHandler*);
static ServerHandler* findServer(const std::string& alias);

Expand All @@ -142,7 +145,7 @@ class ServerHandler : public QObject {
const std::string& host,
const std::string& port,
const std::string& user,
bool ssl);
ecf::Protocol protocol);
~ServerHandler() override;
void logoutAndDelete();
void queueLoggedOut();
Expand All @@ -166,7 +169,7 @@ class ServerHandler : public QObject {
std::string host_;
std::string port_;
std::string user_;
bool ssl_;
ecf::Protocol protocol_;
ClientInvoker* client_;
std::string longName_;
std::string fullLongName_;
Expand Down Expand Up @@ -226,21 +229,21 @@ private Q_SLOTS:

void setActivity(Activity activity);

typedef void (ServerObserver::*SoMethod)(ServerHandler*);
typedef void (ServerObserver::*SoMethodV1)(ServerHandler*, const VServerChange&);
typedef void (ServerObserver::*SoMethodV2)(ServerHandler*, const std::string&);
typedef void (ServerObserver::* SoMethod)(ServerHandler*);
typedef void (ServerObserver::* SoMethodV1)(ServerHandler*, const VServerChange&);
typedef void (ServerObserver::* SoMethodV2)(ServerHandler*, const std::string&);
void broadcast(SoMethod);
void broadcast(SoMethodV1, const VServerChange&);
void broadcast(SoMethodV2, const std::string&);

typedef void (NodeObserver::*NoMethod)(const VNode*);
typedef void (NodeObserver::*NoMethodV1)(const VNode*, const std::vector<ecf::Aspect::Type>&, const VNodeChange&);
typedef void (NodeObserver::*NoMethodV2)(const VNode*, const VNodeChange&);
typedef void (NodeObserver::* NoMethod)(const VNode*);
typedef void (NodeObserver::* NoMethodV1)(const VNode*, const std::vector<ecf::Aspect::Type>&, const VNodeChange&);
typedef void (NodeObserver::* NoMethodV2)(const VNode*, const VNodeChange&);
void broadcast(NoMethod, const VNode*);
void broadcast(NoMethodV1, const VNode*, const std::vector<ecf::Aspect::Type>&, const VNodeChange&);
void broadcast(NoMethodV2, const VNode*, const VNodeChange&);

typedef void (ServerComObserver::*SocMethod)(ServerHandler*);
typedef void (ServerComObserver::* SocMethod)(ServerHandler*);
void broadcast(SocMethod);

void saveConf();
Expand Down
Loading
Loading