User Mgr: Update GetUserInfo to read ldap user privilege
Without this fix privilege mapping was fetched from the standalone
mapper application. Now with the recent changes privilege
mapping is part of the config object itself.
This fix is to address that change.
TestedBy:
1.Added privilege mapper for ldap user and
then GetUserInfo for ldap user and verified
if privilege is correct.
2.Created local user and verified local user info
through GetUserInfo and check privilege.
Signed-off-by: Ravi Teja <raviteja28031990@gmail.com>
Change-Id: Ie149cc1ef46370a899aa8312ce17448b6c00c0e9
diff --git a/test/user_mgr_test.cpp b/test/user_mgr_test.cpp
index c7f1f89..943f0a8 100644
--- a/test/user_mgr_test.cpp
+++ b/test/user_mgr_test.cpp
@@ -40,9 +40,18 @@
{
DbusUserObj object;
DbusUserObjValue objValue;
- DbusUserObjPath object_path("/xyz/openbmc_project/user/ldap");
- DbusUserPropVariant group("ldapGroup");
- DbusUserPropVariant priv("priv-admin");
+
+ DbusUserObjPath obj_path("/xyz/openbmc_project/user/ldap/openldap");
+ DbusUserPropVariant enabled(true);
+ DbusUserObjProperties property = {std::make_pair("Enabled", enabled)};
+ std::string intf = "xyz.openbmc_project.Object.Enable";
+ objValue.emplace(intf, property);
+ object.emplace(obj_path, objValue);
+
+ DbusUserObjPath object_path(
+ "/xyz/openbmc_project/user/ldap/openldap/role_map/1");
+ std::string group = "ldapGroup";
+ std::string priv = "priv-admin";
DbusUserObjProperties properties = {std::make_pair("GroupName", group),
std::make_pair("Privilege", priv)};
std::string interface = "xyz.openbmc_project.User.PrivilegeMapperEntry";
@@ -52,6 +61,20 @@
return object;
}
+
+ DbusUserObj createLdapConfigObjectWithoutPrivilegeMapper(void)
+ {
+ DbusUserObj object;
+ DbusUserObjValue objValue;
+
+ DbusUserObjPath obj_path("/xyz/openbmc_project/user/ldap/openldap");
+ DbusUserPropVariant enabled(true);
+ DbusUserObjProperties property = {std::make_pair("Enabled", enabled)};
+ std::string intf = "xyz.openbmc_project.Object.Enable";
+ objValue.emplace(intf, property);
+ object.emplace(obj_path, objValue);
+ return object;
+ }
};
TEST_F(TestUserMgr, ldapEntryDoesNotExist)
@@ -105,10 +128,11 @@
UserInfoMap userInfo;
std::string userName = "ldapUser";
std::string ldapGroup = "ldapGroup";
- DbusUserObj object;
EXPECT_CALL(mockManager, getLdapGroupName(userName))
.WillRepeatedly(Return(ldapGroup));
+ // Create LDAP config object without privilege mapper
+ DbusUserObj object = createLdapConfigObjectWithoutPrivilegeMapper();
EXPECT_CALL(mockManager, getPrivilegeMapperObject())
.WillRepeatedly(Return(object));
userInfo = mockManager.getUserInfo(userName);