diff --git a/src/lib.rs b/src/lib.rs index 9db0e61..5e6d474 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -670,3 +670,22 @@ where const JOSE_JSON: &str = "application/jose+json"; const REPLAY_NONCE: &str = "Replay-Nonce"; + +#[cfg(test)] +mod tests { + use super::*; + + #[tokio::test] + async fn deserialize_old_credentials() -> Result<(), Error> { + const CREDENTIALS: &str = r#"{"id":"id","key_pkcs8":"MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgJVWC_QzOTCS5vtsJp2IG-UDc8cdDfeoKtxSZxaznM-mhRANCAAQenCPoGgPFTdPJ7VLLKt56RxPlYT1wNXnHc54PEyBg3LxKaH0-sJkX0mL8LyPEdsfL_Oz4TxHkWLJGrXVtNhfH","urls":{"newNonce":"new-nonce","newAccount":"new-acct","newOrder":"new-order"}}"#; + Account::from_credentials(serde_json::from_str::(CREDENTIALS)?).await?; + Ok(()) + } + + #[tokio::test] + async fn deserialize_new_credentials() -> Result<(), Error> { + const CREDENTIALS: &str = r#"{"id":"id","key_pkcs8":"MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgJVWC_QzOTCS5vtsJp2IG-UDc8cdDfeoKtxSZxaznM-mhRANCAAQenCPoGgPFTdPJ7VLLKt56RxPlYT1wNXnHc54PEyBg3LxKaH0-sJkX0mL8LyPEdsfL_Oz4TxHkWLJGrXVtNhfH","directory":"https://acme-staging-v02.api.letsencrypt.org/directory"}"#; + Account::from_credentials(serde_json::from_str::(CREDENTIALS)?).await?; + Ok(()) + } +}