mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 01:32:57 +01:00
test for cors
This commit is contained in:
parent
16e9512457
commit
1445cc7a2c
@ -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 New Issue
Block a user