-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,5 +1,10 @@ | ||
use std::time::{Duration, Instant}; | ||
|
||
use reqwest::header::{self}; | ||
use uuid::Uuid; | ||
|
||
#[cfg(feature = "secrets")] | ||
use crate::auth::login::{access_token_login, AccessTokenLoginRequest, AccessTokenLoginResponse}; | ||
#[cfg(feature = "internal")] | ||
use crate::{ | ||
auth::login::{ | ||
|
@@ -13,11 +18,6 @@ use crate::{ | |
SecretVerificationRequest, SyncRequest, SyncResponse, UserApiKeyResponse, | ||
}, | ||
}; | ||
use reqwest::header::{self}; | ||
use uuid::Uuid; | ||
|
||
#[cfg(feature = "secrets")] | ||
use crate::auth::login::{access_token_login, AccessTokenLoginRequest, AccessTokenLoginResponse}; | ||
use crate::{ | ||
auth::renew::renew_token, | ||
client::{ | ||
|
@@ -288,14 +288,9 @@ impl Client { | |
|
||
#[cfg(test)] | ||
mod tests { | ||
use std::num::NonZeroU32; | ||
|
||
use wiremock::{matchers, Mock, ResponseTemplate}; | ||
|
||
use crate::{ | ||
auth::login::AccessTokenLoginRequest, client::kdf::Kdf, mobile::crypto::InitCryptoRequest, | ||
secrets_manager::secrets::*, Client, | ||
}; | ||
use crate::{auth::login::AccessTokenLoginRequest, secrets_manager::secrets::*}; | ||
|
||
#[tokio::test] | ||
async fn test_access_token_login() { | ||
|
@@ -384,34 +379,4 @@ mod tests { | |
assert_eq!(res.note, "TEST"); | ||
assert_eq!(res.value, "TEST"); | ||
} | ||
|
||
#[cfg(feature = "internal")] | ||
#[tokio::test] | ||
async fn test_register_initialize_crypto() { | ||
let mut client = Client::new(None); | ||
|
||
let email = "[email protected]"; | ||
let password = "test123"; | ||
let kdf = Kdf::PBKDF2 { | ||
iterations: NonZeroU32::new(600_000).unwrap(), | ||
}; | ||
|
||
let register_response = client | ||
.auth() | ||
.make_register_keys(email.to_owned(), password.to_owned(), kdf.clone()) | ||
.unwrap(); | ||
|
||
client | ||
.crypto() | ||
.initialize_crypto(InitCryptoRequest { | ||
kdf_params: kdf, | ||
email: email.to_owned(), | ||
password: password.to_owned(), | ||
user_key: register_response.encrypted_user_key, | ||
private_key: register_response.keys.private.to_string(), | ||
organization_keys: Default::default(), | ||
}) | ||
.await | ||
.unwrap(); | ||
} | ||
} |
This file contains 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,35 @@ | ||
/// Integration test for registering a new user and unlocking the vault | ||
#[cfg(feature = "mobile")] | ||
#[tokio::test] | ||
async fn test_register_initialize_crypto() { | ||
use std::num::NonZeroU32; | ||
|
||
use bitwarden::{client::kdf::Kdf, mobile::crypto::InitCryptoRequest, Client}; | ||
|
||
let mut client = Client::new(None); | ||
|
||
let email = "[email protected]"; | ||
let password = "test123"; | ||
let kdf = Kdf::PBKDF2 { | ||
iterations: NonZeroU32::new(600_000).unwrap(), | ||
}; | ||
|
||
let register_response = client | ||
.auth() | ||
.make_register_keys(email.to_owned(), password.to_owned(), kdf.clone()) | ||
.unwrap(); | ||
|
||
// Ensure we can initialize the crypto with the new keys | ||
client | ||
.crypto() | ||
.initialize_crypto(InitCryptoRequest { | ||
kdf_params: kdf, | ||
email: email.to_owned(), | ||
password: password.to_owned(), | ||
user_key: register_response.encrypted_user_key, | ||
private_key: register_response.keys.private.to_string(), | ||
organization_keys: Default::default(), | ||
}) | ||
.await | ||
.unwrap(); | ||
} |