2022-10-24 01:50:31 +02:00
|
|
|
use kanidm_client::KanidmClient;
|
|
|
|
|
|
|
|
#[kanidmd_testkit::test]
|
|
|
|
async fn test_https_middleware_headers(rsclient: KanidmClient) {
|
|
|
|
// We need to do manual reqwests here.
|
|
|
|
|
|
|
|
// here we test the /ui/ endpoint which should have the headers
|
2023-08-14 12:47:49 +02:00
|
|
|
let response = match reqwest::get(rsclient.make_url("/ui")).await {
|
2022-10-24 01:50:31 +02:00
|
|
|
Ok(value) => value,
|
|
|
|
Err(error) => {
|
2023-08-14 12:47:49 +02:00
|
|
|
panic!(
|
|
|
|
"Failed to query {:?} : {:#?}",
|
|
|
|
rsclient.make_url("/ui"),
|
|
|
|
error
|
|
|
|
);
|
2022-10-24 01:50:31 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
eprintln!("response: {:#?}", response);
|
|
|
|
assert_eq!(response.status(), 200);
|
|
|
|
eprintln!(
|
|
|
|
"csp headers: {:#?}",
|
|
|
|
response.headers().get("content-security-policy")
|
|
|
|
);
|
|
|
|
assert_ne!(response.headers().get("content-security-policy"), None);
|
|
|
|
|
2023-07-05 14:26:39 +02:00
|
|
|
// here we test the /ui/login endpoint which should have the headers
|
2023-08-14 12:47:49 +02:00
|
|
|
let response = match reqwest::get(rsclient.make_url("/ui/login")).await {
|
2023-07-05 14:26:39 +02:00
|
|
|
Ok(value) => value,
|
|
|
|
Err(error) => {
|
2023-08-14 12:47:49 +02:00
|
|
|
panic!(
|
|
|
|
"Failed to query {:?} : {:#?}",
|
|
|
|
rsclient.make_url("/ui/login"),
|
|
|
|
error
|
|
|
|
);
|
2023-07-05 14:26:39 +02:00
|
|
|
}
|
|
|
|
};
|
2022-10-24 01:50:31 +02:00
|
|
|
eprintln!("response: {:#?}", response);
|
|
|
|
assert_eq!(response.status(), 200);
|
2023-07-05 14:26:39 +02:00
|
|
|
|
2022-10-24 01:50:31 +02:00
|
|
|
eprintln!(
|
|
|
|
"csp headers: {:#?}",
|
|
|
|
response.headers().get("content-security-policy")
|
|
|
|
);
|
2023-07-05 14:26:39 +02:00
|
|
|
assert_ne!(response.headers().get("content-security-policy"), None);
|
2022-10-24 01:50:31 +02:00
|
|
|
}
|