Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
4501220
test: restore blocking mode on streams accepted by std fixtures
prk-Jr Nov 20, 2026
6ac23fb
test: run source-bound proxy hosting tests only on Linux by default
prk-Jr Nov 20, 2026
ce8421a
test: make the Secrets Manager attempt-timeout proof deterministic
prk-Jr Nov 20, 2026
09b09d9
test: keep hosting port reservations from leaking into fixture processes
prk-Jr Nov 20, 2026
d86a5d3
test: close remaining gaps in the macOS hosting and timeout fixtures
prk-Jr Nov 20, 2026
e8cf40e
test: run the trusted-proxy hosting tests on every platform
aram356 Nov 23, 2026
f03a7b0
Merge PR #510 into PR #519 for outbound compatibility stack
aram356 Nov 25, 2026
fc5aab9
Merge PR #510 into PR #519 for outbound compatibility stack
aram356 Nov 25, 2026
4960680
Merge PR #510 into PR #519 for outbound compatibility stack
aram356 Nov 26, 2026
cdea926
Merge PR #510 into PR #519 for outbound compatibility stack
aram356 Nov 26, 2026
689e372
Merge PR #510 into PR #519 for the identity integration chain
aram356 Dec 1, 2026
352d7d1
Merge PR #510 into PR #519 for the identity integration chain
aram356 Dec 1, 2026
58a238f
Share native test fixtures and strengthen timeout evidence
prk-Jr Dec 2, 2026
f75296d
Refresh offline dependency closure and isolate cancellation fixtures
prk-Jr Dec 3, 2026
cb44398
Merge PR #510 into PR #519 for the identity integration chain
aram356 Dec 3, 2026
d1d5640
Merge local PR #510 fixes into PR #519
aram356 Dec 4, 2026
6ab171a
Merge PR #510 into PR #519 for the identity integration chain
aram356 Dec 4, 2026
1cedc2e
Merge PR #510 into PR #519 for the identity integration chain
aram356 Dec 4, 2026
9fc6818
Merge PR #510 into PR #519 for the identity integration chain
aram356 Dec 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 55 additions & 35 deletions crates/edgezero-adapter-axum/tests/fixtures/native_proxy.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
//! Test-only source-bound proxy and verified TLS ingress. No response is collected here.
//! Test-only loopback proxy and verified TLS ingress. No response is collected here.
//!
//! Every proxy socket is on 127.0.0.1, the IPv4 loopback address every platform has, so the
//! server's direct peer is always a real 127.0.0.1 socket. An appending proxy writes the
//! predecessor it is given rather than its own socket peer: the server only sees that hop as
//! header text, and a real 127.0.0.1 predecessor would collide with the trusted peer.
#![expect(
clippy::arbitrary_source_item_ordering,
reason = "fixture ownership precedes bounded relay helpers"
Expand Down Expand Up @@ -27,18 +32,31 @@ use super::tests::reserve_or_spawn;
const MAX_HEAD: usize = 0x8000;
const RELAY_BUFFER: usize = 0x4000;

#[derive(Clone, Copy)]
pub(crate) struct Hop {
predecessor: IpAddr,
host: &'static str,
scheme: &'static str,
}

impl Hop {
#[must_use]
#[inline]
pub(crate) const fn new(predecessor: IpAddr, host: &'static str, scheme: &'static str) -> Self {
Self {
predecessor,
host,
scheme,
}
}
}

