feat: with fmt

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2023-10-22 16:56:07 +02:00
parent df74c70fa0
commit 6ca2c54b10
Signed by: kjuulh
GPG Key ID: 9AA7BC13CE474394
3 changed files with 17 additions and 31 deletions

View File

@ -10,17 +10,11 @@ pub mod auth {
use anyhow::Context;
use async_trait::async_trait;
use axum::http::{header::SET_COOKIE, HeaderMap};
use oauth2::{
basic::BasicClient, reqwest::async_http_client, url::Url, AuthUrl, AuthorizationCode,
ClientId, ClientSecret, CsrfToken, RedirectUrl, Scope, TokenResponse, TokenUrl,
};
use oauth2::url::Url;
use crate::{
introspection::IntrospectionService,
login::{
config::{AuthEngine, ZitadelClap},
AuthClap,
},
login::{config::AuthEngine, AuthClap},
oauth::{OAuth, ZitadelConfig},
session::{SessionService, User},
};
@ -179,7 +173,7 @@ mod test {
#[test]
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!(
cli.command,
@ -205,7 +199,7 @@ mod test {
#[test]
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!(
cli.command,
@ -231,7 +225,7 @@ mod test {
#[test]
fn test_command_parse_as_zitadel() {
let cli: Cli = Cli::parse_from(&[
let cli: Cli = Cli::parse_from([
"base",
"one",
"--auth-engine=zitadel",

View File

@ -86,32 +86,32 @@ pub mod config {
pub fn merge(&mut self, config: AuthConfigFile) -> &mut Self {
if let Some(zitadel) = config.zitadel {
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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}

View File

@ -1,21 +1,13 @@
use std::{ops::Deref, sync::Arc};
use anyhow::Context;
use async_trait::async_trait;
use axum::http::{header::SET_COOKIE, HeaderMap};
use oauth2::{
basic::BasicClient, reqwest::async_http_client, url::Url, AuthUrl, AuthorizationCode, ClientId,
ClientSecret, CsrfToken, RedirectUrl, Scope, TokenResponse, TokenUrl,
};
use crate::{
introspection::IntrospectionService,
login::{
config::{AuthEngine, ZitadelClap},
AuthClap,
},
session::{SessionService, User},
};
use crate::login::config::ZitadelClap;
#[async_trait]
pub trait OAuthClient {
@ -212,7 +204,7 @@ mod tests {
#[tokio::test]
async fn test_parse_clap_zitadel() {
let cli: Cli = Cli::parse_from(&[
let cli: Cli = Cli::parse_from([
"base",
"--zitadel-client-id=something",
"--zitadel-client-secret=something",
@ -238,7 +230,7 @@ mod tests {
#[test]
fn test_parse_clap_zitadel_fails_require_all() {
let cli = CliSubCommand::try_parse_from(&[
let cli = CliSubCommand::try_parse_from([
"base",
"one",
// "--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_AUTHORITY_URL", "https://something");
let cli = CliSubCommand::parse_from(&["base", "one"]);
let cli = CliSubCommand::parse_from(["base", "one"]);
pretty_assertions::assert_eq!(
cli.command,
@ -279,7 +271,7 @@ mod tests {
}
#[test]
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!(
cli.command,