Add test_presence_resync
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
3b49a5ae40
commit
506e288b90
2 changed files with 73 additions and 2 deletions
|
@ -18,8 +18,9 @@ file.
|
|||
* [ ] Multiple sessions non-MSN
|
||||
* [ ] MSN
|
||||
- [ ] Presence
|
||||
* [ ] Probes
|
||||
* [ ] Resync
|
||||
* [x] Updates
|
||||
* [x] Resync
|
||||
* [ ] Probes (storing updates to answer probes)
|
||||
- [ ] Iq
|
||||
* [ ] Ping answers
|
||||
* [ ] Ping probes?
|
||||
|
|
70
src/tests.rs
70
src/tests.rs
|
@ -303,6 +303,76 @@ async fn test_join_presence_existing_room() {
|
|||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_presence_resync() {
|
||||
let realjid1 = FullJid::from_str("foo@bar/qxx").unwrap();
|
||||
let realjid2 = FullJid::from_str("qxx@bar/foo").unwrap();
|
||||
let roomjid = COMPONENT_JID.clone().with_node("room");
|
||||
let participant1 = roomjid.clone().with_resource("nick1");
|
||||
let participant2 = roomjid.clone().with_resource("nick2");
|
||||
|
||||
let join1: Element = Presence::new(PresenceType::None)
|
||||
.with_from(Jid::Full(realjid1.clone()))
|
||||
.with_to(Jid::Full(participant1.clone()))
|
||||
.with_payloads(vec![Muc::new().into()])
|
||||
.into();
|
||||
|
||||
let join2: Element = Presence::new(PresenceType::None)
|
||||
.with_from(Jid::Full(realjid2.clone()))
|
||||
.with_to(Jid::Full(participant2.clone()))
|
||||
.with_payloads(vec![Muc::new().into()])
|
||||
.into();
|
||||
|
||||
let mut component = TestComponent::new(vec![join1.clone(), join2, join1]);
|
||||
let mut rooms: HashMap<BareJid, Room> = HashMap::new();
|
||||
|
||||
// Self-presence for participant1
|
||||
component.expect_presence(|_| ());
|
||||
// Subject for participant1
|
||||
component.expect_message(|_| ());
|
||||
// Participant1 presence for participant2
|
||||
component.expect_presence(|_| ());
|
||||
// Participant2 presence for participant1
|
||||
component.expect_presence(|_| ());
|
||||
// Self-presence for participant2
|
||||
component.expect_presence(|_| ());
|
||||
// Subject for participant2
|
||||
component.expect_message(|_| ());
|
||||
|
||||
// Resync: Participant2 presence for participant1
|
||||
component.expect(
|
||||
Presence::new(PresenceType::None)
|
||||
.with_from(Jid::Full(participant2.clone()))
|
||||
.with_to(Jid::Full(realjid1.clone()))
|
||||
.with_payloads(vec![MucUser {
|
||||
status: Vec::new(),
|
||||
items: vec![MucItem::new(Affiliation::Owner, Role::Moderator)],
|
||||
}
|
||||
.into()]),
|
||||
);
|
||||
|
||||
// Resync: Participant1 self-presence
|
||||
component.expect(
|
||||
Presence::new(PresenceType::None)
|
||||
.with_from(Jid::Full(participant1))
|
||||
.with_to(Jid::Full(realjid1.clone()))
|
||||
.with_payloads(vec![MucUser {
|
||||
status: vec![MucStatus::SelfPresence, MucStatus::AssignedNick],
|
||||
items: vec![MucItem::new(Affiliation::Owner, Role::Moderator)],
|
||||
}
|
||||
.into()]),
|
||||
);
|
||||
|
||||
handle_stanza(&mut component, &mut rooms).await.unwrap();
|
||||
component.assert();
|
||||
|
||||
match rooms.get(&roomjid) {
|
||||
Some(room) => assert_eq!(room.occupants.len(), 2),
|
||||
None => panic!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_leave_non_existing_room() {
|
||||
let realjid1 = FullJid::from_str("foo@bar/qxx").unwrap();
|
||||
|
|
Loading…
Reference in a new issue