minor cleanup

This commit is contained in:
Robin Appelman 2021-07-29 16:45:38 +02:00
commit 3f6837c87c
2 changed files with 68 additions and 25 deletions

View file

@ -83,3 +83,25 @@ async fn test_trusted_forwarded_no_for() {
.await;
assert_eq!(res.body(), "1.2.3.4");
}
#[tokio::test]
async fn test_quoted() {
let remote: IpAddr = [1, 2, 3, 4].into();
let res = warp::test::request()
.remote_addr((remote, 80).into())
.header("x-forwarded-for", "\"10.10.10.10\"")
.reply(&serve(vec![remote]))
.await;
assert_eq!(res.body(), "10.10.10.10");
}
#[tokio::test]
async fn test_nested_quoted() {
let remote: IpAddr = [1, 2, 3, 4].into();
let res = warp::test::request()
.remote_addr((remote, 80).into())
.header("x-forwarded-for", "\"10.10.10.10\", 11.11.11.11")
.reply(&serve(vec![remote, [10, 10, 10, 10].into()]))
.await;
assert_eq!(res.body(), "11.11.11.11");
}