2022-06-12 03:43:50 +03:00
|
|
|
mod fixtures;
|
|
|
|
mod utils;
|
|
|
|
|
|
|
|
use fixtures::{server, Error, TestServer};
|
|
|
|
use rstest::rstest;
|
|
|
|
|
|
|
|
#[rstest]
|
2022-06-19 12:27:09 +03:00
|
|
|
fn cors(#[with(&["--enable-cors"])] server: TestServer) -> Result<(), Error> {
|
2022-06-12 03:43:50 +03:00
|
|
|
let resp = reqwest::blocking::get(server.url())?;
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
resp.headers().get("access-control-allow-origin").unwrap(),
|
|
|
|
"*"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
resp.headers().get("access-control-allow-headers").unwrap(),
|
|
|
|
"range, content-type, accept, origin, www-authenticate"
|
|
|
|
);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[rstest]
|
2022-06-19 12:27:09 +03:00
|
|
|
fn cors_options(#[with(&["--enable-cors"])] server: TestServer) -> Result<(), Error> {
|
2022-06-12 03:43:50 +03:00
|
|
|
let resp = fetch!(b"OPTIONS", server.url()).send()?;
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
resp.headers().get("access-control-allow-origin").unwrap(),
|
|
|
|
"*"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
resp.headers().get("access-control-allow-headers").unwrap(),
|
|
|
|
"range, content-type, accept, origin, www-authenticate"
|
|
|
|
);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|