backend/keycloak_api/
mock_api.rs

1//! Mock implementation for the keycloak admin API.
2//! It is used for when the environment variables are not set which are needed to connect to the real keycloak API.
3
4use async_trait::async_trait;
5
6use crate::model::dto::{PageParameters, UserSearchParameters};
7
8use super::{
9    traits::{KeycloakApi, Result},
10    UserDto,
11};
12
13pub struct MockApi;
14
15#[async_trait]
16impl KeycloakApi for MockApi {
17    async fn search_users_by_username(
18        &self,
19        _search_params: &UserSearchParameters,
20        _pagination: &PageParameters,
21        _client: &reqwest::Client,
22    ) -> Result<Vec<UserDto>> {
23        Ok(vec![])
24    }
25
26    async fn get_users_by_ids(
27        &self,
28        _client: &reqwest::Client,
29        _user_ids: Vec<uuid::Uuid>,
30    ) -> Result<Vec<UserDto>> {
31        Ok(vec![])
32    }
33
34    async fn get_user_by_id(
35        &self,
36        _client: &reqwest::Client,
37        user_id: uuid::Uuid,
38    ) -> Result<UserDto> {
39        Ok(UserDto {
40            id: user_id,
41            username: "mock_user".to_owned(),
42        })
43    }
44}