From f38c20321504d063b5000844bc250428a3c73a05 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Sun, 13 Sep 2020 11:55:31 -0700 Subject: [PATCH] Fix cookies_on_redirect unittest. Previously this test relied on a specific ordering of cookies, which was not guaranteed. This makes the test robust to random ordering. Also, fix the check for the `second` cookie to actually check the right cookie. --- src/test/agent_test.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/agent_test.rs b/src/test/agent_test.rs index 58bdd31..57025b4 100644 --- a/src/test/agent_test.rs +++ b/src/test/agent_test.rs @@ -111,7 +111,7 @@ fn cookie_and_redirect(mut stream: TcpStream) -> io::Result<()> { stream.write_all(b"Content-Length: 0\r\n\r\n")?; }, "/second" => { - if headers.headers().iter().find(|&x| x.contains("Cookie: first")).is_none() { + if headers.headers().iter().find(|&x| x.contains("first=true")).is_none() { panic!("request did not contain cookie 'first'"); } stream.write_all(b"HTTP/1.1 302 Found\r\n")?; @@ -120,7 +120,7 @@ fn cookie_and_redirect(mut stream: TcpStream) -> io::Result<()> { stream.write_all(b"Content-Length: 0\r\n\r\n")?; }, "/third" => { - if headers.headers().iter().find(|&x| x.contains("Cookie: first")).is_none() { + if headers.headers().iter().find(|&x| x.contains("second=true")).is_none() { panic!("request did not contain cookie 'second'"); } stream.write_all(b"HTTP/1.1 200 OK\r\n")?;