Print the inner string in Address debug output
This commit is contained in:
@@ -21,7 +21,7 @@ pub enum Tls {
|
|||||||
Disabled,
|
Disabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A database address may contain credentials.
|
/// A database address. Debug output includes the full value, which may contain credentials.
|
||||||
#[derive(Clone, Deserialize)]
|
#[derive(Clone, Deserialize)]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
pub struct Address(String);
|
pub struct Address(String);
|
||||||
@@ -40,7 +40,7 @@ impl From<String> for Address {
|
|||||||
|
|
||||||
impl fmt::Debug for Address {
|
impl fmt::Debug for Address {
|
||||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
formatter.write_str("Address([redacted])")
|
fmt::Debug::fmt(&self.0, formatter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use clusters::{Cluster, ConfigError, DeploymentConfig, Driver, Tls};
|
use clusters::{Address, Cluster, ConfigError, DeploymentConfig, Driver, Tls};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn named_cluster_requires_matching_addresses_and_redacts_credentials() {
|
fn address_debug_formats_the_inner_string() {
|
||||||
|
let value = "bedrock.sqlite3";
|
||||||
|
assert_eq!(format!("{:?}", Address::from(value)), format!("{value:?}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn named_cluster_requires_matching_addresses() {
|
||||||
let mut config = DeploymentConfig {
|
let mut config = DeploymentConfig {
|
||||||
cluster: Some("regional".into()),
|
cluster: Some("regional".into()),
|
||||||
clusters: BTreeMap::from([(
|
clusters: BTreeMap::from([(
|
||||||
@@ -30,8 +36,6 @@ fn named_cluster_requires_matching_addresses_and_redacts_credentials() {
|
|||||||
.connection_string()
|
.connection_string()
|
||||||
.ends_with("sslmode=verify-full")
|
.ends_with("sslmode=verify-full")
|
||||||
);
|
);
|
||||||
assert!(!format!("{resolved:?}").contains("secret"));
|
|
||||||
|
|
||||||
config.clusters.get_mut("regional").unwrap().replicas[0] =
|
config.clusters.get_mut("regional").unwrap().replicas[0] =
|
||||||
"mysql://user:secret@replica/bedrock".into();
|
"mysql://user:secret@replica/bedrock".into();
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
|
|||||||
Reference in New Issue
Block a user