feat(registry,cli): RFC 7232 conditional requests; require trusted verify keys
This commit is contained in:
1 parent
27d909fdad
commit
ea6ac852e7
9 files changed
+138
-6
No files matched your search
@@ -1021,6 +1021,40 @@ VOID_TEST(RegistryTests, registry_binary_variant_publish_download_and_materializ
|
||||
std::string::npos);
|
||||
Void::Testing::expect(binary_detail->body.find("\"download_url\":") != std::string::npos);
|
||||
}
|
||||
// The binary detail response is ETag-validated: matching (strong, weak, list or `*`)
|
||||
// If-None-Match values yield a bodyless 304, while a stale validator returns the full 200.
|
||||
if (binary_detail) {
|
||||
Void::Testing::expect_eq(binary_detail->headers.at("cache-control"),
|
||||
std::string{"no-cache"});
|
||||
const auto etag_it = binary_detail->headers.find("etag");
|
||||
Void::Testing::expect(etag_it != binary_detail->headers.end());
|
||||
if (etag_it != binary_detail->headers.end()) {
|
||||
const std::string &etag = etag_it->second;
|
||||
auto not_modified =
|
||||
send_loopback_http(port, "GET", binary_path, {{"If-None-Match", etag}});
|
||||
Void::Testing::expect(not_modified.has_value() && not_modified->status == 304);
|
||||
if (not_modified) {
|
||||
Void::Testing::expect(not_modified->body.empty());
|
||||
Void::Testing::expect_eq(not_modified->headers.at("etag"), etag);
|
||||
Void::Testing::expect_eq(not_modified->headers.at("cache-control"),
|
||||
std::string{"no-cache"});
|
||||
}
|
||||
auto weak =
|
||||
send_loopback_http(port, "GET", binary_path, {{"If-None-Match", "W/" + etag}});
|
||||
Void::Testing::expect(weak.has_value() && weak->status == 304);
|
||||
auto list_match = send_loopback_http(port, "GET", binary_path,
|
||||
{{"If-None-Match", "\"stale\", " + etag}});
|
||||
Void::Testing::expect(list_match.has_value() && list_match->status == 304);
|
||||
auto wildcard = send_loopback_http(port, "GET", binary_path, {{"If-None-Match", "*"}});
|
||||
Void::Testing::expect(wildcard.has_value() && wildcard->status == 304);
|
||||
auto stale =
|
||||
send_loopback_http(port, "GET", binary_path, {{"If-None-Match", "\"stale\""}});
|
||||
Void::Testing::expect(stale.has_value() && stale->status == 200);
|
||||
if (stale) {
|
||||
Void::Testing::expect_eq(stale->body, binary_detail->body);
|
||||
}
|
||||
}
|
||||
}
|
||||
auto missing_binary = send_loopback_http(port, "GET", binary_path + "-missing");
|
||||
Void::Testing::expect(missing_binary.has_value() && missing_binary->status == 404);
|
||||
|
||||
|
||||
Reference in new issue
Block a user