diff --git a/src/identity/application/port/output/db/create_verification_secret.rs b/src/identity/application/port/output/db/create_verification_secret.rs new file mode 100644 index 0000000..e7f2b34 --- /dev/null +++ b/src/identity/application/port/output/db/create_verification_secret.rs @@ -0,0 +1,51 @@ +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// 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; + +#[cfg(test)] +pub mod tests { + use super::*; + + use std::sync::Arc; + + pub fn mock_create_verification_secret_db_port( + times: Option, + ) -> 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) + } +}