From b3f68c60c77979442e480fe0b21235d0263982d5 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sun, 22 Oct 2023 22:44:12 +0200 Subject: [PATCH] feat: fix tests Signed-off-by: kjuulh --- crates/nefarious-login/src/lib.rs | 6 ------ crates/nefarious-login/src/oauth.rs | 12 ------------ examples/basic/src/main.rs | 6 ++---- examples/clap/src/main.rs | 1 - 4 files changed, 2 insertions(+), 23 deletions(-) diff --git a/crates/nefarious-login/src/lib.rs b/crates/nefarious-login/src/lib.rs index eb5104c..6287b1f 100644 --- a/crates/nefarious-login/src/lib.rs +++ b/crates/nefarious-login/src/lib.rs @@ -43,11 +43,9 @@ mod test { options: AuthClap { engine: AuthEngine::Noop, zitadel: ZitadelClap { - auth_url: None, client_id: None, client_secret: None, redirect_url: None, - token_url: None, authority_url: None, }, session_backend: SessionBackend::InMemory, @@ -69,11 +67,9 @@ mod test { options: AuthClap { engine: AuthEngine::Noop, zitadel: ZitadelClap { - auth_url: None, client_id: None, client_secret: None, redirect_url: None, - token_url: None, authority_url: None, }, session_backend: SessionBackend::InMemory, @@ -105,11 +101,9 @@ mod test { options: AuthClap { engine: AuthEngine::Zitadel, zitadel: ZitadelClap { - auth_url: Some("https://something".into()), client_id: Some("something".into()), client_secret: Some("something".into()), redirect_url: Some("https://something".into()), - token_url: Some("https://something".into()), authority_url: Some("https://something".into()), }, session_backend: SessionBackend::InMemory, diff --git a/crates/nefarious-login/src/oauth.rs b/crates/nefarious-login/src/oauth.rs index 01904b2..3e47c26 100644 --- a/crates/nefarious-login/src/oauth.rs +++ b/crates/nefarious-login/src/oauth.rs @@ -73,9 +73,7 @@ mod tests { "base", "--zitadel-client-id=something", "--zitadel-client-secret=something", - "--zitadel-auth-url=https://something", "--zitadel-redirect-url=https://something", - "--zitadel-token-url=https://something", "--zitadel-authority-url=https://something", ]); println!("{:?}", cli.options); @@ -83,11 +81,9 @@ mod tests { pretty_assertions::assert_eq!( cli.options, ZitadelClap { - auth_url: Some("https://something".into()), client_id: Some("something".into()), client_secret: Some("something".into()), redirect_url: Some("https://something".into()), - token_url: Some("https://something".into()), authority_url: Some("https://something".into()), } ); @@ -100,9 +96,7 @@ mod tests { "one", // "--zitadel-client-id=something", // We want to trigger missing variable "--zitadel-client-secret=something", - "--zitadel-auth-url=https://something", "--zitadel-redirect-url=https://something", - "--zitadel-token-url=https://something", "--zitadel-authority-url=https://something", ]); @@ -113,9 +107,7 @@ mod tests { fn test_parse_clap_env_zitadel() { std::env::set_var("ZITADEL_CLIENT_ID", "something"); std::env::set_var("ZITADEL_CLIENT_SECRET", "something"); - std::env::set_var("ZITADEL_AUTH_URL", "https://something"); std::env::set_var("ZITADEL_REDIRECT_URL", "https://something"); - std::env::set_var("ZITADEL_TOKEN_URL", "https://something"); std::env::set_var("ZITADEL_AUTHORITY_URL", "https://something"); let cli = CliSubCommand::parse_from(["base", "one"]); @@ -124,11 +116,9 @@ mod tests { cli.command, Commands::One { options: ZitadelClap { - auth_url: Some("https://something".into()), client_id: Some("something".into()), client_secret: Some("something".into()), redirect_url: Some("https://something".into()), - token_url: Some("https://something".into()), authority_url: Some("https://something".into()), } } @@ -142,11 +132,9 @@ mod tests { cli.command, Commands::One { options: ZitadelClap { - auth_url: None, client_id: None, client_secret: None, redirect_url: None, - token_url: None, authority_url: None, }, } diff --git a/examples/basic/src/main.rs b/examples/basic/src/main.rs index 433d151..a840a0f 100644 --- a/examples/basic/src/main.rs +++ b/examples/basic/src/main.rs @@ -9,13 +9,11 @@ use axum::{ use nefarious_login::{ auth::AuthService, axum::{AuthController, UserFromSession}, - introspection::IntrospectionService, login::{ config::{AuthEngine, ZitadelClap}, AuthClap, }, - oauth::OAuth, - session::{PostgresqlSessionClap, SessionBackend, SessionService}, + session::{PostgresqlSessionClap, SessionBackend}, }; use tracing_subscriber::EnvFilter; @@ -48,7 +46,7 @@ async fn main() -> anyhow::Result<()> { }, }; - let auth_service = AuthService::new(&auth); + let auth_service = AuthService::new(&auth).await?; let state = AppState { auth: auth_service.clone(), diff --git a/examples/clap/src/main.rs b/examples/clap/src/main.rs index 60414a4..3d5c98f 100644 --- a/examples/clap/src/main.rs +++ b/examples/clap/src/main.rs @@ -11,7 +11,6 @@ use nefarious_login::{ auth::AuthService, axum::{AuthController, UserFromSession}, login::AuthClap, - session::SessionService, }; use tracing_subscriber::EnvFilter;