From 45bfc721dd049193abf3b2be2aa7b097466ddbe9 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Thu, 14 Mar 2024 16:33:17 +0100 Subject: clean up test linking (#4) - Improvement: Add zenhttp-test and zenutil-test - Improvement: Moved cachepolicy test to cachepolicy.cpp - Improvement: Renamed cachestore tests from z$ to cachestore - Improvement: Moved test linking so test for a lib is linked by -test - Improvement: Removed HttpRequestParseRelativeUri in httpstructuredcache.cpp and use the one in cacherequests.h instead --- src/zenstore/cache/cacherpc.cpp | 52 +++-------------------------------------- 1 file changed, 3 insertions(+), 49 deletions(-) (limited to 'src/zenstore/cache/cacherpc.cpp') diff --git a/src/zenstore/cache/cacherpc.cpp b/src/zenstore/cache/cacherpc.cpp index 5acb2b8c9..e6ba6629d 100644 --- a/src/zenstore/cache/cacherpc.cpp +++ b/src/zenstore/cache/cacherpc.cpp @@ -14,55 +14,9 @@ #include #include #include +#include #include -namespace zen { namespace { - - constinit AsciiSet ValidNamespaceNameCharactersSet{"abcdefghijklmnopqrstuvwxyz0123456789-_.ABCDEFGHIJKLMNOPQRSTUVWXYZ"}; - constinit AsciiSet ValidBucketNameCharactersSet{"abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}; - - std::optional GetValidNamespaceName(std::string_view Name) - { - if (Name.empty()) - { - ZEN_WARN("Namespace is invalid, empty namespace is not allowed"); - return {}; - } - - if (Name.length() > 64) - { - ZEN_WARN("Namespace '{}' is invalid, length exceeds 64 characters", Name); - return {}; - } - - if (!AsciiSet::HasOnly(Name, ValidNamespaceNameCharactersSet)) - { - ZEN_WARN("Namespace '{}' is invalid, invalid characters detected", Name); - return {}; - } - - return ToLower(Name); - } - - std::optional GetValidBucketName(std::string_view Name) - { - if (Name.empty()) - { - ZEN_WARN("Bucket name is invalid, empty bucket name is not allowed"); - return {}; - } - - if (!AsciiSet::HasOnly(Name, ValidBucketNameCharactersSet)) - { - ZEN_WARN("Bucket name '{}' is invalid, invalid characters detected", Name); - return {}; - } - - return ToLower(Name); - } - -}} // namespace zen:: - ////////////////////////////////////////////////////////////////////////// namespace zen { @@ -86,7 +40,7 @@ GetRpcRequestNamespace(const CbObjectView Params) { return {}; } - return GetValidNamespaceName(NamespaceField.AsString()); + return cacherequests::GetValidNamespaceName(NamespaceField.AsString()); } bool @@ -101,7 +55,7 @@ GetRpcRequestCacheKey(const CbObjectView& KeyView, CacheKey& Key) { return false; } - std::optional Bucket = GetValidBucketName(BucketField.AsString()); + std::optional Bucket = cacherequests::GetValidBucketName(BucketField.AsString()); if (!Bucket.has_value()) { return false; -- cgit v1.2.3