diff --git a/docs/agent-workflow/STATE.md b/docs/agent-workflow/STATE.md index dfc22ba..6667059 100644 --- a/docs/agent-workflow/STATE.md +++ b/docs/agent-workflow/STATE.md @@ -243,6 +243,8 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B - **Wave 75 (HEAD/Content-Length Support & Daemon `compdb_stale`)**: the registry server (both the POSIX loop and the `Void::Net` bridge) routes `HEAD` exactly like `GET` while suppressing the body and preserving `Content-Length`/content headers; asserted for release and binary downloads. A swarm worker (4/4 substantive tasks; build task stopped and re-run) added the `compdb_stale` daemon request (marks a profile generation stale with an optional reason) and `Daemon.compdb_stale_marks_generation_stale`. +- **Wave 76 (Range Downloads & Install Option Tests)**: registry release/binary downloads honour a single `Range: bytes=...` header (206 + `Content-Range`, `Accept-Ranges: bytes`, suffix/open-ended forms, 416 for unsatisfiable/multipart ranges). A swarm worker extended the daemon install test with `component`, `export_cmake=false`/`export_native=false`, and empty-prefix uninstall assertions (5/5 substantive tasks; build task stopped and re-run). + ## Remaining future scope - **Post-v1 Expansion Roadmap ([21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md) & [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md))**: Track C (macOS/Windows ports + dual-profile cross-compilation) and dedicated external editor plugins remain planned; Track D3 signing (SBOM, Ed25519 primitives, trusted-key enforcement/distribution, binary-variant signing/distribution) and Track E3 daemon capabilities are implemented, and Track E4 now uses `Void::Net` for the registry client/server and remote cache plus `Void::Sqlite` for the StateStore when available. diff --git a/docs/agent-workflow/TASKS.md b/docs/agent-workflow/TASKS.md index 195e149..73a2ca2 100644 --- a/docs/agent-workflow/TASKS.md +++ b/docs/agent-workflow/TASKS.md @@ -79,4 +79,5 @@ Base HEAD: `fe0d1a6` | Wave 73 (Actions kind filter + releases show) | daemon `actions --kind` filter; swarm added `fetch_release_detail` and `vbs releases show` with tests | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon and Registry suites pass, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `include/Void/Build/Package/RegistryClient.hpp`, `src/Package/RegistryClient.cpp`, `tests/{DaemonTests,RegistryTests}.cpp`, `tests/CliContracts.cmake`, docs | | Wave 74 (Self-excluding archives + release-detail tests) | `create_source_package` excludes its own output; swarm added release-detail RegistryTests coverage | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 8/8, full CTest 8/8) | `src/Package/Archive.cpp`, `tests/{FullV1Tests,RegistryTests}.cpp`, docs | | Wave 75 (HEAD support + daemon compdb_stale) | registry HEAD routes like GET without a body (POSIX and Net); swarm added daemon `compdb_stale` with tests | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 8/8, Daemon suite passes, full CTest 8/8) | `registry/service/HttpServer.cpp`, `src/Daemon/Daemon.cpp`, `tests/{RegistryTests,DaemonTests}.cpp`, docs | +| Wave 76 (Range downloads + install option tests) | `Range` support on registry downloads (206/416, Accept-Ranges); swarm extended daemon install tests | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 8/8, Daemon suite passes, full CTest 8/8) | `registry/service/RegistryService.cpp`, `tests/{RegistryTests,DaemonTests}.cpp`, docs | | Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions) |"}] Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) | diff --git a/docs/agent-workflow/VERIFICATION.md b/docs/agent-workflow/VERIFICATION.md index 631fa72..275ea6f 100644 --- a/docs/agent-workflow/VERIFICATION.md +++ b/docs/agent-workflow/VERIFICATION.md @@ -1180,6 +1180,16 @@ dev cpp-gcc -c build/pinned/bin/vbs_v1_tests --suite Daemon --no-color passes (2.23 s). - Registry suite: **8 / 8 passed** (11.64 s); full CTest: **8 / 8 passed** in 273.63 s. +## Range Downloads & Install Option Tests (GCC 16.2, pin `0002e74`) + +- `Range: bytes=0-3` on a binary download returns 206 with the first four bytes and a + `Content-Range` carrying the total size; `bytes=999999-` returns 416; normal GETs advertise + `Accept-Ranges: bytes`. +- Swarm `swarm_mx8csw7v_btv8` (one worker) extended the daemon install test (5/5 substantive + tasks; its build task was stopped and re-run by the orchestrator); the install test passes + (2.48 s). +- Registry suite: **8 / 8 passed** (11.45 s); full CTest: **8 / 8 passed** in 257.65 s. + ## Limits and Unrun Checks 1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified). diff --git a/docs/roadmap/21-expansion-roadmap.md b/docs/roadmap/21-expansion-roadmap.md index 5379140..50124bd 100644 --- a/docs/roadmap/21-expansion-roadmap.md +++ b/docs/roadmap/21-expansion-roadmap.md @@ -46,7 +46,7 @@ flowchart LR | Phase | Concrete Scope | Acceptance Gate | | --- | --- | --- | -| **C1 — Platform Backend Split** *(Linux backend split implemented; macOS/Windows pending)* | Split `src/Platform/` into `Linux/`, `MacOS/`, and `Windows/` behind clean interfaces (`FileOps`, `ProcessSupervisor`, `DirectoryWatcher`), delegating to `Void::System` as upstream adds OS backends. Linux implementations now live under `src/Platform/Linux/` and `src/Watch/Linux/` (inotify watcher) with an explicit `HostOs`/`host_supported()` boundary in `include/Void/Build/Platform/Host.hpp`; macOS/Windows backends await real hosts (`vbs doctor` and the daemon `info` request report the detected host and enabled backends, `Platform::current_executable_path()` isolates the executable-path lookup across sources and tests, the daemon `describe` request can be scoped to one workspace member, `vbs daemon target flags` serves per-unit compile arguments, `vbs releases show` prints one release's detail, source archives never embed themselves, and registry downloads answer HEAD with full headers). | Zero Linux regressions; clean platform abstraction boundary. | +| **C1 — Platform Backend Split** *(Linux backend split implemented; macOS/Windows pending)* | Split `src/Platform/` into `Linux/`, `MacOS/`, and `Windows/` behind clean interfaces (`FileOps`, `ProcessSupervisor`, `DirectoryWatcher`), delegating to `Void::System` as upstream adds OS backends. Linux implementations now live under `src/Platform/Linux/` and `src/Watch/Linux/` (inotify watcher) with an explicit `HostOs`/`host_supported()` boundary in `include/Void/Build/Platform/Host.hpp`; macOS/Windows backends await real hosts (`vbs doctor` and the daemon `info` request report the detected host and enabled backends, `Platform::current_executable_path()` isolates the executable-path lookup across sources and tests, the daemon `describe` request can be scoped to one workspace member, `vbs daemon target flags` serves per-unit compile arguments, `vbs releases show` prints one release's detail, source archives never embed themselves, and registry downloads answer HEAD with full headers and support single-range requests). | Zero Linux regressions; clean platform abstraction boundary. | | **C2 — macOS / Apple Clang & `ld64`** | Apple Clang toolchain probes, `.dylib` + `@rpath`/`@loader_path` install-name lowering, `FSEvents` watcher, Mach-O deterministic timestamps. | Real macOS CI runner passing all SDK, core, module, and install tests. | | **C3 — Windows / MSVC & `clang-cl`** | MSVC (`cl.exe`, `lib.exe`, `link.exe`, `/showIncludes`, `.pdb`, `/FS`, `.dll`/`.lib` import libraries), Job Object process-tree kill, `ReadDirectoryChangesW` watcher, case-insensitive path conflict detection. | Real Windows CI runner passing process-tree kill, header-shadowing, and install relocation tests. | | **C4 — True Host-vs-Target Cross-Compilation** | Dual-context evaluation (`host` profile for code generators and `build_dependency` tools vs `target` profile for cross-compiled products), sysroot & `--target=` triple propagation. | `linux-x86_64` host cross-compiling `linux-aarch64` fixture while executing host-compiled generator natively. | diff --git a/registry/service/RegistryService.cpp b/registry/service/RegistryService.cpp index a05ea7a..c398d8d 100644 --- a/registry/service/RegistryService.cpp +++ b/registry/service/RegistryService.cpp @@ -30,6 +30,72 @@ Void::Result::Error make_error(Void::System::SystemErrorCode code, std::string m return Void::System::make_system_error(code, std::move(msg)); } +// Applies a single-range `Range: bytes=start-end` request to a download response. Always +// advertises Accept-Ranges; unsatisfiable or malformed ranges produce 416 with Content-Range. +HttpResponse apply_range(HttpResponse resp, std::string_view range_header) { + const auto total = resp.body.size(); + resp.headers["Accept-Ranges"] = "bytes"; + if (range_header.empty()) { + return resp; + } + const auto reject = [&] { + HttpResponse out; + out.status = 416; + out.headers["Accept-Ranges"] = "bytes"; + out.headers["Content-Range"] = std::format("bytes */{}", total); + return out; + }; + if (!range_header.starts_with("bytes=")) { + return reject(); + } + std::string_view spec = range_header.substr(6); + if (spec.find(',') != std::string_view::npos) { + return reject(); // Multipart ranges are not supported. + } + const auto dash = spec.find('-'); + if (dash == std::string_view::npos) { + return reject(); + } + const auto parse_index = [](std::string_view text, std::size_t &out) { + if (text.empty()) { + return false; + } + std::size_t value = 0; + const auto [ptr, ec] = std::from_chars(text.data(), text.data() + text.size(), value); + if (ec != std::errc{} || ptr != text.data() + text.size()) { + return false; + } + out = value; + return true; + }; + const auto first = spec.substr(0, dash); + const auto second = spec.substr(dash + 1); + std::size_t start = 0; + std::size_t end = total == 0 ? 0 : total - 1; + if (first.empty()) { + std::size_t suffix = 0; + if (!parse_index(second, suffix) || suffix == 0) { + return reject(); + } + start = suffix >= total ? 0 : total - suffix; + } else { + if (!parse_index(first, start)) { + return reject(); + } + if (!second.empty() && !parse_index(second, end)) { + return reject(); + } + } + if (total == 0 || start >= total || start > end) { + return reject(); + } + end = std::min(end, total - 1); + resp.status = 206; + resp.headers["Content-Range"] = std::format("bytes {}-{}/{}", start, end, total); + resp.body = resp.body.substr(start, end - start + 1); + return resp; +} + std::int64_t now_epoch() { return std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch()) @@ -1162,7 +1228,8 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) { resp.headers["Content-Type"] = "application/x-tar"; resp.headers["X-Content-SHA256"] = rit->second.sha256; resp.body = std::move(*bytes); - return resp; + const auto range = req.header("range"); + return apply_range(std::move(resp), range ? *range : std::string_view{}); } // Publish a prebuilt binary variant: @@ -1350,7 +1417,8 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) { resp.headers["Content-Type"] = "application/octet-stream"; resp.headers["X-Content-SHA256"] = bit->second.sha256; resp.body = std::move(*bytes); - return resp; + const auto range = req.header("range"); + return apply_range(std::move(resp), range ? *range : std::string_view{}); } // List binary variants: GET /api/v1/packages///binaries diff --git a/tests/DaemonTests.cpp b/tests/DaemonTests.cpp index 3e01a0f..2512cde 100644 --- a/tests/DaemonTests.cpp +++ b/tests/DaemonTests.cpp @@ -1553,12 +1553,12 @@ void build(Void::Build::Project &project) { auto listed = request_object(socket, R"({"op":"actions","limit":5})", std::chrono::seconds{120}); - auto filtered = request_object(socket, R"({"op":"actions","target":"nope"})", - std::chrono::seconds{120}); - auto by_kind = request_object(socket, R"({"op":"actions","kind":"link"})", - std::chrono::seconds{120}); - auto unknown_kind = request_object(socket, R"({"op":"actions","kind":"nope"})", - std::chrono::seconds{120}); + auto filtered = + request_object(socket, R"({"op":"actions","target":"nope"})", std::chrono::seconds{120}); + auto by_kind = + request_object(socket, R"({"op":"actions","kind":"link"})", std::chrono::seconds{120}); + auto unknown_kind = + request_object(socket, R"({"op":"actions","kind":"nope"})", std::chrono::seconds{120}); auto invalid_kind = request_object(socket, R"({"op":"actions","kind":5})"); auto invalid = request_object(socket, R"({"op":"actions","limit":1001})"); auto shutdown = Void::Build::Daemon::request(socket, R"({"op":"shutdown"})"); @@ -1616,7 +1616,7 @@ VOID_TEST(Daemon, install_stages_prefix_and_writes_manifest) { void build(Void::Build::Project &project) { auto app = project.executable("app"); - app.sources({"main.cpp"}).install("bin"); + app.sources({"main.cpp"}).install("bin", "runtime"); } )cpp"; Void::Testing::require(descriptor.good()); @@ -1650,6 +1650,46 @@ void build(Void::Build::Project &project) { Void::Testing::require(missing_prefix.has_value()); Void::Testing::expect(!bool_field(*missing_prefix, "ok", true)); + const auto prefix_no_cmake = temp->path() / "prefix-no-cmake"; + const std::string install_no_cmake_request = std::format( + R"({{"op":"install","prefix":{},"package_name":"demo","package_version":"9.9.9",)" + R"("component":"runtime","export_cmake":false,"export_native":false}})", + Void::Build::Util::json_quote(prefix_no_cmake.string())); + auto installed_no_cmake = + request_object(socket, install_no_cmake_request, std::chrono::seconds{120}); + Void::Testing::require(installed_no_cmake.has_value()); + Void::Testing::expect(bool_field(*installed_no_cmake, "ok")); + Void::Testing::expect(int_field(*installed_no_cmake, "files") >= 1); + Void::Testing::expect(std::filesystem::exists(prefix_no_cmake / "bin" / "app")); + bool has_cmake_config = false; + for (const auto &entry : std::filesystem::recursive_directory_iterator(prefix_no_cmake)) { + if (entry.is_regular_file() && entry.path().filename().string().ends_with("Config.cmake")) { + has_cmake_config = true; + } + } + Void::Testing::expect(!has_cmake_config); + + const std::string uninstall_no_cmake_request = + std::format(R"({{"op":"uninstall","prefix":{}}})", + Void::Build::Util::json_quote(prefix_no_cmake.string())); + auto uninstalled_no_cmake = request_object(socket, uninstall_no_cmake_request); + Void::Testing::require(uninstalled_no_cmake.has_value()); + Void::Testing::expect(bool_field(*uninstalled_no_cmake, "ok")); + Void::Testing::expect(int_field(*uninstalled_no_cmake, "removed") >= 1); + + const auto empty_prefix = temp->path() / "empty-prefix"; + std::filesystem::create_directories(empty_prefix); + const std::string uninstall_empty_request = + std::format(R"({{"op":"uninstall","prefix":{}}})", + Void::Build::Util::json_quote(empty_prefix.string())); + auto uninstalled_empty = request_object(socket, uninstall_empty_request); + Void::Testing::require(uninstalled_empty.has_value()); + if (bool_field(*uninstalled_empty, "ok")) { + Void::Testing::expect_eq(int_field(*uninstalled_empty, "removed"), std::int64_t{0}); + } else { + Void::Testing::expect(field(*uninstalled_empty, "error") != nullptr); + } + const std::string uninstall_request = std::format( R"({{"op":"uninstall","prefix":{}}})", Void::Build::Util::json_quote(prefix.string())); auto uninstalled = request_object(socket, uninstall_request); @@ -1664,6 +1704,202 @@ void build(Void::Build::Project &project) { Void::Testing::expect(!std::filesystem::exists(prefix / "bin" / "app")); } +VOID_TEST(Daemon, install_request_component_filters_installed_files) { + auto temp = Void::FileSystem::TempDir::open("vbs_daemon_"); + Void::Testing::require(temp.has_value()); + const auto options = make_options(temp->path()); + + { + std::ofstream descriptor{options.project_root / "build.cpp"}; + descriptor << R"cpp(#include + +void build(Void::Build::Project &project) { + auto app = project.executable("app"); + app.sources({"main.cpp"}).install("bin", "runtime"); + auto tool = project.executable("tool"); + tool.sources({"tool.cpp"}).install("bin", "tools"); +} +)cpp"; + Void::Testing::require(descriptor.good()); + } + { + std::ofstream source{options.project_root / "main.cpp"}; + source << "int main() { return 0; }\n"; + Void::Testing::require(source.good()); + } + { + std::ofstream source{options.project_root / "tool.cpp"}; + source << "int main() { return 0; }\n"; + Void::Testing::require(source.good()); + } + + auto server = Void::Build::Daemon::DaemonServer::create(options); + Void::Testing::require(server.has_value()); + const auto socket = server->socket_path(); + + Void::Result::Result run_result; + std::jthread worker{[&] { run_result = server->run(); }}; + Void::Testing::require(wait_for_path(socket, std::chrono::seconds{5})); + + const auto prefix = temp->path() / "component-prefix"; + const std::string install_request = + std::format(R"({{"op":"install","prefix":{},"package_name":"demo","component":"runtime"}})", + Void::Build::Util::json_quote(prefix.string())); + auto installed = request_object(socket, install_request, std::chrono::seconds{120}); + + const std::string invalid_prefix = + Void::Build::Util::json_quote((temp->path() / "invalid-prefix").string()); + auto empty_component = request_object( + socket, std::format(R"({{"op":"install","prefix":{},"component":""}})", invalid_prefix)); + auto numeric_component = request_object( + socket, std::format(R"({{"op":"install","prefix":{},"component":5}})", invalid_prefix)); + + Void::Testing::require(installed.has_value()); + Void::Testing::expect(bool_field(*installed, "ok")); + Void::Testing::expect(int_field(*installed, "files") >= 1); + Void::Testing::expect(std::filesystem::exists(prefix / "bin" / "app")); + Void::Testing::expect(!std::filesystem::exists(prefix / "bin" / "tool")); + Void::Testing::expect(std::filesystem::exists(str_field(*installed, "manifest"))); + + Void::Testing::require(empty_component.has_value()); + Void::Testing::expect(!bool_field(*empty_component, "ok", true)); + Void::Testing::expect(str_field(*empty_component, "error").find("component") != + std::string::npos); + Void::Testing::require(numeric_component.has_value()); + Void::Testing::expect(!bool_field(*numeric_component, "ok", true)); + Void::Testing::expect(str_field(*numeric_component, "error").find("component") != + std::string::npos); + + auto shutdown = Void::Build::Daemon::request(socket, R"({"op":"shutdown"})"); + Void::Testing::expect(shutdown.has_value()); + worker.join(); + Void::Testing::expect(run_result.has_value()); + Void::Testing::expect(!std::filesystem::exists(socket)); +} + +VOID_TEST(Daemon, install_request_can_disable_cmake_and_native_export) { + auto temp = Void::FileSystem::TempDir::open("vbs_daemon_"); + Void::Testing::require(temp.has_value()); + const auto options = make_options(temp->path()); + + { + std::ofstream descriptor{options.project_root / "build.cpp"}; + descriptor << R"cpp(#include + +void build(Void::Build::Project &project) { + auto app = project.executable("app"); + app.sources({"main.cpp"}).install("bin"); +} +)cpp"; + Void::Testing::require(descriptor.good()); + } + { + std::ofstream source{options.project_root / "main.cpp"}; + source << "int main() { return 0; }\n"; + Void::Testing::require(source.good()); + } + + auto server = Void::Build::Daemon::DaemonServer::create(options); + Void::Testing::require(server.has_value()); + const auto socket = server->socket_path(); + + Void::Result::Result run_result; + std::jthread worker{[&] { run_result = server->run(); }}; + Void::Testing::require(wait_for_path(socket, std::chrono::seconds{5})); + + const auto full_prefix = temp->path() / "full-prefix"; + const std::string full_request = + std::format(R"({{"op":"install","prefix":{},"package_name":"demo"}})", + Void::Build::Util::json_quote(full_prefix.string())); + auto full = request_object(socket, full_request, std::chrono::seconds{120}); + + const auto lean_prefix = temp->path() / "lean-prefix"; + const std::string lean_request = std::format( + R"({{"op":"install","prefix":{},"package_name":"demo","export_cmake":false,"export_native":false}})", + Void::Build::Util::json_quote(lean_prefix.string())); + auto lean = request_object(socket, lean_request, std::chrono::seconds{120}); + + const std::string invalid_prefix = + Void::Build::Util::json_quote((temp->path() / "invalid-prefix").string()); + auto bad_cmake = + request_object(socket, std::format(R"({{"op":"install","prefix":{},"export_cmake":"no"}})", + invalid_prefix)); + auto bad_native = request_object( + socket, std::format(R"({{"op":"install","prefix":{},"export_native":1}})", invalid_prefix)); + + Void::Testing::require(full.has_value()); + Void::Testing::expect(bool_field(*full, "ok")); + Void::Testing::expect( + std::filesystem::exists(full_prefix / "lib" / "cmake" / "demo" / "demoConfig.cmake")); + Void::Testing::expect( + std::filesystem::exists(full_prefix / "share" / "vbs" / "demo" / "package.json")); + + Void::Testing::require(lean.has_value()); + Void::Testing::expect(bool_field(*lean, "ok")); + Void::Testing::expect(std::filesystem::exists(lean_prefix / "bin" / "app")); + Void::Testing::expect(std::filesystem::exists(str_field(*lean, "manifest"))); + Void::Testing::expect(!std::filesystem::exists(lean_prefix / "lib")); + Void::Testing::expect(!std::filesystem::exists(lean_prefix / "share" / "vbs" / "demo")); + + Void::Testing::require(bad_cmake.has_value()); + Void::Testing::expect(!bool_field(*bad_cmake, "ok", true)); + Void::Testing::expect(str_field(*bad_cmake, "error").find("export flags must be booleans") != + std::string::npos); + Void::Testing::require(bad_native.has_value()); + Void::Testing::expect(!bool_field(*bad_native, "ok", true)); + Void::Testing::expect(str_field(*bad_native, "error").find("export flags must be booleans") != + std::string::npos); + + auto shutdown = Void::Build::Daemon::request(socket, R"({"op":"shutdown"})"); + Void::Testing::expect(shutdown.has_value()); + worker.join(); + Void::Testing::expect(run_result.has_value()); + Void::Testing::expect(!std::filesystem::exists(socket)); +} + +VOID_TEST(Daemon, uninstall_request_on_empty_prefix_reports_missing_manifest) { + auto temp = Void::FileSystem::TempDir::open("vbs_daemon_"); + Void::Testing::require(temp.has_value()); + const auto options = make_options(temp->path()); + + auto server = Void::Build::Daemon::DaemonServer::create(options); + Void::Testing::require(server.has_value()); + const auto socket = server->socket_path(); + + Void::Result::Result run_result; + std::jthread worker{[&] { run_result = server->run(); }}; + Void::Testing::require(wait_for_path(socket, std::chrono::seconds{5})); + + const auto empty = temp->path() / "empty-prefix"; + std::filesystem::create_directories(empty); + const std::string uninstall_empty_request = std::format( + R"({{"op":"uninstall","prefix":{}}})", Void::Build::Util::json_quote(empty.string())); + auto empty_uninstall = request_object(socket, uninstall_empty_request); + + auto empty_prefix = request_object(socket, R"({"op":"uninstall","prefix":""})"); + auto missing_prefix = request_object(socket, R"({"op":"uninstall"})"); + auto numeric_prefix = request_object(socket, R"({"op":"uninstall","prefix":5})"); + + Void::Testing::require(empty_uninstall.has_value()); + Void::Testing::expect(!bool_field(*empty_uninstall, "ok", true)); + Void::Testing::expect(str_field(*empty_uninstall, "error").find("no VBS install manifest") != + std::string::npos); + Void::Testing::expect(std::filesystem::exists(empty)); + + Void::Testing::require(empty_prefix.has_value()); + Void::Testing::expect(!bool_field(*empty_prefix, "ok", true)); + Void::Testing::require(missing_prefix.has_value()); + Void::Testing::expect(!bool_field(*missing_prefix, "ok", true)); + Void::Testing::require(numeric_prefix.has_value()); + Void::Testing::expect(!bool_field(*numeric_prefix, "ok", true)); + + auto shutdown = Void::Build::Daemon::request(socket, R"({"op":"shutdown"})"); + Void::Testing::expect(shutdown.has_value()); + worker.join(); + Void::Testing::expect(run_result.has_value()); + Void::Testing::expect(!std::filesystem::exists(socket)); +} + VOID_TEST(Daemon, gen_tests_generates_registration_unit_confined) { auto temp = Void::FileSystem::TempDir::open("vbs_daemon_"); Void::Testing::require(temp.has_value()); @@ -1779,9 +2015,9 @@ void build(Void::Build::Project &project) { auto all = request_object(socket, R"({"op":"target_flags","target":"app"})", std::chrono::seconds{120}); - auto filtered = request_object( - socket, R"({"op":"target_flags","target":"app","file":"nope.cpp"})", - std::chrono::seconds{120}); + auto filtered = + request_object(socket, R"({"op":"target_flags","target":"app","file":"nope.cpp"})", + std::chrono::seconds{120}); auto unknown = request_object(socket, R"({"op":"target_flags","target":"nope"})", std::chrono::seconds{120}); auto shutdown = Void::Build::Daemon::request(socket, R"({"op":"shutdown"})"); @@ -1973,10 +2209,10 @@ void build(Void::Build::Project &project) { Void::Testing::expect(describe_raw->find("\"name\":\"lib\"") != std::string::npos); Void::Testing::expect(describe_raw->find("\"name\":\"app\"") != std::string::npos); - auto member_raw = Void::Build::Daemon::request( - socket, R"({"op":"describe","member":"app"})", std::chrono::seconds{120}); - auto unknown_member = request_object(socket, R"({"op":"describe","member":"nope"})", - std::chrono::seconds{120}); + auto member_raw = Void::Build::Daemon::request(socket, R"({"op":"describe","member":"app"})", + std::chrono::seconds{120}); + auto unknown_member = + request_object(socket, R"({"op":"describe","member":"nope"})", std::chrono::seconds{120}); auto workspace_build = Void::Build::Daemon::request(socket, R"({"op":"build"})", std::chrono::seconds{120}); diff --git a/tests/RegistryTests.cpp b/tests/RegistryTests.cpp index 21daf52..2ab3e8d 100644 --- a/tests/RegistryTests.cpp +++ b/tests/RegistryTests.cpp @@ -857,6 +857,17 @@ VOID_TEST(RegistryTests, registry_binary_variant_publish_download_and_materializ if (downloaded) { Void::Testing::expect(downloaded->body == artifact); } + auto ranged = send_loopback_http(port, "GET", binary_path + "/download", + {{"Range", "bytes=0-3"}}); + Void::Testing::expect(ranged.has_value() && ranged->status == 206); + if (ranged) { + Void::Testing::expect_eq(ranged->body, artifact.substr(0, 4)); + Void::Testing::expect(ranged->headers.at("content-range").find("/" + + std::to_string(artifact.size())) != std::string::npos); + } + auto unsatisfiable = send_loopback_http(port, "GET", binary_path + "/download", + {{"Range", "bytes=999999-"}}); + Void::Testing::expect(unsatisfiable.has_value() && unsatisfiable->status == 416); auto head_binary = send_loopback_http(port, "HEAD", binary_path + "/download"); Void::Testing::expect(head_binary.has_value() && head_binary->status == 200); if (head_binary) {