use std::collections::BTreeMap; use clusters::{Cluster, ConfigError, DeploymentConfig, Driver, Tls}; #[test] fn named_cluster_requires_matching_addresses_and_redacts_credentials() { let mut config = DeploymentConfig { cluster: Some("regional".into()), clusters: BTreeMap::from([( "regional".into(), Cluster { driver: Driver::Postgres, primary: "postgres://user:secret@primary/bedrock".into(), replicas: vec!["postgresql://reader:secret@replica/bedrock".into()], tls: Tls::VerifyFull, max_connections: 5, }, )]), ..DeploymentConfig::default() }; let resolved = config.resolve().unwrap(); assert!( resolved .primary .connection_string() .ends_with("sslmode=verify-full") ); assert!( resolved.replicas[0] .connection_string() .ends_with("sslmode=verify-full") ); assert!(!format!("{resolved:?}").contains("secret")); config.clusters.get_mut("regional").unwrap().replicas[0] = "mysql://user:secret@replica/bedrock".into(); assert!(matches!( config.resolve(), Err(ConfigError::Url("postgres")) )); }