Skip to content

[PM-23712] Migrate remaining folder domain to SDK #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
eb7dc30
Add ClientManagedTokens trait
Hinton Jun 30, 2025
a58679c
wip
Hinton Jun 30, 2025
425aaa0
Fix
Hinton Jun 30, 2025
890450d
Migrate folder
Hinton Jun 30, 2025
3813a28
Add repository
Hinton Jun 30, 2025
665a5a2
Cleanup
Hinton Jun 30, 2025
4bcf32a
Cleanup
Hinton Jun 30, 2025
f05db2c
Wire up repository and return folder view
Hinton Jun 30, 2025
5261641
clippt
Hinton Jun 30, 2025
44cec30
Fix linting
Hinton Jun 30, 2025
97598f0
Merge branch 'main' of github.com:bitwarden/sdk-internal into arch/clโ€ฆ
Hinton Jul 1, 2025
2c1bdf0
Remove folder client changes
Hinton Jul 1, 2025
40335fa
Remove more folder changes
Hinton Jul 1, 2025
bc6f217
Remove folder from wasm
Hinton Jul 1, 2025
5bb5b4d
lint
Hinton Jul 1, 2025
caec5c5
Document and clean up
Hinton Jul 1, 2025
5c67cd4
Remove wasm bindgen futures from vault
Hinton Jul 1, 2025
9ef95f8
Restore
Hinton Jul 1, 2025
7ed4274
Add a test for folder creation
Hinton Jul 1, 2025
f462d5d
Reorganize
Hinton Jul 1, 2025
25e1233
Edit
Hinton Jul 1, 2025
b30d0b6
Fix test hangs
Hinton Jul 1, 2025
78d1cfb
fmt
Hinton Jul 1, 2025
9528e58
Create bitwarden-test and refactor code
Hinton Jul 3, 2025
754ac79
Merge branch 'main' of github.com:bitwarden/sdk-internal into arch/foโ€ฆ
Hinton Jul 3, 2025
46979ef
Expand tests
Hinton Jul 3, 2025
a4f489f
Resolve review feedback
Hinton Jul 7, 2025
e00c6d9
Add list and get
Hinton Jul 11, 2025
11e0ecf
Rename error
Hinton Jul 11, 2025
646d222
Properly cfg flag wasm
Hinton Jul 11, 2025
76120be
Merge branch 'main' of github.com:bitwarden/sdk-internal into arch/foโ€ฆ
Hinton Jul 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"spki",
"totp",
"uniffi",
"wiremock",
"wordlist",
"XCHACHA",
"Zeroize",
Expand Down
16 changes: 15 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ bitwarden-fido = { path = "crates/bitwarden-fido", version = "=1.0.0" }
bitwarden-generators = { path = "crates/bitwarden-generators", version = "=1.0.0" }
bitwarden-ipc = { path = "crates/bitwarden-ipc", version = "=1.0.0" }
bitwarden-send = { path = "crates/bitwarden-send", version = "=1.0.0" }
bitwarden-state = { path = "crates/bitwarden-state", version = "=1.0.0" }
bitwarden-threading = { path = "crates/bitwarden-threading", version = "=1.0.0" }
bitwarden-sm = { path = "bitwarden_license/bitwarden-sm", version = "=1.0.0" }
bitwarden-ssh = { path = "crates/bitwarden-ssh", version = "=1.0.0" }
bitwarden-state = { path = "crates/bitwarden-state", version = "=1.0.0" }
bitwarden-test = { path = "crates/bitwarden-test", version = "=1.0.0" }
bitwarden-threading = { path = "crates/bitwarden-threading", version = "=1.0.0" }
bitwarden-uuid = { path = "crates/bitwarden-uuid", version = "=1.0.0" }
bitwarden-uuid-macro = { path = "crates/bitwarden-uuid-macro", version = "=1.0.0" }
bitwarden-vault = { path = "crates/bitwarden-vault", version = "=1.0.0" }
Expand All @@ -60,6 +61,7 @@ serde = { version = ">=1.0, <2.0", features = ["derive"] }
serde_json = ">=1.0.96, <2.0"
serde_qs = ">=0.12.0, <0.16"
serde_repr = ">=0.1.12, <0.2"
serde-wasm-bindgen = ">=0.6.0, <0.7"
syn = ">=2.0.87, <3"
thiserror = ">=1.0.40, <3"
tokio = { version = "1.36.0", features = ["macros"] }
Expand All @@ -72,7 +74,7 @@ validator = { version = ">=0.18.1, <0.21", features = ["derive"] }
wasm-bindgen = { version = ">=0.2.91, <0.3", features = ["serde-serialize"] }
wasm-bindgen-futures = "0.4.41"
wasm-bindgen-test = "0.3.45"
serde-wasm-bindgen = ">=0.6.0, <0.7"
wiremock = ">=0.6.0, <0.7"

# There is an incompatibility when using pkcs5 and chacha20 on wasm builds. This can be removed once a new
# rustcrypto-formats crate version is released since the fix has been upstreamed.
Expand Down
2 changes: 1 addition & 1 deletion bitwarden_license/bitwarden-sm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ validator = { workspace = true }

