From 876989c3c32ee7d018bdc3d892cfb98606527343 Mon Sep 17 00:00:00 2001 From: Francisco Micaelli Date: Tue, 5 Apr 2022 10:41:07 +0200 Subject: [PATCH] feat: temporary remove session token tests Those tests will be added back after the session certificate flag is removed from the server --- tests/identity/admin.rs | 7 -- tests/identity/test_app.rs | 2 - tests/verify_tests.rs | 131 ++----------------------------------- 3 files changed, 7 insertions(+), 133 deletions(-) diff --git a/tests/identity/admin.rs b/tests/identity/admin.rs index b91c11e..d075fdd 100644 --- a/tests/identity/admin.rs +++ b/tests/identity/admin.rs @@ -69,7 +69,6 @@ impl Admin { id: &str, oidc_client_id: Option<&str>, oidc_provider: Option<&str>, - with_session_token: Option, preverified_verification: Option, ) -> Result<(), Error> { let url = self.make_url(id); @@ -80,12 +79,6 @@ impl Admin { if let Some(oidc_provider) = oidc_provider { json.insert("oidc_provider".to_owned(), oidc_provider.into()); } - if let Some(with_session_token) = with_session_token { - json.insert( - "session_certificates_enabled".to_owned(), - with_session_token.into(), - ); - } if let Some(preverified_verification) = preverified_verification { json.insert( "preverified_verification_enabled".to_owned(), diff --git a/tests/identity/test_app.rs b/tests/identity/test_app.rs index 012f073..a8b77c6 100644 --- a/tests/identity/test_app.rs +++ b/tests/identity/test_app.rs @@ -81,7 +81,6 @@ impl TestApp { &self, oidc_client_id: Option<&str>, oidc_provider: Option<&str>, - with_session_token: Option, preverified_verification: Option, ) -> Result<(), Error> { self.admin @@ -89,7 +88,6 @@ impl TestApp { &self.app.id, oidc_client_id, oidc_provider, - with_session_token, preverified_verification, ) .await diff --git a/tests/verify_tests.rs b/tests/verify_tests.rs index 0c33c38..f9ecc6c 100644 --- a/tests/verify_tests.rs +++ b/tests/verify_tests.rs @@ -171,7 +171,7 @@ async fn unlock_with_oidc_id_token() -> Result<(), Box> { 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> { 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> { - 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> { - 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 = "mono@chromat.ic"; @@ -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 = "mono@chromat.ic"; @@ -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 = "mono@chromat.ic"; @@ -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();