diff options
Diffstat (limited to 'src/zenserver-test/cache-tests.cpp')
| -rw-r--r-- | src/zenserver-test/cache-tests.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/zenserver-test/cache-tests.cpp b/src/zenserver-test/cache-tests.cpp index 14748e214..986dc67e0 100644 --- a/src/zenserver-test/cache-tests.cpp +++ b/src/zenserver-test/cache-tests.cpp @@ -9,6 +9,7 @@ # include <zencore/compactbinarypackage.h> # include <zencore/compress.h> # include <zencore/fmtutils.h> +# include <zenhttp/localrefpolicy.h> # include <zenhttp/packageformat.h> # include <zenstore/cache/cachepolicy.h> # include <zencore/filesystem.h> @@ -25,6 +26,13 @@ namespace zen::tests { TEST_SUITE_BEGIN("server.cache"); +/// Permissive policy that allows any path, for use in tests that exercise local ref +/// functionality but are not testing path validation. +struct PermissiveLocalRefPolicy : public ILocalRefPolicy +{ + void ValidatePath(const std::filesystem::path&) const override {} +}; + TEST_CASE("zcache.basic") { using namespace std::literals; @@ -743,7 +751,11 @@ TEST_CASE("zcache.rpc") if (Result.StatusCode == HttpResponseCode::OK) { - CbPackage Response = ParsePackageMessage(Result.ResponsePayload); + ParseFlags PFlags = EnumHasAllFlags(AcceptOptions, RpcAcceptOptions::kAllowLocalReferences) ? ParseFlags::kAllowLocalReferences + : ParseFlags::kDefault; + PermissiveLocalRefPolicy AllowAllPolicy; + const ILocalRefPolicy* PPolicy = EnumHasAllFlags(PFlags, ParseFlags::kAllowLocalReferences) ? &AllowAllPolicy : nullptr; + CbPackage Response = ParsePackageMessage(Result.ResponsePayload, {}, PFlags, PPolicy); CHECK(!Response.IsNull()); OutResult.Response = std::move(Response); CHECK(OutResult.Result.Parse(OutResult.Response)); @@ -1745,8 +1757,13 @@ TEST_CASE("zcache.rpc.partialchunks") CHECK(Result.StatusCode == HttpResponseCode::OK); - CbPackage Response = ParsePackageMessage(Result.ResponsePayload); - bool Loaded = !Response.IsNull(); + ParseFlags PFlags = EnumHasAllFlags(Options.AcceptOptions, RpcAcceptOptions::kAllowLocalReferences) + ? ParseFlags::kAllowLocalReferences + : ParseFlags::kDefault; + PermissiveLocalRefPolicy AllowAllPolicy; + const ILocalRefPolicy* PPolicy = EnumHasAllFlags(PFlags, ParseFlags::kAllowLocalReferences) ? &AllowAllPolicy : nullptr; + CbPackage Response = ParsePackageMessage(Result.ResponsePayload, {}, PFlags, PPolicy); + bool Loaded = !Response.IsNull(); CHECK_MESSAGE(Loaded, "GetCacheChunks response failed to load."); cacherequests::GetCacheChunksResult GetCacheChunksResult; CHECK(GetCacheChunksResult.Parse(Response)); |