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:
@@ -44,6 +44,8 @@ async fn human_read_endpoints_reject_anonymous_and_outpost_tokens() {
|
|||||||
.db
|
.db
|
||||||
.insert_test_credential("synthetic-outpost", &outpost.to_string(), "fixture");
|
.insert_test_credential("synthetic-outpost", &outpost.to_string(), "fixture");
|
||||||
let app = router(state);
|
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("| /")) {
|
for row in CONTRACT.lines().filter(|line| line.starts_with("| /")) {
|
||||||
let fields: Vec<_> = row.split('|').map(str::trim).collect();
|
let fields: Vec<_> = row.split('|').map(str::trim).collect();
|
||||||
if fields[3] != "human" || !fields[2].split(',').any(|method| method == "GET") {
|
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");
|
let path = fields[1].replace(":id", "00000000-0000-0000-0000-000000000001");
|
||||||
for token in [None, Some("synthetic-outpost")] {
|
for token in [None, Some("synthetic-outpost")] {
|
||||||
let mut request = Request::builder()
|
source += 1;
|
||||||
.uri(&path)
|
let mut request = Request::builder().uri(&path).extension(ConnectInfo(
|
||||||
.extension(ConnectInfo("127.0.0.1:9000".parse::<SocketAddr>().unwrap()));
|
SocketAddr::from(([10, 0, (source >> 8) as u8, source as u8], 9000)),
|
||||||
|
));
|
||||||
if let Some(token) = token {
|
if let Some(token) = token {
|
||||||
request = request
|
request = request
|
||||||
.header(header::AUTHORIZATION, format!("Bearer {token}"))
|
.header(header::AUTHORIZATION, format!("Bearer {token}"))
|
||||||
|
|||||||
Reference in New Issue
Block a user