use chipp::ChippConfig;
#[test]
fn test_config_debug_redacts_api_key() {
let secret_api_key = "live_super_secret_key_12345";
let config = ChippConfig {
api_key: secret_api_key.to_string(),
model: "test-model".to_string(),
..Default::default()
};
let debug_output = format!("{:?}", config);
assert!(
!debug_output.contains(secret_api_key),
"SECURITY VIOLATION: API key '{}' was exposed in Debug output: {}",
secret_api_key,
debug_output
);
assert!(
debug_output.contains("[REDACTED]"),
"Debug output should show [REDACTED] for api_key, got: {}",
debug_output
);
}
#[test]
fn test_config_debug_shows_non_sensitive_fields() {
let config = ChippConfig {
api_key: "secret-key".to_string(),
model: "my-app-123".to_string(),
base_url: "https://custom.api.example.com".to_string(),
..Default::default()
};
let debug_output = format!("{:?}", config);
assert!(
debug_output.contains("my-app-123"),
"Debug output should show model name, got: {}",
debug_output
);
assert!(
debug_output.contains("https://custom.api.example.com"),
"Debug output should show base_url, got: {}",
debug_output
);
assert!(
debug_output.contains("ChippConfig"),
"Debug output should show struct name, got: {}",
debug_output
);
}
#[test]
fn test_config_builder_debug_redacts_api_key() {
let secret_api_key = "live_builder_secret_key_67890";
let builder = ChippConfig::builder().api_key(secret_api_key);
let debug_output = format!("{:?}", builder);
assert!(
!debug_output.contains(secret_api_key),
"SECURITY VIOLATION: API key '{}' was exposed in Builder Debug output: {}",
secret_api_key,
debug_output
);
}