forked from lavina/lavina
Return empty message
This commit is contained in:
parent
1c2dcc05f0
commit
45bd3f3819
|
@ -88,7 +88,15 @@ impl<'a> XmppConnection<'a> {
|
|||
req.serialize(output);
|
||||
}
|
||||
IqClientBody::MessageArchiveRequest(request) => {
|
||||
// let response = self.mam().await?;
|
||||
let response = self.mam().await;
|
||||
// let req = Iq {
|
||||
// from: iq.to,
|
||||
// id: iq.id,
|
||||
// to: None,
|
||||
// r#type: IqType::Result,
|
||||
// body: response,
|
||||
// };
|
||||
response.serialize(output);
|
||||
}
|
||||
_ => {
|
||||
let req = Iq {
|
||||
|
@ -224,9 +232,9 @@ impl<'a> XmppConnection<'a> {
|
|||
ItemQuery { item }
|
||||
}
|
||||
|
||||
async fn mam(&self) -> Result<Message<Ignore>, ()> {
|
||||
async fn mam(&self) -> Message<()> {
|
||||
// return Ok(());
|
||||
Ok(Message::<Ignore> {
|
||||
Message::<()> {
|
||||
from: None,
|
||||
id: Some("aacea".to_string()),
|
||||
to: Some(Jid {
|
||||
|
@ -238,7 +246,7 @@ impl<'a> XmppConnection<'a> {
|
|||
lang: None,
|
||||
subject: Some("daa".into()),
|
||||
body: "bbb".into(),
|
||||
custom: vec![Ignore],
|
||||
})
|
||||
custom: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ impl<'a> TestScopeTls<'a> {
|
|||
assert_matches!(self.next_xml_event().await?, Event::Start(b) => assert_eq!(element_name(&b.local_name()), "features"));
|
||||
assert_matches!(self.next_xml_event().await?, Event::Start(b) => assert_eq!(element_name(&b.local_name()), "mechanisms"));
|
||||
assert_matches!(self.next_xml_event().await?, Event::Start(b) => assert_eq!(element_name(&b.local_name()), "mechanism"));
|
||||
assert_matches!(self.next_xml_event().await?, Event::Text(b) => assert_eq!(&*b, "PLAIN"));
|
||||
assert_matches!(self.next_xml_event().await?, Event::Text(b) => assert_eq!(&*b, b"PLAIN"));
|
||||
assert_matches!(self.next_xml_event().await?, Event::End(b) => assert_eq!(element_name(&b.local_name()), "mechanism"));
|
||||
assert_matches!(self.next_xml_event().await?, Event::End(b) => assert_eq!(element_name(&b.local_name()), "mechanisms"));
|
||||
assert_matches!(self.next_xml_event().await?, Event::End(b) => assert_eq!(element_name(&b.local_name()), "features"));
|
||||
|
@ -233,7 +233,7 @@ async fn scenario_basic() -> Result<()> {
|
|||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => assert_eq!(element_name(&b.local_name()), "iq"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => assert_eq!(element_name(&b.local_name()), "bind"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => assert_eq!(element_name(&b.local_name()), "jid"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::Text(b) => assert_eq!(&*b, "tester@localhost/tester"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::Text(b) => assert_eq!(&*b, b"tester@localhost/tester"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::End(b) => assert_eq!(element_name(&b.local_name()), "jid"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::End(b) => assert_eq!(element_name(&b.local_name()), "bind"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::End(b) => assert_eq!(element_name(&b.local_name()), "iq"));
|
||||
|
@ -395,7 +395,7 @@ async fn test_message_archive_request() -> Result<()> {
|
|||
// test scenario
|
||||
|
||||
server.storage.create_user("tester").await?;
|
||||
server.storage.set_password("tester", "password").await?;
|
||||
Authenticator::new(&server.storage).set_password("tester", "password").await?;
|
||||
|
||||
let mut stream = TcpStream::connect(server.server.addr).await?;
|
||||
let mut s = TestScope::new(&mut stream);
|
||||
|
@ -405,11 +405,7 @@ async fn test_message_archive_request() -> Result<()> {
|
|||
s.send(r#"<stream:stream xmlns:stream="http://etherx.jabber.org/streams" to="127.0.0.1" xml:lang="en" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns="jabber:client" version="1.0">"#).await?;
|
||||
assert_matches!(s.next_xml_event().await?, Event::Decl(_) => {});
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => assert_eq!(element_name(&b.local_name()), "stream"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => assert_eq!(element_name(&b.local_name()), "features"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => assert_eq!(element_name(&b.local_name()), "starttls"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::Empty(b) => assert_eq!(element_name(&b.local_name()), "required"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::End(b) => assert_eq!(element_name(&b.local_name()), "starttls"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::End(b) => assert_eq!(element_name(&b.local_name()), "features"));
|
||||
s.expect_starttls_required().await?;
|
||||
s.send(r#"<starttls/>"#).await?;
|
||||
assert_matches!(s.next_xml_event().await?, Event::Empty(b) => assert_eq!(element_name(&b.local_name()), "proceed"));
|
||||
let buffer = s.buffer;
|
||||
|
@ -431,40 +427,36 @@ async fn test_message_archive_request() -> Result<()> {
|
|||
s.send(r#"<stream:stream xmlns:stream="http://etherx.jabber.org/streams" to="127.0.0.1" xml:lang="en" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns="jabber:client" version="1.0">"#).await?;
|
||||
assert_matches!(s.next_xml_event().await?, Event::Decl(_) => {});
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => assert_eq!(element_name(&b.local_name()), "stream"));
|
||||
s.expect_auth_mechanisms().await?;
|
||||
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => {
|
||||
assert_eq!(element_name(&b.local_name()), "features")
|
||||
});
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => {
|
||||
assert_eq!(element_name(&b.local_name()), "mechanisms")
|
||||
});
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => {
|
||||
assert_eq!(element_name(&b.local_name()), "mechanism")
|
||||
});
|
||||
assert_matches!(s.next_xml_event().await?, Event::Text(b) => {
|
||||
// b.
|
||||
// let local_name: &str = from_utf8(element_name(&b.local_name())).unwrap();
|
||||
// assert_eq!(local_name, "mechanism")
|
||||
});
|
||||
assert_matches!(s.next_xml_event().await?, Event::End(b) => {
|
||||
// let local_name: &str = from_utf8(element_name(&b.local_name())).unwrap();
|
||||
// assert_eq!(local_name, "mechanism")
|
||||
});
|
||||
assert_matches!(s.next_xml_event().await?, Event::End(b) => {
|
||||
assert_eq!(element_name(&b.local_name()), "mechanisms")
|
||||
});
|
||||
assert_matches!(s.next_xml_event().await?, Event::End(b) => {
|
||||
assert_eq!(element_name(&b.local_name()), "features")
|
||||
});
|
||||
// s.send(r#"<iq type='get' id='juliet1'><query xmlns='urn:xmpp:mam:tmp' queryid='f27'/></iq>"#).await?;
|
||||
// base64-encoded "\x00tester\x00password"
|
||||
s.send(r#"<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">AHRlc3RlcgBwYXNzd29yZA==</auth>"#)
|
||||
.await?;
|
||||
assert_matches!(s.next_xml_event().await?, Event::Empty(b) => assert_eq!(element_name(&b.local_name()), "success"));
|
||||
s.send(r#"<?xml version="1.0"?>"#).await?;
|
||||
s.send(r#"<stream:stream xmlns:stream="http://etherx.jabber.org/streams" to="127.0.0.1" xml:lang="en" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns="jabber:client" version="1.0">"#).await?;
|
||||
assert_matches!(s.next_xml_event().await?, Event::Decl(_) => {});
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => assert_eq!(element_name(&b.local_name()), "stream"));
|
||||
s.expect_bind_feature().await?;
|
||||
s.send(r#"<iq id="bind_1" type="set"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>kek</resource></bind></iq>"#).await?;
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => assert_eq!(element_name(&b.local_name()), "iq"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => assert_eq!(element_name(&b.local_name()), "bind"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => assert_eq!(element_name(&b.local_name()), "jid"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::Text(b) => assert_eq!(&*b, b"tester@localhost/tester"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::End(b) => assert_eq!(element_name(&b.local_name()), "jid"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::End(b) => assert_eq!(element_name(&b.local_name()), "bind"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::End(b) => assert_eq!(element_name(&b.local_name()), "iq"));
|
||||
|
||||
s.send(r#"<iq type='get' id='juliet1'><query xmlns='urn:xmpp:mam:2' queryid='f27'/></iq>"#).await?;
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => {
|
||||
assert_eq!(element_name(&b.local_name()), "message")
|
||||
});
|
||||
s.send(r#"<presence xmlns="jabber:client" type="unavailable"><status>Logged out</status></presence>"#).await?;
|
||||
|
||||
stream.shutdown().await?;
|
||||
|
||||
// wrap up
|
||||
|
||||
server.server.terminate().await?;
|
||||
server.shutdown().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue