Skip to content

Commit 95e329a

Browse files
authored
Fix wasm gated features in bitwarden-vault crate (#543)
## 🎟️ Tracking N/A ## 📔 Objective Several tests referenced fields and methods only available with the `wasm` feature. Gate these code sections with `#[cfg(feature = "wasm")]` to allow tests to compile without the `wasm` feature. This fixes `cargo test --package bitwarden-vault` which previously failed due to feature resolution differences between workspace and package-specific testing. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## 🦮 Reviewer guidelines <!-- Suggested interactions but feel free to use (or not) as you desire! --> - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes
1 parent e91bfd2 commit 95e329a

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

crates/bitwarden-vault/src/cipher/attachment.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ mod tests {
288288
size_name: Some("100 Bytes".into()),
289289
file_name: Some("Test.txt".into()),
290290
key: None,
291+
#[cfg(feature = "wasm")]
291292
decrypted_key: None,
292293
};
293294

@@ -347,6 +348,7 @@ mod tests {
347348
size_name: Some("161 Bytes".into()),
348349
file_name: Some("Test.txt".into()),
349350
key: Some("2.r288/AOSPiaLFkW07EBGBw==|SAmnnCbOLFjX5lnURvoualOetQwuyPc54PAmHDTRrhT0gwO9ailna9U09q9bmBfI5XrjNNEsuXssgzNygRkezoVQvZQggZddOwHB6KQW5EQ=|erIMUJp8j+aTcmhdE50zEX+ipv/eR1sZ7EwULJm/6DY=".parse().unwrap()),
351+
#[cfg(feature = "wasm")]
350352
decrypted_key: None,
351353
};
352354

@@ -407,6 +409,7 @@ mod tests {
407409
size_name: Some("161 Bytes".into()),
408410
file_name: Some("Test.txt".into()),
409411
key: None,
412+
#[cfg(feature = "wasm")]
410413
decrypted_key: None,
411414
};
412415

crates/bitwarden-vault/src/cipher/cipher.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,7 @@ mod tests {
11271127
size_name: None,
11281128
file_name: Some("Attachment test name".into()),
11291129
key: None,
1130+
#[cfg(feature = "wasm")]
11301131
decrypted_key: None,
11311132
};
11321133
cipher.attachments = Some(vec![attachment]);
@@ -1239,6 +1240,7 @@ mod tests {
12391240
size_name: None,
12401241
file_name: Some("Attachment test name".into()),
12411242
key: None,
1243+
#[cfg(feature = "wasm")]
12421244
decrypted_key: None,
12431245
};
12441246
cipher.attachments = Some(vec![attachment]);
@@ -1283,6 +1285,7 @@ mod tests {
12831285
size_name: None,
12841286
file_name: Some("Attachment test name".into()),
12851287
key: Some(attachment_key_enc),
1288+
#[cfg(feature = "wasm")]
12861289
decrypted_key: None,
12871290
};
12881291
cipher.attachments = Some(vec![attachment]);
@@ -1351,6 +1354,7 @@ mod tests {
13511354
size_name: None,
13521355
file_name: Some("Attachment test name".into()),
13531356
key: Some(attachment_key_enc.clone()),
1357+
#[cfg(feature = "wasm")]
13541358
decrypted_key: None,
13551359
};
13561360
cipher.attachments = Some(vec![attachment]);

crates/bitwarden-vault/src/cipher/cipher_client/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
use std::sync::Arc;
22

33
use bitwarden_core::{Client, OrganizationId};
4-
use bitwarden_crypto::{CompositeEncryptable, IdentifyKey, SymmetricCryptoKey};
4+
use bitwarden_crypto::IdentifyKey;
5+
#[cfg(feature = "wasm")]
6+
use bitwarden_crypto::{CompositeEncryptable, SymmetricCryptoKey};
57
#[cfg(feature = "wasm")]
68
use bitwarden_encoding::B64;
79
use bitwarden_state::repository::{Repository, RepositoryError};
810
#[cfg(feature = "wasm")]
911
use wasm_bindgen::prelude::*;
1012

1113
use super::EncryptionContext;
14+
#[cfg(feature = "wasm")]
15+
use crate::Fido2CredentialFullView;
1216
use crate::{
1317
Cipher, CipherError, CipherListView, CipherView, DecryptError, EncryptError,
14-
Fido2CredentialFullView, cipher::cipher::DecryptCipherListResult,
18+
cipher::cipher::DecryptCipherListResult,
1519
};
1620

1721
mod create;
@@ -195,6 +199,7 @@ impl CiphersClient {
195199
mod tests {
196200

197201
use bitwarden_core::client::test_accounts::test_bitwarden_com_account;
202+
#[cfg(feature = "wasm")]
198203
use bitwarden_crypto::CryptoError;
199204

200205
use super::*;
@@ -533,6 +538,7 @@ mod tests {
533538
}
534539

535540
#[tokio::test]
541+
#[cfg(feature = "wasm")]
536542
async fn test_encrypt_cipher_for_rotation() {
537543
let client = Client::init_test_account(test_bitwarden_com_account()).await;
538544

crates/bitwarden-vault/src/collection_client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use bitwarden_collections::{
55
tree::{NodeItem, Tree},
66
};
77
use bitwarden_core::Client;
8+
#[cfg(feature = "wasm")]
89
use serde::{Deserialize, Serialize};
910
#[cfg(feature = "wasm")]
1011
use tsify::Tsify;

0 commit comments

Comments
 (0)