From 1445cc7a2ccc20d6ab3edb8e7b0c3dd7cb78d0fa Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 10 Jan 2018 14:21:48 -0800 Subject: [PATCH] test for cors --- src/middleware/cors.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/middleware/cors.rs b/src/middleware/cors.rs index a2667430a..f251d6b4b 100644 --- a/src/middleware/cors.rs +++ b/src/middleware/cors.rs @@ -748,13 +748,18 @@ mod tests { #[test] fn test_validate_origin() { let cors = Cors::build() - .allowed_origin("http://www.example.com").finish().unwrap(); + .allowed_origin("https://www.example.com").finish().unwrap(); - let mut req = TestRequest::with_header( - "Origin", "https://www.unknown.com") + let mut req = TestRequest::with_header("Origin", "https://www.unknown.com") .method(Method::GET) .finish(); assert!(cors.start(&mut req).is_err()); + + let mut req = TestRequest::with_header("Origin", "https://www.example.com") + .method(Method::GET) + .finish(); + + assert!(cors.start(&mut req).unwrap().is_done()); } }