@@ -11,53 +11,13 @@ use crate::config::Config;
1111use crate :: error:: AppError ;
1212use crate :: pages:: * ;
1313
14- /// Mock configuration for testing
15- fn create_mock_config ( ) -> Config {
16- Config {
17- database_url : "sqlite::memory:" . to_string ( ) ,
18- listen_host : "127.0.0.1" . to_string ( ) ,
19- listen_port : 8080 ,
20- path_prefix : "/demo" . to_string ( ) ,
21- external_url : "http://localhost:8080" . to_string ( ) ,
22- link_duration : chrono:: Duration :: try_hours ( 12 ) . unwrap ( ) ,
23- session_duration : chrono:: Duration :: try_days ( 30 ) . unwrap ( ) ,
24- secrets_cleanup_interval : chrono:: Duration :: try_hours ( 24 ) . unwrap ( ) ,
25- title : "MagicEntry Demo" . to_string ( ) ,
26- static_path : "static" . to_string ( ) ,
27- auth_url_enable : true ,
28- auth_url_user_header : "X-Remote-User" . to_string ( ) ,
29- auth_url_email_header : "X-Remote-Email" . to_string ( ) ,
30- auth_url_name_header : "X-Remote-Name" . to_string ( ) ,
31- auth_url_realms_header : "X-Remote-Realms" . to_string ( ) ,
32- oidc_code_duration : chrono:: Duration :: try_minutes ( 1 ) . unwrap ( ) ,
33- saml_cert_pem_path : "saml_cert.pem" . to_string ( ) ,
34- saml_key_pem_path : "saml_key.pem" . to_string ( ) ,
35- smtp_enable : false ,
36- smtp_url : "smtp://localhost:25" . to_string ( ) ,
37- smtp_from : "{title} <magicentry@example.com>" . to_string ( ) ,
38- smtp_subject : "{title} Login" . to_string ( ) ,
39- smtp_body : "Click the link to login: {magic_link}" . to_string ( ) ,
40- request_enable : false ,
41- request_url : "https://www.cinotify.cc/api/notify" . to_string ( ) ,
42- request_method : "POST" . to_string ( ) ,
43- request_data : Some ( "to={email}&subject={title} Login&body=Click the link to login: <a href=\" {magic_link}\" >Login</a>&type=text/html" . to_string ( ) ) ,
44- request_content_type : "application/x-www-form-urlencoded" . to_string ( ) ,
45- webauthn_enable : true ,
46- users_file : None ,
47- users_sql_query : None ,
48- users_sql_url : None ,
49- users : vec ! [ ] ,
50- services : crate :: service:: Services ( vec ! [ ] ) ,
51- }
52- }
53-
5414/// Helper function to render pages with mock config
5515fn render_with_mock_config < P : Page > ( page : & P , filename : & str ) -> Result < ( ) , AppError > {
5616 // For this example, we'll simulate the global CONFIG with a local Arc<RwLock>
5717 // In a real application, the global CONFIG would be properly initialized
5818
5919 // Create a mock config and use it directly with render_partial
60- let mock_config = create_mock_config ( ) ;
20+ let mock_config = Config :: default ( ) ;
6121
6222 // Manually implement the render logic using the mock config
6323 let content = page. render_partial ( ) ;
0 commit comments