feat(registry): yank binary variants and exclude them from selection
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 30s

This commit is contained in:
faumaray committed 2026-12-03 22:15:50 +03:00
1 parent 502f2b0c51
commit 66d2fa6a2e
9 files changed
+116 -7

No files matched your search

+34
View File
@@ -583,6 +583,11 @@ VOID_TEST(RegistryTests, registry_binary_variant_publish_download_and_materializ
"different");
Void::Testing::expect(conflict.has_value() && conflict->status == 409);
// Binary yank requires authentication (bearer tokens are not CSRF-exempt).
auto bin_yank =
send_loopback_http(port, "POST", binary_path + "/yank", {}, "{\"yanked\":true}");
Void::Testing::expect(bin_yank.has_value() && bin_yank->status == 401);
// The registry-served artifact materializes through the signed binary-variant path.
Package::BinaryVariantMeta variant;
variant.variant_id = variant_id;
@@ -644,6 +649,35 @@ VOID_TEST(RegistryTests, registry_binary_variant_publish_download_and_materializ
}
Void::Testing::expect(found_client_variant);
// Authenticated session + CSRF allows yanking the variant; the detail JSON reflects it.
auto yank_login = send_loopback_http(port, "POST", "/api/v1/auth/login",
{{"Content-Type", "application/json"}},
"{\"username\":\"admin\",\"password\":\"admin_pw\"}");
Void::Testing::require(yank_login.has_value() && yank_login->status == 200);
const auto yank_cookie = extract_session_cookie(yank_login->set_cookies);
const auto yank_csrf = extract_json_str(yank_login->body, "csrf_token");
Void::Testing::expect(!yank_cookie.empty() && !yank_csrf.empty());
auto session_yank = send_loopback_http(port, "POST", binary_path + "/yank",
{{"Cookie", yank_cookie}, {"X-CSRF-Token", yank_csrf}},
"{\"yanked\":true}");
Void::Testing::expect(session_yank.has_value() && session_yank->status == 200);
auto after_yank = send_loopback_http(port, "GET", "/api/v1/packages/demo-bin",
{{"Authorization", "Bearer " + *tok}});
Void::Testing::expect(after_yank.has_value() && after_yank->status == 200);
if (after_yank) {
const auto variant_pos = after_yank->body.find(variant_id);
Void::Testing::expect(variant_pos != std::string::npos);
if (variant_pos != std::string::npos) {
Void::Testing::expect(after_yank->body.find("\"yanked\":true", variant_pos) !=
std::string::npos);
}
}
auto variants_after_yank =
Package::fetch_binary_variants(reg_url, "demo-bin", "1.0.0", Package::RegistryAuth{*tok});
Void::Testing::require(variants_after_yank.has_value());
Void::Testing::expect(std::ranges::none_of(
*variants_after_yank, [&](const auto &info) { return info.variant_id == variant_id; }));
(*svc)->stop_http();
}