1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-28 09:42:40 +01:00

test for cors

This commit is contained in:
Nikolay Kim 2018-01-10 14:21:48 -08:00
parent 16e9512457
commit 1445cc7a2c

View File

@ -748,13 +748,18 @@ mod tests {
#[test] #[test]
fn test_validate_origin() { fn test_validate_origin() {
let cors = Cors::build() 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( let mut req = TestRequest::with_header("Origin", "https://www.unknown.com")
"Origin", "https://www.unknown.com")
.method(Method::GET) .method(Method::GET)
.finish(); .finish();
assert!(cors.start(&mut req).is_err()); 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());
} }
} }