From d514e5dc3de8dcd305328783ae11ee8e56b27d9a Mon Sep 17 00:00:00 2001 From: Nagaraju Goruganti Date: Thu, 8 Nov 2018 03:07:25 -0600 Subject: phosphor-ldap-conf: add unit tests Added uinit tests to create and to restore config file. Change-Id: Idf5231d46542cda1ff84241aa67aadd91a4788d6 Signed-off-by: Nagaraju Goruganti Signed-off-by: Deepak Kodihalli Signed-off-by: Nagaraju Goruganti --- phosphor-ldap-config/ldap_configuration.hpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'phosphor-ldap-config/ldap_configuration.hpp') diff --git a/phosphor-ldap-config/ldap_configuration.hpp b/phosphor-ldap-config/ldap_configuration.hpp index 034aab8..0dfb56d 100644 --- a/phosphor-ldap-config/ldap_configuration.hpp +++ b/phosphor-ldap-config/ldap_configuration.hpp @@ -16,10 +16,10 @@ namespace phosphor { namespace ldap { -static constexpr auto defaultNslcdFile = "/etc/nslcd.conf.default"; -static constexpr auto nsSwitchFile = "/etc/nsswitch.conf"; -static constexpr auto LDAPNsSwitchFile = "/etc/nsswitch_ldap.conf"; -static constexpr auto linuxNsSwitchFile = "/etc/nsswitch_linux.conf"; +static constexpr auto defaultNslcdFile = "nslcd.conf.default"; +static constexpr auto nsSwitchFile = "nsswitch.conf"; +static constexpr auto LDAPNsSwitchFile = "nsswitch_ldap.conf"; +static constexpr auto linuxNsSwitchFile = "nsswitch_linux.conf"; using namespace phosphor::logging; using namespace sdbusplus::xyz::openbmc_project::Common::Error; @@ -144,13 +144,16 @@ class ConfigMgr : public CreateIface * @param[in] bus - Bus to attach to. * @param[in] path - Path to attach at. * @param[in] filePath - LDAP configuration file. + * @param[in] caCertfile - LDAP's CA certificate file. */ - ConfigMgr(sdbusplus::bus::bus& bus, const char* path) : - CreateIface(bus, path, true), bus(bus) + ConfigMgr(sdbusplus::bus::bus& bus, const char* path, + const char* filePath) : + CreateIface(bus, path, true), + configFilePath(filePath), bus(bus) { try { - restore(LDAP_CONFIG_FILE); + restore(configFilePath.c_str()); emit_object_added(); } catch (const std::exception& e) @@ -193,8 +196,10 @@ class ConfigMgr : public CreateIface */ void deleteObject(); - private: + protected: std::string configFilePath{}; + std::string tlsCacertfile{}; + /** @brief Persistent sdbusplus D-Bus bus connection. */ sdbusplus::bus::bus& bus; -- cgit v1.2.1