1use xso::{AsXml, FromXml};
8
9use crate::iq::IqGetPayload;
10use crate::message::MessagePayload;
11use crate::ns;
12
13#[derive(FromXml, AsXml, PartialEq, Eq, Hash, Debug, Clone)]
22#[xml(namespace = ns::HTTP_AUTH, name = "confirm")]
23pub struct Confirm {
24 #[xml(attribute)]
26 pub method: String,
27
28 #[xml(attribute)]
30 pub url: String,
31
32 #[xml(attribute)]
34 pub id: String,
35}
36
37impl IqGetPayload for Confirm {}
38impl MessagePayload for Confirm {}
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43 use crate::ns;
44 use minidom::Element;
45
46 #[cfg(target_pointer_width = "32")]
47 #[test]
48 fn test_size() {
49 assert_size!(Confirm, 36);
50 }
51
52 #[cfg(target_pointer_width = "64")]
53 #[test]
54 fn test_size() {
55 assert_size!(Confirm, 72);
56 }
57
58 #[test]
59 fn test_simple() {
60 let elem: Element = "<confirm xmlns='http://jabber.org/protocol/http-auth' \
61 id='a7374jnjlalasdf82' method='GET' \
62 url='https://files.shakespeare.lit:9345/missive.html'/>"
63 .parse()
64 .unwrap();
65 let confirm = Confirm::try_from(elem).unwrap();
66 assert_eq!(confirm.method, "GET");
67 assert_eq!(confirm.id, "a7374jnjlalasdf82");
68 assert_eq!(
69 confirm.url,
70 "https://files.shakespeare.lit:9345/missive.html"
71 );
72 }
73
74 #[test]
75 fn test_serialise() {
76 let confirm = Confirm {
77 method: "GET".to_string(),
78 url: "https://files.shakespeare.lit/".to_string(),
79 id: "sesame".to_string(),
80 };
81 let elem: Element = confirm.into();
82 assert!(elem.is("confirm", ns::HTTP_AUTH));
83 }
84}