feat: factory for GetUsername, OAuthAuthReqUrl & RequestAccessToken
This commit is contained in:
parent
8eff4adbb8
commit
57d0579971
|
@ -4,11 +4,16 @@ use mockall::predicate::*;
|
|||
use mockall::*;
|
||||
|
||||
use super::forgejo::Forgejo;
|
||||
use crate::auth::application::port::out::forge::oauth_auth_req_uri::OAuthAuthReqUri;
|
||||
use crate::auth::application::port::out::forge::{
|
||||
get_username::GetUsername, oauth_auth_req_uri::OAuthAuthReqUri,
|
||||
request_access_token::RequestAccessToken,
|
||||
};
|
||||
|
||||
#[automock]
|
||||
pub trait ForgeAdapterFactoryInterface: Send + Sync {
|
||||
fn get_oauth_auth_req_uri_adapter(&self) -> Arc<dyn OAuthAuthReqUri>;
|
||||
fn oauth_auth_req_uri_adapter(&self) -> Arc<dyn OAuthAuthReqUri>;
|
||||
fn request_access_token_adapter(&self) -> Arc<dyn RequestAccessToken>;
|
||||
fn get_username_adapter(&self) -> Arc<dyn GetUsername>;
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -17,7 +22,13 @@ pub struct ForgeAdapterFactory {
|
|||
}
|
||||
|
||||
impl ForgeAdapterFactoryInterface for ForgeAdapterFactory {
|
||||
fn get_oauth_auth_req_uri_adapter(&self) -> Arc<dyn OAuthAuthReqUri> {
|
||||
fn oauth_auth_req_uri_adapter(&self) -> Arc<dyn OAuthAuthReqUri> {
|
||||
self.forgejo.clone()
|
||||
}
|
||||
fn request_access_token_adapter(&self) -> Arc<dyn RequestAccessToken> {
|
||||
self.forgejo.clone()
|
||||
}
|
||||
fn get_username_adapter(&self) -> Arc<dyn GetUsername> {
|
||||
self.forgejo.clone()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
use reqwest::Client;
|
||||
use url::Url;
|
||||
|
||||
pub mod get_username;
|
||||
pub mod oauth_auth_req_uri;
|
||||
pub mod request_access_token;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Forgejo {
|
||||
url: Url,
|
||||
client_id: String,
|
||||
client_secret: String,
|
||||
pub http_client: Client,
|
||||
}
|
||||
|
||||
impl Forgejo {
|
||||
|
@ -15,6 +19,7 @@ impl Forgejo {
|
|||
url,
|
||||
client_id,
|
||||
client_secret,
|
||||
http_client: Client::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue