feat: db: store OTP links port
This commit is contained in:
parent
d1d87fa28c
commit
a7f9c3f9c6
1 changed files with 51 additions and 0 deletions
|
@ -0,0 +1,51 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use tests::*;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Builder)]
|
||||||
|
pub struct CreateSecretMsg {
|
||||||
|
pub secret: String,
|
||||||
|
pub purpose: String,
|
||||||
|
pub username: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait CreateVerificationSecretOutDBPort: Send + Sync {
|
||||||
|
async fn create_verification_secret(&self, msg: CreateSecretMsg) -> OutDBPortResult<()>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type CreateVerificationSecretOutDBPortObj =
|
||||||
|
std::sync::Arc<dyn CreateVerificationSecretOutDBPort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_create_verification_secret_db_port(
|
||||||
|
times: Option<usize>,
|
||||||
|
) -> CreateVerificationSecretOutDBPortObj {
|
||||||
|
let mut m = MockCreateVerificationSecretOutDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_create_verification_secret()
|
||||||
|
.times(times)
|
||||||
|
.returning(|_| Ok(()));
|
||||||
|
} else {
|
||||||
|
m.expect_create_verification_secret().returning(|_| Ok(()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue