feat: with fmt
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
df74c70fa0
commit
6ca2c54b10
@ -10,17 +10,11 @@ pub mod auth {
|
|||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use axum::http::{header::SET_COOKIE, HeaderMap};
|
use axum::http::{header::SET_COOKIE, HeaderMap};
|
||||||
use oauth2::{
|
use oauth2::url::Url;
|
||||||
basic::BasicClient, reqwest::async_http_client, url::Url, AuthUrl, AuthorizationCode,
|
|
||||||
ClientId, ClientSecret, CsrfToken, RedirectUrl, Scope, TokenResponse, TokenUrl,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
introspection::IntrospectionService,
|
introspection::IntrospectionService,
|
||||||
login::{
|
login::{config::AuthEngine, AuthClap},
|
||||||
config::{AuthEngine, ZitadelClap},
|
|
||||||
AuthClap,
|
|
||||||
},
|
|
||||||
oauth::{OAuth, ZitadelConfig},
|
oauth::{OAuth, ZitadelConfig},
|
||||||
session::{SessionService, User},
|
session::{SessionService, User},
|
||||||
};
|
};
|
||||||
@ -179,7 +173,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_command_parse_as_default_noop() {
|
fn test_command_parse_as_default_noop() {
|
||||||
let cli: Cli = Cli::parse_from(&["base", "one"]);
|
let cli: Cli = Cli::parse_from(["base", "one"]);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
cli.command,
|
cli.command,
|
||||||
@ -205,7 +199,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_command_parse_as_noop() {
|
fn test_command_parse_as_noop() {
|
||||||
let cli: Cli = Cli::parse_from(&["base", "one", "--auth-engine", "noop"]);
|
let cli: Cli = Cli::parse_from(["base", "one", "--auth-engine", "noop"]);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
cli.command,
|
cli.command,
|
||||||
@ -231,7 +225,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_command_parse_as_zitadel() {
|
fn test_command_parse_as_zitadel() {
|
||||||
let cli: Cli = Cli::parse_from(&[
|
let cli: Cli = Cli::parse_from([
|
||||||
"base",
|
"base",
|
||||||
"one",
|
"one",
|
||||||
"--auth-engine=zitadel",
|
"--auth-engine=zitadel",
|
||||||
|
@ -86,32 +86,32 @@ pub mod config {
|
|||||||
pub fn merge(&mut self, config: AuthConfigFile) -> &mut Self {
|
pub fn merge(&mut self, config: AuthConfigFile) -> &mut Self {
|
||||||
if let Some(zitadel) = config.zitadel {
|
if let Some(zitadel) = config.zitadel {
|
||||||
if let Some(auth_url) = zitadel.auth_url {
|
if let Some(auth_url) = zitadel.auth_url {
|
||||||
if let Some(_) = self.zitadel.auth_url {
|
if self.zitadel.auth_url.is_some() {
|
||||||
_ = self.zitadel.auth_url.replace(auth_url);
|
_ = self.zitadel.auth_url.replace(auth_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(client_id) = zitadel.client_id {
|
if let Some(client_id) = zitadel.client_id {
|
||||||
if let Some(_) = self.zitadel.client_id {
|
if self.zitadel.client_id.is_some() {
|
||||||
_ = self.zitadel.client_id.replace(client_id);
|
_ = self.zitadel.client_id.replace(client_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(client_secret) = zitadel.client_secret {
|
if let Some(client_secret) = zitadel.client_secret {
|
||||||
if let Some(_) = self.zitadel.client_secret {
|
if self.zitadel.client_secret.is_some() {
|
||||||
_ = self.zitadel.client_secret.replace(client_secret);
|
_ = self.zitadel.client_secret.replace(client_secret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(redirect_url) = zitadel.redirect_url {
|
if let Some(redirect_url) = zitadel.redirect_url {
|
||||||
if let Some(_) = self.zitadel.redirect_url {
|
if self.zitadel.redirect_url.is_some() {
|
||||||
_ = self.zitadel.redirect_url.replace(redirect_url);
|
_ = self.zitadel.redirect_url.replace(redirect_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(authority_url) = zitadel.authority_url {
|
if let Some(authority_url) = zitadel.authority_url {
|
||||||
if let Some(_) = self.zitadel.authority_url {
|
if self.zitadel.authority_url.is_some() {
|
||||||
_ = self.zitadel.authority_url.replace(authority_url);
|
_ = self.zitadel.authority_url.replace(authority_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(token_url) = zitadel.token_url {
|
if let Some(token_url) = zitadel.token_url {
|
||||||
if let Some(_) = self.zitadel.token_url {
|
if self.zitadel.token_url.is_some() {
|
||||||
_ = self.zitadel.token_url.replace(token_url);
|
_ = self.zitadel.token_url.replace(token_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,13 @@
|
|||||||
use std::{ops::Deref, sync::Arc};
|
use std::{ops::Deref, sync::Arc};
|
||||||
|
|
||||||
use anyhow::Context;
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use axum::http::{header::SET_COOKIE, HeaderMap};
|
|
||||||
use oauth2::{
|
use oauth2::{
|
||||||
basic::BasicClient, reqwest::async_http_client, url::Url, AuthUrl, AuthorizationCode, ClientId,
|
basic::BasicClient, reqwest::async_http_client, url::Url, AuthUrl, AuthorizationCode, ClientId,
|
||||||
ClientSecret, CsrfToken, RedirectUrl, Scope, TokenResponse, TokenUrl,
|
ClientSecret, CsrfToken, RedirectUrl, Scope, TokenResponse, TokenUrl,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::login::config::ZitadelClap;
|
||||||
introspection::IntrospectionService,
|
|
||||||
login::{
|
|
||||||
config::{AuthEngine, ZitadelClap},
|
|
||||||
AuthClap,
|
|
||||||
},
|
|
||||||
session::{SessionService, User},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait OAuthClient {
|
pub trait OAuthClient {
|
||||||
@ -212,7 +204,7 @@ mod tests {
|
|||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_parse_clap_zitadel() {
|
async fn test_parse_clap_zitadel() {
|
||||||
let cli: Cli = Cli::parse_from(&[
|
let cli: Cli = Cli::parse_from([
|
||||||
"base",
|
"base",
|
||||||
"--zitadel-client-id=something",
|
"--zitadel-client-id=something",
|
||||||
"--zitadel-client-secret=something",
|
"--zitadel-client-secret=something",
|
||||||
@ -238,7 +230,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_clap_zitadel_fails_require_all() {
|
fn test_parse_clap_zitadel_fails_require_all() {
|
||||||
let cli = CliSubCommand::try_parse_from(&[
|
let cli = CliSubCommand::try_parse_from([
|
||||||
"base",
|
"base",
|
||||||
"one",
|
"one",
|
||||||
// "--zitadel-client-id=something", // We want to trigger missing variable
|
// "--zitadel-client-id=something", // We want to trigger missing variable
|
||||||
@ -261,7 +253,7 @@ mod tests {
|
|||||||
std::env::set_var("ZITADEL_TOKEN_URL", "https://something");
|
std::env::set_var("ZITADEL_TOKEN_URL", "https://something");
|
||||||
std::env::set_var("ZITADEL_AUTHORITY_URL", "https://something");
|
std::env::set_var("ZITADEL_AUTHORITY_URL", "https://something");
|
||||||
|
|
||||||
let cli = CliSubCommand::parse_from(&["base", "one"]);
|
let cli = CliSubCommand::parse_from(["base", "one"]);
|
||||||
|
|
||||||
pretty_assertions::assert_eq!(
|
pretty_assertions::assert_eq!(
|
||||||
cli.command,
|
cli.command,
|
||||||
@ -279,7 +271,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_clap_defaults_to_noop() {
|
fn test_parse_clap_defaults_to_noop() {
|
||||||
let cli = CliSubCommand::parse_from(&["base", "one"]);
|
let cli = CliSubCommand::parse_from(["base", "one"]);
|
||||||
|
|
||||||
pretty_assertions::assert_eq!(
|
pretty_assertions::assert_eq!(
|
||||||
cli.command,
|
cli.command,
|
||||||
|
Loading…
Reference in New Issue
Block a user