diff --git a/Cargo.lock b/Cargo.lock index 13d4e684..6c9d59c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -437,6 +437,33 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "awc" +version = "3.0.0-beta.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "364ef81705bf38403a3c3da4fab9eeec1e1503cd72dd6cd7c4259d2a6b08aa98" +dependencies = [ + "actix-codec", + "actix-http", + "actix-rt", + "actix-service", + "base64", + "bytes", + "cfg-if", + "cookie", + "derive_more", + "futures-core", + "itoa", + "log", + "mime", + "percent-encoding", + "pin-project-lite", + "rand 0.8.4", + "serde 1.0.126", + "serde_json", + "serde_urlencoded", +] + [[package]] name = "base-x" version = "0.2.8" @@ -1533,6 +1560,7 @@ dependencies = [ "actix-web", "actix-web-codegen 0.5.0-beta.3 (git+https://github.com/realaravinth/actix-web)", "argon2-creds", + "awc", "cache-buster", "config", "derive_builder", diff --git a/Cargo.toml b/Cargo.toml index 9c67af2b..318db6a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -89,6 +89,7 @@ mime = "0.3.16" [dev-dependencies] pow_sha256 = { version = "0.2.1", git = "https://github.com/mcaptcha/pow_sha256" } +awc = "3.0.0-beta.7" [target.x86_64-unknown-linux-musl] diff --git a/src/email/verification.rs b/src/email/verification.rs index 1eb7d039..5e4eed2e 100644 --- a/src/email/verification.rs +++ b/src/email/verification.rs @@ -100,6 +100,8 @@ project website: {}", mod tests { use super::*; + use awc::Client; + #[actix_rt::test] async fn email_verification_works() { const TO_ADDR: &str = "Hello "; @@ -108,5 +110,21 @@ mod tests { verification(&data, TO_ADDR, VERIFICATION_LINK) .await .unwrap(); + + let client = Client::default(); + let mut resp = client.get("http://localhost:1080/email") + .send() + .await + .unwrap(); + let data: serde_json::Value = resp.json().await.unwrap(); + let data = &data[0]; + let smtp = SETTINGS.smtp.as_ref().unwrap(); + + let from_addr = &data["headers"]["from"];["address"]; + + assert!(from_addr.to_string().contains(&smtp.from)); + + let body = &data["html"]; + assert!(body.to_string().contains(VERIFICATION_LINK)); } }