mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 08:22:59 +01:00
test for cors
This commit is contained in:
parent
16e9512457
commit
1445cc7a2c
@ -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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user