Skip to content

Commit 120a9ab

Browse files
committed
RUST-992 Enable auth tests for PLAIN and fix default authSource for such
1 parent 44d79b8 commit 120a9ab

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/client/auth/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl AuthMechanism {
205205
uri_db.unwrap_or("admin")
206206
}
207207
AuthMechanism::MongoDbX509 => "$external",
208-
AuthMechanism::Plain => "$external",
208+
AuthMechanism::Plain => uri_db.unwrap_or("$external"),
209209
#[cfg(feature = "aws-auth")]
210210
AuthMechanism::MongoDbAws => "$external",
211211
_ => "",
@@ -336,7 +336,8 @@ pub struct Credential {
336336
pub username: Option<String>,
337337

338338
/// The database used to authenticate. This applies to all mechanisms and defaults to "admin"
339-
/// in SCRAM authentication mechanisms and "$external" for GSSAPI, MONGODB-X509 and PLAIN.
339+
/// in SCRAM authentication mechanisms, "$external" for GSSAPI and MONGODB-X509, and the
340+
/// database name or "$external" for PLAIN.
340341
pub source: Option<String>,
341342

342343
/// The password to authenticate with. This does not apply to all mechanisms.

src/test/spec/auth.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,12 @@ async fn run_auth_test(test_file: TestFile) {
5252

5353
let skipped_mechanisms = [
5454
"GSSAPI",
55-
"PLAIN",
5655
"MONGODB-CR",
5756
#[cfg(not(feature = "aws-auth"))]
5857
"MONGODB-AWS",
5958
];
6059

6160
// TODO: GSSAPI (RUST-196)
62-
// TODO: PLAIN (RUST-992)
6361
if skipped_mechanisms
6462
.iter()
6563
.any(|mech| test_case.description.contains(mech))

0 commit comments

Comments
 (0)