all4art_authservice_mocks/
lib.rs

1use std::sync::Arc;
2
3use all4art_authservice_domain::{factories::ClearTextPasswordFactory, clear_text_password::ClearTextPassword, hashed_password::HashedPassword};
4
5pub struct ClearTextPasswordFactoryMock { 
6
7}
8
9impl ClearTextPasswordFactory for ClearTextPasswordFactoryMock { 
10    fn create(&self, text: String) -> Result<Arc<dyn ClearTextPassword + Send + Sync>, std::io::Error> { 
11        Ok(Arc::new(ClearTextPasswordMock{}))
12    }
13}
14
15pub struct ClearTextPasswordMock { 
16
17}
18
19impl ClearTextPassword for ClearTextPasswordMock { 
20    fn text(&self) -> Result<String, std::io::Error> { 
21        Ok(String::from("some_password"))
22    }    
23
24    fn hashed_password(&self) 
25    -> Result<Arc<dyn HashedPassword + Send + Sync>, std::io::Error> { 
26        let hashed_password = Arc::new(HashedPasswordMock{});
27        Ok(hashed_password)
28    }
29}
30
31pub struct HashedPasswordMock { 
32
33}
34
35impl HashedPassword for HashedPasswordMock { 
36    fn equals(&self, hashed_password: Arc<dyn HashedPassword>) -> Result<bool, std::io::Error> { 
37        Ok(true)
38    }
39}