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