summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Shuvalov <andrew.shuvalov@mongodb.com>2020-09-23 01:49:43 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-28 13:59:28 +0000
commit55209f44d80a7351f3a3ad81052e6bea0202bea8 (patch)
tree93c9612cd231f98a619cc11ececedd52cd7f6408
parentb541c8a5d2475600d5d96030a08ba5b71aa1afeb (diff)
downloadmongo-55209f44d80a7351f3a3ad81052e6bea0202bea8.tar.gz
SERVER-47616: improve error message plus tests
-rw-r--r--src/mongo/db/auth/authorization_session_impl.cpp4
-rw-r--r--src/mongo/db/logical_session_id_test.cpp8
2 files changed, 10 insertions, 2 deletions
diff --git a/src/mongo/db/auth/authorization_session_impl.cpp b/src/mongo/db/auth/authorization_session_impl.cpp
index 9966d7f1320..a87ada01587 100644
--- a/src/mongo/db/auth/authorization_session_impl.cpp
+++ b/src/mongo/db/auth/authorization_session_impl.cpp
@@ -163,7 +163,9 @@ User* AuthorizationSessionImpl::getSingleUser() {
if (userNameItr.more()) {
userName = userNameItr.next();
if (userNameItr.more()) {
- uasserted(ErrorCodes::Unauthorized, "too many users are authenticated");
+ uasserted(ErrorCodes::Unauthorized,
+ "logical sessions can't have multiple authenticated users (for more details see: "
+ "https://docs.mongodb.com/manual/core/authentication/#authentication-methods)");
}
} else {
uasserted(ErrorCodes::Unauthorized, "there are no users authenticated");
diff --git a/src/mongo/db/logical_session_id_test.cpp b/src/mongo/db/logical_session_id_test.cpp
index de37f424f3f..883ac77c502 100644
--- a/src/mongo/db/logical_session_id_test.cpp
+++ b/src/mongo/db/logical_session_id_test.cpp
@@ -230,7 +230,13 @@ TEST_F(LogicalSessionIdTest, GenWithMultipleAuthedUsers) {
addSimpleUser(UserName("simple", "test"));
addSimpleUser(UserName("simple", "test2"));
- ASSERT_THROWS(makeLogicalSessionId(_opCtx.get()), AssertionException);
+ ASSERT_THROWS_WITH_CHECK(
+ makeLogicalSessionId(_opCtx.get()),
+ AssertionException,
+ [](const AssertionException& exception) {
+ ASSERT_EQ(exception.code(), ErrorCodes::Unauthorized);
+ ASSERT_STRING_CONTAINS(exception.reason(), "docs.mongodb.com/manual/core/authentication");
+ });
}
TEST_F(LogicalSessionIdTest, GenWithoutAuthedUser) {