Skip to content

Commit abffb22

Browse files
CXX-394 Find auth mechanism in client test
1 parent 644fcbf commit abffb22

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/mongo/client/examples/authTest.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,14 @@ int main( int argc, const char **argv ) {
9191
}
9292

9393
errmsg.clear();
94-
conn->auth(BSON("user" << "eliot" <<
95-
"db" << "test" <<
96-
"pwd" << "bar" <<
97-
"mechanism" << "MONGODB-CR"));
98-
99-
try {
100-
conn->auth(BSON("user" << "eliot" <<
101-
"db" << "test" <<
102-
"pwd" << "bars" << // incorrect password
103-
"mechanism" << "MONGODB-CR"));
104-
// Shouldn't get here.
94+
if (!conn->auth("test", "eliot", "bar", errmsg)) {
95+
cout << "Authentication failed, when it should have succeeded. Got error: " << errmsg << endl;
96+
return EXIT_FAILURE;
97+
}
98+
99+
if (conn->auth("test", "eliot", "bars", errmsg)) { // incorrect password
105100
cout << "Authentication with invalid password should have failed but didn't" << endl;
106101
return EXIT_FAILURE;
107-
} catch (const DBException&) {
108-
// expected
109102
}
110103
return EXIT_SUCCESS;
111104
}

0 commit comments

Comments
 (0)