feat(package,daemon): list registry tokens; list daemon targets
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 4s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 9s

This commit is contained in:
faumaray committed 2026-12-04 07:05:12 +03:00
1 parent 1aaece3231
commit eb35bb6b6e
11 files changed
+326 -18

No files matched your search

+2
View File
@@ -50,6 +50,8 @@ check_process(0 "Usage: vbs publish-binary " "" publish-binary --help)
check_process(0 "Usage: vbs binaries <command>.*Commands:.*list.*fetch" "" binaries --help)
check_process(0 "Usage: vbs binaries list " "" binaries list --help)
check_process(0 "Usage: vbs releases list " "" releases list --help)
check_process(0 "Usage: vbs tokens list " "" tokens list --help)
check_process(2 "" "vbs tokens list: --registry is required" tokens list)
check_process(2 "" "--registry and --name are required" releases list)
check_process(0 "Usage: vbs releases show " "" releases show --help)
check_process(2 "" "--registry, --name, and --version are required" releases show)
+94
View File
@@ -2337,6 +2337,100 @@ void build(Void::Build::Project &project) {
Void::Testing::expect(!bool_field(*unknown, "ok", true));
}
VOID_TEST(Daemon, target_list_reports_targets) {
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.hpp>
void build(Void::Build::Project &project) {
auto app = project.executable("app");
app.sources({"main.cpp"});
auto lib = project.static_library("lib");
lib.sources({"lib.cpp"});
}
)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 / "lib.cpp"};
source << "int lib_value() { 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<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 listed = request_object(socket, R"({"op":"target_list"})", std::chrono::seconds{120});
auto bounded =
request_object(socket, R"({"op":"target_list","limit":1})", std::chrono::seconds{120});
auto invalid = request_object(socket, R"({"op":"target_list","limit":1001})");
auto invalid_type = request_object(socket, R"({"op":"target_list","limit":"x"})");
auto empty = request_object(socket, R"({"op":"target_list","limit":0})");
auto unknown_member = request_object(socket, R"({"op":"target_list","member":"nope"})");
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(listed.has_value());
Void::Testing::expect(bool_field(*listed, "ok"));
Void::Testing::expect_eq(str_field(*listed, "op"), std::string{"target_list"});
Void::Testing::expect(int_field(*listed, "total") >= 1);
Void::Testing::expect(int_field(*listed, "returned") == int_field(*listed, "total"));
const auto *targets = field(*listed, "targets");
Void::Testing::require(targets != nullptr);
const auto *target_array = std::get_if<JsonValue::Array>(&targets->value);
Void::Testing::require(target_array != nullptr && !target_array->empty());
bool found_app = false;
bool found_lib = false;
for (const auto &item : *target_array) {
const auto *entry = std::get_if<JsonObject>(&item.value);
Void::Testing::require(entry != nullptr);
if (str_field(*entry, "name") == "app") {
found_app = true;
Void::Testing::expect_eq(str_field(*entry, "kind"), std::string{"executable"});
Void::Testing::expect(bool_field(*entry, "enabled"));
}
if (str_field(*entry, "name") == "lib") {
found_lib = true;
Void::Testing::expect_eq(str_field(*entry, "kind"), std::string{"static_library"});
Void::Testing::expect(bool_field(*entry, "enabled"));
}
}
Void::Testing::expect(found_app);
Void::Testing::expect(found_lib);
Void::Testing::require(bounded.has_value());
Void::Testing::expect(bool_field(*bounded, "ok"));
Void::Testing::expect_eq(int_field(*bounded, "returned"), std::int64_t{1});
Void::Testing::expect(int_field(*bounded, "total") >= 2);
Void::Testing::require(empty.has_value());
Void::Testing::expect(bool_field(*empty, "ok"));
Void::Testing::expect_eq(int_field(*empty, "returned"), std::int64_t{0});
Void::Testing::require(invalid.has_value());
Void::Testing::expect(!bool_field(*invalid, "ok", true));
Void::Testing::require(invalid_type.has_value());
Void::Testing::expect(!bool_field(*invalid_type, "ok", true));
Void::Testing::require(unknown_member.has_value());
Void::Testing::expect(!bool_field(*unknown_member, "ok", true));
}
VOID_TEST(Daemon, describe_empty_project_reports_zero_targets) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());
+14 -1
View File
@@ -521,7 +521,7 @@ VOID_TEST(RegistryTests, registry_rbac_immutability_csrf_xss_web_and_backup_rest
Void::Testing::expect(stats->headers.contains("etag"));
}
auto stats_non_admin = send_loopback_http(port, "GET", "/api/v1/stats",
{{"Authorization", "Bearer " + *alice_tok}});
{{"Authorization", "Bearer " + *alice_tok}});
Void::Testing::expect(stats_non_admin.has_value() && stats_non_admin->status == 403);
auto bad_limit_text = send_loopback_http(port, "GET", "/api/v1/packages?limit=abc");
@@ -1318,6 +1318,19 @@ target_include_directories(hello_pkg PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include
auto trusted_binary_res = Platform::run_supervised(trusted_fetch);
Void::Testing::expect(trusted_binary_res.has_value() && !trusted_binary_res->succeeded());
Platform::ProcessRequest tokens_list;
tokens_list.executable = vbs_bin;
tokens_list.arguments = {"tokens", "list", "--registry", reg_url};
tokens_list.environment.set_vars["VBS_REGISTRY_TOKEN"] = *tok;
auto tokens_res = Platform::run_supervised(tokens_list);
Void::Testing::expect(tokens_res.has_value() && tokens_res->succeeded());
if (tokens_res) {
Void::Testing::expect(tokens_res->stdout_data.find("ci_pub") != std::string::npos);
Void::Testing::expect(tokens_res->stdout_data.find("active") != std::string::npos);
// The plaintext secret must never be listed.
Void::Testing::expect(tokens_res->stdout_data.find(*tok) == std::string::npos);
}
Platform::ProcessRequest releases_list;
releases_list.executable = vbs_bin;
releases_list.arguments = {"releases", "list", "--registry", reg_url, "--name", "hello-pkg"};