Skip to content

Commit c816c03

Browse files
pietroalbiniJoshua Nelson
authored andcommitted
statics: test that the response for dir traversal is 404
1 parent 957695f commit c816c03

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/web/statics.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ pub(super) fn ico_handler(req: &mut Request) -> IronResult<Response> {
132132

133133
#[cfg(test)]
134134
mod tests {
135+
use iron::status::Status;
136+
135137
use super::{serve_file, STATIC_SEARCH_PATHS, STYLE_CSS, VENDORED_CSS};
136138
use crate::test::wrapper;
137139
use std::fs;
@@ -295,7 +297,12 @@ mod tests {
295297
// Still, the test ensures the underlying function called by the request handler to
296298
// serve the file also includes protection for path traversal, in the event we switch
297299
// to a framework that doesn't include builtin protection in the future.
298-
assert!(serve_file(path).is_err(), "{} was served", path);
300+
assert_eq!(
301+
Some(Status::NotFound),
302+
serve_file(path).unwrap_err().response.status,
303+
"{} did not return a 404",
304+
path
305+
);
299306
}
300307
}
301308
}

0 commit comments

Comments
 (0)