summaryrefslogtreecommitdiff
path: root/src/mongo/db/auth/user_document_parser_test.cpp
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@mongodb.com>2013-10-30 13:30:36 -0400
committerSpencer T Brody <spencer@mongodb.com>2013-10-30 13:30:36 -0400
commit6ba2b81c3260ad0f62a8b1f03ec6c99e51c0b35d (patch)
treef8dd763351fdc96170eb1e57e0e067007686370b /src/mongo/db/auth/user_document_parser_test.cpp
parent6c36992cc9e2c505c54676afed9cce9d94e42428 (diff)
downloadmongo-6ba2b81c3260ad0f62a8b1f03ec6c99e51c0b35d.tar.gz
fix unit test now that external users have 'credentials' fields
Diffstat (limited to 'src/mongo/db/auth/user_document_parser_test.cpp')
-rw-r--r--src/mongo/db/auth/user_document_parser_test.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/mongo/db/auth/user_document_parser_test.cpp b/src/mongo/db/auth/user_document_parser_test.cpp
index 0fba05a5168..f4a67373170 100644
--- a/src/mongo/db/auth/user_document_parser_test.cpp
+++ b/src/mongo/db/auth/user_document_parser_test.cpp
@@ -214,17 +214,18 @@ namespace {
"db" << "test" <<
"credentials" << BSON("MONGODB-CR" << "a"))));
- // Don't need credentials field if userSource is $external
+ // Empty roles arrays are OK
ASSERT_OK(v2parser.checkValidUserDocument(
BSON("user" << "spencer" <<
- "db" << "$external" <<
+ "db" << "test" <<
+ "credentials" << BSON("MONGODB-CR" << "a") <<
"roles" << emptyArray)));
- // Empty roles arrays are OK
+ // Need credentials of {external: true} if user's db is $external
ASSERT_OK(v2parser.checkValidUserDocument(
BSON("user" << "spencer" <<
- "db" << "test" <<
- "credentials" << BSON("MONGODB-CR" << "a") <<
+ "db" << "$external" <<
+ "credentials" << BSON("external" << true) <<
"roles" << emptyArray)));
// Roles must be objects
@@ -285,7 +286,7 @@ namespace {
"db" << "test" <<
"pwd" << "")));
- // Credentials must be provided (so long as userSource is not $external)
+ // Credentials must be provided
ASSERT_NOT_OK(v2parser.initializeUserCredentialsFromUserDocument(
user.get(),
BSON("user" << "spencer" <<
@@ -314,11 +315,12 @@ namespace {
ASSERT(user->getCredentials().password == "a");
ASSERT(!user->getCredentials().isExternal);
- // Leaving out 'credentials' field is OK so long as userSource is $external
+ // Credentials are {external:true if users's db is $external
ASSERT_OK(v2parser.initializeUserCredentialsFromUserDocument(
user.get(),
BSON("user" << "spencer" <<
- "db" << "$external")));
+ "db" << "$external" <<
+ "credentials" << BSON("external" << true))));
ASSERT(user->getCredentials().password.empty());
ASSERT(user->getCredentials().isExternal);