MCPcopy Create free account
hub / github.com/dfinity/orbit / assert_initial_users

Function assert_initial_users

tests/integration/src/install_tests.rs:694–762  ·  view source on GitHub ↗
(
    env: &PocketIc,
    canister_id: Principal,
    requester: Principal,
    expected_users: &Vec<InitUserInput>,
    default_groups: &Vec<UuidDTO>,
)

Source from the content-addressed store, hash-verified

692}
693
694fn assert_initial_users(
695 env: &PocketIc,
696 canister_id: Principal,
697 requester: Principal,
698 expected_users: &Vec<InitUserInput>,
699 default_groups: &Vec<UuidDTO>,
700) -> Result<(), String> {
701 let listed_users = list_users(env, canister_id, requester)
702 .expect("failed to get users")
703 .0
704 .expect("failed to get users");
705
706 if expected_users.len() != listed_users.users.len() {
707 return Err(format!(
708 "expected {} users, got {}",
709 expected_users.len(),
710 listed_users.users.len()
711 ));
712 }
713
714 for expected_user in expected_users {
715 let user = listed_users
716 .users
717 .iter()
718 .find(|user| user.name == expected_user.name)
719 .ok_or(format!("user {} not found", expected_user.name))?;
720
721 if !expected_user.identities.iter().all(|identity| {
722 user.identities
723 .iter()
724 .any(|user_identity| user_identity == &identity.identity)
725 }) {
726 return Err(format!(
727 "user {} has identities {:?}, expected {:?}",
728 expected_user.name, user.identities, expected_user.identities
729 ));
730 }
731
732 if !expected_user
733 .groups
734 .as_ref()
735 .unwrap_or(default_groups)
736 .iter()
737 .all(|group| user.groups.iter().any(|user_group| &user_group.id == group))
738 || !user.groups.iter().all(|user_group| {
739 expected_user
740 .groups
741 .as_ref()
742 .unwrap_or(default_groups)
743 .iter()
744 .any(|group| group == &user_group.id)
745 })
746 {
747 return Err(format!(
748 "user {} has groups {:?}, expected {:?}",
749 expected_user.name, user.groups, expected_user.groups
750 ));
751 }

Callers 3

install_with_all_entriesFunction · 0.85

Calls 4

iterMethod · 0.80
allMethod · 0.80
list_usersFunction · 0.50
lenMethod · 0.45

Tested by

no test coverage detected