all4art_authservice_mocks/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use std::sync::Arc;

use all4art_authservice_domain::{factories::ClearTextPasswordFactory, clear_text_password::ClearTextPassword, hashed_password::HashedPassword};

pub struct ClearTextPasswordFactoryMock { 

}

impl ClearTextPasswordFactory for ClearTextPasswordFactoryMock { 
    fn create(&self, text: String) -> Result<Arc<dyn ClearTextPassword + Send + Sync>, std::io::Error> { 
        Ok(Arc::new(ClearTextPasswordMock{}))
    }
}

pub struct ClearTextPasswordMock { 

}

impl ClearTextPassword for ClearTextPasswordMock { 
    fn text(&self) -> Result<String, std::io::Error> { 
        Ok(String::from("some_password"))
    }    

    fn hashed_password(&self) 
    -> Result<Arc<dyn HashedPassword + Send + Sync>, std::io::Error> { 
        let hashed_password = Arc::new(HashedPasswordMock{});
        Ok(hashed_password)
    }
}

pub struct HashedPasswordMock { 

}

impl HashedPassword for HashedPasswordMock { 
    fn equals(&self, hashed_password: Arc<dyn HashedPassword>) -> Result<bool, std::io::Error> { 
        Ok(true)
    }
}