MCPcopy Create free account
hub / github.com/chatmail/core / test_decryption_error_msg

Function test_decryption_error_msg

src/pgp.rs:771–799  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

769
770 #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
771 async fn test_decryption_error_msg() -> Result<()> {
772 let mut tcm = TestContextManager::new();
773 let alice = &tcm.alice().await;
774 let bob = &tcm.bob().await;
775
776 let plain = Vec::from(b"this is the secret message");
777 let pk_for_encryption = load_self_public_key(alice).await?;
778
779 // Encrypt a message, but only to self, not to Bob:
780 let compress = true;
781 let ctext = pk_encrypt(
782 plain,
783 vec![pk_for_encryption],
784 KEYS.alice_secret.clone(),
785 compress,
786 SeipdVersion::V2,
787 )
788 .await?;
789
790 // Trying to decrypt it should fail with an OK error message:
791 let bob_private_keyring = crate::key::load_self_secret_keyring(bob).await?;
792 let error = decrypt_bytes(ctext.into(), &bob_private_keyring, &[])
793 .await
794 .unwrap_err();
795
796 assert_eq!(format!("{error:#}"), "decrypt_with_keys: missing key");
797
798 Ok(())
799 }
800
801 /// Tests that recipient key IDs and fingerprints
802 /// are omitted or replaced with wildcards.

Callers

nothing calls this directly

Calls 7

load_self_public_keyFunction · 0.85
pk_encryptFunction · 0.85
load_self_secret_keyringFunction · 0.85
decrypt_bytesFunction · 0.85
aliceMethod · 0.80
bobMethod · 0.80
cloneMethod · 0.80

Tested by

no test coverage detected