Ensure that invitees do not have permissions
They have to accept the invite, (which joining the channel will do), first.
This commit is contained in:
parent
4e7b35c917
commit
2feb091961
4 changed files with 256 additions and 178 deletions
|
@ -7,7 +7,7 @@ use channel::{ChannelId, ChannelMembership, ChannelStore};
|
|||
use client::User;
|
||||
use gpui::{executor::Deterministic, ModelHandle, TestAppContext};
|
||||
use rpc::{
|
||||
proto::{self},
|
||||
proto::{self, ChannelRole},
|
||||
RECEIVE_TIMEOUT,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
@ -965,6 +965,67 @@ async fn test_guest_access(
|
|||
})
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_invite_access(
|
||||
deterministic: Arc<Deterministic>,
|
||||
cx_a: &mut TestAppContext,
|
||||
cx_b: &mut TestAppContext,
|
||||
) {
|
||||
deterministic.forbid_parking();
|
||||
|
||||
let mut server = TestServer::start(&deterministic).await;
|
||||
let client_a = server.create_client(cx_a, "user_a").await;
|
||||
let client_b = server.create_client(cx_b, "user_b").await;
|
||||
|
||||
let channels = server
|
||||
.make_channel_tree(
|
||||
&[("channel-a", None), ("channel-b", Some("channel-a"))],
|
||||
(&client_a, cx_a),
|
||||
)
|
||||
.await;
|
||||
let channel_a_id = channels[0];
|
||||
let channel_b_id = channels[0];
|
||||
|
||||
let active_call_b = cx_b.read(ActiveCall::global);
|
||||
|
||||
// should not be allowed to join
|
||||
assert!(active_call_b
|
||||
.update(cx_b, |call, cx| call.join_channel(channel_b_id, cx))
|
||||
.await
|
||||
.is_err());
|
||||
|
||||
client_a
|
||||
.channel_store()
|
||||
.update(cx_a, |channel_store, cx| {
|
||||
channel_store.invite_member(
|
||||
channel_a_id,
|
||||
client_b.user_id().unwrap(),
|
||||
ChannelRole::Member,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
active_call_b
|
||||
.update(cx_b, |call, cx| call.join_channel(channel_b_id, cx))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
deterministic.run_until_parked();
|
||||
|
||||
client_b.channel_store().update(cx_b, |channel_store, _| {
|
||||
assert!(channel_store.channel_for_id(channel_b_id).is_some());
|
||||
assert!(channel_store.channel_for_id(channel_a_id).is_some());
|
||||
});
|
||||
|
||||
client_a.channel_store().update(cx_a, |channel_store, _| {
|
||||
let participants = channel_store.channel_participants(channel_b_id);
|
||||
assert_eq!(participants.len(), 1);
|
||||
assert_eq!(participants[0].id, client_b.user_id().unwrap());
|
||||
})
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_channel_moving(
|
||||
deterministic: Arc<Deterministic>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue