Add unit test for sanitize_uri() in MMDS.
@@ -184,6 +184,25 @@ mod tests {
assert!(expected_response.body().unwrap() == actual_response.body().unwrap());
}
+ #[test]
+ fn test_sanitize_uri() {
+ let sanitized = "/a/b/c/d";
+ assert_eq!(sanitize_uri("/a/b/c/d".to_owned()), sanitized);
+ assert_eq!(sanitize_uri("/a////b/c//d".to_owned()), sanitized);
+ assert_eq!(sanitize_uri("/a///b/c///d".to_owned()), sanitized);
+ assert_eq!(sanitize_uri("/a//b/c////d".to_owned()), sanitized);
+ assert_eq!(sanitize_uri("///////a//b///c//d".to_owned()), sanitized);
+ assert_eq!(sanitize_uri("a".to_owned()), "a");
+ assert_eq!(sanitize_uri("a/".to_owned()), "a/");
+ assert_eq!(sanitize_uri("aa//".to_owned()), "aa/");
+ assert_eq!(sanitize_uri("aa".to_owned()), "aa");
+ assert_eq!(sanitize_uri("/".to_owned()), "/");
+ assert_eq!(sanitize_uri("".to_owned()), "");
+ assert_eq!(sanitize_uri("////".to_owned()), "/");
+ assert_eq!(sanitize_uri("aa//bb///cc//d".to_owned()), "aa/bb/cc/d");
+ assert_eq!(sanitize_uri("//aa//bb///cc//d".to_owned()), "/aa/bb/cc/d");
+ }
+
#[test]
fn test_parse_request() {
let data = r#"{
