@@ -156,19 +156,22 @@ impl Default for TestHarness {
156156 authenticator_kind: AuthenticatorKind :: None ,
157157 allowed_roles: AllowedRoles :: Normal ,
158158 enable_tls: false ,
159+ behind_trusted_proxy: false ,
159160 } ,
160161 "internal" . to_owned( ) => SqlListenerConfig {
161162 addr: SocketAddr :: new( IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) , 0 ) ,
162163 authenticator_kind: AuthenticatorKind :: None ,
163164 allowed_roles: AllowedRoles :: NormalAndInternal ,
164165 enable_tls: false ,
166+ behind_trusted_proxy: false ,
165167 } ,
166168 ] ,
167169 http : btreemap ! [
168170 "external" . to_owned( ) => HttpListenerConfig {
169171 addr: SocketAddr :: new( IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) , 0 ) ,
170172 authenticator_kind: AuthenticatorKind :: None ,
171173 enable_tls: false ,
174+ behind_trusted_proxy: false ,
172175 routes: HttpRoutesEnabled {
173176 base: RouteGroup :: Enabled ( AllowedRoles :: Normal ) ,
174177 webhook: RouteGroup :: Enabled ( AllowedRoles :: Normal ) ,
@@ -184,6 +187,7 @@ impl Default for TestHarness {
184187 addr: SocketAddr :: new( IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) , 0 ) ,
185188 authenticator_kind: AuthenticatorKind :: None ,
186189 enable_tls: false ,
190+ behind_trusted_proxy: false ,
187191 routes: HttpRoutesEnabled {
188192 base: RouteGroup :: Enabled ( AllowedRoles :: NormalAndInternal ) ,
189193 webhook: RouteGroup :: Enabled ( AllowedRoles :: NormalAndInternal ) ,
@@ -311,6 +315,18 @@ impl TestHarness {
311315 self
312316 }
313317
318+ /// Models listeners that a trusted proxy (`balancerd`) fronts, so that
319+ /// forwarded connection metadata is honored.
320+ pub fn behind_trusted_proxy ( mut self ) -> Self {
321+ for ( _, listener) in & mut self . listeners_config . sql {
322+ listener. behind_trusted_proxy = true ;
323+ }
324+ for ( _, listener) in & mut self . listeners_config . http {
325+ listener. behind_trusted_proxy = true ;
326+ }
327+ self
328+ }
329+
314330 pub fn unsafe_mode ( mut self ) -> Self {
315331 self . unsafe_mode = true ;
316332 self
@@ -339,19 +355,22 @@ impl TestHarness {
339355 authenticator_kind: AuthenticatorKind :: Frontegg ,
340356 allowed_roles: AllowedRoles :: Normal ,
341357 enable_tls,
358+ behind_trusted_proxy: false ,
342359 } ,
343360 "internal" . to_owned( ) => SqlListenerConfig {
344361 addr: SocketAddr :: new( IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) , 0 ) ,
345362 authenticator_kind: AuthenticatorKind :: None ,
346363 allowed_roles: AllowedRoles :: NormalAndInternal ,
347364 enable_tls: false ,
365+ behind_trusted_proxy: false ,
348366 } ,
349367 } ,
350368 http : btreemap ! {
351369 "external" . to_owned( ) => HttpListenerConfig {
352370 addr: SocketAddr :: new( IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) , 0 ) ,
353371 authenticator_kind: AuthenticatorKind :: Frontegg ,
354372 enable_tls,
373+ behind_trusted_proxy: false ,
355374 routes: HttpRoutesEnabled {
356375 base: RouteGroup :: Enabled ( AllowedRoles :: Normal ) ,
357376 webhook: RouteGroup :: Enabled ( AllowedRoles :: Normal ) ,
@@ -367,6 +386,7 @@ impl TestHarness {
367386 addr: SocketAddr :: new( IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) , 0 ) ,
368387 authenticator_kind: AuthenticatorKind :: None ,
369388 enable_tls: false ,
389+ behind_trusted_proxy: false ,
370390 routes: HttpRoutesEnabled {
371391 base: RouteGroup :: Enabled ( AllowedRoles :: NormalAndInternal ) ,
372392 webhook: RouteGroup :: Enabled ( AllowedRoles :: NormalAndInternal ) ,
@@ -398,19 +418,22 @@ impl TestHarness {
398418 authenticator_kind: AuthenticatorKind :: Oidc ,
399419 allowed_roles: AllowedRoles :: NormalAndInternal ,
400420 enable_tls,
421+ behind_trusted_proxy: false ,
401422 } ,
402423 "internal" . to_owned( ) => SqlListenerConfig {
403424 addr: SocketAddr :: new( IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) , 0 ) ,
404425 authenticator_kind: AuthenticatorKind :: None ,
405426 allowed_roles: AllowedRoles :: NormalAndInternal ,
406427 enable_tls: false ,
428+ behind_trusted_proxy: false ,
407429 } ,
408430 } ,
409431 http : btreemap ! {
410432 "external" . to_owned( ) => HttpListenerConfig {
411433 addr: SocketAddr :: new( IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) , 0 ) ,
412434 authenticator_kind: AuthenticatorKind :: Oidc ,
413435 enable_tls,
436+ behind_trusted_proxy: false ,
414437 routes: HttpRoutesEnabled {
415438 base: RouteGroup :: Enabled ( AllowedRoles :: NormalAndInternal ) ,
416439 webhook: RouteGroup :: Enabled ( AllowedRoles :: NormalAndInternal ) ,
@@ -426,6 +449,7 @@ impl TestHarness {
426449 addr: SocketAddr :: new( IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) , 0 ) ,
427450 authenticator_kind: AuthenticatorKind :: None ,
428451 enable_tls: false ,
452+ behind_trusted_proxy: false ,
429453 routes: HttpRoutesEnabled {
430454 base: RouteGroup :: Enabled ( AllowedRoles :: NormalAndInternal ) ,
431455 webhook: RouteGroup :: Enabled ( AllowedRoles :: NormalAndInternal ) ,
@@ -478,13 +502,15 @@ impl TestHarness {
478502 authenticator_kind: AuthenticatorKind :: Password ,
479503 allowed_roles: AllowedRoles :: NormalAndInternal ,
480504 enable_tls,
505+ behind_trusted_proxy: false ,
481506 } ,
482507 } ,
483508 http : btreemap ! {
484509 "external" . to_owned( ) => HttpListenerConfig {
485510 addr: SocketAddr :: new( IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) , 0 ) ,
486511 authenticator_kind: AuthenticatorKind :: Password ,
487512 enable_tls,
513+ behind_trusted_proxy: false ,
488514 routes: HttpRoutesEnabled {
489515 base: RouteGroup :: Enabled ( AllowedRoles :: NormalAndInternal ) ,
490516 webhook: RouteGroup :: Enabled ( AllowedRoles :: NormalAndInternal ) ,
@@ -500,6 +526,7 @@ impl TestHarness {
500526 addr: SocketAddr :: new( IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) , 0 ) ,
501527 authenticator_kind: AuthenticatorKind :: None ,
502528 enable_tls: false ,
529+ behind_trusted_proxy: false ,
503530 routes: HttpRoutesEnabled {
504531 base: RouteGroup :: Disabled ,
505532 webhook: RouteGroup :: Disabled ,
@@ -526,13 +553,15 @@ impl TestHarness {
526553 authenticator_kind: AuthenticatorKind :: Sasl ,
527554 allowed_roles: AllowedRoles :: NormalAndInternal ,
528555 enable_tls,
556+ behind_trusted_proxy: false ,
529557 } ,
530558 } ,
531559 http : btreemap ! {
532560 "external" . to_owned( ) => HttpListenerConfig {
533561 addr: SocketAddr :: new( IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) , 0 ) ,
534562 authenticator_kind: AuthenticatorKind :: Password ,
535563 enable_tls,
564+ behind_trusted_proxy: false ,
536565 routes: HttpRoutesEnabled {
537566 base: RouteGroup :: Enabled ( AllowedRoles :: NormalAndInternal ) ,
538567 webhook: RouteGroup :: Enabled ( AllowedRoles :: NormalAndInternal ) ,
@@ -548,6 +577,7 @@ impl TestHarness {
548577 addr: SocketAddr :: new( IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) , 0 ) ,
549578 authenticator_kind: AuthenticatorKind :: None ,
550579 enable_tls: false ,
580+ behind_trusted_proxy: false ,
551581 routes: HttpRoutesEnabled {
552582 base: RouteGroup :: Disabled ,
553583 webhook: RouteGroup :: Disabled ,
0 commit comments