1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-24 07:53:00 +01:00

add tests for csrf upgrade filter

This commit is contained in:
Niklas Fiekas 2018-03-07 18:42:21 +01:00
parent b9d6bbd357
commit 0278e364ec

View File

@ -274,4 +274,25 @@ mod tests {
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());
}
}