feat: forge adapter to get redirect URI for OAuth authorization req

This commit is contained in:
Aravinth Manivannan 2024-05-04 22:45:14 +05:30
parent 51ac3e4977
commit 253c26227c
Signed by: realaravinth
GPG key ID: F8F50389936984FF
3 changed files with 49 additions and 0 deletions

View file

@ -0,0 +1,9 @@
use derive_more::Display;
use serde::{Deserialize, Serialize};
pub type OutForgePortResult<V> = Result<V, OutForgePortError>;
#[derive(Debug, Display, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub enum OutForgePortError {
InteralError,
}

View file

@ -0,0 +1,10 @@
use super::errors::*;
use url::Url;
pub trait GetRedirectUri: Send + Sync {
fn get_redirect_uri(
&self,
state: &str,
process_authorization_response_uri: &Url,
) -> OutForgePortResult<Url>;
}

View file

@ -0,0 +1,30 @@
pub mod errors;
pub mod get_redirect_uri;
pub mod refresh_access_token;
pub mod request_access_token;
#[cfg(test)]
pub mod tests {
use url::Url;
use super::*;
use errors::*;
use get_redirect_uri::GetRedirectUri;
#[derive(Clone, Default)]
pub struct MockForge; // {
#[async_trait::async_trait]
impl GetRedirectUri for MockForge {
fn get_redirect_uri(
&self,
state: &str,
process_authorization_response_uri: &Url,
) -> OutForgePortResult<Url> {
let mut u = process_authorization_response_uri.clone();
u.set_query(Some(&format!("state={state}")));
Ok(u)
}
}
}