@@ -41,78 +41,134 @@ TEST_CASE("Test SSLSNIConfig")
4141
4242 SECTION (" The config does not match any SNIs for someport.com:577" )
4343 {
44- auto const &actions{params.get ({ " someport.com" , std::strlen ( " someport.com " )} , 577 )};
44+ auto const &actions{params.get (" someport.com" , 577 )};
4545 CHECK (!actions.first );
4646 }
4747
4848 SECTION (" The config does not match any SNIs for someport.com:808" )
4949 {
50- auto const &actions{params.get ({ " someport.com" , std::strlen ( " someport.com " )} , 808 )};
50+ auto const &actions{params.get (" someport.com" , 808 )};
5151 CHECK (!actions.first );
5252 }
5353
5454 SECTION (" The config does not match any SNIs for oneport.com:1" )
5555 {
56- auto const &actions{params.get ({ " oneport.com" , std::strlen ( " oneport.com " )} , 1 )};
56+ auto const &actions{params.get (" oneport.com" , 1 )};
5757 CHECK (!actions.first );
5858 }
5959
6060 SECTION (" The config does match an SNI for oneport.com:433" )
6161 {
62- auto const &actions{params.get ({ " oneport.com" , std::strlen ( " oneport.com " )} , 433 )};
62+ auto const &actions{params.get (" oneport.com" , 433 )};
6363 REQUIRE (actions.first );
6464 REQUIRE (actions.first ->size () == 2 );
6565 }
6666
6767 SECTION (" The config matches an SNI for allports.com" )
6868 {
69- auto const &actions{params.get ({ " allports.com" , std::strlen ( " allports.com " )} , 1 )};
69+ auto const &actions{params.get (" allports.com" , 1 )};
7070 REQUIRE (actions.first );
7171 REQUIRE (actions.first ->size () == 2 );
7272 }
7373
7474 SECTION (" The config matches an SNI for someport.com:1" )
7575 {
76- auto const &actions{params.get ({ " someport.com" , std::strlen ( " someport.com " )} , 1 )};
76+ auto const &actions{params.get (" someport.com" , 1 )};
7777 REQUIRE (actions.first );
7878 REQUIRE (actions.first ->size () == 3 );
7979 }
8080
8181 SECTION (" The config matches an SNI for someport.com:433" )
8282 {
83- auto const &actions{params.get ({ " someport.com" , std::strlen ( " someport.com " )} , 433 )};
83+ auto const &actions{params.get (" someport.com" , 433 )};
8484 REQUIRE (actions.first );
8585 REQUIRE (actions.first ->size () == 3 );
8686 }
8787
8888 SECTION (" The config matches an SNI for someport:8080" )
8989 {
90- auto const &actions{params.get ({ " someport.com" , std::strlen ( " someport.com " )} , 8080 )};
90+ auto const &actions{params.get (" someport.com" , 8080 )};
9191 REQUIRE (actions.first );
9292 REQUIRE (actions.first ->size () == 2 );
9393 }
9494
9595 SECTION (" The config matches an SNI for someport:65535" )
9696 {
97- auto const &actions{params.get ({ " someport.com" , std::strlen ( " someport.com " )} , 65535 )};
97+ auto const &actions{params.get (" someport.com" , 65535 )};
9898 REQUIRE (actions.first );
9999 REQUIRE (actions.first ->size () == 2 );
100100 }
101101
102102 SECTION (" The config matches an SNI for someport:482" )
103103 {
104- auto const &actions{params.get ({ " someport.com" , std::strlen ( " someport.com " )} , 482 )};
104+ auto const &actions{params.get (" someport.com" , 482 )};
105105 REQUIRE (actions.first );
106106 REQUIRE (actions.first ->size () == 3 );
107107 }
108108
109109 SECTION (" Matching order" )
110110 {
111- std::string_view target = " foo.bar.com" ;
112- auto const &actions{params.get (target, 443 )};
111+ auto const &actions{params.get (" foo.bar.com" , 443 )};
113112 REQUIRE (actions.first );
114113 REQUIRE (actions.first ->size () == 5 ); // /< three H2 config + early data + fqdn
115114 }
115+
116+ SECTION (" Test mixed-case" )
117+ {
118+ auto const &actions{params.get (" SoMePoRt.CoM" , 65535 )};
119+ REQUIRE (actions.first );
120+ REQUIRE (actions.first ->size () == 2 );
121+ }
122+
123+ SECTION (" Test mixed-case with wildcard in yaml config" )
124+ {
125+ auto const &actions{params.get (" AnYtHiNg.BaR.CoM" , 443 )};
126+ REQUIRE (actions.first );
127+ REQUIRE (actions.first ->size () == 4 );
128+ // verify the capture group
129+ REQUIRE (actions.second ._fqdn_wildcard_captured_groups ->at (0 ) == " AnYtHiNg" );
130+ }
131+
132+ SECTION (" Test mixed-case in yaml config" )
133+ {
134+ auto const &actions{params.get (" mixedcase.foo.com" , 31337 )};
135+ REQUIRE (actions.first );
136+ REQUIRE (actions.first ->size () == 4 );
137+ }
138+
139+ SECTION (" Test mixed-case glob in yaml config" )
140+ {
141+ auto const &actions{params.get (" FoO.mixedcase.com" , 443 )};
142+ REQUIRE (actions.first );
143+ REQUIRE (actions.first ->size () == 3 );
144+ // verify the capture group
145+ REQUIRE (actions.second ._fqdn_wildcard_captured_groups ->at (0 ) == " FoO" );
146+ }
147+
148+ SECTION (" Test empty SNI does not match" )
149+ {
150+ auto const &actions{params.get (" " , 443 )};
151+ CHECK (!actions.first );
152+ }
153+
154+ SECTION (" Test SNI with special characters does not match" )
155+ {
156+ auto const &actions{params.get (" some$port.com" , 443 )};
157+ CHECK (!actions.first );
158+ }
159+
160+ SECTION (" Test with invalid glob in the middle in yaml config (e.g. cat.*.com) does not match" )
161+ {
162+ auto const &actions{params.get (" cat.dog.com" , 443 )};
163+ REQUIRE (!actions.first );
164+ }
165+
166+ SECTION (" Test with invalid glob in the middle in yaml config (e.g. cat.*.com) does an exact match" )
167+ {
168+ auto const &actions{params.get (" cat.*.com" , 443 )};
169+ REQUIRE (actions.first );
170+ REQUIRE (actions.first ->size () == 2 );
171+ }
116172}
117173
118174TEST_CASE (" SNIConfig reconfigure callback is invoked" )
0 commit comments