summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/auth/authorization_session_impl.cpp5
-rw-r--r--src/mongo/db/logical_session_id_test.cpp9
2 files changed, 12 insertions, 2 deletions
diff --git a/src/mongo/db/auth/authorization_session_impl.cpp b/src/mongo/db/auth/authorization_session_impl.cpp
index 34e3345ce69..f98a3226ce3 100644
--- a/src/mongo/db/auth/authorization_session_impl.cpp
+++ b/src/mongo/db/auth/authorization_session_impl.cpp
@@ -194,7 +194,10 @@ 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 c9729c163c4..611e5e5f1f0 100644
--- a/src/mongo/db/logical_session_id_test.cpp
+++ b/src/mongo/db/logical_session_id_test.cpp
@@ -232,7 +232,14 @@ 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) {