mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
email verification test
This commit is contained in:
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"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
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]]
|
[[package]]
|
||||||
name = "base-x"
|
name = "base-x"
|
||||||
version = "0.2.8"
|
version = "0.2.8"
|
||||||
@@ -1533,6 +1560,7 @@ dependencies = [
|
|||||||
"actix-web",
|
"actix-web",
|
||||||
"actix-web-codegen 0.5.0-beta.3 (git+https://github.com/realaravinth/actix-web)",
|
"actix-web-codegen 0.5.0-beta.3 (git+https://github.com/realaravinth/actix-web)",
|
||||||
"argon2-creds",
|
"argon2-creds",
|
||||||
|
"awc",
|
||||||
"cache-buster",
|
"cache-buster",
|
||||||
"config",
|
"config",
|
||||||
"derive_builder",
|
"derive_builder",
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ mime = "0.3.16"
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pow_sha256 = { version = "0.2.1", git = "https://github.com/mcaptcha/pow_sha256" }
|
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]
|
[target.x86_64-unknown-linux-musl]
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ project website: {}",
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
use awc::Client;
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn email_verification_works() {
|
async fn email_verification_works() {
|
||||||
const TO_ADDR: &str = "Hello <realaravinth@localhost>";
|
const TO_ADDR: &str = "Hello <realaravinth@localhost>";
|
||||||
@@ -108,5 +110,21 @@ mod tests {
|
|||||||
verification(&data, TO_ADDR, VERIFICATION_LINK)
|
verification(&data, TO_ADDR, VERIFICATION_LINK)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user