mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
fix export of self private keys
This commit is contained in:
19
src/imex.rs
19
src/imex.rs
@@ -964,7 +964,7 @@ where
|
|||||||
let any_key = key as &dyn Any;
|
let any_key = key as &dyn Any;
|
||||||
let kind = if any_key.downcast_ref::<SignedPublicKey>().is_some() {
|
let kind = if any_key.downcast_ref::<SignedPublicKey>().is_some() {
|
||||||
"public"
|
"public"
|
||||||
} else if any_key.downcast_ref::<SignedPublicKey>().is_some() {
|
} else if any_key.downcast_ref::<SignedSecretKey>().is_some() {
|
||||||
"private"
|
"private"
|
||||||
} else {
|
} else {
|
||||||
"unknown"
|
"unknown"
|
||||||
@@ -1040,7 +1040,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_export_key_to_asc_file() {
|
async fn test_export_public_key_to_asc_file() {
|
||||||
let context = TestContext::new().await;
|
let context = TestContext::new().await;
|
||||||
let key = alice_keypair().public;
|
let key = alice_keypair().public;
|
||||||
let blobdir = "$BLOBDIR";
|
let blobdir = "$BLOBDIR";
|
||||||
@@ -1054,6 +1054,21 @@ mod tests {
|
|||||||
assert_eq!(bytes, key.to_asc(None).into_bytes());
|
assert_eq!(bytes, key.to_asc(None).into_bytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_std::test]
|
||||||
|
async fn test_export_private_key_to_asc_file() {
|
||||||
|
let context = TestContext::new().await;
|
||||||
|
let key = alice_keypair().secret;
|
||||||
|
let blobdir = "$BLOBDIR";
|
||||||
|
assert!(export_key_to_asc_file(&context.ctx, blobdir, None, &key)
|
||||||
|
.await
|
||||||
|
.is_ok());
|
||||||
|
let blobdir = context.ctx.get_blobdir().to_str().unwrap();
|
||||||
|
let filename = format!("{}/private-key-default.asc", blobdir);
|
||||||
|
let bytes = async_std::fs::read(&filename).await.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(bytes, key.to_asc(None).into_bytes());
|
||||||
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_export_and_import_key() {
|
async fn test_export_and_import_key() {
|
||||||
let context = TestContext::new().await;
|
let context = TestContext::new().await;
|
||||||
|
|||||||
Reference in New Issue
Block a user