ThrowForInvalidGroups: add unit test

This commit adds unit test for the |throwForInvalidGroups| function.

Tested: unit test passed

Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I6c004dde1e3a27f60ee7de5cb1775940e19fffc8
diff --git a/test/user_mgr_test.cpp b/test/user_mgr_test.cpp
index f44282e..4595743 100644
--- a/test/user_mgr_test.cpp
+++ b/test/user_mgr_test.cpp
@@ -437,5 +437,20 @@
     EXPECT_NO_THROW(throwForInvalidPrivilege("priv-noaccess"));
 }
 
+TEST_F(UserMgrInTest, ThrowForInvalidGroupsThrowsWhenGroupIsInvalid)
+{
+    EXPECT_THROW(
+        throwForInvalidGroups({"whatever"}),
+        sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument);
+}
+
+TEST_F(UserMgrInTest, ThrowForInvalidGroupsNoThrowWhenGroupIsValid)
+{
+    EXPECT_NO_THROW(throwForInvalidGroups({"ipmi"}));
+    EXPECT_NO_THROW(throwForInvalidGroups({"ssh"}));
+    EXPECT_NO_THROW(throwForInvalidGroups({"redfish"}));
+    EXPECT_NO_THROW(throwForInvalidGroups({"web"}));
+}
+
 } // namespace user
 } // namespace phosphor
diff --git a/user_mgr.hpp b/user_mgr.hpp
index 9f2770d..0195de8 100644
--- a/user_mgr.hpp
+++ b/user_mgr.hpp
@@ -320,6 +320,13 @@
      */
     void throwForInvalidPrivilege(const std::string& priv);
 
+    /** @brief check for valid groups
+     *  method to check valid groups, and throw if invalid
+     *
+     *  @param[in] groupNames - user groups
+     */
+    void throwForInvalidGroups(const std::vector<std::string>& groupName);
+
   private:
     /** @brief sdbusplus handler */
     sdbusplus::bus_t& bus;
@@ -355,13 +362,6 @@
      */
     UserSSHLists getUserAndSshGrpList(void);
 
-    /** @brief check for valid groups
-     *  method to check valid groups, and throw if invalid
-     *
-     *  @param[in] groupNames - user groups
-     */
-    void throwForInvalidGroups(const std::vector<std::string>& groupName);
-
     /** @brief get user enabled state
      *  method to get user enabled state.
      *