use dynamic_config_store_core::LoneAuthority;
pub(crate) fn redacted(url: &str) -> String {
dynamic_config_store_core::redacted(url, LoneAuthority::Secret)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn a_token_in_a_remote_url_never_survives_redaction() {
assert_eq!(
redacted("https://x-access-token:ghs_hunter2@github.com/acme/config.git"),
"https://x-access-token:***@github.com/acme/config.git"
);
assert_eq!(
redacted("https://x-access-token:gh@s@hun@ter2@github.com/acme/config.git"),
"https://x-access-token:***@github.com/acme/config.git"
);
assert_eq!(
redacted("https://ghp_hunter2@github.com/acme/config.git"),
"https://***@github.com/acme/config.git"
);
assert_eq!(
redacted("https://:hunter2-pat@dev.azure.com/acme/_git/config"),
"https://:***@dev.azure.com/acme/_git/config"
);
}
#[test]
fn a_url_with_nothing_to_hide_is_left_alone() {
assert_eq!(
redacted("https://github.com/acme/config.git"),
"https://github.com/acme/config.git"
);
assert_eq!(
redacted("git@github.com:acme/config.git"),
"git@github.com:acme/config.git"
);
assert_eq!(redacted("/srv/config.git"), "/srv/config.git");
}
}