kanidm/server/testkit/tests/routes.rs

682 lines
15 KiB
Rust
Raw Normal View History

Converting from tide to axum (#1797) * Starting to chase down testing * commenting out unused/inactive endpoints, adding more tests * clippyism * making clippy happy v2 * testing when things are not right * moar checkpoint * splitting up testkit things a bit * moving https -> tide * mad lad be crabbin * spawning like a frog * something something different spawning * woot it works ish * more server things * adding version header to requests * adding kopid_middleware * well that was supposed to be an hour... four later * more nonsense * carrying on with the conversion * first pass through the conversion is DONE! * less pub more better * session storage works better, fixed some paths * axum-csp version thing * try a typedheader * better openssl config things * updating lockfile * http2 * actually sending JSON when we say we will! * just about to do something dumb * flargl * more yak shaving * So many clippy-isms, fixing up a query handler bleep bloop * So many clippy-isms, fixing up a query handler bleep bloop * fmt * all tests pass including basic web logins and nav * so much clippyism * stripping out old comments * fmt * commenty things * stripping out tide * updates * de-tiding things * fmt * adding optional header matching ,thanks @cuberoot74088 * oauth2 stuff to match #1807 but in axum * CLIPPY IS FINALLY SATED * moving scim from /v1/scim to /scim * one day clippy will make sense * cleanups * removing sketching middleware * cleanup, strip a broken test endpoint (routemap), more clippy * docs fmt * pulling axum-csp from the wrong cargo.toml * docs fmt * fmt fixes
2023-07-05 14:26:39 +02:00
use kanidm_client::KanidmClient;
#[kanidmd_testkit::test]
async fn test_routes(rsclient: KanidmClient) {
let routemap = r#"
[
{
"path": "/",
"method": "GET"
},
{
"path": "/robots.txt",
"method": "GET"
},
{
"path": "/manifest.webmanifest",
"method": "GET"
},
{
2023-07-07 10:53:31 +02:00
"path": "/ui",
Converting from tide to axum (#1797) * Starting to chase down testing * commenting out unused/inactive endpoints, adding more tests * clippyism * making clippy happy v2 * testing when things are not right * moar checkpoint * splitting up testkit things a bit * moving https -> tide * mad lad be crabbin * spawning like a frog * something something different spawning * woot it works ish * more server things * adding version header to requests * adding kopid_middleware * well that was supposed to be an hour... four later * more nonsense * carrying on with the conversion * first pass through the conversion is DONE! * less pub more better * session storage works better, fixed some paths * axum-csp version thing * try a typedheader * better openssl config things * updating lockfile * http2 * actually sending JSON when we say we will! * just about to do something dumb * flargl * more yak shaving * So many clippy-isms, fixing up a query handler bleep bloop * So many clippy-isms, fixing up a query handler bleep bloop * fmt * all tests pass including basic web logins and nav * so much clippyism * stripping out old comments * fmt * commenty things * stripping out tide * updates * de-tiding things * fmt * adding optional header matching ,thanks @cuberoot74088 * oauth2 stuff to match #1807 but in axum * CLIPPY IS FINALLY SATED * moving scim from /v1/scim to /scim * one day clippy will make sense * cleanups * removing sketching middleware * cleanup, strip a broken test endpoint (routemap), more clippy * docs fmt * pulling axum-csp from the wrong cargo.toml * docs fmt * fmt fixes
2023-07-05 14:26:39 +02:00
"method": "GET"
},
{
2023-07-07 10:53:31 +02:00
"path": "/ui/login",
Converting from tide to axum (#1797) * Starting to chase down testing * commenting out unused/inactive endpoints, adding more tests * clippyism * making clippy happy v2 * testing when things are not right * moar checkpoint * splitting up testkit things a bit * moving https -> tide * mad lad be crabbin * spawning like a frog * something something different spawning * woot it works ish * more server things * adding version header to requests * adding kopid_middleware * well that was supposed to be an hour... four later * more nonsense * carrying on with the conversion * first pass through the conversion is DONE! * less pub more better * session storage works better, fixed some paths * axum-csp version thing * try a typedheader * better openssl config things * updating lockfile * http2 * actually sending JSON when we say we will! * just about to do something dumb * flargl * more yak shaving * So many clippy-isms, fixing up a query handler bleep bloop * So many clippy-isms, fixing up a query handler bleep bloop * fmt * all tests pass including basic web logins and nav * so much clippyism * stripping out old comments * fmt * commenty things * stripping out tide * updates * de-tiding things * fmt * adding optional header matching ,thanks @cuberoot74088 * oauth2 stuff to match #1807 but in axum * CLIPPY IS FINALLY SATED * moving scim from /v1/scim to /scim * one day clippy will make sense * cleanups * removing sketching middleware * cleanup, strip a broken test endpoint (routemap), more clippy * docs fmt * pulling axum-csp from the wrong cargo.toml * docs fmt * fmt fixes
2023-07-05 14:26:39 +02:00
"method": "GET"
},
{
"path": "/v1/account/:id/_unix/_token",
"method": "GET"
},
{
"path": "/v1/account/:id/_radius/_token",
"method": "GET"
},
{
"path": "/v1/group/:id/_unix/_token",
"method": "GET"
},
{
"path": "/v1/oauth2/:rs_name/_icon",
"method": "GET"
},
{
"path": "/status",
"method": "GET"
},
{
"path": "/oauth2/authorise",
"method": "POST"
},
{
"path": "/oauth2/authorise",
"method": "GET"
},
{
"path": "/oauth2/authorise/permit",
"method": "POST"
},
{
"path": "/oauth2/authorise/permit",
"method": "GET"
},
{
"path": "/oauth2/authorise/reject",
"method": "POST"
},
{
"path": "/oauth2/authorise/reject",
"method": "GET"
},
{
"path": "/oauth2/token",
"method": "POST"
},
{
"path": "/oauth2/token/introspect",
"method": "POST"
},
{
"path": "/oauth2/token/revoke",
"method": "POST"
},
{
"path": "/oauth2/openid/:client_id/.well-known/openid-configuration",
"method": "GET"
},
{
"path": "/oauth2/openid/:client_id/userinfo",
"method": "GET"
},
{
"path": "/oauth2/openid/:client_id/public_key.jwk",
"method": "GET"
},
{
"path": "/scim/v1/Sync",
"method": "POST"
},
{
"path": "/scim/v1/Sync",
"method": "GET"
},
{
"path": "/scim/v1/Sink",
"method": "GET"
},
{
"path": "/v1/sync_account",
"method": "GET"
},
{
"path": "/v1/sync_account",
"method": "POST"
},
{
"path": "/v1/sync_account/:id",
"method": "GET"
},
{
"path": "/v1/sync_account/:id",
"method": "PATCH"
},
{
"path": "/v1/sync_account/:id/_finalise",
"method": "GET"
},
{
"path": "/v1/sync_account/:id/_terminate",
"method": "GET"
},
{
"path": "/v1/sync_account/:id/_sync_token",
"method": "POST"
},
{
"path": "/v1/sync_account/:id/_sync_token",
"method": "DELETE"
},
{
"path": "/v1/raw/create",
"method": "POST"
},
{
"path": "/v1/raw/modify",
"method": "POST"
},
{
"path": "/v1/raw/delete",
"method": "POST"
},
{
"path": "/v1/raw/search",
"method": "POST"
},
{
"path": "/v1/auth",
"method": "POST"
},
{
"path": "/v1/auth/valid",
"method": "GET"
},
{
"path": "/v1/reauth",
"method": "POST"
},
{
"path": "/v1/logout",
"method": "GET"
},
{
"path": "/v1/schema",
"method": "GET"
},
{
"path": "/v1/schema/attributetype",
"method": "GET"
},
{
"path": "/v1/schema/attributetype",
"method": "POST"
},
{
"path": "/v1/schema/attributetype/:id",
"method": "GET"
},
{
"path": "/v1/schema/attributetype/:id",
"method": "PUT"
},
{
"path": "/v1/schema/attributetype/:id",
"method": "PATCH"
},
{
"path": "/v1/schema/classtype",
"method": "GET"
},
{
"path": "/v1/schema/classtype",
"method": "POST"
},
{
"path": "/v1/schema/classtype/:id",
"method": "GET"
},
{
"path": "/v1/schema/classtype/:id",
"method": "PUT"
},
{
"path": "/v1/schema/classtype/:id",
"method": "PATCH"
},
{
"path": "/v1/oauth2",
"method": "GET"
},
{
"path": "/v1/oauth2/_basic",
"method": "POST"
},
{
"path": "/v1/oauth2/:rs_name",
"method": "GET"
},
{
"path": "/v1/oauth2/:rs_name",
"method": "PATCH"
},
{
"path": "/v1/oauth2/:rs_name",
"method": "DELETE"
},
{
"path": "/v1/oauth2/:rs_name/_basic_secret",
"method": "GET"
},
{
"path": "/v1/oauth2/_scopemap/:id/:group",
"method": "POST"
},
{
"path": "/v1/oauth2/_scopemap/:id/:group",
"method": "DELETE"
},
{
"path": "/v1/oauth2/_sup_scopemap/:id/:group",
"method": "POST"
},
{
"path": "/v1/oauth2/_sup_scopemap/:id/:group",
"method": "DELETE"
},
{
"path": "/v1/self",
"method": "GET"
},
{
"path": "/v1/self/_uat",
"method": "GET"
},
{
"path": "/v1/self/_attr/:attr",
"method": "GET"
},
{
"path": "/v1/self/_credential",
"method": "GET"
},
{
"path": "/v1/self/_credential/:cid/_lock",
"method": "GET"
},
{
"path": "/v1/self/_radius",
"method": "GET"
},
{
"path": "/v1/self/_radius",
"method": "DELETE"
},
{
"path": "/v1/self/_radius",
"method": "POST"
},
{
"path": "/v1/self/_radius/_config",
"method": "POST"
},
{
"path": "/v1/self/_radius/_config/:token",
"method": "GET"
},
{
"path": "/v1/self/_radius/_config/:token/apple",
"method": "GET"
},
{
"path": "/v1/self/_applinks",
"method": "GET"
},
{
"path": "/v1/person",
"method": "GET"
},
{
"path": "/v1/person",
"method": "POST"
},
{
"path": "/v1/person/:id",
"method": "GET"
},
{
"path": "/v1/person/:id",
"method": "PATCH"
},
{
"path": "/v1/person/:id",
"method": "DELETE"
},
{
"path": "/v1/person/:id/_attr/:attr",
"method": "GET"
},
{
"path": "/v1/person/:id/_attr/:attr",
"method": "PUT"
},
{
"path": "/v1/person/:id/_attr/:attr",
"method": "POST"
},
{
"path": "/v1/person/:id/_attr/:attr",
"method": "DELETE"
},
{
"path": "/v1/person/:id/_lock",
"method": "GET"
},
{
"path": "/v1/person/:id/_credential",
"method": "GET"
},
{
"path": "/v1/person/:id/_credential/_status",
"method": "GET"
},
{
"path": "/v1/person/:id/_credential/:cid/_lock",
"method": "GET"
},
{
"path": "/v1/person/:id/_credential/_update",
"method": "GET"
},
{
"path": "/v1/person/:id/_credential/_update_intent",
"method": "GET"
},
{
"path": "/v1/person/:id/_credential/_update_intent/:ttl",
"method": "GET"
},
{
"path": "/v1/person/:id/_ssh_pubkeys",
"method": "GET"
},
{
"path": "/v1/person/:id/_ssh_pubkeys",
"method": "POST"
},
{
"path": "/v1/person/:id/_ssh_pubkeys/:tag",
"method": "GET"
},
{
"path": "/v1/person/:id/_ssh_pubkeys/:tag",
"method": "DELETE"
},
{
"path": "/v1/person/:id/_radius",
"method": "GET"
},
{
"path": "/v1/person/:id/_radius",
"method": "POST"
},
{
"path": "/v1/person/:id/_radius",
"method": "DELETE"
},
{
"path": "/v1/person/:id/_unix",
"method": "POST"
},
{
"path": "/v1/person/:id/_unix/_credential",
"method": "PUT"
},
{
"path": "/v1/person/:id/_unix/_credential",
"method": "DELETE"
},
{
"path": "/v1/service_account",
"method": "GET"
},
{
"path": "/v1/service_account",
"method": "POST"
},
{
"path": "/v1/service_account/:id",
"method": "GET"
},
{
"path": "/v1/service_account/:id",
"method": "PATCH"
},
{
"path": "/v1/service_account/:id",
"method": "DELETE"
},
{
"path": "/v1/service_account/:id/_attr/:attr",
"method": "GET"
},
{
"path": "/v1/service_account/:id/_attr/:attr",
"method": "PUT"
},
{
"path": "/v1/service_account/:id/_attr/:attr",
"method": "POST"
},
{
"path": "/v1/service_account/:id/_attr/:attr",
"method": "DELETE"
},
{
"path": "/v1/service_account/:id/_lock",
"method": "GET"
},
{
"path": "/v1/service_account/:id/_into_person",
"method": "POST"
},
{
"path": "/v1/service_account/:id/_api_token",
"method": "POST"
},
{
"path": "/v1/service_account/:id/_api_token",
"method": "GET"
},
{
"path": "/v1/service_account/:id/_api_token/:token_id",
"method": "DELETE"
},
{
"path": "/v1/service_account/:id/_credential",
"method": "GET"
},
{
"path": "/v1/service_account/:id/_credential/_generate",
"method": "GET"
},
{
"path": "/v1/service_account/:id/_credential/_status",
"method": "GET"
},
{
"path": "/v1/service_account/:id/_credential/:cid/_lock",
"method": "GET"
},
{
"path": "/v1/service_account/:id/_ssh_pubkeys",
"method": "GET"
},
{
"path": "/v1/service_account/:id/_ssh_pubkeys",
"method": "POST"
},
{
"path": "/v1/service_account/:id/_ssh_pubkeys/:tag",
"method": "GET"
},
{
"path": "/v1/service_account/:id/_ssh_pubkeys/:tag",
"method": "DELETE"
},
{
"path": "/v1/service_account/:id/_unix",
"method": "POST"
},
{
"path": "/v1/account/:id/_unix/_auth",
"method": "POST"
},
{
"path": "/v1/account/:id/_ssh_pubkeys",
"method": "GET"
},
{
"path": "/v1/account/:id/_ssh_pubkeys/:tag",
"method": "GET"
},
{
"path": "/v1/account/:id/_user_auth_token",
"method": "GET"
},
{
"path": "/v1/account/:id/_user_auth_token/:token_id",
"method": "DELETE"
},
{
"path": "/v1/credential/_exchange_intent",
"method": "POST"
},
{
"path": "/v1/credential/_status",
"method": "POST"
},
{
"path": "/v1/credential/_update",
"method": "POST"
},
{
"path": "/v1/credential/_commit",
"method": "POST"
},
{
"path": "/v1/credential/_cancel",
"method": "POST"
},
{
"path": "/v1/group",
"method": "GET"
},
{
"path": "/v1/group",
"method": "POST"
},
{
"path": "/v1/group/:id",
"method": "GET"
},
{
"path": "/v1/group/:id",
"method": "DELETE"
},
{
"path": "/v1/group/:id/_attr/:attr",
"method": "DELETE"
},
{
"path": "/v1/group/:id/_attr/:attr",
"method": "GET"
},
{
"path": "/v1/group/:id/_attr/:attr",
"method": "PUT"
},
{
"path": "/v1/group/:id/_attr/:attr",
"method": "POST"
},
{
"path": "/v1/group/:id/_unix",
"method": "POST"
},
{
"path": "/v1/domain",
"method": "GET"
},
{
"path": "/v1/domain/_attr/:attr",
"method": "GET"
},
{
"path": "/v1/domain/_attr/:attr",
"method": "PUT"
},
{
"path": "/v1/domain/_attr/:attr",
"method": "DELETE"
},
{
"path": "/v1/system",
"method": "GET"
},
{
"path": "/v1/system/_attr/:attr",
"method": "GET"
},
{
"path": "/v1/system/_attr/:attr",
"method": "POST"
},
{
"path": "/v1/system/_attr/:attr",
"method": "DELETE"
},
{
"path": "/v1/recycle_bin",
"method": "GET"
},
{
"path": "/v1/recycle_bin/:id",
"method": "GET"
},
{
"path": "/v1/recycle_bin/:id/_revive",
"method": "POST"
},
{
"path": "/v1/access_profile",
"method": "GET"
},
{
"path": "/v1/access_profile/:id",
"method": "GET"
},
{
"path": "/v1/access_profile/:id/_attr/:attr",
"method": "GET"
}
]
"#;
// ,{
// "path": "/v1/routemap",
// "method": "GET"
// }
let routelist: Vec<serde_json::Value> = serde_json::from_str(routemap).unwrap();
let client = reqwest::ClientBuilder::new()
.danger_accept_invalid_certs(true)
.danger_accept_invalid_hostnames(true)
.build()
.unwrap();
for route in routelist {
// println!("{:?}", route);
let path: String = route.get("path").unwrap().to_string();
let method: String = route.get("method").unwrap().to_string();
let method = method.replace('"', "");
let method = method.as_str();
println!("'{method}'");
let method = match method {
"GET" => reqwest::Method::GET,
"POST" => reqwest::Method::POST,
"DELETE" => reqwest::Method::DELETE,
"PATCH" => reqwest::Method::PATCH,
"PUT" => reqwest::Method::PUT,
_ => todo!("{}", method),
};
if path.contains(':') {
println!("Can't do this because it has an attribute: {}", path);
continue;
}
let url = format!("{}{}", rsclient.get_url(), path.replace('"', ""));
println!("#### {:?} {} {}", method, path, url);
let res = match client
.request(method, &url)
// .version(http::Version::HTTP_11)
.send()
.await
{
Ok(val) => val,
Err(error) => {
panic!("Failed to query {:?} : {:#?}", url, error);
}
};
if res.status() == 404 {
panic!("Failed to query {:?} : {:#?}", url, res);
}
}
}