Browse Source

Fix the certificate generation tests

pull/39/head
Rodolphe Breard 4 years ago
parent
commit
7292cc68ca
  1. 26
      acme_common/src/tests/certificate.rs

26
acme_common/src/tests/certificate.rs

@ -1,4 +1,4 @@
use crate::crypto::{KeyType, X509Certificate};
use crate::crypto::{HashFunction, KeyType, X509Certificate};
use std::collections::HashSet; use std::collections::HashSet;
use std::iter::FromIterator; use std::iter::FromIterator;
@ -85,38 +85,50 @@ fn test_san_domains_and_ip() {
#[test] #[test]
fn generate_rsa2048_certificate() { fn generate_rsa2048_certificate() {
let (kp, _) = X509Certificate::from_acme_ext("example.org", "", KeyType::Rsa2048).unwrap();
let (kp, _) =
X509Certificate::from_acme_ext("example.org", "", KeyType::Rsa2048, HashFunction::Sha256)
.unwrap();
assert_eq!(kp.key_type, KeyType::Rsa2048); assert_eq!(kp.key_type, KeyType::Rsa2048);
} }
#[test] #[test]
fn generate_rsa4096_certificate() { fn generate_rsa4096_certificate() {
let (kp, _) = X509Certificate::from_acme_ext("example.org", "", KeyType::Rsa4096).unwrap();
let (kp, _) =
X509Certificate::from_acme_ext("example.org", "", KeyType::Rsa4096, HashFunction::Sha256)
.unwrap();
assert_eq!(kp.key_type, KeyType::Rsa4096); assert_eq!(kp.key_type, KeyType::Rsa4096);
} }
#[test] #[test]
fn generate_ecdsa_p256_certificate() { fn generate_ecdsa_p256_certificate() {
let (kp, _) = X509Certificate::from_acme_ext("example.org", "", KeyType::EcdsaP256).unwrap();
let (kp, _) =
X509Certificate::from_acme_ext("example.org", "", KeyType::EcdsaP256, HashFunction::Sha256)
.unwrap();
assert_eq!(kp.key_type, KeyType::EcdsaP256); assert_eq!(kp.key_type, KeyType::EcdsaP256);
} }
#[test] #[test]
fn generate_ecdsa_p384_certificate() { fn generate_ecdsa_p384_certificate() {
let (kp, _) = X509Certificate::from_acme_ext("example.org", "", KeyType::EcdsaP384).unwrap();
let (kp, _) =
X509Certificate::from_acme_ext("example.org", "", KeyType::EcdsaP384, HashFunction::Sha256)
.unwrap();
assert_eq!(kp.key_type, KeyType::EcdsaP384); assert_eq!(kp.key_type, KeyType::EcdsaP384);
} }
#[cfg(ed25519)] #[cfg(ed25519)]
#[test] #[test]
fn generate_ed25519_certificate() { fn generate_ed25519_certificate() {
let (kp, _) = X509Certificate::from_acme_ext("example.org", "", KeyType::Ed25519).unwrap();
let (kp, _) =
X509Certificate::from_acme_ext("example.org", "", KeyType::Ed25519, HashFunction::Sha256)
.unwrap();
assert_eq!(kp.key_type, KeyType::Ed25519); assert_eq!(kp.key_type, KeyType::Ed25519);
} }
#[cfg(ed448)] #[cfg(ed448)]
#[test] #[test]
fn generate_ed448_certificate() { fn generate_ed448_certificate() {
let (kp, _) = X509Certificate::from_acme_ext("example.org", "", KeyType::Ed448).unwrap();
let (kp, _) =
X509Certificate::from_acme_ext("example.org", "", KeyType::Ed448, HashFunction::Sha256)
.unwrap();
assert_eq!(kp.key_type, KeyType::Ed448); assert_eq!(kp.key_type, KeyType::Ed448);
} }
Loading…
Cancel
Save