diff --git a/crates/robonode-client/src/authenticate.rs b/crates/robonode-client/src/authenticate.rs index da86dfcf5..2460583d8 100644 --- a/crates/robonode-client/src/authenticate.rs +++ b/crates/robonode-client/src/authenticate.rs @@ -96,7 +96,7 @@ mod tests { use wiremock::{matchers, Mock, MockServer, ResponseTemplate}; use super::*; - use crate::test_utils::{mkerr, mkerr_containing_blob}; + use crate::test_utils::{mkerr, mkerr_before_2023_05}; #[test] fn request_serialization() { @@ -115,7 +115,7 @@ mod tests { } #[test] - fn response_deserialization() { + fn response_deserialization_before_2023_05() { let sample_response = serde_json::json!({ "authTicket": [1, 2, 3], "authTicketSignature": [4, 5, 6], @@ -132,7 +132,7 @@ mod tests { } #[test] - fn response_deserialization_containing_blob() { + fn response_deserialization() { let sample_response = serde_json::json!({ "authTicket": [1, 2, 3], "authTicketSignature": [4, 5, 6], @@ -150,7 +150,7 @@ mod tests { } #[tokio::test] - async fn mock_success() { + async fn mock_success_before_2023_05() { let mock_server = MockServer::start().await; let sample_request = AuthenticateRequest { @@ -182,7 +182,7 @@ mod tests { } #[tokio::test] - async fn mock_success_containing_blob() { + async fn mock_success() { let mock_server = MockServer::start().await; let sample_request = AuthenticateRequest { @@ -215,7 +215,7 @@ mod tests { } #[tokio::test] - async fn mock_error_response() { + async fn mock_error_response_before_2023_05() { let cases = [ ( StatusCode::BAD_REQUEST, @@ -257,7 +257,8 @@ mod tests { liveness_data_signature: b"123", }; - let response = ResponseTemplate::new(case.0).set_body_json(mkerr(case.1)); + let response = + ResponseTemplate::new(case.0).set_body_json(mkerr_before_2023_05(case.1)); Mock::given(matchers::method("POST")) .and(matchers::path("/authenticate")) @@ -277,7 +278,7 @@ mod tests { } #[tokio::test] - async fn mock_error_response_containing_blob() { + async fn mock_error_response() { let cases = [ ( StatusCode::BAD_REQUEST, @@ -320,7 +321,7 @@ mod tests { }; let response = - ResponseTemplate::new(case.0).set_body_json(mkerr_containing_blob(case.1, "blob")); + ResponseTemplate::new(case.0).set_body_json(mkerr(case.1, "scan result blob")); Mock::given(matchers::method("POST")) .and(matchers::path("/authenticate")) diff --git a/crates/robonode-client/src/enroll.rs b/crates/robonode-client/src/enroll.rs index 55c96f5c9..388314f6a 100644 --- a/crates/robonode-client/src/enroll.rs +++ b/crates/robonode-client/src/enroll.rs @@ -89,7 +89,7 @@ mod tests { use wiremock::{matchers, Mock, MockServer, ResponseTemplate}; use super::*; - use crate::test_utils::{mkerr, mkerr_containing_blob}; + use crate::test_utils::{mkerr, mkerr_before_2023_05}; #[test] fn request_serialization() { @@ -110,7 +110,7 @@ mod tests { } #[tokio::test] - async fn mock_success() { + async fn mock_success_before_2023_05() { let mock_server = MockServer::start().await; let sample_request = EnrollRequest { @@ -135,7 +135,7 @@ mod tests { } #[tokio::test] - async fn mock_success_containing_blob() { + async fn mock_success() { let mock_server = MockServer::start().await; let sample_request = EnrollRequest { @@ -163,7 +163,7 @@ mod tests { } #[tokio::test] - async fn mock_error_response() { + async fn mock_error_response_before_2023_05() { let cases = [ ( StatusCode::BAD_REQUEST, @@ -211,7 +211,8 @@ mod tests { public_key: b"123", }; - let response = ResponseTemplate::new(case.0).set_body_json(mkerr(case.1)); + let response = + ResponseTemplate::new(case.0).set_body_json(mkerr_before_2023_05(case.1)); Mock::given(matchers::method("POST")) .and(matchers::path("/enroll")) @@ -231,7 +232,7 @@ mod tests { } #[tokio::test] - async fn mock_error_response_containing_blob() { + async fn mock_error_response() { let cases = [ ( StatusCode::BAD_REQUEST, @@ -280,7 +281,7 @@ mod tests { }; let response = - ResponseTemplate::new(case.0).set_body_json(mkerr_containing_blob(case.1, "blob")); + ResponseTemplate::new(case.0).set_body_json(mkerr(case.1, "scan result blob")); Mock::given(matchers::method("POST")) .and(matchers::path("/enroll")) diff --git a/crates/robonode-client/src/error_response.rs b/crates/robonode-client/src/error_response.rs index 3fbed2e01..0a5ffd76e 100644 --- a/crates/robonode-client/src/error_response.rs +++ b/crates/robonode-client/src/error_response.rs @@ -21,18 +21,18 @@ impl TryFrom for ErrorResponse { #[cfg(test)] pub mod tests { use super::*; - use crate::test_utils::{mkerr, mkerr_containing_blob}; + use crate::test_utils::{mkerr, mkerr_before_2023_05}; #[test] - fn decodes() { - let err = mkerr("MY_ERR_CODE").to_string(); + fn decodes_before_2023_05() { + let err = mkerr_before_2023_05("MY_ERR_CODE").to_string(); let ErrorResponse { error_code } = err.try_into().unwrap(); assert_eq!(error_code, "MY_ERR_CODE"); } #[test] - fn decodes_containing_blob() { - let err = mkerr_containing_blob("MY_ERR_CODE", "scan result blob").to_string(); + fn decodes() { + let err = mkerr("MY_ERR_CODE", "scan result blob").to_string(); let ErrorResponse { error_code } = err.try_into().unwrap(); assert_eq!(error_code, "MY_ERR_CODE"); } diff --git a/crates/robonode-client/src/test_utils.rs b/crates/robonode-client/src/test_utils.rs index 624e34460..5ea782ecc 100644 --- a/crates/robonode-client/src/test_utils.rs +++ b/crates/robonode-client/src/test_utils.rs @@ -1,8 +1,8 @@ -pub fn mkerr(error_code: &str) -> serde_json::Value { +pub fn mkerr_before_2023_05(error_code: &str) -> serde_json::Value { serde_json::json!({ "errorCode": error_code }) } -pub fn mkerr_containing_blob(error_code: &str, scan_result_blob: &str) -> serde_json::Value { +pub fn mkerr(error_code: &str, scan_result_blob: &str) -> serde_json::Value { serde_json::json!({ "errorCode": error_code, "scanResultBlob": scan_result_blob }) } @@ -13,12 +13,12 @@ mod tests { #[test] fn evals_properly() { assert_eq!( - mkerr("MY_ERR_CODE").to_string(), + mkerr_before_2023_05("MY_ERR_CODE").to_string(), serde_json::json!({ "errorCode": "MY_ERR_CODE" }).to_string() ); assert_eq!( - mkerr_containing_blob("MY_ERR_CODE", "scan result blob").to_string(), + mkerr("MY_ERR_CODE", "scan result blob").to_string(), serde_json::json!({ "errorCode": "MY_ERR_CODE", "scanResultBlob": "scan result blob" }) .to_string() );