MCPcopy Create free account
hub / github.com/PowerShell/DSC / multiple_match_blocks

Function multiple_match_blocks

resources/sshdconfig/src/parser.rs:561–581  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

559
560 #[test]
561 fn multiple_match_blocks() {
562 let input = r#"
563match user alice
564 passwordauthentication yes
565match group administrators
566 permitrootlogin yes
567"#;
568 let result: Map<String, Value> = parse_text_to_map(input).unwrap();
569 let match_array = result.get("match").unwrap().as_array().unwrap();
570 assert_eq!(match_array.len(), 2);
571 let match_obj1 = match_array[0].as_object().unwrap();
572 let criteria1 = match_obj1.get("criteria").unwrap().as_object().unwrap();
573 let user_array1 = criteria1.get("user").unwrap().as_array().unwrap();
574 assert_eq!(user_array1[0], Value::String("alice".to_string()));
575 assert_eq!(match_obj1.get("passwordauthentication").unwrap(), &Value::Bool(true));
576 let match_obj2 = match_array[1].as_object().unwrap();
577 let criteria2 = match_obj2.get("criteria").unwrap().as_object().unwrap();
578 let group_array2 = criteria2.get("group").unwrap().as_array().unwrap();
579 assert_eq!(group_array2[0], Value::String("administrators".to_string()));
580 assert_eq!(match_obj2.get("permitrootlogin").unwrap(), &Value::Bool(true));
581 }
582
583 #[test]
584 fn match_with_comma_separated_criteria() {

Callers

nothing calls this directly

Calls 2

parse_text_to_mapFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected