Skip to content

Commit

Permalink
Properly use blob related cases in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrylavrenov committed Sep 16, 2024
1 parent 331ac4e commit c33af4a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 76 deletions.
44 changes: 2 additions & 42 deletions crates/robonode-client/src/authenticate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,41 +268,21 @@ mod tests {
"AUTHENTICATE_PERSON_NOT_FOUND",
AuthenticateError::PersonNotFoundNoBlob,
),
(
StatusCode::NOT_FOUND,
"AUTHENTICATE_PERSON_NOT_FOUND",
AuthenticateError::PersonNotFound("scan result blob".to_owned()),
),
(
StatusCode::FORBIDDEN,
"AUTHENTICATE_FACE_SCAN_REJECTED",
AuthenticateError::FaceScanRejectedNoBlob,
),
(
StatusCode::FORBIDDEN,
"AUTHENTICATE_FACE_SCAN_REJECTED",
AuthenticateError::FaceScanRejected("scan result blob".to_owned()),
),
(
StatusCode::FORBIDDEN,
"AUTHENTICATE_SIGNATURE_INVALID",
AuthenticateError::SignatureInvalidNoBlob,
),
(
StatusCode::FORBIDDEN,
"AUTHENTICATE_SIGNATURE_INVALID",
AuthenticateError::SignatureInvalid("scan result blob".to_owned()),
),
(
StatusCode::INTERNAL_SERVER_ERROR,
"LOGIC_INTERNAL_ERROR",
AuthenticateError::LogicInternalNoBlob,
),
(
StatusCode::INTERNAL_SERVER_ERROR,
"LOGIC_INTERNAL_ERROR",
AuthenticateError::LogicInternal("scan result blob".to_owned()),
),
(
StatusCode::BAD_REQUEST,
"MY_ERR_CODE",
Expand Down Expand Up @@ -345,41 +325,21 @@ mod tests {
"AUTHENTICATE_INVALID_LIVENESS_DATA",
AuthenticateError::InvalidLivenessData,
),
(
StatusCode::NOT_FOUND,
"AUTHENTICATE_PERSON_NOT_FOUND",
AuthenticateError::PersonNotFoundNoBlob,
),
(
StatusCode::NOT_FOUND,
"AUTHENTICATE_PERSON_NOT_FOUND",
AuthenticateError::PersonNotFound("scan result blob".to_owned()),
),
(
StatusCode::FORBIDDEN,
"AUTHENTICATE_FACE_SCAN_REJECTED",
AuthenticateError::FaceScanRejectedNoBlob,
),
(
StatusCode::FORBIDDEN,
"AUTHENTICATE_FACE_SCAN_REJECTED",
AuthenticateError::FaceScanRejected("scan result blob".to_owned()),
),
(
StatusCode::FORBIDDEN,
"AUTHENTICATE_SIGNATURE_INVALID",
AuthenticateError::SignatureInvalidNoBlob,
),
(
StatusCode::FORBIDDEN,
"AUTHENTICATE_SIGNATURE_INVALID",
AuthenticateError::SignatureInvalid("scan result blob".to_owned()),
),
(
StatusCode::INTERNAL_SERVER_ERROR,
"LOGIC_INTERNAL_ERROR",
AuthenticateError::LogicInternalNoBlob,
),
(
StatusCode::INTERNAL_SERVER_ERROR,
"LOGIC_INTERNAL_ERROR",
Expand All @@ -400,8 +360,8 @@ mod tests {
liveness_data_signature: b"123",
};

let response =
ResponseTemplate::new(case.0).set_body_json(mkerr_containing_blob(case.1, "blob"));
let response = ResponseTemplate::new(case.0)
.set_body_json(mkerr_containing_blob(case.1, "scan result blob"));

Mock::given(matchers::method("POST"))
.and(matchers::path("/authenticate"))
Expand Down
38 changes: 4 additions & 34 deletions crates/robonode-client/src/enroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ impl Client {
let res = self.reqwest.post(url).json(&req).send().await?;
match res.status() {
StatusCode::CREATED if res.content_length() == Some(0) => Ok(EnrollResponse {
scan_result_blob: None,
})
scan_result_blob: None,
}),
StatusCode::CREATED => Ok(res.json().await?),
status => Err(Error::Call(EnrollError::from_response(
status,
Expand Down Expand Up @@ -222,11 +222,6 @@ mod tests {
"ENROLL_FACE_SCAN_REJECTED",
EnrollError::FaceScanRejectedNoBlob,
),
(
StatusCode::FORBIDDEN,
"ENROLL_FACE_SCAN_REJECTED",
EnrollError::FaceScanRejected("scan result blob".to_owned()),
),
(
StatusCode::CONFLICT,
"ENROLL_PUBLIC_KEY_ALREADY_USED",
Expand All @@ -237,21 +232,11 @@ mod tests {
"ENROLL_PERSON_ALREADY_ENROLLED",
EnrollError::PersonAlreadyEnrolledNoBlob,
),
(
StatusCode::CONFLICT,
"ENROLL_PERSON_ALREADY_ENROLLED",
EnrollError::PersonAlreadyEnrolled("scan result blob".to_owned()),
),
(
StatusCode::INTERNAL_SERVER_ERROR,
"LOGIC_INTERNAL_ERROR",
EnrollError::LogicInternalNoBlob,
),
(
StatusCode::INTERNAL_SERVER_ERROR,
"LOGIC_INTERNAL_ERROR",
EnrollError::LogicInternal("scan result blob".to_owned()),
),
(
StatusCode::BAD_REQUEST,
"MY_ERR_CODE",
Expand Down Expand Up @@ -300,11 +285,6 @@ mod tests {
"ENROLL_INVALID_LIVENESS_DATA",
EnrollError::InvalidLivenessData,
),
(
StatusCode::FORBIDDEN,
"ENROLL_FACE_SCAN_REJECTED",
EnrollError::FaceScanRejectedNoBlob,
),
(
StatusCode::FORBIDDEN,
"ENROLL_FACE_SCAN_REJECTED",
Expand All @@ -315,21 +295,11 @@ mod tests {
"ENROLL_PUBLIC_KEY_ALREADY_USED",
EnrollError::PublicKeyAlreadyUsed,
),
(
StatusCode::CONFLICT,
"ENROLL_PERSON_ALREADY_ENROLLED",
EnrollError::PersonAlreadyEnrolledNoBlob,
),
(
StatusCode::CONFLICT,
"ENROLL_PERSON_ALREADY_ENROLLED",
EnrollError::PersonAlreadyEnrolled("scan result blob".to_owned()),
),
(
StatusCode::INTERNAL_SERVER_ERROR,
"LOGIC_INTERNAL_ERROR",
EnrollError::LogicInternalNoBlob,
),
(
StatusCode::INTERNAL_SERVER_ERROR,
"LOGIC_INTERNAL_ERROR",
Expand All @@ -351,8 +321,8 @@ mod tests {
public_key: b"123",
};

let response =
ResponseTemplate::new(case.0).set_body_json(mkerr_containing_blob(case.1, "blob"));
let response = ResponseTemplate::new(case.0)
.set_body_json(mkerr_containing_blob(case.1, "scan result blob"));

Mock::given(matchers::method("POST"))
.and(matchers::path("/enroll"))
Expand Down

0 comments on commit c33af4a

Please sign in to comment.