@@ -202,7 +202,7 @@ impl RuntimeConfig {
202
202
. into_iter ( )
203
203
. map ( |host| ( host, parsed. clone ( ) ) )
204
204
. collect :: < HashMap < Authority , ParsedClientTlsOpts > > ( ) ;
205
- components_map. insert ( component_id. to_owned ( ) , hostmap) ;
205
+ components_map. insert ( component_id. to_string ( ) . to_owned ( ) , hostmap) ;
206
206
}
207
207
}
208
208
}
@@ -532,10 +532,14 @@ mod tests {
532
532
Ok ( ( ) )
533
533
}
534
534
535
+ fn to_component_id ( inp : & str ) -> spin_serde:: KebabId {
536
+ spin_serde:: KebabId :: try_from ( inp. to_string ( ) ) . expect ( "parse component id into kebab id" )
537
+ }
538
+
535
539
#[ test]
536
540
fn test_parsing_valid_hosts_in_client_tls_opts ( ) {
537
541
let input = ClientTlsOpts {
538
- component_ids : vec ! [ "component-id-foo" . to_string ( ) ] ,
542
+ component_ids : vec ! [ to_component_id ( "component-id-foo" ) ] ,
539
543
hosts : vec ! [ "fermyon.com" . to_string( ) , "fermyon.com:5443" . to_string( ) ] ,
540
544
ca_roots_file : None ,
541
545
cert_chain_file : None ,
@@ -551,7 +555,7 @@ mod tests {
551
555
#[ test]
552
556
fn test_parsing_empty_hosts_in_client_tls_opts ( ) {
553
557
let input = ClientTlsOpts {
554
- component_ids : vec ! [ "component-id-foo" . to_string ( ) ] ,
558
+ component_ids : vec ! [ to_component_id ( "component-id-foo" ) ] ,
555
559
hosts : vec ! [ "" . to_string( ) , "fermyon.com:5443" . to_string( ) ] ,
556
560
ca_roots_file : None ,
557
561
cert_chain_file : None ,
@@ -570,7 +574,7 @@ mod tests {
570
574
#[ test]
571
575
fn test_parsing_invalid_hosts_in_client_tls_opts ( ) {
572
576
let input = ClientTlsOpts {
573
- component_ids : vec ! [ "component-id-foo" . to_string ( ) ] ,
577
+ component_ids : vec ! [ to_component_id ( "component-id-foo" ) ] ,
574
578
hosts : vec ! [ "perc%ent:443" . to_string( ) , "fermyon.com:5443" . to_string( ) ] ,
575
579
ca_roots_file : None ,
576
580
cert_chain_file : None ,
@@ -628,10 +632,12 @@ ca_roots_file = "{}"
628
632
let client_tls_opts_ok = client_tls_opts. as_ref ( ) . unwrap ( ) ;
629
633
630
634
// assert for component-no1
631
- assert ! ( client_tls_opts_ok. get( "component-no1" ) . is_some( ) ) ;
635
+ assert ! ( client_tls_opts_ok
636
+ . get( & "component-no1" . to_string( ) )
637
+ . is_some( ) ) ;
632
638
633
639
let component_no1_client_tls_opts = client_tls_opts_ok
634
- . get ( "component-no1" )
640
+ . get ( & "component-no1" . to_string ( ) )
635
641
. expect ( "get opts for component-no1" ) ;
636
642
assert ! ( component_no1_client_tls_opts
637
643
. get( & "localhost:6551" . parse:: <Authority >( ) . unwrap( ) )
@@ -643,10 +649,12 @@ ca_roots_file = "{}"
643
649
assert ! ( component_no1_host_client_tls_opts. custom_root_ca. is_none( ) ) ;
644
650
645
651
// assert for component-no2
646
- assert ! ( client_tls_opts_ok. get( "component-no2" ) . is_some( ) ) ;
652
+ assert ! ( client_tls_opts_ok
653
+ . get( & "component-no2" . to_string( ) )
654
+ . is_some( ) ) ;
647
655
648
656
let component_no2_client_tls_opts = client_tls_opts_ok
649
- . get ( "component-no2" )
657
+ . get ( & "component-no2" . to_string ( ) )
650
658
. expect ( "get opts for component-no2" ) ;
651
659
assert ! ( component_no2_client_tls_opts
652
660
. get( & "localhost:6551" . parse:: <Authority >( ) . unwrap( ) )
@@ -700,10 +708,12 @@ ca_roots_file = "{}"
700
708
let client_tls_opts_ok = client_tls_opts. as_ref ( ) . unwrap ( ) ;
701
709
702
710
// assert for component-no1
703
- assert ! ( client_tls_opts_ok. get( "component-no1" ) . is_some( ) ) ;
711
+ assert ! ( client_tls_opts_ok
712
+ . get( & "component-no1" . to_string( ) )
713
+ . is_some( ) ) ;
704
714
705
715
let component_no1_client_tls_opts = client_tls_opts_ok
706
- . get ( "component-no1" )
716
+ . get ( & "component-no1" . to_string ( ) )
707
717
. expect ( "get opts for component-no1" ) ;
708
718
assert ! ( component_no1_client_tls_opts
709
719
. get( & "localhost:6551" . parse:: <Authority >( ) . unwrap( ) )
@@ -783,9 +793,16 @@ fn parse_client_tls_opts(inp: &ClientTlsOpts) -> Result<ParsedClientTlsOpts, any
783
793
inp. ca_webpki_roots
784
794
. unwrap_or ( if custom_root_ca_provided { false } else { true } ) ;
785
795
796
+ let parsed_component_ids: Vec < String > = inp
797
+ . component_ids
798
+ . clone ( )
799
+ . into_iter ( )
800
+ . map ( |s| s. to_string ( ) )
801
+ . collect ( ) ;
802
+
786
803
Ok ( ParsedClientTlsOpts {
787
804
hosts : parsed_hosts,
788
- components : inp . component_ids . clone ( ) ,
805
+ components : parsed_component_ids ,
789
806
custom_root_ca,
790
807
cert_chain,
791
808
private_key,
0 commit comments