Browse Source

Update the tests

pull/5/head
Rodolphe Breard 5 years ago
parent
commit
5a1aaa443a
  1. 12
      acmed/src/acme_proto/jws.rs
  2. 4
      acmed/src/acme_proto/jws/algorithms.rs

12
acmed/src/acme_proto/jws.rs

@ -88,10 +88,10 @@ mod tests {
#[test]
fn test_default_jwk() {
let (_, priv_key) = gen_keypair(KeyType::EcdsaP256).unwrap();
let key_pair = gen_keypair(KeyType::EcdsaP256).unwrap();
let payload = "Dummy payload 1";
let payload_b64 = "RHVtbXkgcGF5bG9hZCAx";
let s = encode_jwk(&priv_key, payload.as_bytes(), "", "");
let s = encode_jwk(&key_pair, payload.as_bytes(), "", "");
assert!(s.is_ok());
let s = s.unwrap();
assert!(s.contains("\"protected\""));
@ -102,11 +102,11 @@ mod tests {
#[test]
fn test_default_nopad_jwk() {
let (_, priv_key) = gen_keypair(KeyType::EcdsaP256).unwrap();
let key_pair = gen_keypair(KeyType::EcdsaP256).unwrap();
let payload = "Dummy payload";
let payload_b64 = "RHVtbXkgcGF5bG9hZA";
let payload_b64_pad = "RHVtbXkgcGF5bG9hZA==";
let s = encode_jwk(&priv_key, payload.as_bytes(), "", "");
let s = encode_jwk(&key_pair, payload.as_bytes(), "", "");
assert!(s.is_ok());
let s = s.unwrap();
assert!(s.contains("\"protected\""));
@ -118,11 +118,11 @@ mod tests {
#[test]
fn test_default_kid() {
let (_, priv_key) = gen_keypair(KeyType::EcdsaP256).unwrap();
let key_pair = gen_keypair(KeyType::EcdsaP256).unwrap();
let payload = "Dummy payload 1";
let payload_b64 = "RHVtbXkgcGF5bG9hZCAx";
let key_id = "0x2a";
let s = encode_kid(&priv_key, key_id, payload.as_bytes(), "", "");
let s = encode_kid(&key_pair, key_id, payload.as_bytes(), "", "");
assert!(s.is_ok());
let s = s.unwrap();
assert!(s.contains("\"protected\""));

4
acmed/src/acme_proto/jws/algorithms.rs

@ -71,7 +71,7 @@ impl SignatureAlgorithm {
#[cfg(test)]
mod tests {
use super::{EdDsaVariant, SignatureAlgorithm};
use acme_common::crypto::PrivateKey;
use acme_common::crypto::KeyPair;
use std::str::FromStr;
#[test]
@ -115,7 +115,7 @@ MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg6To1BW8qTehGhPca
0eMcW8iQU4yA02dvtKkuqfny4HChRANCAAQwxx+j3wYGzD5LSFNBTLlT7J+7rWrq
4BGdR8705iwpBeOQgMpLj+9vuFutlVtmoYpJSYa9+49Hxz8aCe1AQeWt
-----END PRIVATE KEY-----";
let k = PrivateKey::from_pem(pem).unwrap();
let k = KeyPair::from_pem(pem).unwrap();
let s = SignatureAlgorithm::from_pkey(&k);
assert!(s.is_ok());
let s = s.unwrap();

Loading…
Cancel
Save