Fix parsing of stream errors
skip-changelog, because there's no release with the stream_error module yet.
This commit is contained in:
parent
e438813fb2
commit
1262b560e9
2 changed files with 22 additions and 1 deletions
|
|
@ -10,6 +10,8 @@ pub const JABBER_CLIENT: &str = "jabber:client";
|
|||
/// RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core
|
||||
pub const XMPP_STANZAS: &str = "urn:ietf:params:xml:ns:xmpp-stanzas";
|
||||
/// RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core
|
||||
pub const XMPP_STREAMS: &str = "urn:ietf:params:xml:ns:xmpp-streams";
|
||||
/// RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core
|
||||
pub const STREAM: &str = "http://etherx.jabber.org/streams";
|
||||
/// RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core
|
||||
pub const TLS: &str = "urn:ietf:params:xml:ns:xmpp-tls";
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use crate::ns;
|
|||
///
|
||||
/// [RFC 6120]: https://datatracker.ietf.org/doc/html/rfc6120#section-4.9.3
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::STREAM)]
|
||||
#[xml(namespace = ns::XMPP_STREAMS)]
|
||||
pub enum DefinedCondition {
|
||||
/// The entity has sent XML that cannot be processed.
|
||||
///
|
||||
|
|
@ -360,3 +360,22 @@ impl fmt::Display for SentStreamError {
|
|||
}
|
||||
|
||||
impl Error for SentStreamError {}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn parses_condition_from_prosody() {
|
||||
let doc = "<undefined-condition xmlns='urn:ietf:params:xml:ns:xmpp-streams'/>";
|
||||
let err: DefinedCondition = xso::from_bytes(doc.as_bytes()).unwrap();
|
||||
assert_eq!(err, DefinedCondition::UndefinedCondition);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_stream_error_from_prosody() {
|
||||
let doc = "<stream:error xmlns:stream='http://etherx.jabber.org/streams'><undefined-condition xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xmlns='urn:ietf:params:xml:ns:xmpp-streams'>No stream features to proceed with</text></stream:error>";
|
||||
let err: StreamError = xso::from_bytes(doc.as_bytes()).unwrap();
|
||||
assert_eq!(err.condition, DefinedCondition::UndefinedCondition);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue