Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton committed Jul 29, 2024
1 parent 3bc91ee commit c69e5e7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
16 changes: 8 additions & 8 deletions crates/bitwarden-core/src/auth/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ mod tests {
use super::*;
use crate::client::{Client, LoginMethod, UserLoginMethod};

fn init_client() -> Client {
let client = Client::new(None);
async fn init_client() -> Client {
let client = Client::new(None).await;

let password = "asdfasdfasdf";
let email = "[email protected]";
Expand Down Expand Up @@ -77,25 +77,25 @@ mod tests {
client
}

#[test]
fn test_validate_valid_pin() {
#[tokio::test]
async fn test_validate_valid_pin() {
let pin = "1234".to_string();
let pin_protected_user_key = "2.BXgvdBUeEMyvumqAJkAzPA==|JScDPoqOkVdrC1X755Ubt8tS9pC/thvrvNf5CyNcRg8HZtZ466EcRo7aCqwUzLyTVNRkbCYtFYT+09acGGHur8tGuS7Kmg/pYeaUo4K0UKI=|NpIFg5P9z0SN1MffbixD9OQE0l+NiNmnRQJs/kTsyoQ="
.parse()
.unwrap();

let client = init_client();
let client = init_client().await;
assert!(validate_pin(&client, pin.clone(), pin_protected_user_key).unwrap());
}

#[test]
fn test_validate_invalid_pin() {
#[tokio::test]
async fn test_validate_invalid_pin() {
let pin = "1234".to_string();
let pin_protected_user_key = "2.BXgvdBUeEMyvumqAJkAyPA==|JScDPoqOkVdrC1X755Ubt8tS9pC/thvrvNf5CyNcRg8HZtZ466EcRo7aCqwUzLyTVNRkbCYtFYT+09acGGHur8tGuS7Kmg/pYeaUo4K0UKI=|NpIFg5P9z0SN1MffbixD9OQE0l+NiNmnRQJs/kTsyoQ="
.parse()
.unwrap();

let client = init_client();
let client = init_client().await;
assert!(!validate_pin(&client, pin.clone(), pin_protected_user_key).unwrap());
}
}
2 changes: 1 addition & 1 deletion crates/bitwarden-sm/src/projects/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ mod tests {
name,
};

super::create_project(&Client::new(None), &input).await
super::create_project(&Client::new(None).await, &input).await
}

#[tokio::test]
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-sm/src/projects/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ mod tests {
name,
};

super::update_project(&Client::new(None), &input).await
super::update_project(&Client::new(None).await, &input).await
}

#[tokio::test]
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-sm/src/secrets/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ mod tests {
project_ids: Some(vec![Uuid::new_v4()]),
};

super::create_secret(&Client::new(None), &input).await
super::create_secret(&Client::new(None).await, &input).await
}

#[tokio::test]
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-sm/src/secrets/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mod tests {
project_ids: Some(vec![Uuid::new_v4()]),
};

super::update_secret(&Client::new(None), &input).await
super::update_secret(&Client::new(None).await, &input).await
}

#[tokio::test]
Expand Down
20 changes: 10 additions & 10 deletions crates/bitwarden-vault/src/cipher/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,32 +211,32 @@ mod tests {
}
}

#[test]
fn test_save_get_all() {
#[tokio::test]
async fn test_save_get_all() {
let repo = CipherRepository::new(Arc::new(Mutex::new(Database::new_test())));

let cipher = mock_cipher("d55d65d7-c161-40a4-94ca-b0d20184d91a".parse().unwrap());

repo.save(&cipher).unwrap();

let ciphers = repo.get_all().unwrap();
let ciphers = repo.get_all().await.unwrap();

assert_eq!(ciphers.len(), 1);
assert_eq!(ciphers[0].id, cipher.id);
}

#[test]
fn test_delete_by_id() {
#[tokio::test]
async fn test_delete_by_id() {
let repo = CipherRepository::new(Arc::new(Mutex::new(Database::new_test())));

let cipher = mock_cipher("d55d65d7-c161-40a4-94ca-b0d20184d91a".parse().unwrap());
repo.save(&cipher).unwrap();

let ciphers = repo.get_all().unwrap();
let ciphers = repo.get_all().await.unwrap();
assert_eq!(ciphers.len(), 1);

repo.delete_by_id(cipher.id.unwrap()).unwrap();
let ciphers = repo.get_all().unwrap();
repo.delete_by_id(cipher.id.unwrap()).await.unwrap();
let ciphers = repo.get_all().await.unwrap();
assert_eq!(ciphers.len(), 0);
}

Expand All @@ -248,7 +248,7 @@ mod tests {

repo.save(&old_cipher).unwrap();

let ciphers = repo.get_all().unwrap();
let ciphers = repo.get_all().await.unwrap();
assert_eq!(ciphers.len(), 1);
assert_eq!(ciphers[0].id, old_cipher.id);

Expand All @@ -258,7 +258,7 @@ mod tests {

repo.replace_all(new_ciphers.as_slice()).await.unwrap();

let ciphers = repo.get_all().unwrap();
let ciphers = repo.get_all().await.unwrap();
assert_eq!(ciphers.len(), 1);
assert_eq!(ciphers[0].id, new_ciphers[0].id);
}
Expand Down

0 comments on commit c69e5e7

Please sign in to comment.