fix: give each auth-contract request its own source so the token throttle cannot mask a 401

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 21:11:34 +07:00
parent 9219319ff3
commit c18815eb5d

View File

@@ -44,6 +44,8 @@ async fn human_read_endpoints_reject_anonymous_and_outpost_tokens() {
.db
.insert_test_credential("synthetic-outpost", &outpost.to_string(), "fixture");
let app = router(state);
// each request comes from its own source so the wrong-token throttle does not mask the 401s
let mut source = 0u32;
for row in CONTRACT.lines().filter(|line| line.starts_with("| /")) {
let fields: Vec<_> = row.split('|').map(str::trim).collect();
if fields[3] != "human" || !fields[2].split(',').any(|method| method == "GET") {
@@ -51,9 +53,10 @@ async fn human_read_endpoints_reject_anonymous_and_outpost_tokens() {
}
let path = fields[1].replace(":id", "00000000-0000-0000-0000-000000000001");
for token in [None, Some("synthetic-outpost")] {
let mut request = Request::builder()
.uri(&path)
.extension(ConnectInfo("127.0.0.1:9000".parse::<SocketAddr>().unwrap()));
source += 1;
let mut request = Request::builder().uri(&path).extension(ConnectInfo(
SocketAddr::from(([10, 0, (source >> 8) as u8, source as u8], 9000)),
));
if let Some(token) = token {
request = request
.header(header::AUTHORIZATION, format!("Bearer {token}"))