From ea02e9029292a17866c6f3cbe6151d496cdcd08c Mon Sep 17 00:00:00 2001 From: Rodolphe Breard Date: Mon, 24 Aug 2020 10:30:09 +0200 Subject: [PATCH] Fix the JWS tests --- acmed/src/jws.rs | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/acmed/src/jws.rs b/acmed/src/jws.rs index 1f1b376..2c5f6b0 100644 --- a/acmed/src/jws.rs +++ b/acmed/src/jws.rs @@ -89,10 +89,17 @@ mod tests { #[test] fn test_default_jwk() { - let key_pair = gen_keypair(KeyType::EcdsaP256).unwrap(); + let key_type = KeyType::EcdsaP256; + let key_pair = gen_keypair(key_type).unwrap(); let payload = "Dummy payload 1"; let payload_b64 = "RHVtbXkgcGF5bG9hZCAx"; - let s = encode_jwk(&key_pair, payload.as_bytes(), "", ""); + let s = encode_jwk( + &key_pair, + &key_type.get_default_signature_alg(), + payload.as_bytes(), + "", + "", + ); assert!(s.is_ok()); let s = s.unwrap(); assert!(s.contains("\"protected\"")); @@ -103,11 +110,18 @@ mod tests { #[test] fn test_default_nopad_jwk() { - let key_pair = gen_keypair(KeyType::EcdsaP256).unwrap(); + let key_type = KeyType::EcdsaP256; + let key_pair = gen_keypair(key_type).unwrap(); let payload = "Dummy payload"; let payload_b64 = "RHVtbXkgcGF5bG9hZA"; let payload_b64_pad = "RHVtbXkgcGF5bG9hZA=="; - let s = encode_jwk(&key_pair, payload.as_bytes(), "", ""); + let s = encode_jwk( + &key_pair, + &key_type.get_default_signature_alg(), + payload.as_bytes(), + "", + "", + ); assert!(s.is_ok()); let s = s.unwrap(); assert!(s.contains("\"protected\"")); @@ -119,11 +133,19 @@ mod tests { #[test] fn test_default_kid() { - let key_pair = gen_keypair(KeyType::EcdsaP256).unwrap(); + let key_type = KeyType::EcdsaP256; + let key_pair = gen_keypair(key_type).unwrap(); let payload = "Dummy payload 1"; let payload_b64 = "RHVtbXkgcGF5bG9hZCAx"; let key_id = "0x2a"; - let s = encode_kid(&key_pair, key_id, payload.as_bytes(), "", ""); + let s = encode_kid( + &key_pair, + &key_type.get_default_signature_alg(), + key_id, + payload.as_bytes(), + "", + "", + ); assert!(s.is_ok()); let s = s.unwrap(); assert!(s.contains("\"protected\""));