mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
pubsub: Add serialization test for configure element
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
689b7cf836
commit
3c92f849d3
2 changed files with 39 additions and 1 deletions
|
@ -52,6 +52,8 @@ pub const PUBSUB_ERRORS: &str = "http://jabber.org/protocol/pubsub#errors";
|
|||
pub const PUBSUB_EVENT: &str = "http://jabber.org/protocol/pubsub#event";
|
||||
/// XEP-0060: Publish-Subscribe
|
||||
pub const PUBSUB_OWNER: &str = "http://jabber.org/protocol/pubsub#owner";
|
||||
/// XEP-0060: Publish-Subscribe node configuration
|
||||
pub const PUBSUB_CONFIGURE: &str = "http://jabber.org/protocol/pubsub#node_config";
|
||||
|
||||
/// XEP-0071: XHTML-IM
|
||||
pub const XHTML_IM: &str = "http://jabber.org/protocol/xhtml-im";
|
||||
|
|
|
@ -518,6 +518,7 @@ impl From<PubSub> for Element {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::data_forms::{DataForm, DataFormType, Field, FieldType};
|
||||
|
||||
#[test]
|
||||
fn create() {
|
||||
|
@ -556,7 +557,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn create_and_configure() {
|
||||
fn create_and_configure_empty() {
|
||||
let elem: Element =
|
||||
"<pubsub xmlns='http://jabber.org/protocol/pubsub'><create/><configure/></pubsub>"
|
||||
.parse()
|
||||
|
@ -575,6 +576,41 @@ mod tests {
|
|||
assert_eq!(elem1, elem2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_and_configure_simple() {
|
||||
// XXX: Do we want xmpp-parsers to always specify the field type in the output Element?
|
||||
let elem: Element = "<pubsub xmlns='http://jabber.org/protocol/pubsub'><create node='foo'/><configure><x xmlns='jabber:x:data' type='submit'><field var='FORM_TYPE' type='hidden'><value>http://jabber.org/protocol/pubsub#node_config</value></field><field var='pubsub#access_model' type='list-single'><value>whitelist</value></field></x></configure></pubsub>"
|
||||
.parse()
|
||||
.unwrap();
|
||||
let elem1 = elem.clone();
|
||||
|
||||
let pubsub = PubSub::Create {
|
||||
create: Create {
|
||||
node: Some(NodeName(String::from("foo"))),
|
||||
},
|
||||
configure: Some(Configure {
|
||||
form: Some(DataForm {
|
||||
type_: DataFormType::Submit,
|
||||
form_type: Some(String::from(ns::PUBSUB_CONFIGURE)),
|
||||
title: None,
|
||||
instructions: None,
|
||||
fields: vec![Field {
|
||||
var: String::from("pubsub#access_model"),
|
||||
type_: FieldType::ListSingle,
|
||||
label: None,
|
||||
required: false,
|
||||
options: vec![],
|
||||
values: vec![String::from("whitelist")],
|
||||
media: vec![],
|
||||
}],
|
||||
}),
|
||||
}),
|
||||
};
|
||||
|
||||
let elem2 = Element::from(pubsub);
|
||||
assert_eq!(elem1, elem2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn publish() {
|
||||
let elem: Element =
|
||||
|
|
Loading…
Reference in a new issue