F: forward the peer's /api/v1 path and un-ignore the proxied tests

The proxy validated the route without its API prefix and handed the
transport "/systemd/units", which a peer answered with 404. Validation
still works on the bare route; the transport now gets
"/api/v1/systemd/units". Un-ignoring the two acceptance tests
(a_plain_peer_serves_its_own_data_through_the_proxy and
shutdown_ends_a_proxied_follow) is the check for that fix; the unit
tests in api/, mcp/ and the registry script their fakes on the peer's
real paths again.
This commit is contained in:
ari committed 2026-10-20 15:04:09 -04:00
1 parent 2455486205
commit 3ae8e74a1d
5 files changed
+93 -86

No files matched your search

+31 -28
View File
@@ -1312,43 +1312,43 @@ mod tests {
let fake = FakeTransport::new();
fake.peer("beta")
.respond(
"/systemd/units/",
"/api/v1/systemd/units/",
200,
"application/json",
r#"{"name":"peer-teapot.service","n_restarts":3}"#,
)
.respond(
"/systemd/units",
"/api/v1/systemd/units",
200,
"application/json",
r#"[{"name":"peer-teapot.service"}]"#,
)
.respond(
"/systemd/timers",
"/api/v1/systemd/timers",
200,
"application/json",
r#"[{"name":"peer.timer"}]"#,
)
.respond(
"/journal",
"/api/v1/journal",
200,
"application/json",
r#"[{"message":"peer journal line"}]"#,
)
.respond(
"/docker/containers/peer-ctr/logs",
"/api/v1/docker/containers/peer-ctr/logs",
200,
"application/json",
r#"[{"name":"peer-ctr"}]"#,
)
.respond(
"/docker/containers/",
"/api/v1/docker/containers/",
200,
"application/json",
r#"{"name":"peer-ctr"}"#,
)
.respond(
"/docker/ps",
"/api/v1/docker/ps",
200,
"application/json",
r#"[{"name":"peer-ctr"}]"#,
@@ -1433,14 +1433,14 @@ mod tests {
assert_eq!(
paths,
[
"/systemd/units",
"/systemd/units/peer-teapot.service",
"/systemd/timers",
"/journal",
"/docker/ps",
"/docker/containers/peer-ctr",
"/api/v1/systemd/units",
"/api/v1/systemd/units/peer-teapot.service",
"/api/v1/systemd/timers",
"/api/v1/journal",
"/api/v1/docker/ps",
"/api/v1/docker/containers/peer-ctr",
// Docker logs share the container prefix; the script answers both.
"/docker/containers/peer-ctr/logs",
"/api/v1/docker/containers/peer-ctr/logs",
]
);
assert_eq!(
@@ -1498,7 +1498,7 @@ mod tests {
async fn peer_tail_journal_consumes_the_follow_stream() {
let fake = FakeTransport::new();
fake.peer("beta").stream(
"/journal/follow",
"/api/v1/journal/follow",
vec![
bytes::Bytes::from_static(
b"event: journal\ndata: {\"message\":\"one\"}\n\n",
@@ -1526,7 +1526,7 @@ mod tests {
assert_eq!(v["entries"].as_array().unwrap().len(), 2);
assert_eq!(v["entries"][1]["message"], "two");
let calls = fake.calls();
assert_eq!(calls[0].1.path, "/journal/follow");
assert_eq!(calls[0].1.path, "/api/v1/journal/follow");
assert_eq!(calls[0].1.accept.as_deref(), Some("text/event-stream"));
assert!(v["note"].as_str().unwrap().contains("closed the stream"));
}
@@ -1539,7 +1539,7 @@ mod tests {
let fake = FakeTransport::new();
let chunk = bytes::Bytes::from(vec![b'x'; 512]);
fake.peer("beta")
.stream("/journal/follow", vec![chunk; 100]);
.stream("/api/v1/journal/follow", vec![chunk; 100]);
let s = peer_svc_limits(Config::default(), peer_config(4096), &fake);
let start = tokio::time::Instant::now();
let r = s.tail_journal(follow_params("beta", 30)).await.unwrap();
@@ -1564,7 +1564,7 @@ mod tests {
let frames: Vec<bytes::Bytes> = (0..20)
.map(|i| bytes::Bytes::from(format!("data: {{\"n\":{i}}}\n\n")))
.collect();
fake.peer("beta").stream("/journal/follow", frames);
fake.peer("beta").stream("/api/v1/journal/follow", frames);
let mut cfg = Config::default();
cfg.limits.max_lines = 3;
let s = peer_svc_with(cfg, &fake);
@@ -1577,7 +1577,7 @@ mod tests {
async fn peer_tail_journal_accepts_a_buffered_body() {
let fake = FakeTransport::new();
fake.peer("beta").respond(
"/journal/follow",
"/api/v1/journal/follow",
200,
"text/event-stream",
"data: {\"message\":\"a\"}\n\ndata: {\"message\":\"b\"}\n\n",
@@ -1593,7 +1593,7 @@ mod tests {
async fn peer_tail_journal_maps_a_follow_error_like_rest() {
let fake = FakeTransport::new();
fake.peer("beta")
.respond("/journal/follow", 404, "application/json", "{}");
.respond("/api/v1/journal/follow", 404, "application/json", "{}");
let s = peer_svc_with(Config::default(), &fake);
let r = s.tail_journal(follow_params("beta", 30)).await.unwrap();
assert_eq!(r.is_error, Some(true));
@@ -1604,7 +1604,7 @@ mod tests {
let fake = FakeTransport::new();
fake.peer("beta")
.respond("/journal/follow", 500, "application/json", "{}");
.respond("/api/v1/journal/follow", 500, "application/json", "{}");
let s = peer_svc_with(Config::default(), &fake);
let r = s.tail_journal(follow_params("beta", 30)).await.unwrap();
assert!(
@@ -1640,9 +1640,9 @@ mod tests {
async fn peer_failures_are_tool_errors() {
let fake = FakeTransport::new();
fake.peer("beta")
.respond_err("/systemd/units", PeerError::Rejected)
.respond("/systemd/timers", 503, "application/json", "{}")
.respond("/journal", 200, "application/json", "not json");
.respond_err("/api/v1/systemd/units", PeerError::Rejected)
.respond("/api/v1/systemd/timers", 503, "application/json", "{}")
.respond("/api/v1/journal", 200, "application/json", "not json");
let s = peer_svc_with(Config::default(), &fake);
let r = s
@@ -1731,8 +1731,8 @@ mod tests {
async fn peer_paths_encode_and_clamp_like_the_rest_routes() {
let fake = FakeTransport::new();
fake.peer("beta")
.respond("/systemd/units/", 200, "application/json", "{}")
.respond("/docker/containers/", 200, "application/json", "[]");
.respond("/api/v1/systemd/units/", 200, "application/json", "{}")
.respond("/api/v1/docker/containers/", 200, "application/json", "[]");
let mut cfg = Config::default();
cfg.limits.max_tail = 1;
let s = peer_svc_with(cfg, &fake);
@@ -1754,8 +1754,11 @@ mod tests {
.unwrap();
let calls = fake.calls();
assert_eq!(calls[0].1.path, "/systemd/units/dev-disk-by%5Cx2did.device");
assert_eq!(calls[1].1.path, "/docker/containers/web-1/logs");
assert_eq!(
calls[0].1.path,
"/api/v1/systemd/units/dev-disk-by%5Cx2did.device"
);
assert_eq!(calls[1].1.path, "/api/v1/docker/containers/web-1/logs");
assert_eq!(calls[1].1.query, vec![("tail".to_owned(), "1".to_owned())]);
}