diff --git a/src/identity/application/port/output/mailer/account_validation_link.rs b/src/identity/application/port/output/mailer/account_validation_link.rs new file mode 100644 index 0000000..720796e --- /dev/null +++ b/src/identity/application/port/output/mailer/account_validation_link.rs @@ -0,0 +1,48 @@ +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// SPDX-License-Identifier: AGPL-3.0-or-later + +use mockall::predicate::*; +use mockall::*; + +use super::errors::*; +#[cfg(test)] +#[allow(unused_imports)] +pub use tests::*; + +#[automock] +#[async_trait::async_trait] +pub trait AccountValidationLinkOutMailerPort: Send + Sync { + async fn account_validation_link( + &self, + to: &str, + username: &str, + validation_secret: &str, + ) -> OutMailerPortResult<()>; +} + +pub type AccountValidationLinkOutMailerPortObj = + std::sync::Arc; + +#[cfg(test)] +pub mod tests { + use super::*; + + use std::sync::Arc; + + pub fn mock_account_validation_link_db_port( + times: Option, + ) -> AccountValidationLinkOutMailerPortObj { + let mut m = MockAccountValidationLinkOutMailerPort::new(); + if let Some(times) = times { + m.expect_account_validation_link() + .times(times) + .returning(|_, _, _| Ok(())); + } else { + m.expect_account_validation_link() + .returning(|_, _, _| Ok(())); + } + + Arc::new(m) + } +} diff --git a/src/identity/application/port/output/mailer/errors.rs b/src/identity/application/port/output/mailer/errors.rs new file mode 100644 index 0000000..aa43436 --- /dev/null +++ b/src/identity/application/port/output/mailer/errors.rs @@ -0,0 +1,13 @@ +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// SPDX-License-Identifier: AGPL-3.0-or-later + +use derive_more::Display; +use serde::{Deserialize, Serialize}; + +pub type OutMailerPortResult = Result; + +#[derive(Debug, Display, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] +pub enum OutMailerPortError { + InternalError, +} diff --git a/src/identity/application/port/output/mailer/mod.rs b/src/identity/application/port/output/mailer/mod.rs new file mode 100644 index 0000000..4ad0635 --- /dev/null +++ b/src/identity/application/port/output/mailer/mod.rs @@ -0,0 +1,6 @@ +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// SPDX-License-Identifier: AGPL-3.0-or-later + +pub mod account_validation_link; +pub mod errors;