Skip to content

Commit

Permalink
creator is only a super admin, not an admin (#879)
Browse files Browse the repository at this point in the history
Co-authored-by: cameronvoell <[email protected]>
  • Loading branch information
cameronvoell and cameronvoell authored Jul 1, 2024
1 parent f0b83aa commit a33bafe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion xmtp_mls/src/groups/group_mutable_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl GroupMutableMetadata {
opts.image_url_square
.unwrap_or_else(|| DEFAULT_GROUP_IMAGE_URL_SQUARE.to_string()),
);
let admin_list = vec![creator_inbox_id.clone()];
let admin_list = vec![];
let super_admin_list = vec![creator_inbox_id.clone()];
Self {
attributes,
Expand Down
24 changes: 12 additions & 12 deletions xmtp_mls/src/groups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2015,8 +2015,7 @@ mod tests {
// Verify Amal is the only admin and super admin
let admin_list = amal_group.admin_list().unwrap();
let super_admin_list = amal_group.super_admin_list().unwrap();
assert_eq!(admin_list.len(), 1);
assert!(admin_list.contains(&amal.inbox_id()));
assert_eq!(admin_list.len(), 0);
assert_eq!(super_admin_list.len(), 1);
assert!(super_admin_list.contains(&amal.inbox_id()));

Expand All @@ -2038,7 +2037,7 @@ mod tests {
.unwrap();
amal_group.sync(&amal).await.unwrap();
bola_group.sync(&bola).await.unwrap();
assert_eq!(bola_group.admin_list().unwrap().len(), 2);
assert_eq!(bola_group.admin_list().unwrap().len(), 1);
assert!(bola_group.admin_list().unwrap().contains(&bola.inbox_id()));

// Verify that bola can now add caro because they are an admin
Expand All @@ -2047,10 +2046,12 @@ mod tests {
.await
.unwrap();

// Verify that bola can not remove amal as an admin, because
bola_group.sync(&bola).await.unwrap();

// Verify that bola can not remove amal as a super admin, because
// Remove admin is super admin only permissions
bola_group
.update_admin_list(&bola, UpdateAdminListType::Remove, amal.inbox_id())
.update_admin_list(&bola, UpdateAdminListType::RemoveSuper, amal.inbox_id())
.await
.expect_err("expected err");

Expand All @@ -2061,7 +2062,7 @@ mod tests {
.unwrap();
amal_group.sync(&amal).await.unwrap();
bola_group.sync(&bola).await.unwrap();
assert_eq!(bola_group.admin_list().unwrap().len(), 1);
assert_eq!(bola_group.admin_list().unwrap().len(), 0);
assert!(!bola_group.admin_list().unwrap().contains(&bola.inbox_id()));

// Verify that bola can not add charlie because they are not an admin
Expand Down Expand Up @@ -2099,11 +2100,10 @@ mod tests {
let bola_group = bola_groups.first().unwrap();
bola_group.sync(&bola).await.unwrap();

// Verify Amal is the only admin and super admin
// Verify Amal is the only super admin
let admin_list = amal_group.admin_list().unwrap();
let super_admin_list = amal_group.super_admin_list().unwrap();
assert_eq!(admin_list.len(), 1);
assert!(admin_list.contains(&amal.inbox_id()));
assert_eq!(admin_list.len(), 0);
assert_eq!(super_admin_list.len(), 1);
assert!(super_admin_list.contains(&amal.inbox_id()));

Expand Down Expand Up @@ -2137,7 +2137,7 @@ mod tests {
.await
.unwrap();
bola_group.sync(&bola).await.unwrap();
assert_eq!(bola_group.admin_list().unwrap().len(), 2);
assert_eq!(bola_group.admin_list().unwrap().len(), 1);
assert!(bola_group.admin_list().unwrap().contains(&caro.inbox_id()));

// Verify that no one can remove a super admin from a group
Expand Down Expand Up @@ -2312,8 +2312,8 @@ mod tests {
amal_group.sync(&amal).await.unwrap();

let mutable_metadata = amal_group.mutable_metadata().unwrap();
assert_eq!(mutable_metadata.admin_list.len(), 1);
assert_eq!(mutable_metadata.admin_list[0], amal.inbox_id());
assert_eq!(mutable_metadata.super_admin_list.len(), 1);
assert_eq!(mutable_metadata.super_admin_list[0], amal.inbox_id());

let protected_metadata: GroupMetadata = amal_group.metadata().unwrap();
assert_eq!(
Expand Down

0 comments on commit a33bafe

Please sign in to comment.