// SPDX-License-Identifier: AGPL-3.0-or-later #![recursion_limit = "256"] use axum::{ Json, Router, body::{Body, to_bytes}, extract::State, http::{Method, Request, StatusCode, Uri, header}, response::{IntoResponse, Response}, }; use fluxer_admin::{ build_router, config::{AdminConfig, ProxyConfig}, session, }; use serde_json::{Value, json}; use std::sync::{Arc, Mutex}; use tokio::net::TcpListener; use tower::ServiceExt; const SECRET_KEY: &str = "password-reset-link-test-secret"; const ADMIN_ID: &str = "1500000000000000000"; const TARGET_ID: &str = "1500000000000000042"; const RESET_URL: &str = "https://chat.example.test/reset#token=one-time-reset-token"; #[derive(Clone)] struct MockApi { account_identity: &'static str, admin_acls: Vec<&'static str>, requests: Arc>>, } #[tokio::test] async fn an_htmx_reset_link_request_gets_only_the_result_fragment() { let app = setup(true, "username", vec!["*"]).await; let page = get(&app, &format!("/users/{TARGET_ID}?tab=account")).await; assert!(page.contains(r##"hx-target="#password-reset-link-result""##)); assert!(page.contains(r#"hx-push-url="false""#)); let csrf_token = csrf_token(&app).await; let (status, body) = post_form_with_headers( &app, &format!("/users/{TARGET_ID}?action=create_password_reset_link&tab=account"), &format!("_csrf={csrf_token}"), &[ ("HX-Request", "true"), ("HX-Target", "password-reset-link-result"), ], ) .await; assert_eq!(status, StatusCode::OK); assert!( body.starts_with(r#"