feat(package): read package owners through the registry client
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 8s

This commit is contained in:
faumaray committed 2026-12-04 04:02:23 +03:00
1 parent eb4af6f3d2
commit 105519924a
7 files changed
+106 -1

No files matched your search

+29
View File
@@ -16,6 +16,7 @@
#include <Void/Testing/Assert.hpp>
#include <Void/Testing/Test.hpp>
#include <algorithm>
#include <cstring>
#include <fstream>
#include <span>
@@ -187,10 +188,38 @@ VOID_TEST(RegistryTests, registry_rbac_immutability_csrf_xss_web_and_backup_rest
if (owners) {
Void::Testing::expect(owners->body.find("pub_alice") != std::string::npos);
}
// The RegistryClient helper parses the owners endpoint and surfaces a missing package.
const std::string reg_url = "http://127.0.0.1:" + std::to_string(port);
auto client_owners =
Package::fetch_package_owners(reg_url, "owner-pkg", Package::RegistryAuth{*alice_tok});
Void::Testing::require(client_owners.has_value());
Void::Testing::expect(std::ranges::find(*client_owners, std::string{"pub_alice"}) !=
client_owners->end());
auto missing_owners =
Package::fetch_package_owners(reg_url, "missing-pkg", Package::RegistryAuth{*alice_tok});
Void::Testing::expect(!missing_owners.has_value());
if (!missing_owners) {
Void::Testing::expect(missing_owners.error().message().find("404") != std::string::npos);
}
// Private packages require read permission, so anonymous access is rejected.
auto denied_owners =
Package::fetch_package_owners(reg_url, "secret-pkg", Package::RegistryAuth{});
Void::Testing::expect(!denied_owners.has_value());
if (!denied_owners) {
Void::Testing::expect(denied_owners.error().message().find("401") != std::string::npos);
}
auto add_owner = send_loopback_http(port, "PUT", "/api/v1/packages/owner-pkg/owners/read_bob",
{{"Authorization", "Bearer " + *alice_tok}});
Void::Testing::require(add_owner.has_value());
Void::Testing::expect_eq(static_cast<int>(add_owner->status), 200);
// The helper reflects subsequent ownership changes.
auto updated_owners =
Package::fetch_package_owners(reg_url, "owner-pkg", Package::RegistryAuth{*alice_tok});
Void::Testing::require(updated_owners.has_value());
Void::Testing::expect(std::ranges::find(*updated_owners, std::string{"pub_alice"}) !=
updated_owners->end());
Void::Testing::expect(std::ranges::find(*updated_owners, std::string{"read_bob"}) !=
updated_owners->end());
auto add_unknown = send_loopback_http(port, "PUT", "/api/v1/packages/owner-pkg/owners/ghost",
{{"Authorization", "Bearer " + *alice_tok}});
Void::Testing::expect(add_unknown.has_value() && add_unknown->status == 404);