Skip to main content

rust_serv/auto_tls/
mod.rs

1//! Auto TLS (Let's Encrypt) module - Placeholder
2//!
3//! TODO: Complete implementation in v0.3.0
4
5use serde::{Deserialize, Serialize};
6
7/// Auto TLS configuration
8#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
9pub struct AutoTlsConfig {
10    /// Enable auto TLS
11    #[serde(default = "default_enabled")]
12    pub enabled: bool,
13
14    /// Domains for certificate
15    #[serde(default)]
16    pub domains: Vec<String>,
17
18    /// Contact email
19    #[serde(default)]
20    pub email: String,
21
22    /// Challenge type (http-01 or dns-01)
23    #[serde(default = "default_challenge_type")]
24    pub challenge_type: String,
25
26    /// Certificate cache directory
27    #[serde(default = "default_cache_dir")]
28    pub cache_dir: String,
29
30    /// Days before expiration to renew
31    #[serde(default = "default_renew_days")]
32    pub renew_before_days: u32,
33}
34
35fn default_enabled() -> bool { false }
36fn default_challenge_type() -> String { "http-01".to_string() }
37fn default_cache_dir() -> String { "./certs".to_string() }
38fn default_renew_days() -> u32 { 30 }
39
40#[cfg(test)]
41mod tests {
42    use super::*;
43
44    #[test]
45    fn test_auto_tls_config_default() {
46        let config = AutoTlsConfig {
47            enabled: false,
48            domains: vec![],
49            email: "".to_string(),
50            challenge_type: "http-01".to_string(),
51            cache_dir: "./certs".to_string(),
52            renew_before_days: 30,
53        };
54        assert!(!config.enabled);
55        assert_eq!(config.challenge_type, "http-01");
56    }
57}