Separate ldap_handler, add tests

This commit is contained in:
Valentin Tolmer
2021-03-11 10:50:15 +01:00
parent ff4e986a0d
commit 86b89a00cc
4 changed files with 143 additions and 78 deletions

View File

@@ -2,13 +2,16 @@ use crate::infra::configuration::Configuration;
use anyhow::{bail, Result};
use sqlx::any::AnyPool;
#[cfg_attr(test, derive(PartialEq, Eq, Debug))]
pub struct BindRequest {
pub name: String,
pub password: String,
}
#[cfg_attr(test, derive(PartialEq, Eq, Debug))]
pub struct SearchRequest {}
#[cfg_attr(test, derive(PartialEq, Eq, Debug))]
pub struct SearchResponse {}
pub trait BackendHandler: Clone + Send {
@@ -47,3 +50,15 @@ impl BackendHandler for SqlBackendHandler {
Ok(SearchResponse {})
}
}
#[cfg(test)]
mockall::mock! {
pub TestBackendHandler{}
impl Clone for TestBackendHandler {
fn clone(&self) -> Self;
}
impl BackendHandler for TestBackendHandler {
fn bind(&mut self, request: BindRequest) -> Result<()>;
fn search(&mut self, request: SearchRequest) -> Result<SearchResponse>;
}
}