Skip to content

Commit

Permalink
fix: code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
cdmurph32 committed Feb 24, 2025
1 parent c2e3e08 commit bb048e9
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,53 @@ impl TimeStampProvider for EcdsaSigner {
self.time_stamp_service_url.clone()
}
}

#[cfg(test)]
mod tests {
use super::*;
use crate::raw_signature::SigningAlg;

#[test]
fn test_es512_not_supported() {
let cert_chain = include_bytes!("../../../tests/fixtures/raw_signature/es512.pub");
let private_key = include_bytes!("../../../tests/fixtures/raw_signature/es512.priv");
let algorithm = SigningAlg::Es512;
let time_stamp_service_url = None;

let result = EcdsaSigner::from_cert_chain_and_private_key(
cert_chain,
private_key,
algorithm,
time_stamp_service_url,
);

assert!(result.is_err());
if let Err(RawSignerError::InvalidSigningCredentials(err_msg)) = result {
assert_eq!(err_msg, "Rust Crypto does not support Es512, only OpenSSL");
} else {
unreachable!("Expected InvalidSigningCredentials error");

Check warning on line 169 in internal/crypto/src/raw_signature/rust_native/signers/ecdsa_signer.rs

View check run for this annotation

Codecov / codecov/patch

internal/crypto/src/raw_signature/rust_native/signers/ecdsa_signer.rs#L169

Added line #L169 was not covered by tests
}
}

#[test]
fn test_other_not_supported() {
let cert_chain = include_bytes!("../../../tests/fixtures/raw_signature/ps256.pub");
let private_key = include_bytes!("../../../tests/fixtures/raw_signature/ps256.priv");
let algorithm = SigningAlg::Ps256;
let time_stamp_service_url = None;

let result = EcdsaSigner::from_cert_chain_and_private_key(
cert_chain,
private_key,
algorithm,
time_stamp_service_url,
);

assert!(result.is_err());
if let Err(RawSignerError::InvalidSigningCredentials(err_msg)) = result {
assert_eq!(err_msg, "Unsupported algorithm");
} else {
unreachable!("Expected InvalidSigningCredentials error");

Check warning on line 191 in internal/crypto/src/raw_signature/rust_native/signers/ecdsa_signer.rs

View check run for this annotation

Codecov / codecov/patch

internal/crypto/src/raw_signature/rust_native/signers/ecdsa_signer.rs#L191

Added line #L191 was not covered by tests
}
}
}

0 comments on commit bb048e9

Please sign in to comment.