mirror of
https://github.com/nitnelave/lldap.git
synced 2023-04-12 14:25:13 +00:00
40 lines
1.7 KiB
Rust
40 lines
1.7 KiB
Rust
use async_trait::async_trait;
|
|
use std::collections::HashSet;
|
|
|
|
pub type DomainError = crate::domain::error::Error;
|
|
pub type DomainResult<T> = crate::domain::error::Result<T>;
|
|
|
|
#[async_trait]
|
|
pub trait TcpBackendHandler {
|
|
async fn get_jwt_blacklist(&self) -> anyhow::Result<HashSet<u64>>;
|
|
async fn create_refresh_token(&self, user: &str) -> DomainResult<(String, chrono::Duration)>;
|
|
async fn check_token(&self, token: &str, user: &str) -> DomainResult<bool>;
|
|
async fn blacklist_jwts(&self, user: &str) -> DomainResult<HashSet<u64>>;
|
|
async fn delete_refresh_token(&self, token: &str) -> DomainResult<()>;
|
|
}
|
|
|
|
#[cfg(test)]
|
|
use crate::domain::handler::*;
|
|
#[cfg(test)]
|
|
mockall::mock! {
|
|
pub TestTcpBackendHandler{}
|
|
impl Clone for TestTcpBackendHandler {
|
|
fn clone(&self) -> Self;
|
|
}
|
|
#[async_trait]
|
|
impl BackendHandler for TestTcpBackendHandler {
|
|
async fn bind(&self, request: BindRequest) -> DomainResult<()>;
|
|
async fn list_users(&self, request: ListUsersRequest) -> DomainResult<Vec<User>>;
|
|
async fn list_groups(&self) -> DomainResult<Vec<Group>>;
|
|
async fn get_user_groups(&self, user: String) -> DomainResult<HashSet<String>>;
|
|
}
|
|
#[async_trait]
|
|
impl TcpBackendHandler for TestTcpBackendHandler {
|
|
async fn get_jwt_blacklist(&self) -> anyhow::Result<HashSet<u64>>;
|
|
async fn create_refresh_token(&self, user: &str) -> DomainResult<(String, chrono::Duration)>;
|
|
async fn check_token(&self, token: &str, user: &str) -> DomainResult<bool>;
|
|
async fn blacklist_jwts(&self, user: &str) -> DomainResult<HashSet<u64>>;
|
|
async fn delete_refresh_token(&self, token: &str) -> DomainResult<()>;
|
|
}
|
|
}
|