summaryrefslogtreecommitdiffstats
path: root/phosphor-ldap-mapper/ldap_mapper_mgr.cpp
diff options
context:
space:
mode:
authorTom Joseph <tomjoseph@in.ibm.com>2018-11-19 09:49:21 +0530
committerTom Joseph <tomjoseph@in.ibm.com>2018-11-20 09:45:55 +0530
commitf5bd891cf5afb30085d1a5e93d86bd022c097238 (patch)
tree426c12cf2da3825056392426114aa3b919acde23 /phosphor-ldap-mapper/ldap_mapper_mgr.cpp
parent23886efd0780cd6c87741a9ecac2d55d9ab4c7a8 (diff)
downloadphosphor-user-manager-f5bd891cf5afb30085d1a5e93d86bd022c097238.tar.gz
phosphor-user-manager-f5bd891cf5afb30085d1a5e93d86bd022c097238.zip
Refactor mapper application to enable unit tests
Change-Id: I58cac8879f93ce49bfb654a1bf559d7f77b5b486 Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Diffstat (limited to 'phosphor-ldap-mapper/ldap_mapper_mgr.cpp')
-rw-r--r--phosphor-ldap-mapper/ldap_mapper_mgr.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/phosphor-ldap-mapper/ldap_mapper_mgr.cpp b/phosphor-ldap-mapper/ldap_mapper_mgr.cpp
index a321331..a1d6e11 100644
--- a/phosphor-ldap-mapper/ldap_mapper_mgr.cpp
+++ b/phosphor-ldap-mapper/ldap_mapper_mgr.cpp
@@ -19,8 +19,10 @@ using Argument = xyz::openbmc_project::Common::InvalidArgument;
using PrivilegeMappingExists = sdbusplus::xyz::openbmc_project::User::Common::
Error::PrivilegeMappingExists;
-LDAPMapperMgr::LDAPMapperMgr(sdbusplus::bus::bus &bus, const char *path) :
- MapperMgrIface(bus, path), bus(bus), path(path)
+LDAPMapperMgr::LDAPMapperMgr(sdbusplus::bus::bus &bus, const char *path,
+ const char *filePath) :
+ MapperMgrIface(bus, path),
+ bus(bus), path(path), persistPath(filePath)
{
}
@@ -37,9 +39,10 @@ ObjectPath LDAPMapperMgr::create(std::string groupName, std::string privilege)
// Create mapping for LDAP privilege mapper entry
auto entry = std::make_unique<phosphor::user::LDAPMapperEntry>(
- bus, mapperObject.c_str(), groupName, privilege, *this);
+ bus, mapperObject.c_str(), persistPath.c_str(), groupName, privilege,
+ *this);
- serialize(*entry, entryId);
+ serialize(*entry, entryId, persistPath);
PrivilegeMapperList.emplace(entryId, std::move(entry));
@@ -49,7 +52,7 @@ ObjectPath LDAPMapperMgr::create(std::string groupName, std::string privilege)
void LDAPMapperMgr::deletePrivilegeMapper(Id id)
{
// Delete the persistent representation of the privilege mapper.
- fs::path mapperPath(LDAP_MAPPER_PERSIST_PATH);
+ fs::path mapperPath(persistPath);
mapperPath /= std::to_string(id);
fs::remove(mapperPath);
@@ -96,7 +99,7 @@ void LDAPMapperMgr::restore()
{
namespace fs = std::experimental::filesystem;
- fs::path dir(LDAP_MAPPER_PERSIST_PATH);
+ fs::path dir(persistPath);
if (!fs::exists(dir) || fs::is_empty(dir))
{
return;
@@ -108,7 +111,7 @@ void LDAPMapperMgr::restore()
size_t idNum = std::stol(id);
auto entryPath = std::string(mapperMgrRoot) + '/' + id;
auto entry = std::make_unique<phosphor::user::LDAPMapperEntry>(
- bus, entryPath.c_str(), *this);
+ bus, entryPath.c_str(), persistPath.c_str(), *this);
if (deserialize(file.path(), *entry))
{
entry->Ifaces::emit_object_added();
OpenPOWER on IntegriCloud