-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'francisco/remove_session_token_tests' into 'master'
feat: temporary remove session token tests See merge request TankerHQ/sdk-rust!99
- Loading branch information
Showing
3 changed files
with
7 additions
and
133 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
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
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 |
---|---|---|
|
@@ -171,7 +171,7 @@ async fn unlock_with_oidc_id_token() -> Result<(), Box<dyn std::error::Error>> { | |
let martine_config = &oidc.users["martine"]; | ||
let martine_identity = app.create_identity(Some(martine_config.email.clone())); | ||
|
||
app.app_update(Some(&oidc.client_id), Some(&oidc.provider), None, None) | ||
app.app_update(Some(&oidc.client_id), Some(&oidc.provider), None) | ||
.await?; | ||
|
||
let client = reqwest::Client::new(); | ||
|
@@ -212,127 +212,10 @@ async fn unlock_with_oidc_id_token() -> Result<(), Box<dyn std::error::Error>> { | |
Ok(()) | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
async fn get_session_token_with_register_identity() -> Result<(), Error> { | ||
let app = TestApp::get().await; | ||
app.app_update(None, None, Some(true), None).await?; | ||
|
||
let id = &app.create_identity(None); | ||
let pass = Verification::Passphrase("The Cost of Legacy".into()); | ||
|
||
let tanker = Core::new(app.make_options()).await?; | ||
tanker.start(id).await?; | ||
let token = tanker | ||
.register_identity(&pass, &VerificationOptions::new().with_session_token()) | ||
.await?; | ||
assert!(token.is_some()); | ||
tanker.stop().await?; | ||
Ok(()) | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
async fn get_session_token_with_verify_identity() -> Result<(), Error> { | ||
let app = TestApp::get().await; | ||
app.app_update(None, None, Some(true), None).await?; | ||
|
||
let id = &app.create_identity(None); | ||
let pass = Verification::Passphrase("Merge remote-tracking branch 'rust/rust-next'".into()); | ||
|
||
let tanker = Core::new(app.make_options()).await?; | ||
tanker.start(id).await?; | ||
tanker | ||
.register_identity(&pass, &VerificationOptions::new()) | ||
.await?; | ||
|
||
let token = tanker | ||
.verify_identity(&pass, &VerificationOptions::new().with_session_token()) | ||
.await?; | ||
assert!(token.is_some()); | ||
tanker.stop().await?; | ||
Ok(()) | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
async fn get_session_token_with_set_verififcation_method() -> Result<(), Error> { | ||
let app = TestApp::get().await; | ||
app.app_update(None, None, Some(true), None).await?; | ||
|
||
let id = &app.create_identity(None); | ||
let pass = Verification::Passphrase("Phobos".into()); | ||
let pass2 = Verification::Passphrase("Deimos".into()); | ||
|
||
let tanker = Core::new(app.make_options()).await?; | ||
tanker.start(id).await?; | ||
tanker | ||
.register_identity(&pass, &VerificationOptions::new()) | ||
.await?; | ||
|
||
let token = tanker | ||
.set_verification_method(&pass2, &VerificationOptions::new().with_session_token()) | ||
.await?; | ||
assert!(token.is_some()); | ||
tanker.stop().await?; | ||
Ok(()) | ||
} | ||
|
||
async fn check_session_token_with_server( | ||
app: &TestApp, | ||
public_identity: &str, | ||
session_token: &str, | ||
allowed_method: &str, | ||
) -> Result<String, Box<dyn std::error::Error>> { | ||
let url = format!("{}/verification/session-token", app.trustchaind_url(),); | ||
|
||
let reply: Value = reqwest::Client::new() | ||
.post(url) | ||
.json(&json!({ | ||
"app_id": app.id(), | ||
"auth_token": app.auth_token(), | ||
"public_identity": public_identity, | ||
"session_token": session_token, | ||
"allowed_methods": [{ | ||
"type": allowed_method | ||
}] | ||
})) | ||
.send() | ||
.await? | ||
.json() | ||
.await?; | ||
Ok(reply["verification_method"].as_str().unwrap().to_owned()) | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
async fn check_session_token_is_valid() -> Result<(), Box<dyn std::error::Error>> { | ||
let app = TestApp::get().await; | ||
app.app_update(None, None, Some(true), None).await?; | ||
|
||
let tanker = Core::new(app.make_options()).await?; | ||
let identity = &app.create_identity(None); | ||
tanker.start(identity).await?; | ||
let token = tanker | ||
.register_identity( | ||
&Verification::Passphrase("Less than three".into()), | ||
&VerificationOptions::new().with_session_token(), | ||
) | ||
.await? | ||
.unwrap(); | ||
|
||
let expected_method = "passphrase"; | ||
let actual_method_used = check_session_token_with_server( | ||
&app, | ||
&app.get_public_identity(identity), | ||
&token, | ||
expected_method, | ||
) | ||
.await?; | ||
assert_eq!(expected_method, actual_method_used); | ||
Ok(()) | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
async fn register_fail_with_preverified_email() -> Result<(), Error> { | ||
let app = TestApp::get().await; | ||
app.app_update(None, None, None, Some(true)).await?; | ||
app.app_update(None, None, Some(true)).await?; | ||
let id = &app.create_identity(None); | ||
let email = "[email protected]"; | ||
|
||
|
@@ -354,7 +237,7 @@ async fn register_fail_with_preverified_email() -> Result<(), Error> { | |
#[tokio::test(flavor = "multi_thread")] | ||
async fn register_fail_with_preverified_phone_number() -> Result<(), Error> { | ||
let app = TestApp::get().await; | ||
app.app_update(None, None, None, Some(true)).await?; | ||
app.app_update(None, None, Some(true)).await?; | ||
let id = &app.create_identity(None); | ||
let phone_number = "+33639982233"; | ||
|
||
|
@@ -376,7 +259,7 @@ async fn register_fail_with_preverified_phone_number() -> Result<(), Error> { | |
#[tokio::test(flavor = "multi_thread")] | ||
async fn verify_identity_fail_with_preverified_email() -> Result<(), Error> { | ||
let app = TestApp::get().await; | ||
app.app_update(None, None, None, Some(true)).await?; | ||
app.app_update(None, None, Some(true)).await?; | ||
let id = &app.create_identity(None); | ||
let email = "[email protected]"; | ||
|
||
|
@@ -409,7 +292,7 @@ async fn verify_identity_fail_with_preverified_email() -> Result<(), Error> { | |
#[tokio::test(flavor = "multi_thread")] | ||
async fn verify_identity_fail_with_preverified_phone_number() -> Result<(), Error> { | ||
let app = TestApp::get().await; | ||
app.app_update(None, None, None, Some(true)).await?; | ||
app.app_update(None, None, Some(true)).await?; | ||
let id = &app.create_identity(None); | ||
let phone_number = "+33639982233"; | ||
|
||
|
@@ -442,7 +325,7 @@ async fn verify_identity_fail_with_preverified_phone_number() -> Result<(), Erro | |
#[tokio::test(flavor = "multi_thread")] | ||
async fn set_verification_method_with_preverified_email() -> Result<(), Error> { | ||
let app = TestApp::get().await; | ||
app.app_update(None, None, None, Some(true)).await?; | ||
app.app_update(None, None, Some(true)).await?; | ||
let id = &app.create_identity(None); | ||
let pass = Verification::Passphrase("The Beauty In The Ordinary".into()); | ||
let email = "[email protected]"; | ||
|
@@ -497,7 +380,7 @@ async fn set_verification_method_with_preverified_email() -> Result<(), Error> { | |
#[tokio::test(flavor = "multi_thread")] | ||
async fn set_verification_method_with_preverified_phone_number() -> Result<(), Error> { | ||
let app = TestApp::get().await; | ||
app.app_update(None, None, None, Some(true)).await?; | ||
app.app_update(None, None, Some(true)).await?; | ||
let id = &app.create_identity(None); | ||
let pass = Verification::Passphrase("The Beauty In The Ordinary".into()); | ||
let phone_number = "+33639982233".to_string(); | ||
|