summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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) {