Skip to content

Commit 68662b2

Browse files
committed
Add failing test for nested cookies
1 parent 935498f commit 68662b2

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/cookies.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,28 @@ fn successfully_set_multiple_cookies() {
113113

114114
assert!(iter.next().is_none());
115115
}
116+
117+
#[test]
118+
fn nested_cookies() {
119+
let mut inner = tide::new();
120+
inner.at("/2").get(|_req| async move {
121+
let mut r = Response::new(200);
122+
r.set_cookie(Cookie::new("snack", "tuna"));
123+
r.body_string(String::from("ok"))
124+
});
125+
126+
let mut outer = tide::new();
127+
outer.at("/1").nest(inner);
128+
129+
let mut server = make_server(outer.into_http_service()).unwrap();
130+
131+
let req = http::Request::get("/1/2")
132+
.body(Body::empty())
133+
.unwrap();
134+
135+
let res = server.simulate(req).unwrap();
136+
137+
let mut cookies = res.headers().get_all(http::header::SET_COOKIE).iter();
138+
assert_eq!(cookies.next().unwrap(), "snack=tuna");
139+
assert!(cookies.next().is_none());
140+
}

0 commit comments

Comments
 (0)