75 lines
No EOL
1.8 KiB
Rust
75 lines
No EOL
1.8 KiB
Rust
|
|
|
|
|
|
#![allow(unused_imports)]
|
|
#![allow(unused_variables)]
|
|
#![allow(dead_code)]
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_url_conversion() {
|
|
let integration = TlsIntegration::new(true);
|
|
|
|
assert_eq!(
|
|
integration.convert_url("http://localhost:8081"),
|
|
"https://localhost:8444"
|
|
);
|
|
|
|
assert_eq!(
|
|
integration.convert_url("redis://localhost:6379"),
|
|
"rediss://localhost:6380"
|
|
);
|
|
|
|
assert_eq!(
|
|
integration.convert_url("https://example.com"),
|
|
"https://example.com"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_postgres_url_update() {
|
|
let integration = TlsIntegration::new(true);
|
|
|
|
assert_eq!(
|
|
integration.update_postgres_url("postgres://user:pass@localhost:5432/db"),
|
|
"postgres://user:pass@localhost:5433/db?sslmode=require"
|
|
);
|
|
|
|
assert_eq!(
|
|
integration.update_postgres_url("postgres://localhost:5432/db?foo=bar"),
|
|
"postgres://localhost:5433/db?foo=bar&sslmode=require"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_service_url() {
|
|
let integration = TlsIntegration::new(true);
|
|
|
|
assert_eq!(
|
|
integration.get_service_url("llm"),
|
|
Some("https://localhost:8444".to_string())
|
|
);
|
|
|
|
let integration_no_tls = TlsIntegration::new(false);
|
|
assert_eq!(
|
|
integration_no_tls.get_service_url("llm"),
|
|
Some("http://localhost:8081".to_string())
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_secure_port() {
|
|
let integration = TlsIntegration::new(true);
|
|
|
|
assert_eq!(integration.get_secure_port("api"), Some(8443));
|
|
assert_eq!(integration.get_secure_port("redis"), Some(6380));
|
|
assert_eq!(integration.get_secure_port("unknown"), None);
|
|
} |