mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-03-14 13:08:27 +03:00
email verification test
This commit is contained in:
parent
8d32ebcf95
commit
362e2aeae0
3 changed files with 47 additions and 0 deletions
28
Cargo.lock
generated
28
Cargo.lock
generated
|
@ -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",
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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 <realaravinth@localhost>";
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue