fix(mongodb): install legacy driver during connection test

This commit is contained in:
zipg authored and GitHub committed 2026-08-14 14:45:35 +08:00
1 parent b6c4a0be0f
commit 325127419f
8 files changed
+64 -12

No files matched your search

+9 -3
View File
@@ -260,9 +260,13 @@ pub fn mongo_legacy_error_with_auth_hint(err: &str) -> String {
return err.to_string();
};
let source = &source[..source_end];
format!(
"{err}\n\nCurrent authentication database: {source}. If this user was created in admin, set Authentication database to admin or add authSource=admin to URL params."
)
let verification_hint = format!(
"Current authentication database: {source}. The server rejected these credentials. Verify the username and password, and confirm that the user was created in {source}."
);
if source.eq_ignore_ascii_case("admin") {
return format!("{err}\n\n{verification_hint}");
}
format!("{err}\n\n{verification_hint} If the user was created in admin, set Authentication database to admin or add authSource=admin to URL params.")
}
pub fn mongo_uses_legacy_driver(config: &ConnectionConfig) -> bool {
@@ -861,6 +865,8 @@ mod tests {
assert!(hinted.starts_with(err));
assert!(hinted.contains("Current authentication database: admin"));
assert!(hinted.contains("The server rejected these credentials"));
assert!(!hinted.contains("add authSource=admin"));
}
#[test]
+1 -1
View File
@@ -5591,7 +5591,7 @@ mod tests {
assert_eq!(
mongo_legacy_error_with_auth_hint(err),
"Agent RPC error: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='rwuser', source='gray_lite_twin_fat'}\n\nCurrent authentication database: gray_lite_twin_fat. If this user was created in admin, set Authentication database to admin or add authSource=admin to URL params."
"Agent RPC error: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='rwuser', source='gray_lite_twin_fat'}\n\nCurrent authentication database: gray_lite_twin_fat. The server rejected these credentials. Verify the username and password, and confirm that the user was created in gray_lite_twin_fat. If the user was created in admin, set Authentication database to admin or add authSource=admin to URL params."
);
}