mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
parsers: http_upload: add tests
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
ee01d12838
commit
9b6fcd1bd7
1 changed files with 27 additions and 0 deletions
|
@ -156,4 +156,31 @@ mod tests {
|
|||
);
|
||||
assert_eq!(slot.get.url, String::from("https://download.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/tr%C3%A8s%20cool.jpg"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_result_no_header() {
|
||||
let elem: Element = "<slot xmlns='urn:xmpp:http:upload:0'>
|
||||
<put url='https://URL' />
|
||||
<get url='https://URL' />
|
||||
</slot>"
|
||||
.parse()
|
||||
.unwrap();
|
||||
let slot = SlotResult::try_from(elem).unwrap();
|
||||
assert_eq!(slot.put.url, String::from("https://URL"));
|
||||
assert_eq!(slot.put.headers.len(), 0);
|
||||
assert_eq!(slot.get.url, String::from("https://URL"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_result_bad_header() {
|
||||
let elem: Element = "<slot xmlns='urn:xmpp:http:upload:0'>
|
||||
<put url='https://URL'>
|
||||
<header name='EvilHeader'>EvilValue</header>
|
||||
</put>
|
||||
<get url='https://URL' />
|
||||
</slot>"
|
||||
.parse()
|
||||
.unwrap();
|
||||
SlotResult::try_from(elem).unwrap_err();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue