s/maildev/mailpit/
This commit is contained in:
parent
a25a7ce39f
commit
283322cf29
7 changed files with 37 additions and 80 deletions
|
@ -4,6 +4,6 @@ export POSTGRES_DATABASE_URL="postgres://postgres:password@localhost:5432/postgr
|
|||
export VANIKAM_email_USERNAME=admin
|
||||
export VANIKAM_email_PASSWORD=password
|
||||
export VANIKAM_email_SERVER_HOSTNAME=localhost:10025
|
||||
export MAILDEV_URL=http://localhost:1080
|
||||
export MAILPIT_URL=http://localhost:1080
|
||||
export VANIKAM_email_FROM="Vanikam Info <info@vanikam.app>"
|
||||
export VANIKAM_email_REPLY_TO="Vanikam Support <support@vanikam.app>"
|
||||
|
|
|
@ -6,9 +6,9 @@ steps:
|
|||
environment:
|
||||
- DATABASE_URL=postgres://postgres:password@database:5432/postgres
|
||||
- VANIKAM_email_URL=smtp://admin:password@email:10025
|
||||
- MAILDEV_URL=http://email:1080
|
||||
- VANIKAM_meili_API_KEY=5c8eb5f46c148884fb64da09be211a18347fbba24435ca603adc9eba608ba66d
|
||||
- VANIKAM_meili_URL=http://meilisearch:7700
|
||||
- MAILPIT_URL=http://email:1080
|
||||
commands:
|
||||
# - curl -fsSL https://deb.nodesource.com/setup_16.x | bash - &&\
|
||||
# - apt update && apt-get -y --no-install-recommends install nodejs tar gpg curl wget
|
||||
|
@ -69,15 +69,15 @@ steps:
|
|||
# secrets: [RELEASE_BOT_GPG_SIGNING_KEY, DUMBSERVE_PASSWORD, GPG_PASSWORD]
|
||||
#
|
||||
services:
|
||||
email:
|
||||
image: axllent/mailpit
|
||||
environment:
|
||||
- MP_SMTP_AUTH=admin:password
|
||||
- MP_MAX_MESSAGES=5000
|
||||
- MP_SMTP_AUTH_ALLOW_INSECURE=1
|
||||
- MP_SMTP_BIND_ADDR=0.0.0.0:10025
|
||||
- MP_SMTP_AUTH_ALLOW_INSECURE=true
|
||||
- MP_UI_BIND_ADDR=0.0.0.0:1080
|
||||
# email:
|
||||
# image: axllent/mailpit
|
||||
# environment:
|
||||
# - MP_SMTP_AUTH=admin:password
|
||||
# - MP_MAX_MESSAGES=5000
|
||||
# - MP_SMTP_AUTH_ALLOW_INSECURE=1
|
||||
# - MP_SMTP_BIND_ADDR=0.0.0.0:10025
|
||||
# - MP_SMTP_AUTH_ALLOW_INSECURE=true
|
||||
# - MP_UI_BIND_ADDR=0.0.0.0:1080
|
||||
|
||||
|
||||
database:
|
||||
|
|
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -2174,7 +2174,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
|
||||
|
||||
[[package]]
|
||||
name = "maildev_client"
|
||||
name = "mailpit_client"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"actix-rt",
|
||||
|
@ -4447,7 +4447,7 @@ dependencies = [
|
|||
"derive_more 0.99.18",
|
||||
"lettre",
|
||||
"log",
|
||||
"maildev_client",
|
||||
"mailpit_client",
|
||||
"meilisearch-sdk",
|
||||
"mockall",
|
||||
"postgres-es",
|
||||
|
|
|
@ -5,7 +5,7 @@ edition = "2021"
|
|||
|
||||
[workspace]
|
||||
exclude = ["utils/db-migrations"] #, "utils/cache-bust"]
|
||||
members = [".", "maildev_client"]
|
||||
members = [".", "mailpit_client"]
|
||||
|
||||
[dependencies]
|
||||
actix-identity = "0.7.1"
|
||||
|
@ -40,4 +40,4 @@ validator = { version = "0.18.1", features = ["derive"] }
|
|||
|
||||
[dev-dependencies]
|
||||
reqwest = { version = "0.12.4", features = ["json"] }
|
||||
maildev_client = { path = "./maildev_client" }
|
||||
mailpit_client = { path = "./mailpit_client" }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "maildev_client"
|
||||
name = "mailpit_client"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
|
@ -15,17 +15,17 @@ use url::Url;
|
|||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, Getters, Builder)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub struct MaildevAddress {
|
||||
pub struct MailPitAddress {
|
||||
address: String,
|
||||
name: String,
|
||||
}
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, Getters, Builder)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub struct MaildevEmail {
|
||||
pub struct MailPitEmail {
|
||||
#[serde(rename = "ID")]
|
||||
id: String,
|
||||
from: MaildevAddress,
|
||||
to: Vec<MaildevAddress>,
|
||||
from: MailPitAddress,
|
||||
to: Vec<MailPitAddress>,
|
||||
subject: String,
|
||||
#[serde(rename = "Snippet")]
|
||||
text: String,
|
||||
|
@ -33,17 +33,17 @@ pub struct MaildevEmail {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Getters, Builder)]
|
||||
pub struct MaildevHTTPClient {
|
||||
pub struct MailPitHTTPClient {
|
||||
#[builder(default = "Client::default()")]
|
||||
client: Client,
|
||||
url: Url,
|
||||
}
|
||||
|
||||
impl MaildevHTTPClient {
|
||||
pub async fn list_emails(&self) -> Vec<MaildevEmail> {
|
||||
impl MailPitHTTPClient {
|
||||
pub async fn list_emails(&self) -> Vec<MailPitEmail> {
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
|
||||
struct List {
|
||||
messages: Vec<MaildevEmail>,
|
||||
messages: Vec<MailPitEmail>,
|
||||
}
|
||||
|
||||
let mut u = self.url.clone();
|
||||
|
@ -63,14 +63,14 @@ impl MaildevHTTPClient {
|
|||
list.messages
|
||||
}
|
||||
|
||||
pub async fn get_email_addressed_to(&self, email_address: &str) -> MaildevEmail {
|
||||
pub async fn get_email_addressed_to(&self, email_address: &str) -> MailPitEmail {
|
||||
self.list_emails()
|
||||
.await
|
||||
.drain(0..)
|
||||
.find(|e| e.to.iter().any(|f| f.address == email_address))
|
||||
.unwrap()
|
||||
}
|
||||
pub async fn delete_email(&self, email: MaildevEmail) {
|
||||
pub async fn delete_email(&self, email: MailPitEmail) {
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
|
||||
struct DeletePayload {
|
||||
#[serde(rename = "IDs")]
|
|
@ -38,54 +38,11 @@ impl AccountValidationLinkOutMailerPort for LettreMailer {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use reqwest::Client;
|
||||
use url::Url;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use mailpit_client::*;
|
||||
|
||||
use maildev_client::*;
|
||||
|
||||
#[derive(Deserialize, Clone)]
|
||||
struct MailPitAddress {
|
||||
#[serde(rename = "Address")]
|
||||
address: String,
|
||||
#[serde(rename = "Name")]
|
||||
name: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone)]
|
||||
pub struct MailpitSummary {
|
||||
#[serde(rename = "ID")]
|
||||
id: String,
|
||||
#[serde(rename = "To")]
|
||||
to: Vec<MailPitAddress>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone)]
|
||||
pub struct MailpitEmail {
|
||||
#[serde(rename = "From")]
|
||||
from: MailPitAddress,
|
||||
#[serde(rename = "To")]
|
||||
to: Vec<MailPitAddress>,
|
||||
#[serde(rename = "ReplyTo")]
|
||||
reply_to: Vec<MailPitAddress>,
|
||||
#[serde(rename = "Subject")]
|
||||
subject: String,
|
||||
#[serde(rename = "Text")]
|
||||
text: String,
|
||||
#[serde(rename = "HTML")]
|
||||
html: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone)]
|
||||
pub struct MailpitListEmails {
|
||||
messages: Vec<MailpitSummary>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
pub struct MailpitDeleteEmail {
|
||||
IDs: Vec<String>,
|
||||
}
|
||||
use serde::Deserialize;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_mailer_account_validation_link() {
|
||||
|
@ -100,22 +57,22 @@ mod tests {
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
let maildev_url =
|
||||
std::env::var("MAILDEV_URL").expect("Please set maildev instance URL in MAILDEV_URL");
|
||||
let mc = MaildevHTTPClientBuilder::default()
|
||||
.url(Url::parse(&maildev_url).unwrap())
|
||||
let mailpit_url =
|
||||
std::env::var("MAILPIT_URL").expect("Please set mailpit instance URL in MAILPIT_URL");
|
||||
let mc = MailPitHTTPClientBuilder::default()
|
||||
.url(Url::parse(&mailpit_url).unwrap())
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
let maildev_email = mc.get_email_addressed_to(email).await;
|
||||
let mailpit_email = mc.get_email_addressed_to(email).await;
|
||||
|
||||
assert!(maildev_email.text().contains(validation_secret));
|
||||
assert!(maildev_email.text().contains(username));
|
||||
assert!(maildev_email
|
||||
assert!(mailpit_email.text().contains(validation_secret));
|
||||
assert!(mailpit_email.text().contains(username));
|
||||
assert!(mailpit_email
|
||||
.to()
|
||||
.iter()
|
||||
.any(|t| t.address() == email && t.name() == username));
|
||||
|
||||
mc.delete_email(maildev_email).await;
|
||||
mc.delete_email(mailpit_email).await;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue