diff --git a/mithril-aggregator/src/http_server/routes/certificate_routes.rs b/mithril-aggregator/src/http_server/routes/certificate_routes.rs index 001331382d5..082b306756a 100644 --- a/mithril-aggregator/src/http_server/routes/certificate_routes.rs +++ b/mithril-aggregator/src/http_server/routes/certificate_routes.rs @@ -86,8 +86,6 @@ mod handlers { #[cfg(test)] mod tests { - const API_SPEC_FILE: &str = "../openapi.yaml"; - use crate::http_server::SERVER_BASE_PATH; use mithril_common::store::adapter::FailStoreAdapter; use mithril_common::test_utils::apispec::APISpec; @@ -125,13 +123,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&Null) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&Null) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -147,13 +147,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&Null) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&Null) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -168,13 +170,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&Null) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&Null) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -195,13 +199,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&Null) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&Null) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -217,13 +223,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&Null) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&Null) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -244,12 +252,14 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&Null) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&Null) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } } diff --git a/mithril-aggregator/src/http_server/routes/epoch_routes.rs b/mithril-aggregator/src/http_server/routes/epoch_routes.rs index 9d392e34e3a..99fede8ef66 100644 --- a/mithril-aggregator/src/http_server/routes/epoch_routes.rs +++ b/mithril-aggregator/src/http_server/routes/epoch_routes.rs @@ -84,8 +84,6 @@ mod handlers { #[cfg(test)] mod tests { - const API_SPEC_FILE: &str = "../openapi.yaml"; - use crate::http_server::SERVER_BASE_PATH; use mithril_common::test_utils::apispec::APISpec; use serde_json::Value::Null; @@ -120,13 +118,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&Null) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&Null) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -141,12 +141,14 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&Null) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&Null) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } } diff --git a/mithril-aggregator/src/http_server/routes/signatures_routes.rs b/mithril-aggregator/src/http_server/routes/signatures_routes.rs index 5fa93a1e18a..01291707f4c 100644 --- a/mithril-aggregator/src/http_server/routes/signatures_routes.rs +++ b/mithril-aggregator/src/http_server/routes/signatures_routes.rs @@ -56,7 +56,6 @@ mod handlers { #[cfg(test)] mod tests { - const API_SPEC_FILE: &str = "../openapi.yaml"; use crate::http_server::SERVER_BASE_PATH; use mithril_common::messages::RegisterSignatureMessage; @@ -106,13 +105,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&message) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&message) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -137,13 +138,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&message) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&message) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -170,13 +173,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&message) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&message) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -203,12 +208,14 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&message) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&message) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } } diff --git a/mithril-aggregator/src/http_server/routes/signer_routes.rs b/mithril-aggregator/src/http_server/routes/signer_routes.rs index 7ffb138b3b4..6e24b307418 100644 --- a/mithril-aggregator/src/http_server/routes/signer_routes.rs +++ b/mithril-aggregator/src/http_server/routes/signer_routes.rs @@ -116,8 +116,6 @@ mod handlers { #[cfg(test)] mod tests { - const API_SPEC_FILE: &str = "../openapi.yaml"; - use mithril_common::crypto_helper::ProtocolRegistrationError; use mithril_common::messages::RegisterSignerMessage; use mithril_common::test_utils::apispec::APISpec; @@ -165,13 +163,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&signer) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&signer) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -196,13 +196,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&signer) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&signer) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -230,13 +232,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&signer) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&signer) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -263,12 +267,14 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&signer) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&signer) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } } diff --git a/mithril-aggregator/src/http_server/routes/snapshot_routes.rs b/mithril-aggregator/src/http_server/routes/snapshot_routes.rs index 461cc6d351f..105b0972cec 100644 --- a/mithril-aggregator/src/http_server/routes/snapshot_routes.rs +++ b/mithril-aggregator/src/http_server/routes/snapshot_routes.rs @@ -173,8 +173,6 @@ mod handlers { #[cfg(test)] mod tests { - const API_SPEC_FILE: &str = "../openapi.yaml"; - use crate::http_server::SERVER_BASE_PATH; use mithril_common::test_utils::apispec::APISpec; use mithril_common::test_utils::fake_data; @@ -220,13 +218,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&Null) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&Null) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -250,13 +250,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&Null) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&Null) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -279,14 +281,16 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .content_type("application/gzip") - .validate_request(&Null) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .content_type("application/gzip") + .validate_request(&Null) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -308,13 +312,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&Null) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&Null) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -338,13 +344,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&Null) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&Null) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -367,13 +375,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&Null) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&Null) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -395,13 +405,15 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&Null) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&Null) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } #[tokio::test] @@ -425,12 +437,14 @@ mod tests { .reply(&setup_router(Arc::new(dependency_manager))) .await; - APISpec::from_file(API_SPEC_FILE) - .method(method) - .path(path) - .validate_request(&Null) - .unwrap() - .validate_response(&response) - .expect("OpenAPI error"); + for spec_file in APISpec::get_all_spec_files() { + APISpec::from_file(&spec_file) + .method(method) + .path(path) + .validate_request(&Null) + .unwrap() + .validate_response(&response) + .unwrap_or_else(|_| panic!("OpenAPI error in {}", spec_file)); + } } }