Files
horizon-airdef/crates/horizon-telemetry-server/tests/github.rs
T
Ludovic Marie bac51e3fba Telemetry server: the hub's bug reports and suggestions
POST /hub/report opens a GitHub issue at once (labels bug and from-website, the
every template field required, people's text made inert (no mentions, issue
references, HTML or closing keywords) and the same report twice answered with the
first issue. If GitHub fails it answers 202 and the upkeep tries again for a week.
Off (503) without HORIZON_TELEMETRY_GITHUB_TOKEN.

POST /hub/suggest queues a suggestion; GET /hub/suggestions?after=<id> hands the
queue to Kira with the HORIZON_TELEMETRY_HUB_TOKEN bearer (404 when unset, 401 for
a wrong token). Nothing is published.

Per-address limits (20 an hour, bursts of 2) on keyed hashes of the address, daily
caps from everyone (30 reports, 200 suggestions), a honeypot field, entries kept
90 days.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 16:10:18 +01:00

42 lines
1.5 KiB
Rust

//! A website bug report as the issue GitHub gets: the template, and people's text made inert.
use horizon_telemetry_server::github::{issue, neutralise};
use serde_json::{Map, Value, json};
#[test]
fn people_text_mentions_and_references_nothing() {
let text =
neutralise("@octocat see #12 and https://github.com/a/b/issues/3 <img src=x> `x` Fixes it");
assert!(!text.contains("@o") && !text.contains("#1") && !text.contains("github.com/"));
assert!(!text.contains('<') && !text.contains('`'));
assert!(text.contains("F\u{200b}ixes"));
// Words that only start like a keyword stay as they are.
assert_eq!(neutralise("closet fixture"), "closet fixture");
}
#[test]
fn a_report_reads_as_the_template() {
let fields: Map<String, Value> = serde_json::from_value(json!({
"title": "Water is black\non AMD", "did": "Opened a world", "happened": "Black water",
"expected": "Blue water", "system": "Windows 11, RX 6600", "name": "steve_"
}))
.unwrap();
let issue = issue(&fields);
assert_eq!(issue.title, "Water is black on AMD");
assert!(
issue
.body
.starts_with("> **What I did:**\n> Opened a world\n> **What happened:**")
);
assert!(
issue
.body
.contains("> **Horizon version:** not given\n> **OS, CPU, GPU:** Windows 11, RX 6600")
);
assert!(
issue
.body
.contains("Reported on playhorizon.dev by **steve**")
);
assert_eq!(issue.labels, ["bug", "from-website"]);
}