mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 12:37:00 +01:00
* Bump jsonschema from 0.21.0 to 0.26.0 in the all group Bumps the all group with 1 update: [jsonschema](https://github.com/Stranger6667/jsonschema). Updates `jsonschema` from 0.21.0 to 0.26.0 - [Release notes](https://github.com/Stranger6667/jsonschema/releases) - [Changelog](https://github.com/Stranger6667/jsonschema/blob/master/CHANGELOG.md) - [Commits](https://github.com/Stranger6667/jsonschema/compare/rust-v0.21.0...rust-v0.26.0) --- updated-dependencies: - dependency-name: jsonschema dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all ... Signed-off-by: dependabot[bot] <support@github.com> * fixing up change in JSONschema errors --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Hodgkinson <james@terminaloutcomes.com> Co-authored-by: Firstyear <william@blackhats.net.au>
41 lines
1.3 KiB
Rust
41 lines
1.3 KiB
Rust
use jsonschema::Validator;
|
|
use serde::{Deserialize, Serialize};
|
|
use tracing::info;
|
|
|
|
#[kanidmd_testkit::test]
|
|
async fn check_that_the_swagger_api_loads(rsclient: kanidm_client::KanidmClient) {
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
struct OpenAPIResponse {
|
|
pub openapi: String,
|
|
}
|
|
|
|
rsclient.set_token("".into()).await;
|
|
info!("Running test: check_that_the_swagger_api_loads");
|
|
let url = rsclient.make_url("/docs/v1/openapi.json");
|
|
let openapi_response: OpenAPIResponse = reqwest::get(url.clone())
|
|
.await
|
|
.expect("Failed to get openapi.json")
|
|
.json()
|
|
.await
|
|
.unwrap();
|
|
assert_eq!(openapi_response.openapi, "3.0.3");
|
|
|
|
// this validates that it's valid JSON schema, but not that it's valid openapi... but it's a start.
|
|
let schema: serde_json::Value = reqwest::get(url)
|
|
.await
|
|
.expect("Failed to get openapi.json")
|
|
.json()
|
|
.await
|
|
.unwrap();
|
|
|
|
let instance = serde_json::json!("foo");
|
|
let compiled = Validator::new(&schema).expect("A valid schema");
|
|
assert!(jsonschema::is_valid(&schema, &instance));
|
|
let result = compiled.validate(&instance);
|
|
if let Err(errors) = result {
|
|
println!("ERRORS!");
|
|
println!("{:?}", errors);
|
|
panic!("Validation errors!");
|
|
}
|
|
}
|