mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-24 16:02:59 +01:00
add tests for csrf upgrade filter
This commit is contained in:
parent
b9d6bbd357
commit
0278e364ec
@ -274,4 +274,25 @@ mod tests {
|
|||||||
|
|
||||||
assert!(csrf.start(&mut req).is_ok());
|
assert!(csrf.start(&mut req).is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_upgrade() {
|
||||||
|
let strict_csrf = CsrfFilter::build()
|
||||||
|
.allowed_origin("https://www.example.com")
|
||||||
|
.finish();
|
||||||
|
|
||||||
|
let lax_csrf = CsrfFilter::build()
|
||||||
|
.allowed_origin("https://www.example.com")
|
||||||
|
.allow_upgrade()
|
||||||
|
.finish();
|
||||||
|
|
||||||
|
let mut req = TestRequest::with_header("Origin", "https://cswsh.com")
|
||||||
|
.header("Connection", "Upgrade")
|
||||||
|
.header("Upgrade", "websocket")
|
||||||
|
.method(Method::GET)
|
||||||
|
.finish();
|
||||||
|
|
||||||
|
assert!(strict_csrf.start(&mut req).is_err());
|
||||||
|
assert!(lax_csrf.start(&mut req).is_ok());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user