Skip to content

Commit 01afb9a

Browse files
committed
Apply rustfmt formatting
1 parent e69ec52 commit 01afb9a

7 files changed

Lines changed: 25 additions & 34 deletions

File tree

sidecar/src/bridge.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,7 @@ impl GatewayConnector {
9797
}
9898

9999
/// Send a CONNECT request to the gateway. On connection error, reconnect once and retry.
100-
pub async fn send_connect(
101-
&self,
102-
authority: &str,
103-
) -> anyhow::Result<Response<Incoming>> {
100+
pub async fn send_connect(&self, authority: &str) -> anyhow::Result<Response<Incoming>> {
104101
let req = build_connect_request(authority)?;
105102
let mut sender = self.get_sender().await?;
106103

src/config.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ impl Config {
5757
.parse::<std::net::SocketAddr>()
5858
.map_err(|e| anyhow::anyhow!("invalid server.listen_addr: {e}"))?;
5959

60-
let _oid =
61-
x509_parser::oid_registry::Oid::from_str(&self.policy.client_ext_oid)
62-
.map_err(|e| anyhow::anyhow!("invalid policy.client_ext_oid: {e:?}"))?;
60+
let _oid = x509_parser::oid_registry::Oid::from_str(&self.policy.client_ext_oid)
61+
.map_err(|e| anyhow::anyhow!("invalid policy.client_ext_oid: {e:?}"))?;
6362

6463
for (i, rule) in self.policy.rules.iter().enumerate() {
6564
anyhow::ensure!(
@@ -72,9 +71,7 @@ impl Config {
7271
);
7372
for (j, dest) in rule.allowed_destinations.iter().enumerate() {
7473
policy::normalize_destination(dest).map_err(|e| {
75-
anyhow::anyhow!(
76-
"policy.rules[{i}].allowed_destinations[{j}]: {e}"
77-
)
74+
anyhow::anyhow!("policy.rules[{i}].allowed_destinations[{j}]: {e}")
7875
})?;
7976
}
8077
}

src/policy.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ impl TomlPolicyEngine {
5656
rules,
5757
})
5858
}
59-
6059
}
6160

6261
/// Parse a destination string into canonical lowercase `host:port` (or
@@ -94,8 +93,11 @@ pub fn normalize_destination(dest: &str) -> anyhow::Result<String> {
9493
(host_inner.to_owned(), port)
9594
} else if dest.matches(':').count() > 1 {
9695
// Multiple colons without brackets: treat as bare IPv6, validate.
97-
dest.parse::<std::net::Ipv6Addr>()
98-
.map_err(|_| anyhow::anyhow!("ambiguous multi-colon destination {dest:?}; use [ipv6]:port for IPv6 with port"))?;
96+
dest.parse::<std::net::Ipv6Addr>().map_err(|_| {
97+
anyhow::anyhow!(
98+
"ambiguous multi-colon destination {dest:?}; use [ipv6]:port for IPv6 with port"
99+
)
100+
})?;
99101
(dest.to_owned(), 443)
100102
} else if let Some((host, port_str)) = dest.rsplit_once(':') {
101103
match port_str.parse::<u16>() {

src/tls.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ pub fn build_server_config(config: &AppServerConfig) -> anyhow::Result<Arc<Serve
2626
"unparseable certificates in {}",
2727
config.client_ca_path.display()
2828
);
29-
ensure!(added > 0, "no trust anchors in {}", config.client_ca_path.display());
29+
ensure!(
30+
added > 0,
31+
"no trust anchors in {}",
32+
config.client_ca_path.display()
33+
);
3034

3135
let client_verifier = WebPkiClientVerifier::builder(Arc::new(client_ca_store))
3236
.build()

tests/common/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ pub fn generate_ca() -> Result<CertifiedIssuer<'static, KeyPair>, rcgen::Error>
4040
pub fn generate_server_cert(
4141
issuer: &CertifiedIssuer<'_, impl rcgen::SigningKey>,
4242
) -> Result<(rcgen::Certificate, KeyPair), rcgen::Error> {
43-
let mut params =
44-
CertificateParams::new(vec!["localhost".to_owned(), "127.0.0.1".to_owned()])?;
43+
let mut params = CertificateParams::new(vec!["localhost".to_owned(), "127.0.0.1".to_owned()])?;
4544
params.distinguished_name = DistinguishedName::new();
4645
params
4746
.distinguished_name
@@ -361,8 +360,7 @@ pub async fn start_proxy(pki: &TestPki, policy_config: PolicyConfig) -> (SocketA
361360
return;
362361
}
363362
};
364-
let peer_certs =
365-
agent_gateway::proxy::extract_peer_certs(tls_stream.get_ref().1);
363+
let peer_certs = agent_gateway::proxy::extract_peer_certs(tls_stream.get_ref().1);
366364
let service = svc.make_service(peer_certs);
367365
let io = hyper_util::rt::TokioIo::new(tls_stream);
368366
let _ = hyper_util::server::conn::auto::Builder::new(
@@ -425,8 +423,7 @@ pub async fn try_request_with_tls_config(
425423

426424
let io = hyper_util::rt::TokioIo::new(tls_stream);
427425
let (mut send_request, connection) =
428-
hyper::client::conn::http2::handshake(hyper_util::rt::TokioExecutor::new(), io)
429-
.await?;
426+
hyper::client::conn::http2::handshake(hyper_util::rt::TokioExecutor::new(), io).await?;
430427

431428
tokio::spawn(async move {
432429
let _ = connection.await;

tests/e2e.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ async fn tunnel_policy_deny() {
113113
);
114114

115115
let events = wait_for_event(&log, "CONNECT denied", EVENT_TIMEOUT).await;
116-
let denied_evt =
117-
find_event(&events, "CONNECT denied").expect("expected CONNECT denied event");
116+
let denied_evt = find_event(&events, "CONNECT denied").expect("expected CONNECT denied event");
118117
assert!(
119118
denied_evt.fields.get("reason").is_some(),
120119
"CONNECT denied event should have reason field"

tests/integration.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ use rustls::server::WebPkiClientVerifier;
77
use rustls::{ClientConfig, RootCertStore, ServerConfig};
88

99
use agent_gateway::config::{PolicyConfig, PolicyRule};
10-
use agent_gateway::policy::{
11-
self, PolicyDecision, PolicyEngine, RequestContext, TomlPolicyEngine,
12-
};
10+
use agent_gateway::policy::{self, PolicyDecision, PolicyEngine, RequestContext, TomlPolicyEngine};
1311
use agent_gateway::proxy::Destination;
1412

1513
fn test_policy_config() -> PolicyConfig {
@@ -103,18 +101,12 @@ fn normalize_bracketed_ipv6_with_port() {
103101

104102
#[test]
105103
fn normalize_bracketed_ipv6_without_port_defaults_to_443() {
106-
assert_eq!(
107-
policy::normalize_destination("[::1]").unwrap(),
108-
"[::1]:443"
109-
);
104+
assert_eq!(policy::normalize_destination("[::1]").unwrap(), "[::1]:443");
110105
}
111106

112107
#[test]
113108
fn normalize_bare_ipv6_defaults_to_443() {
114-
assert_eq!(
115-
policy::normalize_destination("::1").unwrap(),
116-
"[::1]:443"
117-
);
109+
assert_eq!(policy::normalize_destination("::1").unwrap(), "[::1]:443");
118110
assert_eq!(
119111
policy::normalize_destination("2001:db8::1").unwrap(),
120112
"[2001:db8::1]:443"
@@ -390,7 +382,10 @@ allowed_destinations = ["api.example.com"]
390382
let path = tmpdir.join("reject_metrics_bind.toml");
391383
std::fs::write(&path, toml).unwrap();
392384
let result = agent_gateway::config::Config::load(&path);
393-
assert!(result.is_err(), "metrics_bind should be rejected as an unknown field");
385+
assert!(
386+
result.is_err(),
387+
"metrics_bind should be rejected as an unknown field"
388+
);
394389
}
395390

396391
// ---- Proxy Destination parsing ----

0 commit comments

Comments
 (0)