central nginx manager

This commit is contained in:
Ned Wright
2025-01-13 12:35:42 +00:00
parent 35b2df729f
commit 6db87fc7fe
45 changed files with 390 additions and 130 deletions

View File

@@ -49,6 +49,10 @@ public:
}
virtual bool addGetCall(const std::string &uri, const std::function<std::string()> &callback) = 0;
virtual bool addWildcardGetCall(
const std::string &uri,
const std::function<std::string(const std::string &)> &callback
) = 0;
virtual uint16_t getListeningPort() const = 0;

View File

@@ -10,6 +10,11 @@ class MockRestApi : public Singleton::Provide<I_RestApi>::From<MockProvider<I_Re
public:
MOCK_CONST_METHOD0(getListeningPort, uint16_t());
MOCK_METHOD2(addGetCall, bool(const std::string &, const std::function<std::string()> &));
MOCK_METHOD2(
addWildcardGetCall,
bool(const std::string &, const std::function<std::string(const std::string &)> &)
);
// You can't mock a function with an R-value reference. So mock a slightly different one
MOCK_METHOD3(mockRestCall, bool(RestAction, const std::string &, const std::unique_ptr<RestInit> &));

View File

@@ -114,6 +114,7 @@ DEFINE_FLAG(D_COMPONENT, D_ALL)
DEFINE_FLAG(D_FILE_UPLOAD, D_COMPONENT)
DEFINE_FLAG(D_RATE_LIMIT, D_COMPONENT)
DEFINE_FLAG(D_ROLLBACK_TESTING, D_COMPONENT)
DEFINE_FLAG(D_NGINX_MANAGER, D_COMPONENT)
DEFINE_FLAG(D_PARSER, D_COMPONENT)
DEFINE_FLAG(D_WS, D_COMPONENT)

View File

@@ -162,7 +162,7 @@ class LogField : Singleton::Consume<I_Environment>
void
addFields(const LogField &)
{
dbgAssert(false)
dbgAssertOpt(false)
<< AlertInfo(AlertTeam::CORE, "report i/s")
<< "Trying to add a log field to a 'type'ed field";
}

View File

@@ -26,7 +26,10 @@ public:
void
setBulkSize(uint size)
{
dbgAssert(size > 0) << AlertInfo(AlertTeam::CORE, "report i/s") << "Bulk size must be larger than 0";
if (size <= 0) {
dbgAssertOpt(size > 0) << AlertInfo(AlertTeam::CORE, "report i/s") << "Bulk size must be larger than 0";
size = 100;
}
dbgDebug(D_REPORT_BULK) << "Bulk size is set to " << size;
bulk_size = size;
}

View File

@@ -33,6 +33,7 @@ bool makeDir(const std::string &path, mode_t permission = S_IRWXU);
bool makeDirRecursive(const std::string &path, mode_t permission = S_IRWXU);
bool deleteDirectory(const std::string &path, bool delete_content = false);
bool touchFile(const std::string &path);
std::string resolveFullPath(const std::string &input_path);
bool
copyFile(
@@ -43,11 +44,8 @@ copyFile(
);
bool deleteFile(const std::string &path);
std::string convertToHumanReadable(uint64_t size_in_bytes);
std::string getFileName(const std::string &path);
bool copyDirectory(const std::string &src_dir_path, const std::string &dst_dir_path);
}// namespace Filesystem
@@ -85,6 +83,8 @@ namespace Strings
{
std::string removeTrailingWhitespaces(std::string str);
std::string removeLeadingWhitespaces(std::string str);
std::string trim(std::string str);
} // namespace Strings

View File

@@ -87,9 +87,12 @@ public:
bool
operator==(const IPAddr &other) const
{
dbgAssert(type!=IPType::UNINITIALIZED && other.type!=IPType::UNINITIALIZED)
<< AlertInfo(AlertTeam::CORE, "connkey")
<< "Called on an uninitialized IPType object";
if (type == IPType::UNINITIALIZED || other.type == IPType::UNINITIALIZED) {
dbgAssertOpt(type!=IPType::UNINITIALIZED && other.type!=IPType::UNINITIALIZED)
<< AlertInfo(AlertTeam::CORE, "connkey")
<< "Called on an uninitialized IPType object";
return false;
}
// Always compairing as if IPv6, in case of Ipv4 the rest of the address is zeroed out.
int ip_len = (other.type == IPType::V4) ? sizeof(v4.s_addr) : sizeof(v6.s6_addr);
return (type == other.type) && (memcmp(v6.s6_addr, other.v6.s6_addr, ip_len) == 0);
@@ -308,9 +311,12 @@ public:
IPType
getType() const
{
dbgAssert(src.type == dst.type)
<< AlertInfo(AlertTeam::CORE, "connkey")
<< "Mismatch in connection types (Src and Dst types are not identical)";
if (src.type != dst.type) {
dbgAssertOpt(src.type == dst.type)
<< AlertInfo(AlertTeam::CORE, "connkey")
<< "Mismatch in connection types (Src and Dst types are not identical)";
return IPType::V6;
}
return src.type;
}