1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-30 18:34:36 +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]
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());
}
}