bitwarden_vault/cipher/blob/conversions/
bank_account.rs1use super::{BankAccountDataV1, BankAccountView};
2
3impl_bidirectional_from!(
4 BankAccountView,
5 BankAccountDataV1,
6 [
7 bank_name,
8 name_on_account,
9 account_type,
10 account_number,
11 routing_number,
12 branch_number,
13 pin,
14 swift_code,
15 iban,
16 bank_contact_phone,
17 ]
18);
19
20#[cfg(test)]
21mod tests {
22 use super::super::{CipherBlobV1, test_support::*};
23 use crate::cipher::{bank_account::BankAccountView, cipher::CipherType};
24
25 #[test]
26 fn test_bank_account_cipher_round_trip() {
27 let (key_store, key_id) = create_test_key_store();
28 let mut ctx = key_store.context_mut();
29
30 let original = crate::CipherView {
31 name: "My Bank Account".to_string(),
32 notes: None,
33 r#type: CipherType::BankAccount,
34 bank_account: Some(BankAccountView {
35 bank_name: Some("Test Bank".to_string()),
36 name_on_account: Some("John Doe".to_string()),
37 account_type: Some("Checking".to_string()),
38 account_number: Some("1234567890".to_string()),
39 routing_number: Some("021000021".to_string()),
40 branch_number: Some("001".to_string()),
41 pin: Some("1234".to_string()),
42 swift_code: Some("TESTUS33".to_string()),
43 iban: Some("US12345678901234567890".to_string()),
44 bank_contact_phone: Some("555-0123".to_string()),
45 }),
46 ..create_shell_cipher_view(CipherType::BankAccount)
47 };
48
49 let blob = CipherBlobV1::from_cipher_view(&original, &mut ctx, key_id).unwrap();
50 let mut restored = create_shell_cipher_view(CipherType::BankAccount);
51 blob.apply_to_cipher_view(&mut restored, &mut ctx, key_id)
52 .unwrap();
53
54 assert_eq!(restored.name, "My Bank Account");
55 assert_eq!(restored.r#type, CipherType::BankAccount);
56 let bank_account = restored.bank_account.unwrap();
57 assert_eq!(bank_account.bank_name, Some("Test Bank".to_string()));
58 assert_eq!(bank_account.account_number, Some("1234567890".to_string()));
59 assert!(restored.login.is_none());
60 }
61}