feat: db: store OTP links port

This commit is contained in:
Aravinth Manivannan 2024-05-17 23:22:49 +05:30
parent d1d87fa28c
commit a7f9c3f9c6
Signed by: realaravinth
GPG key ID: F8F50389936984FF

View file

@ -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)
}
}