mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
attention: Add missing unknown attribute check.
This commit is contained in:
parent
1f43cd934b
commit
5ec921fa6f
1 changed files with 14 additions and 0 deletions
|
@ -25,6 +25,9 @@ impl TryFrom<Element> for Attention {
|
|||
for _ in elem.children() {
|
||||
return Err(Error::ParseError("Unknown child in attention element."));
|
||||
}
|
||||
for _ in elem.attrs() {
|
||||
return Err(Error::ParseError("Unknown attribute in attention element."));
|
||||
}
|
||||
Ok(Attention)
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +64,17 @@ mod tests {
|
|||
assert_eq!(message, "Unknown child in attention element.");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invalid_attribute() {
|
||||
let elem: Element = "<attention xmlns='urn:xmpp:attention:0' coucou=''/>".parse().unwrap();
|
||||
let error = Attention::try_from(elem).unwrap_err();
|
||||
let message = match error {
|
||||
Error::ParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message, "Unknown attribute in attention element.");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_serialise() {
|
||||
let elem: Element = "<attention xmlns='urn:xmpp:attention:0'/>".parse().unwrap();
|
||||
|
|
Loading…
Reference in a new issue