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