@@ -68,10 +68,17 @@ pub fn network_access_preset_to_str(value: i32) -> Option<&'static str> {
6868 }
6969}
7070
71+ fn unknown_tls_value ( tls : & str ) -> Option < String > {
72+ ( !matches ! ( tls, "" | "skip" ) ) . then ( || {
73+ format ! ( "unknown tls value '{tls}'; omit the field to keep automatic TLS termination" )
74+ } )
75+ }
76+
7177pub fn validate_endpoint_mode_values ( tls : i32 , enforcement : i32 , access : i32 ) -> Vec < String > {
7278 let mut errors = Vec :: new ( ) ;
73- if network_tls_mode_to_str ( tls) . is_none ( ) {
74- errors. push ( format ! ( "unknown tls enum value {tls}" ) ) ;
79+ match network_tls_mode_to_str ( tls) {
80+ Some ( value) => errors. extend ( unknown_tls_value ( value) ) ,
81+ None => errors. push ( format ! ( "unknown tls enum value {tls}" ) ) ,
7582 }
7683 if network_enforcement_mode_to_str ( enforcement) . is_none ( ) {
7784 errors. push ( format ! ( "unknown enforcement enum value {enforcement}" ) ) ;
@@ -174,7 +181,7 @@ mod agent_transport_tests {
174181 #[ test]
175182 fn agent_cannot_request_native_tcp_or_skip_tls_inspection ( ) {
176183 assert ! ( agent_authored_transport_rejection( "tcp" , "" ) . is_some( ) ) ;
177- assert ! ( agent_authored_transport_rejection( "TCP" , "terminate " ) . is_some( ) ) ;
184+ assert ! ( agent_authored_transport_rejection( "TCP" , "" ) . is_some( ) ) ;
178185 assert ! ( agent_authored_transport_rejection( "" , "skip" ) . is_some( ) ) ;
179186 assert ! ( agent_authored_transport_rejection( "rest" , "SKIP" ) . is_some( ) ) ;
180187 }
@@ -185,11 +192,7 @@ mod agent_transport_tests {
185192pub fn validate_endpoint_modes ( tls : & str , enforcement : & str , access : & str ) -> Vec < String > {
186193 let mut errors = Vec :: new ( ) ;
187194
188- if !matches ! ( tls, "" | "skip" | "terminate" | "passthrough" ) {
189- errors. push ( format ! (
190- "unknown tls value '{tls}' (expected skip, terminate, or passthrough)"
191- ) ) ;
192- }
195+ errors. extend ( unknown_tls_value ( tls) ) ;
193196 if !matches ! ( enforcement, "" | "enforce" | "audit" ) {
194197 errors. push ( format ! (
195198 "unknown enforcement value '{enforcement}' (expected enforce or audit)"
@@ -357,9 +360,18 @@ mod tests {
357360 assert ! ( errors[ 2 ] . contains( "unknown access value 'read-wirte'" ) ) ;
358361 }
359362
363+ #[ test]
364+ fn endpoint_mode_values_reject_removed_tls_enums ( ) {
365+ for legacy in [ 2 , 3 ] {
366+ let errors = validate_endpoint_mode_values ( legacy, 0 , 0 ) ;
367+ assert_eq ! ( errors. len( ) , 1 , "tls: {legacy}" ) ;
368+ assert ! ( errors[ 0 ] . contains( "unknown tls value" ) ) ;
369+ }
370+ }
371+
360372 #[ test]
361373 fn endpoint_modes_accept_documented_values_and_defaults ( ) {
362- for tls in [ "" , "skip" , "terminate" , "passthrough" ] {
374+ for tls in [ "" , "skip" ] {
363375 for enforcement in [ "" , "enforce" , "audit" ] {
364376 for access in [ "" , "read-only" , "read-write" , "full" ] {
365377 assert ! ( validate_endpoint_modes( tls, enforcement, access) . is_empty( ) ) ;
0 commit comments