File tree Expand file tree Collapse file tree 1 file changed +6
-13
lines changed
src/mongo/client/examples Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments