-
Notifications
You must be signed in to change notification settings - Fork 12
Migrate folder create and edit #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
Hinton
wants to merge
26
commits into
main
Choose a base branch
from
arch/folder
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
eb7dc30
Add ClientManagedTokens trait
Hinton a58679c
wip
Hinton 425aaa0
Fix
Hinton 890450d
Migrate folder
Hinton 3813a28
Add repository
Hinton 665a5a2
Cleanup
Hinton 4bcf32a
Cleanup
Hinton f05db2c
Wire up repository and return folder view
Hinton 5261641
clippt
Hinton 44cec30
Fix linting
Hinton 97598f0
Merge branch 'main' of github.com:bitwarden/sdk-internal into arch/clโฆ
Hinton 2c1bdf0
Remove folder client changes
Hinton 40335fa
Remove more folder changes
Hinton bc6f217
Remove folder from wasm
Hinton 5bb5b4d
lint
Hinton caec5c5
Document and clean up
Hinton 5c67cd4
Remove wasm bindgen futures from vault
Hinton 9ef95f8
Restore
Hinton 7ed4274
Add a test for folder creation
Hinton f462d5d
Reorganize
Hinton 25e1233
Edit
Hinton b30d0b6
Fix test hangs
Hinton 78d1cfb
fmt
Hinton 9528e58
Create bitwarden-test and refactor code
Hinton 754ac79
Merge branch 'main' of github.com:bitwarden/sdk-internal into arch/foโฆ
Hinton 46979ef
Expand tests
Hinton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
"spki", | ||
"totp", | ||
"uniffi", | ||
"wiremock", | ||
"wordlist", | ||
"XCHACHA", | ||
"Zeroize", | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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::*; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} | ||
|
||
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(()) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we were running cargo sort to check the order here, I wonder how these went through initially