@@ -798,10 +798,27 @@ mod tests {
798798 #[ test_case( "3.0.0" , "user_id >= 3.0.0" , true ) ]
799799 #[ test_case( "3.0.0-beta.stuff" , "user_id == 3.0.0-beta.stuff" , true ) ]
800800 #[ test_case( "3.0.0-beta.stuff+build1" , "user_id == 3.0.0-beta.stuff+build1" , true ) ]
801+ #[ test_case( "3.0.1" , "user_id >= 3.0.1" , true ) ]
802+ #[ test_case( "3.0.2" , "user_id >= 3.0.1" , true ) ]
801803 fn test_semver_gt ( user_id : & str , rule : & str , expected : bool ) {
802804 run_test ( user_id, rule, expected) ;
803805 }
804806
807+ #[ test_case( "30.0.0" , "user_id <= 30.0.0" , true ) ]
808+ #[ test_case( "3.0.0" , "user_id <= 3.0.0" , true ) ]
809+ #[ test_case( "3.0.0-beta" , "user_id <= 3.0.0-beta" , true ) ]
810+ #[ test_case( "3.0.0-beta.2" , "user_id <= 3.0.0-beta.1" , false ) ]
811+ #[ test_case( "3.0.0-beta" , "user_id <= 3.0.0-alpha" , false ) ]
812+ #[ test_case( "3.0.1-beta" , "user_id <= 3.0.1-alpha" , false ) ]
813+ #[ test_case( "3.0.0" , "user_id <= 3.0.0-alpha" , false ) ]
814+ #[ test_case( "3.0.0-beta.stuff" , "user_id <= 3.0.0-beta.stuff" , true ) ]
815+ #[ test_case( "3.0.0-beta.stuff+build1" , "user_id <= 3.0.0-beta.stuff+build1" , true ) ]
816+ #[ test_case( "3.0.1" , "user_id <= 3.0.1" , true ) ]
817+ #[ test_case( "3.0.2" , "user_id <= 3.0.1" , false ) ]
818+ fn test_semver_lt ( user_id : & str , rule : & str , expected : bool ) {
819+ run_test ( user_id, rule, expected) ;
820+ }
821+
805822 fn run_test ( user_id : & str , rule : & str , expected : bool ) {
806823 let rule = compile_rule ( rule) . expect ( "" ) ;
807824 let context = context_from_user_id ( user_id) ;
@@ -1209,7 +1226,7 @@ mod tests {
12091226 . map ( |x| format ! ( "\" {}\" " , x. trim( ) ) )
12101227 . collect :: < Vec < String > > ( ) ;
12111228
1212- let rule = format ! ( "remote_address contains_ip [{}]" , constraint_ips. join( "," ) ) ;
1229+ let rule = format ! ( "remote_address in_cidr [{}]" , constraint_ips. join( "," ) ) ;
12131230 println ! ( "Current rule {}" , rule) ;
12141231 let rule = compile_rule ( & rule) . unwrap ( ) ;
12151232
@@ -1223,7 +1240,7 @@ mod tests {
12231240
12241241 #[ test]
12251242 fn remote_address_constraint_never_matches_missing_context ( ) {
1226- let rule = compile_rule ( "remote_address contains_ip [\" 127.0.0.1\" ]" ) . unwrap ( ) ;
1243+ let rule = compile_rule ( "remote_address in_cidr [\" 127.0.0.1\" ]" ) . unwrap ( ) ;
12271244 let context = Context :: default ( ) ;
12281245
12291246 assert ! ( !rule( & context) ) ;
0 commit comments