Skip to content
Snippets Groups Projects
Commit 68d8259a authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Fixes for websock user info connect

parent 3556ecdd
No related branches found
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
Pipeline #28360 passed
......@@ -53,6 +53,8 @@ namespace ftl {
*/
std::string getBaseURI(int n);
std::string getBaseURIWithUser();
std::string getPathSegment(int n) const;
void setAttribute(const std::string &key, const std::string &value);
......
......@@ -30,6 +30,7 @@
#include <string>
#include <map>
#include <iostream>
#include <iomanip>
using ftl::config::json_t;
using std::ifstream;
......@@ -201,7 +202,7 @@ bool ftl::saveJSON(const std::string &path, nlohmann::json &json) {
//i.open(path);
if (o.is_open()) {
try {
o << json;
o << std::setw(4) << json << std::endl;
return true;
} catch (...) {
LOG(ERROR) << "Unknown error saving JSON file: " << path;
......
......@@ -182,6 +182,20 @@ string URI::getBaseURI(int n) {
} else return "";
}
std::string URI::getBaseURIWithUser() {
std::string result;
result += m_protostr + "://";
if (m_userinfo.size() > 0) {
result += getUserInfo();
result += "@";
}
result += m_host;
if (m_port > 0) result += std::string(":") + std::to_string(m_port);
result += m_path;
return result;
}
string URI::getQuery() const {
string q;
for (auto x : m_qmap) {
......
......@@ -189,3 +189,15 @@ SCENARIO( "URI::getBaseURI(N)" ) {
}
}
SCENARIO( "URI::getBaseURIWithUser()" ) {
GIVEN( "both username and password" ) {
URI uri("http://nick:test@localhost:1000/hello/world?group=test2");
REQUIRE( uri.getBaseURIWithUser() == "http://nick:test@localhost:1000/hello/world" );
}
GIVEN( "missing username and password" ) {
URI uri("http://localhost:1000/hello/world?group=test2");
REQUIRE( uri.getBaseURIWithUser() == "http://localhost:1000/hello/world" );
}
}
......@@ -671,7 +671,7 @@ uint32_t Feed::add(const std::string &path) {
// TODO: write unit test
auto &known_hosts = getConfig()["known_hosts"];
auto &host_details = known_hosts[uri.getBaseURI()];
auto &host_details = known_hosts[uri.getBaseURIWithUser()];
host_details["last_open"] = ftl::timer::get_time();
net_->connect(path)->waitConnection();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment