diff options
author | Erwin Pe <erwin.pe@mongodb.com> | 2021-08-02 18:42:23 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-08-02 19:27:38 +0000 |
commit | d206fa75eca0b9ce4bd41a493a2edf6a2e9166c8 (patch) | |
tree | 37fb3ae6afd8cf4d4e5a14ffcecb0d4f50640b66 /src/mongo/db/auth/action_set_test.cpp | |
parent | 8fcfd9dd7015a054887fa6ea9ecb3e1a9c6556c0 (diff) | |
download | mongo-d206fa75eca0b9ce4bd41a493a2edf6a2e9166c8.tar.gz |
SERVER-58827 Delete unused method ActionSet::parseActionSetFromString
Diffstat (limited to 'src/mongo/db/auth/action_set_test.cpp')
-rw-r--r-- | src/mongo/db/auth/action_set_test.cpp | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/src/mongo/db/auth/action_set_test.cpp b/src/mongo/db/auth/action_set_test.cpp index 07b0a697b44..1c125f8a2ea 100644 --- a/src/mongo/db/auth/action_set_test.cpp +++ b/src/mongo/db/auth/action_set_test.cpp @@ -38,37 +38,48 @@ namespace mongo { namespace { -TEST(ActionSetTest, ParseActionSetFromString) { +TEST(ActionSetTest, ParseActionSetFromStringVector) { ActionSet result; - ASSERT_OK(ActionSet::parseActionSetFromString("find,insert,update,remove", &result)); + std::vector<std::string> actions1 = {"find", "insert", "update", "remove"}; + std::vector<std::string> actions2 = {"update", "find", "remove", "insert"}; + std::vector<std::string> unrecognized; + + ASSERT_OK(ActionSet::parseActionSetFromStringVector(actions1, &result, &unrecognized)); ASSERT_TRUE(result.contains(ActionType::find)); ASSERT_TRUE(result.contains(ActionType::insert)); ASSERT_TRUE(result.contains(ActionType::update)); ASSERT_TRUE(result.contains(ActionType::remove)); + ASSERT_TRUE(unrecognized.empty()); // Order of the strings doesn't matter - ASSERT_OK(ActionSet::parseActionSetFromString("update,find,remove,insert", &result)); + ASSERT_OK(ActionSet::parseActionSetFromStringVector(actions2, &result, &unrecognized)); ASSERT_TRUE(result.contains(ActionType::find)); ASSERT_TRUE(result.contains(ActionType::insert)); ASSERT_TRUE(result.contains(ActionType::update)); ASSERT_TRUE(result.contains(ActionType::remove)); + ASSERT_TRUE(unrecognized.empty()); - ASSERT_OK(ActionSet::parseActionSetFromString("find", &result)); + ASSERT_OK(ActionSet::parseActionSetFromStringVector({"find"}, &result, &unrecognized)); ASSERT_TRUE(result.contains(ActionType::find)); ASSERT_FALSE(result.contains(ActionType::insert)); ASSERT_FALSE(result.contains(ActionType::update)); ASSERT_FALSE(result.contains(ActionType::remove)); + ASSERT_TRUE(unrecognized.empty()); - ASSERT_OK(ActionSet::parseActionSetFromString("", &result)); + ASSERT_OK(ActionSet::parseActionSetFromStringVector({""}, &result, &unrecognized)); ASSERT_FALSE(result.contains(ActionType::find)); ASSERT_FALSE(result.contains(ActionType::insert)); ASSERT_FALSE(result.contains(ActionType::update)); ASSERT_FALSE(result.contains(ActionType::remove)); + ASSERT_TRUE(unrecognized.size() == 1); + ASSERT_TRUE(unrecognized.front().empty()); - ASSERT_EQUALS(ErrorCodes::FailedToParse, - ActionSet::parseActionSetFromString("INVALID INPUT", &result).code()); + unrecognized.clear(); + ASSERT_OK(ActionSet::parseActionSetFromStringVector({"INVALID INPUT"}, &result, &unrecognized)); + ASSERT_TRUE(unrecognized.size() == 1); + ASSERT_TRUE(unrecognized.front() == "INVALID INPUT"); } TEST(ActionSetTest, ToString) { @@ -99,9 +110,14 @@ TEST(ActionSetTest, ToString) { TEST(ActionSetTest, IsSupersetOf) { ActionSet set1, set2, set3; - ASSERT_OK(ActionSet::parseActionSetFromString("find,update,insert", &set1)); - ASSERT_OK(ActionSet::parseActionSetFromString("find,update,remove", &set2)); - ASSERT_OK(ActionSet::parseActionSetFromString("find,update", &set3)); + std::vector<std::string> actions1 = {"find", "update", "insert"}; + std::vector<std::string> actions2 = {"find", "update", "remove"}; + std::vector<std::string> actions3 = {"find", "update"}; + std::vector<std::string> unrecognized; + + ASSERT_OK(ActionSet::parseActionSetFromStringVector(actions1, &set1, &unrecognized)); + ASSERT_OK(ActionSet::parseActionSetFromStringVector(actions2, &set2, &unrecognized)); + ASSERT_OK(ActionSet::parseActionSetFromStringVector(actions3, &set3, &unrecognized)); ASSERT_FALSE(set1.isSupersetOf(set2)); ASSERT_TRUE(set1.isSupersetOf(set3)); @@ -115,8 +131,10 @@ TEST(ActionSetTest, IsSupersetOf) { TEST(ActionSetTest, anyAction) { ActionSet set; + std::vector<std::string> actions = {"anyAction"}; + std::vector<std::string> unrecognized; - ASSERT_OK(ActionSet::parseActionSetFromString("anyAction", &set)); + ASSERT_OK(ActionSet::parseActionSetFromStringVector(actions, &set, &unrecognized)); ASSERT_TRUE(set.contains(ActionType::find)); ASSERT_TRUE(set.contains(ActionType::insert)); ASSERT_TRUE(set.contains(ActionType::anyAction)); |