@@ -495,6 +495,8 @@ async fn shutdown_signal(handle: Handle, state: Arc<McpAppState>) {
495495mod tests {
496496 use super :: * ;
497497
498+ use tempfile:: NamedTempFile ;
499+
498500 #[ test]
499501 fn test_server_options_base_url_custom ( ) {
500502 let options = HyperServerOptions {
@@ -584,7 +586,45 @@ mod tests {
584586 let options = HyperServerOptions :: default ( ) ;
585587 assert ! ( options. validate( ) . is_ok( ) ) ;
586588
587- // TODO: validate with ssl
589+ // with ssl enabled but no cert or key provided, validate should fail
590+ let options = HyperServerOptions {
591+ enable_ssl : true ,
592+ ..Default :: default ( )
593+ } ;
594+ assert ! ( options. validate( ) . is_err( ) ) ;
595+
596+ // with ssl enabled and invalid cert/key paths, validate should fail
597+ let options = HyperServerOptions {
598+ enable_ssl : true ,
599+ ssl_cert_path : Some ( String :: from ( "/invalid/path/to/cert.pem" ) ) ,
600+ ssl_key_path : Some ( String :: from ( "/invalid/path/to/key.pem" ) ) ,
601+ ..Default :: default ( )
602+ } ;
603+ assert ! ( options. validate( ) . is_err( ) ) ;
604+
605+ // with ssl enabled and valid cert/key paths, validate should succeed
606+ let cert_file =
607+ NamedTempFile :: with_suffix ( ".pem" ) . expect ( "Expected to create test cert file" ) ;
608+ let ssl_cert_path = cert_file
609+ . path ( )
610+ . to_str ( )
611+ . expect ( "Expected to get cert path" )
612+ . to_string ( ) ;
613+ let key_file =
614+ NamedTempFile :: with_suffix ( ".pem" ) . expect ( "Expected to create test key file" ) ;
615+ let ssl_key_path = key_file
616+ . path ( )
617+ . to_str ( )
618+ . expect ( "Expected to get key path" )
619+ . to_string ( ) ;
620+
621+ let options = HyperServerOptions {
622+ enable_ssl : true ,
623+ ssl_cert_path : Some ( ssl_cert_path) ,
624+ ssl_key_path : Some ( ssl_key_path) ,
625+ ..Default :: default ( )
626+ } ;
627+ assert ! ( options. validate( ) . is_ok( ) ) ;
588628 }
589629
590630 #[ tokio:: test]
0 commit comments