[dev-dependencies]
tokio = { workspace = true, features = ["rt"] }
wiremock = "0.6.0"
wiremock = { workspace = true }

[lints]
workspace = true
2 changes: 1 addition & 1 deletion crates/bitwarden-generators/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ wasm-bindgen = { workspace = true, optional = true }
[dev-dependencies]
rand_chacha = "0.3.1"
tokio = { workspace = true, features = ["rt"] }
wiremock = "0.6.0"
wiremock = { workspace = true }

[lints]
workspace = true
25 changes: 25 additions & 0 deletions crates/bitwarden-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "bitwarden-test"
description = """
Internal crate for the bitwarden crate. Do not use.
"""

version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
readme.workspace = true
homepage.workspace = true
repository.workspace = true
license-file.workspace = true
keywords.workspace = true

[dependencies]
async-trait = { workspace = true }
bitwarden-api-api.workspace = true
bitwarden-state = { workspace = true }
reqwest = { workspace = true }
wiremock = { workspace = true }

[lints]
workspace = true
7 changes: 7 additions & 0 deletions crates/bitwarden-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Bitwarden Test

<div class="warning">
This crate should only be used in tests and should not be included in production builds.
</div>

Contains test utilities for Bitwarden.
24 changes: 24 additions & 0 deletions crates/bitwarden-test/src/api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use bitwarden_api_api::apis::configuration::Configuration;

/// Helper for testing the Bitwarden API using wiremock.
///
/// Warning: when using `Mock::expected` ensure `server` is not dropped before the test completes,
pub async fn start_api_mock(mocks: Vec<wiremock::Mock>) -> (wiremock::MockServer, Configuration) {
let server = wiremock::MockServer::start().await;

for mock in mocks {
server.register(mock).await;
}

let config = Configuration {
base_path: server.uri(),
user_agent: Some("test-agent".to_string()),
client: reqwest::Client::new(),
basic_auth: None,
oauth_access_token: None,
bearer_access_token: None,
api_key: None,
};

(server, config)
}
7 changes: 7 additions & 0 deletions crates/bitwarden-test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#![doc = include_str!("../README.md")]

mod api;
pub use api::*;

mod repository;
pub use repository::*;
54 changes: 54 additions & 0 deletions crates/bitwarden-test/src/repository.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use bitwarden_state::repository::{Repository, RepositoryError, RepositoryItem};

/// A simple in-memory repository implementation. The data is only stored in memory and will not
/// persist beyond the lifetime of the repository instance.
///
/// Primary use case is for unit and integration tests.
pub struct MemoryRepository<V: RepositoryItem> {
store: std::sync::Mutex<std::collections::HashMap<String, V>>,
}

impl<V: RepositoryItem + Clone> Default for MemoryRepository<V> {
fn default() -> Self {
Self {
store: std::sync::Mutex::new(std::collections::HashMap::new()),
}
}
}

#[async_trait::async_trait]
impl<V: RepositoryItem + Clone> Repository<V> for MemoryRepository<V> {
async fn get(&self, key: String) -> Result<Option<V>, RepositoryError> {
let store = self
.store
.lock()
.map_err(|e| RepositoryError::Internal(e.to_string()))?;
Ok(store.get(&key).cloned())
}

async fn list(&self) -> Result<Vec<V>, RepositoryError> {
let store = self
.store
.lock()
.map_err(|e| RepositoryError::Internal(e.to_string()))?;
Ok(store.values().cloned().collect())
}

Check warning on line 35 in crates/bitwarden-test/src/repository.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-test/src/repository.rs#L29-L35

Added lines #L29 - L35 were not covered by tests

async fn set(&self, key: String, value: V) -> Result<(), RepositoryError> {
let mut store = self
.store
.lock()
.map_err(|e| RepositoryError::Internal(e.to_string()))?;
store.insert(key, value);
Ok(())
}

async fn remove(&self, key: String) -> Result<(), RepositoryError> {
let mut store = self
.store
.lock()
.map_err(|e| RepositoryError::Internal(e.to_string()))?;
store.remove(&key);
Ok(())
}

Check warning on line 53 in crates/bitwarden-test/src/repository.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-test/src/repository.rs#L46-L53

Added lines #L46 - L53 were not covered by tests
}
6 changes: 5 additions & 1 deletion crates/bitwarden-vault/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ uniffi = [
wasm = [
"bitwarden-core/wasm",
"dep:tsify",
"dep:wasm-bindgen"
"dep:wasm-bindgen",
"dep:wasm-bindgen-futures"
] # WASM support

[dependencies]
Expand All @@ -48,9 +49,12 @@ tsify = { workspace = true, optional = true }
uniffi = { workspace = true, optional = true }
uuid = { workspace = true }
wasm-bindgen = { workspace = true, optional = true }
wasm-bindgen-futures = { workspace = true, optional = true }

[dev-dependencies]
bitwarden-test = { workspace = true }
tokio = { workspace = true, features = ["rt"] }
wiremock = { workspace = true }

[lints]
workspace = true
Loading
Loading