feat(registry): manage package owners with audit
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 02:52:42 +03:00
1 parent 34fe148eb4
commit 18caf2e7e6
6 files changed
+106 -2

No files matched your search

+33
View File
@@ -176,6 +176,39 @@ 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);
// 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",
{{"Authorization", "Bearer " + *alice_tok}, {"X-Content-SHA256", *sha1}}, *bytes1);
Void::Testing::expect(owner_pkg_pub.has_value() && owner_pkg_pub->status == 201);
auto owners = send_loopback_http(port, "GET", "/api/v1/packages/owner-pkg/owners",
{{"Authorization", "Bearer " + *alice_tok}});
Void::Testing::expect(owners.has_value() && owners->status == 200);
if (owners) {
Void::Testing::expect(owners->body.find("pub_alice") != 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);
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);
// A reader who was added as an owner still lacks publish authority, so cannot mutate.
auto reader_remove =
send_loopback_http(port, "DELETE", "/api/v1/packages/owner-pkg/owners/pub_alice",
{{"Authorization", "Bearer " + *bob_tok}});
Void::Testing::expect(reader_remove.has_value() && reader_remove->status == 403);
auto remove_added =
send_loopback_http(port, "DELETE", "/api/v1/packages/owner-pkg/owners/read_bob",
{{"Authorization", "Bearer " + *alice_tok}});
Void::Testing::expect(remove_added.has_value() && remove_added->status == 200);
// The last remaining owner cannot be removed.
auto remove_last =
send_loopback_http(port, "DELETE", "/api/v1/packages/owner-pkg/owners/pub_alice",
{{"Authorization", "Bearer " + *alice_tok}});
Void::Testing::expect(remove_last.has_value() && remove_last->status == 409);
// Unauthenticated access to private package MUST fail (401)!
auto anon_priv = send_loopback_http(port, "GET", "/api/v1/packages/secret-pkg");
Void::Testing::expect(anon_priv.has_value() && anon_priv->status == 401);