Skip to content

Commit

Permalink
Adjust tests to ensure Windows compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
stephank committed Dec 23, 2022
1 parent 356b960 commit 277658d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,26 +103,26 @@ async fn returns_404_if_file_not_found() {

#[tokio::test]
async fn redirects_if_trailing_slash_is_missing() {
let harness = Harness::new(vec![("dir/index.html", "this is index")]);
let harness = Harness::new(vec![("foo/bar/index.html", "this is index")]);

let res = harness.get("/dir").await.unwrap();
let res = harness.get("/foo/bar").await.unwrap();
assert_eq!(res.status(), StatusCode::MOVED_PERMANENTLY);

let url = res.headers().get(header::LOCATION).unwrap();
assert_eq!(url, "/dir/");
assert_eq!(url, "/foo/bar/");
}

#[tokio::test]
async fn redirects_to_sanitized_path() {
let harness = Harness::new(vec![("dir/index.html", "this is index")]);
let harness = Harness::new(vec![("foo.org/bar/index.html", "this is index")]);

// Previous versions would base the redirect on the request path, but that is user input, and
// the user could construct a schema-relative redirect this way.
let res = harness.get("//dir").await.unwrap();
let res = harness.get("//foo.org/bar").await.unwrap();
assert_eq!(res.status(), StatusCode::MOVED_PERMANENTLY);

let url = res.headers().get(header::LOCATION).unwrap();
assert_eq!(url, "/dir/");
assert_eq!(url, "/foo.org/bar/");
}

#[tokio::test]
Expand Down

0 comments on commit 277658d

Please sign in to comment.