| 450 | |
| 451 | #[test] |
| 452 | fn test_sysusers_parse() -> Result<()> { |
| 453 | let mut entries = parse_all(SYSUSERS_REF); |
| 454 | assert_eq!( |
| 455 | entries.next().unwrap(), |
| 456 | SysusersEntry::User { |
| 457 | name: "root".into(), |
| 458 | uid: Some(0.into()), |
| 459 | pgid: Some(0.into()), |
| 460 | gecos: "Super User".into(), |
| 461 | home: Some("/root".into()), |
| 462 | shell: Some("/bin/bash".into()) |
| 463 | } |
| 464 | ); |
| 465 | assert_eq!( |
| 466 | entries.next().unwrap(), |
| 467 | SysusersEntry::User { |
| 468 | name: "root".into(), |
| 469 | uid: Some(0.into()), |
| 470 | pgid: Some(0.into()), |
| 471 | gecos: "Super User".into(), |
| 472 | home: Some("/root".into()), |
| 473 | shell: None |
| 474 | } |
| 475 | ); |
| 476 | assert_eq!( |
| 477 | entries.next().unwrap(), |
| 478 | SysusersEntry::User { |
| 479 | name: "bin".into(), |
| 480 | uid: Some(1.into()), |
| 481 | pgid: Some(1.into()), |
| 482 | gecos: "bin".into(), |
| 483 | home: Some("/bin".into()), |
| 484 | shell: None |
| 485 | } |
| 486 | ); |
| 487 | let _ = entries.next().unwrap(); |
| 488 | assert_eq!( |
| 489 | entries.next().unwrap(), |
| 490 | SysusersEntry::User { |
| 491 | name: "adm".into(), |
| 492 | uid: Some(3.into()), |
| 493 | pgid: Some(4.into()), |
| 494 | gecos: "adm".into(), |
| 495 | home: Some("/var/adm".into()), |
| 496 | shell: None |
| 497 | } |
| 498 | ); |
| 499 | assert_eq!(entries.count(), 10); |
| 500 | |
| 501 | let mut entries = parse_all(OTHER_SYSUSERS_REF); |
| 502 | assert_eq!( |
| 503 | entries.next().unwrap(), |
| 504 | SysusersEntry::User { |
| 505 | name: "qemu".into(), |
| 506 | uid: Some(107.into()), |
| 507 | pgid: Some(GroupReference::Name("qemu".into())), |
| 508 | gecos: "qemu user".into(), |
| 509 | home: None, |