email with token & confirmation works

This commit is contained in:
Andre Heber
2024-02-27 15:21:54 +01:00
parent f4f16d621d
commit fd4ba6ae31
11 changed files with 210 additions and 27 deletions

View File

@ -114,20 +114,8 @@ async fn subscribe_sends_a_confirmation_email_with_a_link() {
assert_eq!(200, response.status().as_u16());
let email_request = &app.email_server.received_requests().await.unwrap()[0];
let body: serde_json::Value = serde_json::from_slice(&email_request.body).unwrap();
let get_link = |s: &str| {
let links: Vec<_> = linkify::LinkFinder::new()
.links(s)
.filter(|l| *l.kind() == linkify::LinkKind::Url)
.collect();
assert_eq!(links.len(), 1);
links[0].as_str().to_owned()
};
let html_link = get_link(body["HtmlBody"].as_str().unwrap());
let text_link = get_link(body["TextBody"].as_str().unwrap());
let confirmation_links = app.get_confirmation_links(email_request);
// The two links should be identical
assert_eq!(html_link, text_link);
assert_eq!(confirmation_links.html, confirmation_links.plain_text);
}