Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton committed Aug 15, 2024
1 parent be2650a commit b0161a0
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions crates/bitwarden-core/src/mobile/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ pub(super) fn derive_key_connector(request: DeriveKeyConnectorRequest) -> Result

#[cfg(test)]
mod tests {
use std::num::NonZeroU32;

use super::*;
use crate::Client;

Expand Down Expand Up @@ -521,8 +523,6 @@ mod tests {

#[test]
fn test_enroll_admin_password_reset() {
use std::num::NonZeroU32;

use base64::{engine::general_purpose::STANDARD, Engine};
use bitwarden_crypto::AsymmetricCryptoKey;

Expand Down Expand Up @@ -557,4 +557,20 @@ mod tests {
let expected = enc.get_key(&None).unwrap();
assert_eq!(&decrypted, &expected.to_vec());
}

#[test]
fn test_derive_key_connector() {
let request = DeriveKeyConnectorRequest {
password: "asdfasdfasdf".to_string(),
email: "[email protected]".to_string(),
kdf: Kdf::PBKDF2 {
iterations: NonZeroU32::new(600_000).unwrap(),
},
user_key_encrypted: "2.Q/2PhzcC7GdeiMHhWguYAQ==|GpqzVdr0go0ug5cZh1n+uixeBC3oC90CIe0hd/HWA/pTRDZ8ane4fmsEIcuc8eMKUt55Y2q/fbNzsYu41YTZzzsJUSeqVjT8/iTQtgnNdpo=|dwI+uyvZ1h/iZ03VQ+/wrGEFYVewBUUl/syYgjsNMbE=".parse().unwrap(),
};

let result = derive_key_connector(request).unwrap();

assert_eq!(result, "ySXq1RVLKEaV1eoQE/ui9aFKIvXTl9PAXwp1MljfF50=");
}
}

0 comments on commit b0161a0

Please sign in to comment.