From 9b6fcd1bd7c82569a912b4ba0e2672832805bbdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Mon, 27 Dec 2021 20:15:34 +0100 Subject: [PATCH] parsers: http_upload: add tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- parsers/src/http_upload.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/parsers/src/http_upload.rs b/parsers/src/http_upload.rs index beec863..e76aea0 100644 --- a/parsers/src/http_upload.rs +++ b/parsers/src/http_upload.rs @@ -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 = " + + + " + .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 = " + +
EvilValue
+
+ +
" + .parse() + .unwrap(); + SlotResult::try_from(elem).unwrap_err(); + } }