#[derive(Clone, Copy)]
pub(crate) enum Assertions {
/// Keep deliberate malformed/gap inputs unchanged while preserving a real owned peer.
Preserve,
AppendForwarded {
host: &'static str,
scheme: &'static str,
},
AppendXForwarded {
host: &'static str,
scheme: &'static str,
},
AppendForwarded(Hop),
AppendXForwarded(Hop),
ReplaceForwarded {
client: IpAddr,
host: &'static str,
Expand All @@ -61,12 +79,7 @@ impl LocalProxy {

#[must_use]
#[inline]
pub(crate) fn start(
upstream: SocketAddr,
source: Ipv4Addr,
assertions: Assertions,
tls: bool,
) -> Self {
pub(crate) fn start(upstream: SocketAddr, assertions: Assertions, tls: bool) -> Self {
let std_listener = {
let _reserving = reserve_or_spawn();
StdTcpListener::bind((Ipv4Addr::LOCALHOST, 0)).expect("proxy listener")
Expand All @@ -93,21 +106,21 @@ impl LocalProxy {
finished.map_err(io::Error::other)??;
},
accepted = listener.accept(), if tasks.len() < 64 => {
let (socket, peer) = accepted?;
let (socket, _peer) = accepted?;
let task_acceptor = tls_acceptor.clone();
tasks.spawn(async move {
let operation = async {
if let Some(acceptor) = task_acceptor {
match acceptor.accept(socket).await {
Ok(mut client) => relay(&mut client, peer, upstream, source, assertions).await,
Ok(mut client) => relay(&mut client, upstream, assertions).await,
// The wrong-name client sends this alert before any HTTP request.
// Its test checks the exact certificate verification error separately.
Err(error) if rejected_certificate(&error) => Ok(()),
Err(error) => Err(error),
}
} else {
let mut client = socket;
relay(&mut client, peer, upstream, source, assertions).await
relay(&mut client, upstream, assertions).await
}
};
timeout(Duration::from_secs(5), operation)
Expand Down Expand Up @@ -203,7 +216,14 @@ where
}
}

fn rewrite(head: &str, peer: SocketAddr, assertions: Assertions) -> io::Result<String> {
fn forwarded_node(address: IpAddr) -> String {
match address {
IpAddr::V4(ip) => ip.to_string(),
IpAddr::V6(ip) => format!("\"[{ip}]\""),
}
}

fn rewrite(head: &str, assertions: Assertions) -> io::Result<String> {
let mut lines = head.split("\r\n");
let request = lines
.next()
Expand All @@ -214,21 +234,22 @@ fn rewrite(head: &str, peer: SocketAddr, assertions: Assertions) -> io::Result<S
let (name, value) = line.split_once(':').ok_or_else(invalid)?;
headers.push((name.to_owned(), value.trim().to_owned()));
}
let predecessor = match peer.ip() {
IpAddr::V4(ip) => ip.to_string(),
IpAddr::V6(ip) => format!("\"[{ip}]\""),
};
match assertions {
Assertions::Preserve => {}
Assertions::AppendForwarded { host, scheme } => {
Assertions::AppendForwarded(Hop {
predecessor,
host,
scheme,
}) => {
let previous = headers
.iter()
.filter(|(name, _)| name.eq_ignore_ascii_case("forwarded"))
.map(|(_, value)| value.as_str())
.collect::<Vec<_>>()
.join(",");
headers.retain(|(name, _)| !name.eq_ignore_ascii_case("forwarded"));
let assertion = format!("for={predecessor};host=\"{host}\";proto={scheme}");
let node = forwarded_node(predecessor);
let assertion = format!("for={node};host=\"{host}\";proto={scheme}");
headers.push((
"Forwarded".into(),
if previous.is_empty() {
Expand All @@ -238,15 +259,19 @@ fn rewrite(head: &str, peer: SocketAddr, assertions: Assertions) -> io::Result<S
},
));
}
Assertions::AppendXForwarded { host, scheme } => {
Assertions::AppendXForwarded(Hop {
predecessor,
host,
scheme,
}) => {
let previous = headers
.iter()
.filter(|(name, _)| name.eq_ignore_ascii_case("x-forwarded-for"))
.map(|(_, value)| value.as_str())
.collect::<Vec<_>>()
.join(",");
headers.retain(|(name, _)| !name.to_ascii_lowercase().starts_with("x-forwarded-"));
let node = peer.ip().to_string();
let node = predecessor.to_string();
headers.push((
"X-Forwarded-For".into(),
if previous.is_empty() {
Expand All @@ -269,10 +294,7 @@ fn rewrite(head: &str, peer: SocketAddr, assertions: Assertions) -> io::Result<S
});
// The test gateway's client assertion is explicitly supplied by its trusted producer,
// never taken from the visitor's fields. This is not a provider-discovery mechanism.
let node = match client {
IpAddr::V4(ip) => ip.to_string(),
IpAddr::V6(ip) => format!("\"[{ip}]\""),
};
let node = forwarded_node(client);
headers.push((
"Forwarded".into(),
format!("for={node};host=\"{host}\";proto={scheme}"),
Expand All @@ -293,20 +315,18 @@ fn rewrite(head: &str, peer: SocketAddr, assertions: Assertions) -> io::Result<S

async fn relay<Client>(
client: &mut Client,
peer: SocketAddr,
upstream: SocketAddr,
source: Ipv4Addr,
assertions: Assertions,
) -> io::Result<()>
where
Client: AsyncRead + AsyncWrite + Unpin,
{
let (head, body_prefix) = read_head(client).await?;
let rewritten = rewrite(&head, peer, assertions)?;
let rewritten = rewrite(&head, assertions)?;
let socket = {
let _reserving = reserve_or_spawn();
let socket = TcpSocket::new_v4()?;
socket.bind(SocketAddr::new(IpAddr::V4(source), 0))?;
socket.bind(SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 0))?;
socket
};
let mut origin = socket.connect(upstream).await?;
Expand Down
6 changes: 1 addition & 5 deletions crates/edgezero-adapter-axum/tests/native_aws_startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@
//! They exercise the public runner and real pinned SDK, not a provider seam. No AWS account,
//! DNS hostname, external socket, image, or real cloud credential is used.

#[cfg(test)]
#[path = "fixtures/blocking_accept.rs"]
mod blocking_accept;

#[cfg(test)]
#[expect(
clippy::arbitrary_source_item_ordering,
reason = "loopback fixture helpers remain grouped before startup scenarios"
)]
mod tests {
use crate::blocking_accept::accept_blocking;
use edgezero_core::test_net::accept_blocking;
use std::fmt::Write as _;
use std::fs;
use std::io::{self, ErrorKind, Read, Write as _};
Expand Down
3 changes: 2 additions & 1 deletion crates/edgezero-adapter-axum/tests/native_celld_startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#[cfg(test)]
mod tests {
use edgezero_core::test_net::accept_blocking;
use std::fs;
use std::io::{ErrorKind, Read, Write as _};
use std::net::{SocketAddr, TcpListener, TcpStream};
Expand Down Expand Up @@ -72,7 +73,7 @@ mod tests {
let worker_stop = Arc::clone(&stop);
thread::spawn(move || {
while !worker_stop.load(Ordering::Relaxed) {
match listener.accept() {
match accept_blocking(&listener) {
Ok((mut stream, peer)) => {
assert!(peer.ip().is_loopback());
stream
Expand Down
Loading
Loading