mirror of
https://github.com/actix/actix-web.git
synced 2025-01-30 10:58:08 +00:00
test for cors
This commit is contained in:
parent
16e9512457
commit
1445cc7a2c
1 changed files with 8 additions and 3 deletions
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue