diff --git a/parsers/src/ns.rs b/parsers/src/ns.rs index 5dedc3efc879a0f0c7b09c77bb6af87b247f3656..d5dfe0791a7ee881e8354ead7f06e32bee12069d 100644 --- a/parsers/src/ns.rs +++ b/parsers/src/ns.rs @@ -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"; diff --git a/parsers/src/stream_error.rs b/parsers/src/stream_error.rs index 317f131d7bfe9a260e718fa4c874fa90858c034d..1d6b64b76bc0113c47ee4779c188d9ac039451c0 100644 --- a/parsers/src/stream_error.rs +++ b/parsers/src/stream_error.rs @@ -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 = ""; + let err: DefinedCondition = xso::from_bytes(doc.as_bytes()).unwrap(); + assert_eq!(err, DefinedCondition::UndefinedCondition); + } + + #[test] + fn parses_stream_error_from_prosody() { + let doc = "No stream features to proceed with"; + let err: StreamError = xso::from_bytes(doc.as_bytes()).unwrap(); + assert_eq!(err.condition, DefinedCondition::UndefinedCondition); + } +}