feat(registry,daemon): patch package metadata; report workspace info
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 10s

This commit is contained in:
faumaray committed 2026-12-04 06:13:13 +03:00
1 parent 85ff7a8c75
commit e7698a411d
8 files changed
+250 -4

No files matched your search

+88
View File
@@ -1113,6 +1113,94 @@ VOID_TEST(Daemon, workspace_members_lists_declared_members) {
Void::Testing::expect(raw->find("packages/lib") != std::string::npos);
}
VOID_TEST(Daemon, workspace_info_reports_members_and_lockfile) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());
const auto options = make_options(temp->path());
const auto ws = options.project_root;
{
std::ofstream workspace{ws / "workspace.cpp"};
workspace << "#include <Void/Build.hpp>\n"
"void workspace(Void::Build::Workspace &workspace) {\n"
" workspace.member(\"lib\", \"packages/lib\");\n"
" workspace.member(\"app\", \"packages/app\");\n"
"}\n";
Void::Testing::require(workspace.good());
}
std::filesystem::create_directories(ws / "packages" / "lib");
std::filesystem::create_directories(ws / "packages" / "app");
{
std::ofstream lockfile{ws / "vbs.lock"};
lockfile << "{}\n";
Void::Testing::require(lockfile.good());
}
auto server = Void::Build::Daemon::DaemonServer::create(options);
Void::Testing::require(server.has_value());
const auto socket = server->socket_path();
Void::Result::Result<void, Void::Result::Error> run_result;
std::jthread worker{[&] { run_result = server->run(); }};
Void::Testing::require(wait_for_path(socket, std::chrono::seconds{5}));
auto raw = Void::Build::Daemon::request(socket, R"({"op":"workspace_info"})",
std::chrono::seconds{120});
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::require(raw.has_value());
const auto parsed = parse_json(*raw);
Void::Testing::require(parsed.has_value());
const auto *object = as_object(*parsed);
Void::Testing::require(object != nullptr);
Void::Testing::expect(bool_field(*object, "ok"));
Void::Testing::expect_eq(str_field(*object, "op"), std::string{"workspace_info"});
Void::Testing::expect(bool_field(*object, "workspace"));
Void::Testing::expect(raw->find("\"name\":\"lib\"") != std::string::npos);
Void::Testing::expect(raw->find("\"name\":\"app\"") != std::string::npos);
const auto *lockfile_value = field(*object, "lockfile");
Void::Testing::require(lockfile_value != nullptr);
const auto *lockfile_object = as_object(*lockfile_value);
Void::Testing::require(lockfile_object != nullptr);
Void::Testing::expect(bool_field(*lockfile_object, "exists"));
Void::Testing::expect(int_field(*lockfile_object, "size_bytes") > 0);
Void::Testing::expect(str_field(*lockfile_object, "path").find("vbs.lock") !=
std::string::npos);
// A plain project is not a workspace and reports a null lockfile.
auto plain_temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(plain_temp.has_value());
const auto plain_options = make_options(plain_temp->path());
auto plain_server = Void::Build::Daemon::DaemonServer::create(plain_options);
Void::Testing::require(plain_server.has_value());
const auto plain_socket = plain_server->socket_path();
Void::Result::Result<void, Void::Result::Error> plain_run_result;
std::jthread plain_worker{[&] { plain_run_result = plain_server->run(); }};
Void::Testing::require(wait_for_path(plain_socket, std::chrono::seconds{5}));
auto plain = request_object(plain_socket, R"({"op":"workspace_info"})");
auto plain_shutdown = Void::Build::Daemon::request(plain_socket, R"({"op":"shutdown"})");
Void::Testing::expect(plain_shutdown.has_value());
plain_worker.join();
Void::Testing::expect(plain_run_result.has_value());
Void::Testing::require(plain.has_value());
Void::Testing::expect(bool_field(*plain, "ok"));
Void::Testing::expect(!bool_field(*plain, "workspace", true));
const auto *plain_members = field(*plain, "members");
Void::Testing::require(plain_members != nullptr);
const auto *plain_members_array = std::get_if<JsonValue::Array>(&plain_members->value);
Void::Testing::require(plain_members_array != nullptr);
Void::Testing::expect(plain_members_array->empty());
const auto *plain_lockfile = field(*plain, "lockfile");
Void::Testing::require(plain_lockfile != nullptr);
Void::Testing::expect(std::holds_alternative<std::nullptr_t>(plain_lockfile->value));
}
VOID_TEST(Daemon, ide_configs_reports_generated_files) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());
+41 -3
View File
@@ -205,6 +205,44 @@ VOID_TEST(RegistryTests, registry_rbac_immutability_csrf_xss_web_and_backup_rest
*bytes1);
Void::Testing::expect(half_sig_pub.has_value() && half_sig_pub->status == 400);
// Mutable metadata: an owner can patch the description; invalid updates are rejected.
// A private package keeps anonymous search totals unchanged for later assertions.
auto meta_pub = send_loopback_http(port, "PUT", "/api/v1/packages/meta-pkg/1.0.0",
{{"Authorization", "Bearer " + *alice_tok},
{"X-Content-SHA256", *sha1},
{"X-Package-Private", "true"}},
*bytes1);
Void::Testing::expect(meta_pub.has_value() && meta_pub->status == 201);
auto patched = send_loopback_http(
port, "PATCH", "/api/v1/packages/meta-pkg",
{{"Authorization", "Bearer " + *alice_tok}, {"Content-Type", "application/json"}},
"{\"description\":\"patched description\"}");
Void::Testing::expect(patched.has_value() && patched->status == 200);
auto patched_detail = send_loopback_http(port, "GET", "/api/v1/packages/meta-pkg",
{{"Authorization", "Bearer " + *alice_tok}});
Void::Testing::expect(patched_detail.has_value() && patched_detail->status == 200);
if (patched_detail) {
Void::Testing::expect(patched_detail->body.find("patched description") !=
std::string::npos);
}
auto patch_no_auth = send_loopback_http(port, "PATCH", "/api/v1/packages/meta-pkg", {},
"{\"description\":\"x\"}");
Void::Testing::expect(patch_no_auth.has_value() && patch_no_auth->status == 401);
auto patch_non_owner = send_loopback_http(
port, "PATCH", "/api/v1/packages/meta-pkg",
{{"Authorization", "Bearer " + *bob_tok}, {"Content-Type", "application/json"}},
"{\"description\":\"x\"}");
Void::Testing::expect(patch_non_owner.has_value() && patch_non_owner->status == 403);
auto patch_empty = send_loopback_http(
port, "PATCH", "/api/v1/packages/meta-pkg",
{{"Authorization", "Bearer " + *alice_tok}, {"Content-Type", "application/json"}}, "{}");
Void::Testing::expect(patch_empty.has_value() && patch_empty->status == 400);
auto patch_bad_private = send_loopback_http(
port, "PATCH", "/api/v1/packages/meta-pkg",
{{"Authorization", "Bearer " + *alice_tok}, {"Content-Type", "application/json"}},
"{\"private\":\"yes\"}");
Void::Testing::expect(patch_bad_private.has_value() && patch_bad_private->status == 400);
// Package ownership management (bearer tokens are not ambient browser credentials).
auto owner_pkg_pub = send_loopback_http(
port, "PUT", "/api/v1/packages/owner-pkg/1.0.0",
@@ -878,15 +916,15 @@ VOID_TEST(RegistryTests, registry_binary_variant_publish_download_and_materializ
Void::Testing::expect(etag_it != etag_head->headers.end());
if (etag_it != etag_head->headers.end()) {
auto cached = send_loopback_http(port, "GET", binary_path + "/download",
{{"If-None-Match", etag_it->second}});
{{"If-None-Match", etag_it->second}});
Void::Testing::expect(cached.has_value() && cached->status == 304);
if (cached) {
Void::Testing::expect(cached->body.empty());
}
}
}
auto ranged = send_loopback_http(port, "GET", binary_path + "/download",
{{"Range", "bytes=0-3"}});
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));