clang-tidy: enable clang-tidy
Enable the first check: readability-identifier-naming
Also fixed all check failures.
Tested:
1. compiles, no clang-tidy failures
2. the two daemons work correctly on hardware regarding DBus APIs
Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: Ic415e857726e8f521c1d61a3e7f0c85121c0d284
diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644
index 0000000..383c1a4
--- /dev/null
+++ b/.clang-tidy
@@ -0,0 +1,16 @@
+Checks: '
+-*,
+readability-identifier-naming'
+
+WarningsAsErrors: '*'
+HeaderFilterRegex: '.*'
+
+CheckOptions:
+ - { key: readability-identifier-naming.ClassCase, value: CamelCase }
+ - { key: readability-identifier-naming.VariableCase, value: camelBack }
+ - { key: readability-identifier-naming.EnumCase, value: CamelCase }
+ - { key: readability-identifier-naming.EnumConstantCase, value: camelBack }
+ - { key: readability-identifier-naming.FunctionCase, value: camelBack }
+ - { key: readability-identifier-naming.ParameterCase, value: camelBack }
+ - { key: readability-identifier-naming.NamespaceCase, value: lower_case }
+ - { key: readability-identifier-naming.StructCase, value: CamelCase }
diff --git a/mainapp.cpp b/mainapp.cpp
index 9ae2ac4..d8258cc 100644
--- a/mainapp.cpp
+++ b/mainapp.cpp
@@ -20,14 +20,14 @@
#include <string>
// D-Bus root for user manager
-constexpr auto USER_MANAGER_ROOT = "/xyz/openbmc_project/user";
+constexpr auto userManagerRoot = "/xyz/openbmc_project/user";
int main(int /*argc*/, char** /*argv*/)
{
auto bus = sdbusplus::bus::new_default();
- sdbusplus::server::manager_t objManager(bus, USER_MANAGER_ROOT);
+ sdbusplus::server::manager_t objManager(bus, userManagerRoot);
- phosphor::user::UserMgr userMgr(bus, USER_MANAGER_ROOT);
+ phosphor::user::UserMgr userMgr(bus, userManagerRoot);
// Claim the bus now
bus.request_name(USER_MANAGER_BUSNAME);
diff --git a/phosphor-ldap-config/ldap_config.cpp b/phosphor-ldap-config/ldap_config.cpp
index 97e23ca..b7bd4c6 100644
--- a/phosphor-ldap-config/ldap_config.cpp
+++ b/phosphor-ldap-config/ldap_config.cpp
@@ -25,8 +25,8 @@
{
constexpr auto nslcdService = "nslcd.service";
-constexpr auto LDAPscheme = "ldap";
-constexpr auto LDAPSscheme = "ldaps";
+constexpr auto ldapScheme = "ldap";
+constexpr auto ldapsScheme = "ldaps";
constexpr auto certObjPath = "/xyz/openbmc_project/certs/client/ldap/1";
constexpr auto certRootPath = "/xyz/openbmc_project/certs/client/ldap";
constexpr auto authObjPath = "/xyz/openbmc_project/certs/authority/ldap";
@@ -362,11 +362,11 @@
{
return value;
}
- if (isValidLDAPURI(value, LDAPSscheme))
+ if (isValidLDAPURI(value, ldapsScheme))
{
secureLDAP = true;
}
- else if (isValidLDAPURI(value, LDAPscheme))
+ else if (isValidLDAPURI(value, ldapScheme))
{
secureLDAP = false;
}
@@ -717,11 +717,11 @@
cereal::BinaryInputArchive iarchive(is);
iarchive(*this);
- if (isValidLDAPURI(ldapServerURI(), LDAPscheme))
+ if (isValidLDAPURI(ldapServerURI(), ldapScheme))
{
secureLDAP = false;
}
- else if (isValidLDAPURI(ldapServerURI(), LDAPSscheme))
+ else if (isValidLDAPURI(ldapServerURI(), ldapsScheme))
{
secureLDAP = true;
}
diff --git a/phosphor-ldap-config/ldap_config_mgr.cpp b/phosphor-ldap-config/ldap_config_mgr.cpp
index 87791b8..a359273 100644
--- a/phosphor-ldap-config/ldap_config_mgr.cpp
+++ b/phosphor-ldap-config/ldap_config_mgr.cpp
@@ -14,8 +14,8 @@
constexpr auto nslcdService = "nslcd.service";
constexpr auto nscdService = "nscd.service";
-constexpr auto LDAPscheme = "ldap";
-constexpr auto LDAPSscheme = "ldaps";
+constexpr auto ldapScheme = "ldap";
+constexpr auto ldapsScheme = "ldaps";
using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
@@ -84,11 +84,11 @@
{
bool secureLDAP = false;
- if (isValidLDAPURI(ldapServerURI, LDAPSscheme))
+ if (isValidLDAPURI(ldapServerURI, ldapsScheme))
{
secureLDAP = true;
}
- else if (isValidLDAPURI(ldapServerURI, LDAPscheme))
+ else if (isValidLDAPURI(ldapServerURI, ldapScheme))
{
secureLDAP = false;
}
@@ -145,7 +145,7 @@
else
{
ADConfigPtr.reset(nullptr);
- objPath = ADDbusObjectPath;
+ objPath = adDbusObjectPath;
ADConfigPtr = std::make_unique<Config>(
bus, objPath.c_str(), configFilePath.c_str(), tlsCacertFile.c_str(),
tlsCertFile.c_str(), secureLDAP, ldapServerURI, ldapBindDN,
@@ -171,7 +171,7 @@
if (!ADConfigPtr)
{
ADConfigPtr = std::make_unique<Config>(
- bus, ADDbusObjectPath.c_str(), configFilePath.c_str(),
+ bus, adDbusObjectPath.c_str(), configFilePath.c_str(),
tlsCacertFile.c_str(), tlsCertFile.c_str(),
ConfigIface::Type::ActiveDirectory, *this);
ADConfigPtr->emit_object_added();
diff --git a/phosphor-ldap-config/ldap_config_mgr.hpp b/phosphor-ldap-config/ldap_config_mgr.hpp
index af3051c..850fc54 100644
--- a/phosphor-ldap-config/ldap_config_mgr.hpp
+++ b/phosphor-ldap-config/ldap_config_mgr.hpp
@@ -22,7 +22,7 @@
static constexpr auto nsSwitchFile = "nsswitch.conf";
static auto openLDAPDbusObjectPath =
std::string(LDAP_CONFIG_ROOT) + "/openldap";
-static auto ADDbusObjectPath =
+static auto adDbusObjectPath =
std::string(LDAP_CONFIG_ROOT) + "/active_directory";
using namespace phosphor::logging;
diff --git a/phosphor-ldap-config/utils.cpp b/phosphor-ldap-config/utils.cpp
index 66e1474..4ad69d9 100644
--- a/phosphor-ldap-config/utils.cpp
+++ b/phosphor-ldap-config/utils.cpp
@@ -14,7 +14,7 @@
namespace ldap
{
-bool isValidLDAPURI(const std::string& URI, const char* scheme)
+bool isValidLDAPURI(const std::string& uri, const char* scheme)
{
// Return false if the user tries to configure port 0
// This check is not done in line 42, because ldap_url_parse
@@ -22,14 +22,14 @@
// will always return true (thus allowing the user to
// configure port 0)
- if (boost::algorithm::ends_with(URI, ":0"))
+ if (boost::algorithm::ends_with(uri, ":0"))
{
return false;
}
LDAPURLDesc* ludpp = nullptr;
int res = LDAP_URL_ERR_BADURL;
- res = ldap_url_parse(URI.c_str(), &ludpp);
+ res = ldap_url_parse(uri.c_str(), &ludpp);
auto ludppCleanupFunc = [](LDAPURLDesc* ludpp) {
ldap_free_urldesc(ludpp);
diff --git a/phosphor-ldap-config/utils.hpp b/phosphor-ldap-config/utils.hpp
index 984aae6..b1450b7 100644
--- a/phosphor-ldap-config/utils.hpp
+++ b/phosphor-ldap-config/utils.hpp
@@ -14,7 +14,7 @@
* against LDAPS type URI, for LDAP type URI it is equals to "ldap".
* @returns true if it is valid otherwise false.
*/
-bool isValidLDAPURI(const std::string& URI, const char* scheme);
+bool isValidLDAPURI(const std::string& uri, const char* scheme);
} // namespace ldap
} // namespace phosphor
diff --git a/test/ldap_config_test.cpp b/test/ldap_config_test.cpp
index b687383..c210b84 100644
--- a/test/ldap_config_test.cpp
+++ b/test/ldap_config_test.cpp
@@ -42,18 +42,18 @@
char tmpldap[] = "/tmp/ldap_test.XXXXXX";
dir = fs::path(mkdtemp(tmpldap));
fs::path tlsCacertFilePath{TLS_CACERT_PATH};
- tlsCacertFile = tlsCacertFilePath.filename().c_str();
+ tlsCACertFile = tlsCacertFilePath.filename().c_str();
fs::path tlsCertFilePath{TLS_CERT_FILE};
tlsCertFile = tlsCertFilePath.filename().c_str();
fs::path confFilePath{LDAP_CONFIG_FILE};
- ldapconfFile = confFilePath.filename().c_str();
+ ldapConfFile = confFilePath.filename().c_str();
std::fstream fs;
fs.open(dir / defaultNslcdFile, std::fstream::out);
fs.close();
fs.open(dir / nsSwitchFile, std::fstream::out);
fs.close();
- fs.open(dir / tlsCacertFile, std::fstream::out);
+ fs.open(dir / tlsCACertFile, std::fstream::out);
fs.close();
fs.open(dir / tlsCertFile, std::fstream::out);
fs.close();
@@ -66,9 +66,9 @@
protected:
fs::path dir;
- std::string tlsCacertFile;
+ std::string tlsCACertFile;
std::string tlsCertFile;
- std::string ldapconfFile;
+ std::string ldapConfFile;
sdbusplus::bus_t bus;
};
@@ -118,9 +118,9 @@
TEST_F(TestLDAPConfig, testCreate)
{
- auto configFilePath = std::string(dir.c_str()) + "/" + ldapconfFile;
- auto tlsCacertfile = std::string(dir.c_str()) + "/" + tlsCacertFile;
- auto tlsCertfile = std::string(dir.c_str()) + "/" + tlsCertFile;
+ auto configFilePath = std::string(dir.c_str()) + "/" + ldapConfFile;
+ auto tlsCACertFilePath = std::string(dir.c_str()) + "/" + tlsCACertFile;
+ auto tlsCertFilePath = std::string(dir.c_str()) + "/" + tlsCertFile;
auto dbusPersistentFilePath = std::string(dir.c_str());
if (fs::exists(configFilePath))
@@ -129,8 +129,8 @@
}
EXPECT_FALSE(fs::exists(configFilePath));
MockConfigMgr manager(bus, LDAP_CONFIG_ROOT, configFilePath.c_str(),
- dbusPersistentFilePath.c_str(), tlsCacertfile.c_str(),
- tlsCertfile.c_str());
+ dbusPersistentFilePath.c_str(),
+ tlsCACertFilePath.c_str(), tlsCertFilePath.c_str());
EXPECT_CALL(manager, stopService("nslcd.service")).Times(2);
EXPECT_CALL(manager, restartService("nslcd.service")).Times(2);
@@ -178,9 +178,9 @@
TEST_F(TestLDAPConfig, testDefaultObject)
{
- auto configFilePath = std::string(dir.c_str()) + "/" + ldapconfFile;
- auto tlsCacertfile = std::string(dir.c_str()) + "/" + tlsCacertFile;
- auto tlsCertfile = std::string(dir.c_str()) + "/" + tlsCertFile;
+ auto configFilePath = std::string(dir.c_str()) + "/" + ldapConfFile;
+ auto tlsCACertFilePath = std::string(dir.c_str()) + "/" + tlsCACertFile;
+ auto tlsCertFilePath = std::string(dir.c_str()) + "/" + tlsCertFile;
auto dbusPersistentFilePath = std::string(dir.c_str());
if (fs::exists(configFilePath))
@@ -190,8 +190,8 @@
EXPECT_FALSE(fs::exists(configFilePath));
MockConfigMgr manager(bus, LDAP_CONFIG_ROOT, configFilePath.c_str(),
- dbusPersistentFilePath.c_str(), tlsCacertfile.c_str(),
- tlsCertfile.c_str());
+ dbusPersistentFilePath.c_str(),
+ tlsCACertFilePath.c_str(), tlsCertFilePath.c_str());
manager.createDefaultObjects();
@@ -205,9 +205,9 @@
TEST_F(TestLDAPConfig, testRestoresDefault)
{
- auto configFilePath = std::string(dir.c_str()) + "/" + ldapconfFile;
- auto tlsCacertfile = std::string(dir.c_str()) + "/" + tlsCacertFile;
- auto tlsCertfile = std::string(dir.c_str()) + "/" + tlsCertFile;
+ auto configFilePath = std::string(dir.c_str()) + "/" + ldapConfFile;
+ auto tlsCACertFilePath = std::string(dir.c_str()) + "/" + tlsCACertFile;
+ auto tlsCertFilePath = std::string(dir.c_str()) + "/" + tlsCertFile;
auto dbusPersistentFilePath = std::string(dir.c_str());
if (fs::exists(configFilePath))
@@ -217,8 +217,8 @@
EXPECT_FALSE(fs::exists(configFilePath));
MockConfigMgr manager(bus, LDAP_CONFIG_ROOT, configFilePath.c_str(),
- dbusPersistentFilePath.c_str(), tlsCacertfile.c_str(),
- tlsCertfile.c_str());
+ dbusPersistentFilePath.c_str(),
+ tlsCACertFilePath.c_str(), tlsCertFilePath.c_str());
EXPECT_CALL(manager, stopService("nslcd.service")).Times(1);
EXPECT_CALL(manager, restartService("nslcd.service")).Times(0);
@@ -238,9 +238,9 @@
TEST_F(TestLDAPConfig, testRestores)
{
- auto configFilePath = std::string(dir.c_str()) + "/" + ldapconfFile;
- auto tlsCacertfile = std::string(dir.c_str()) + "/" + tlsCacertFile;
- auto tlsCertfile = std::string(dir.c_str()) + "/" + tlsCertFile;
+ auto configFilePath = std::string(dir.c_str()) + "/" + ldapConfFile;
+ auto tlsCACertFilePath = std::string(dir.c_str()) + "/" + tlsCACertFile;
+ auto tlsCertFilePath = std::string(dir.c_str()) + "/" + tlsCertFile;
auto dbusPersistentFilePath = std::string(dir.c_str());
if (fs::exists(configFilePath))
@@ -250,8 +250,8 @@
EXPECT_FALSE(fs::exists(configFilePath));
MockConfigMgr* managerPtr =
new MockConfigMgr(bus, LDAP_CONFIG_ROOT, configFilePath.c_str(),
- dbusPersistentFilePath.c_str(), tlsCacertfile.c_str(),
- tlsCertfile.c_str());
+ dbusPersistentFilePath.c_str(),
+ tlsCACertFilePath.c_str(), tlsCertFilePath.c_str());
EXPECT_CALL(*managerPtr, stopService("nslcd.service")).Times(1);
EXPECT_CALL(*managerPtr, restartService("nslcd.service")).Times(2);
EXPECT_CALL(*managerPtr, restartService("nscd.service")).Times(1);
@@ -286,9 +286,9 @@
TEST_F(TestLDAPConfig, testLDAPServerURI)
{
- auto configFilePath = std::string(dir.c_str()) + "/" + ldapconfFile;
- auto tlsCacertfile = std::string(dir.c_str()) + "/" + tlsCacertFile;
- auto tlsCertfile = std::string(dir.c_str()) + "/" + tlsCertFile;
+ auto configFilePath = std::string(dir.c_str()) + "/" + ldapConfFile;
+ auto tlsCACertFilePath = std::string(dir.c_str()) + "/" + tlsCACertFile;
+ auto tlsCertFilePath = std::string(dir.c_str()) + "/" + tlsCertFile;
auto dbusPersistentFilePath = std::string(dir.c_str());
if (fs::exists(configFilePath))
@@ -298,8 +298,8 @@
EXPECT_FALSE(fs::exists(configFilePath));
MockConfigMgr* managerPtr =
new MockConfigMgr(bus, LDAP_CONFIG_ROOT, configFilePath.c_str(),
- dbusPersistentFilePath.c_str(), tlsCacertfile.c_str(),
- tlsCertfile.c_str());
+ dbusPersistentFilePath.c_str(),
+ tlsCACertFilePath.c_str(), tlsCertFilePath.c_str());
EXPECT_CALL(*managerPtr, stopService("nslcd.service")).Times(1);
EXPECT_CALL(*managerPtr, restartService("nslcd.service")).Times(3);
@@ -316,7 +316,7 @@
EXPECT_EQ(managerPtr->getADConfigPtr()->ldapServerURI(),
"ldap://9.194.251.139/");
- fs::remove(tlsCacertfile.c_str());
+ fs::remove(tlsCACertFilePath.c_str());
// Change LDAP Server URI to make it secure
EXPECT_THROW(
managerPtr->getADConfigPtr()->ldapServerURI("ldaps://9.194.251.139/"),
@@ -335,9 +335,9 @@
TEST_F(TestLDAPConfig, testLDAPBindDN)
{
- auto configFilePath = std::string(dir.c_str()) + "/" + ldapconfFile;
- auto tlsCacertfile = std::string(dir.c_str()) + "/" + tlsCacertFile;
- auto tlsCertfile = std::string(dir.c_str()) + "/" + tlsCertFile;
+ auto configFilePath = std::string(dir.c_str()) + "/" + ldapConfFile;
+ auto tlsCACertFilePath = std::string(dir.c_str()) + "/" + tlsCACertFile;
+ auto tlsCertFilePath = std::string(dir.c_str()) + "/" + tlsCertFile;
auto dbusPersistentFilePath = std::string(dir.c_str());
if (fs::exists(configFilePath))
@@ -347,8 +347,8 @@
EXPECT_FALSE(fs::exists(configFilePath));
MockConfigMgr* managerPtr =
new MockConfigMgr(bus, LDAP_CONFIG_ROOT, configFilePath.c_str(),
- dbusPersistentFilePath.c_str(), tlsCacertfile.c_str(),
- tlsCertfile.c_str());
+ dbusPersistentFilePath.c_str(),
+ tlsCACertFilePath.c_str(), tlsCertFilePath.c_str());
EXPECT_CALL(*managerPtr, stopService("nslcd.service")).Times(1);
EXPECT_CALL(*managerPtr, restartService("nslcd.service")).Times(3);
@@ -388,9 +388,9 @@
TEST_F(TestLDAPConfig, testLDAPBaseDN)
{
- auto configFilePath = std::string(dir.c_str()) + "/" + ldapconfFile;
- auto tlsCacertfile = std::string(dir.c_str()) + "/" + tlsCacertFile;
- auto tlsCertfile = std::string(dir.c_str()) + "/" + tlsCertFile;
+ auto configFilePath = std::string(dir.c_str()) + "/" + ldapConfFile;
+ auto tlsCACertFilePath = std::string(dir.c_str()) + "/" + tlsCACertFile;
+ auto tlsCertFilePath = std::string(dir.c_str()) + "/" + tlsCertFile;
auto dbusPersistentFilePath = std::string(dir.c_str());
if (fs::exists(configFilePath))
@@ -400,8 +400,8 @@
EXPECT_FALSE(fs::exists(configFilePath));
MockConfigMgr* managerPtr =
new MockConfigMgr(bus, LDAP_CONFIG_ROOT, configFilePath.c_str(),
- dbusPersistentFilePath.c_str(), tlsCacertfile.c_str(),
- tlsCertfile.c_str());
+ dbusPersistentFilePath.c_str(),
+ tlsCACertFilePath.c_str(), tlsCertFilePath.c_str());
EXPECT_CALL(*managerPtr, stopService("nslcd.service")).Times(1);
EXPECT_CALL(*managerPtr, restartService("nslcd.service")).Times(3);
EXPECT_CALL(*managerPtr, restartService("nscd.service")).Times(1);
@@ -438,9 +438,9 @@
TEST_F(TestLDAPConfig, testSearchScope)
{
- auto configFilePath = std::string(dir.c_str()) + "/" + ldapconfFile;
- auto tlsCacertfile = std::string(dir.c_str()) + "/" + tlsCacertFile;
- auto tlsCertfile = std::string(dir.c_str()) + "/" + tlsCertFile;
+ auto configFilePath = std::string(dir.c_str()) + "/" + ldapConfFile;
+ auto tlsCACertFilePath = std::string(dir.c_str()) + "/" + tlsCACertFile;
+ auto tlsCertFilePath = std::string(dir.c_str()) + "/" + tlsCertFile;
auto dbusPersistentFilePath = std::string(dir.c_str());
if (fs::exists(configFilePath))
@@ -450,8 +450,8 @@
EXPECT_FALSE(fs::exists(configFilePath));
MockConfigMgr* managerPtr =
new MockConfigMgr(bus, LDAP_CONFIG_ROOT, configFilePath.c_str(),
- dbusPersistentFilePath.c_str(), tlsCacertfile.c_str(),
- tlsCertfile.c_str());
+ dbusPersistentFilePath.c_str(),
+ tlsCACertFilePath.c_str(), tlsCertFilePath.c_str());
EXPECT_CALL(*managerPtr, stopService("nslcd.service")).Times(1);
EXPECT_CALL(*managerPtr, restartService("nslcd.service")).Times(3);
EXPECT_CALL(*managerPtr, restartService("nscd.service")).Times(1);
@@ -476,9 +476,9 @@
TEST_F(TestLDAPConfig, testLDAPType)
{
- auto configFilePath = std::string(dir.c_str()) + "/" + ldapconfFile;
- auto tlsCacertfile = std::string(dir.c_str()) + "/" + tlsCacertFile;
- auto tlsCertfile = std::string(dir.c_str()) + "/" + tlsCertFile;
+ auto configFilePath = std::string(dir.c_str()) + "/" + ldapConfFile;
+ auto tlsCACertFilePath = std::string(dir.c_str()) + "/" + tlsCACertFile;
+ auto tlsCertFilePath = std::string(dir.c_str()) + "/" + tlsCertFile;
auto dbusPersistentFilePath = std::string(dir.c_str());
if (fs::exists(configFilePath))
@@ -488,8 +488,8 @@
EXPECT_FALSE(fs::exists(configFilePath));
MockConfigMgr* managerPtr =
new MockConfigMgr(bus, LDAP_CONFIG_ROOT, configFilePath.c_str(),
- dbusPersistentFilePath.c_str(), tlsCacertfile.c_str(),
- tlsCertfile.c_str());
+ dbusPersistentFilePath.c_str(),
+ tlsCACertFilePath.c_str(), tlsCertFilePath.c_str());
EXPECT_CALL(*managerPtr, stopService("nslcd.service")).Times(1);
EXPECT_CALL(*managerPtr, restartService("nslcd.service")).Times(2);
EXPECT_CALL(*managerPtr, restartService("nscd.service")).Times(1);
@@ -516,9 +516,9 @@
TEST_F(TestLDAPConfig, testsecureLDAPRestore)
{
- auto configFilePath = std::string(dir.c_str()) + "/" + ldapconfFile;
- auto tlsCacertfile = std::string(dir.c_str()) + "/" + tlsCacertFile;
- auto tlsCertfile = std::string(dir.c_str()) + "/" + tlsCertFile;
+ auto configFilePath = std::string(dir.c_str()) + "/" + ldapConfFile;
+ auto tlsCACertFilePath = std::string(dir.c_str()) + "/" + tlsCACertFile;
+ auto tlsCertFilePath = std::string(dir.c_str()) + "/" + tlsCertFile;
auto dbusPersistentFilePath = std::string(dir.c_str());
if (fs::exists(configFilePath))
@@ -528,8 +528,8 @@
EXPECT_FALSE(fs::exists(configFilePath));
MockConfigMgr* managerPtr =
new MockConfigMgr(bus, LDAP_CONFIG_ROOT, configFilePath.c_str(),
- dbusPersistentFilePath.c_str(), tlsCacertfile.c_str(),
- tlsCertfile.c_str());
+ dbusPersistentFilePath.c_str(),
+ tlsCACertFilePath.c_str(), tlsCertFilePath.c_str());
EXPECT_CALL(*managerPtr, stopService("nslcd.service")).Times(1);
EXPECT_CALL(*managerPtr, restartService("nslcd.service")).Times(2);
EXPECT_CALL(*managerPtr, restartService("nscd.service")).Times(1);
@@ -548,9 +548,9 @@
TEST_F(TestLDAPConfig, filePermission)
{
- auto configFilePath = std::string(dir.c_str()) + "/" + ldapconfFile;
- auto tlsCacertfile = std::string(dir.c_str()) + "/" + tlsCacertFile;
- auto tlsCertfile = std::string(dir.c_str()) + "/" + tlsCertFile;
+ auto configFilePath = std::string(dir.c_str()) + "/" + ldapConfFile;
+ auto tlsCACertFilePath = std::string(dir.c_str()) + "/" + tlsCACertFile;
+ auto tlsCertFilePath = std::string(dir.c_str()) + "/" + tlsCertFile;
auto dbusPersistentFilePath = std::string(dir.c_str());
if (fs::exists(configFilePath))
@@ -560,8 +560,8 @@
EXPECT_FALSE(fs::exists(configFilePath));
MockConfigMgr* managerPtr =
new MockConfigMgr(bus, LDAP_CONFIG_ROOT, configFilePath.c_str(),
- dbusPersistentFilePath.c_str(), tlsCacertfile.c_str(),
- tlsCertfile.c_str());
+ dbusPersistentFilePath.c_str(),
+ tlsCACertFilePath.c_str(), tlsCertFilePath.c_str());
EXPECT_CALL(*managerPtr, stopService("nslcd.service")).Times(1);
EXPECT_CALL(*managerPtr, restartService("nslcd.service")).Times(1);
EXPECT_CALL(*managerPtr, restartService("nscd.service")).Times(1);
@@ -576,7 +576,7 @@
auto permission =
fs::perms::owner_read | fs::perms::owner_write | fs::perms::group_read;
auto persistFilepath = std::string(dir.c_str());
- persistFilepath += ADDbusObjectPath;
+ persistFilepath += adDbusObjectPath;
persistFilepath += "/config";
EXPECT_EQ(fs::status(persistFilepath).permissions(), permission);
@@ -585,9 +585,9 @@
TEST_F(TestLDAPConfig, ConditionalEnableConfig)
{
- auto configFilePath = std::string(dir.c_str()) + "/" + ldapconfFile;
- auto tlsCacertfile = std::string(dir.c_str()) + "/" + tlsCacertFile;
- auto tlsCertfile = std::string(dir.c_str()) + "/" + tlsCertFile;
+ auto configFilePath = std::string(dir.c_str()) + "/" + ldapConfFile;
+ auto tlsCACertFilePath = std::string(dir.c_str()) + "/" + tlsCACertFile;
+ auto tlsCertFilePath = std::string(dir.c_str()) + "/" + tlsCertFile;
auto dbusPersistentFilePath = std::string(dir.c_str());
if (fs::exists(configFilePath))
@@ -597,8 +597,8 @@
EXPECT_FALSE(fs::exists(configFilePath));
MockConfigMgr* managerPtr =
new MockConfigMgr(bus, LDAP_CONFIG_ROOT, configFilePath.c_str(),
- dbusPersistentFilePath.c_str(), tlsCacertfile.c_str(),
- tlsCertfile.c_str());
+ dbusPersistentFilePath.c_str(),
+ tlsCACertFilePath.c_str(), tlsCertFilePath.c_str());
EXPECT_CALL(*managerPtr, stopService("nslcd.service")).Times(3);
EXPECT_CALL(*managerPtr, restartService("nslcd.service")).Times(2);
EXPECT_CALL(*managerPtr, restartService("nscd.service")).Times(2);
@@ -648,9 +648,9 @@
TEST_F(TestLDAPConfig, createPrivMapping)
{
- auto configFilePath = std::string(dir.c_str()) + "/" + ldapconfFile;
- auto tlsCacertfile = std::string(dir.c_str()) + "/" + tlsCacertFile;
- auto tlsCertfile = std::string(dir.c_str()) + "/" + tlsCertFile;
+ auto configFilePath = std::string(dir.c_str()) + "/" + ldapConfFile;
+ auto tlsCACertFilePath = std::string(dir.c_str()) + "/" + tlsCACertFile;
+ auto tlsCertFilePath = std::string(dir.c_str()) + "/" + tlsCertFile;
auto dbusPersistentFilePath = std::string(dir.c_str());
if (fs::exists(configFilePath))
@@ -659,8 +659,8 @@
}
EXPECT_FALSE(fs::exists(configFilePath));
MockConfigMgr manager(bus, LDAP_CONFIG_ROOT, configFilePath.c_str(),
- dbusPersistentFilePath.c_str(), tlsCacertfile.c_str(),
- tlsCertfile.c_str());
+ dbusPersistentFilePath.c_str(),
+ tlsCACertFilePath.c_str(), tlsCertFilePath.c_str());
manager.createDefaultObjects();
// Create the priv-mapping under the config.
manager.getADConfigPtr()->create("admin", "priv-admin");
@@ -681,9 +681,9 @@
TEST_F(TestLDAPConfig, deletePrivMapping)
{
- auto configFilePath = std::string(dir.c_str()) + "/" + ldapconfFile;
- auto tlsCacertfile = std::string(dir.c_str()) + "/" + tlsCacertFile;
- auto tlsCertfile = std::string(dir.c_str()) + "/" + tlsCertFile;
+ auto configFilePath = std::string(dir.c_str()) + "/" + ldapConfFile;
+ auto tlsCACertFilePath = std::string(dir.c_str()) + "/" + tlsCACertFile;
+ auto tlsCertFilePath = std::string(dir.c_str()) + "/" + tlsCertFile;
auto dbusPersistentFilePath = std::string(dir.c_str());
if (fs::exists(configFilePath))
@@ -692,8 +692,8 @@
}
EXPECT_FALSE(fs::exists(configFilePath));
MockConfigMgr manager(bus, LDAP_CONFIG_ROOT, configFilePath.c_str(),
- dbusPersistentFilePath.c_str(), tlsCacertfile.c_str(),
- tlsCertfile.c_str());
+ dbusPersistentFilePath.c_str(),
+ tlsCACertFilePath.c_str(), tlsCertFilePath.c_str());
manager.createDefaultObjects();
// Create the priv-mapping under the config.
manager.getADConfigPtr()->create("admin", "priv-admin");
@@ -722,9 +722,9 @@
TEST_F(TestLDAPConfig, restorePrivMapping)
{
- auto configFilePath = std::string(dir.c_str()) + "/" + ldapconfFile;
- auto tlsCacertfile = std::string(dir.c_str()) + "/" + tlsCacertFile;
- auto tlsCertfile = std::string(dir.c_str()) + "/" + tlsCertFile;
+ auto configFilePath = std::string(dir.c_str()) + "/" + ldapConfFile;
+ auto tlsCACertFilePath = std::string(dir.c_str()) + "/" + tlsCACertFile;
+ auto tlsCertFilePath = std::string(dir.c_str()) + "/" + tlsCertFile;
auto dbusPersistentFilePath = std::string(dir.c_str());
if (fs::exists(configFilePath))
@@ -733,8 +733,8 @@
}
EXPECT_FALSE(fs::exists(configFilePath));
MockConfigMgr manager(bus, LDAP_CONFIG_ROOT, configFilePath.c_str(),
- dbusPersistentFilePath.c_str(), tlsCacertfile.c_str(),
- tlsCertfile.c_str());
+ dbusPersistentFilePath.c_str(),
+ tlsCACertFilePath.c_str(), tlsCertFilePath.c_str());
manager.createDefaultObjects();
// Create the priv-mapping under the config.
manager.getADConfigPtr()->create("admin", "priv-admin");
@@ -769,9 +769,9 @@
TEST_F(TestLDAPConfig, testPrivileges)
{
- auto configFilePath = std::string(dir.c_str()) + "/" + ldapconfFile;
- auto tlsCacertfile = std::string(dir.c_str()) + "/" + tlsCacertFile;
- auto tlsCertfile = std::string(dir.c_str()) + "/" + tlsCertFile;
+ auto configFilePath = std::string(dir.c_str()) + "/" + ldapConfFile;
+ auto tlsCACertFilePath = std::string(dir.c_str()) + "/" + tlsCACertFile;
+ auto tlsCertFilePath = std::string(dir.c_str()) + "/" + tlsCertFile;
auto dbusPersistentFilePath = std::string(dir.c_str());
if (fs::exists(configFilePath))
@@ -780,8 +780,8 @@
}
EXPECT_FALSE(fs::exists(configFilePath));
MockConfigMgr manager(bus, LDAP_CONFIG_ROOT, configFilePath.c_str(),
- dbusPersistentFilePath.c_str(), tlsCacertfile.c_str(),
- tlsCertfile.c_str());
+ dbusPersistentFilePath.c_str(),
+ tlsCACertFilePath.c_str(), tlsCertFilePath.c_str());
manager.createDefaultObjects();
std::string groupName = "admin";
diff --git a/test/user_mgr_test.cpp b/test/user_mgr_test.cpp
index 3059ea3..a7801ae 100644
--- a/test/user_mgr_test.cpp
+++ b/test/user_mgr_test.cpp
@@ -21,12 +21,12 @@
class TestUserMgr : public testing::Test
{
public:
- sdbusplus::SdBusMock sdbusMock;
+ sdbusplus::SdBusMock sdBusMock;
sdbusplus::bus_t bus;
MockManager mockManager;
TestUserMgr() :
- bus(sdbusplus::get_mocked_new(&sdbusMock)), mockManager(bus, objpath)
+ bus(sdbusplus::get_mocked_new(&sdBusMock)), mockManager(bus, objpath)
{}
void createLocalUser(const std::string& userName,
@@ -37,9 +37,9 @@
tempObjPath /= userName;
std::string userObj(tempObjPath);
mockManager.usersList.emplace(
- userName, std::move(std::make_unique<phosphor::user::Users>(
+ userName, std::make_unique<phosphor::user::Users>(
mockManager.bus, userObj.c_str(), groupNames, priv,
- enabled, mockManager)));
+ enabled, mockManager));
}
DbusUserObj createPrivilegeMapperDbusObject(void)
@@ -47,14 +47,14 @@
DbusUserObj object;
DbusUserObjValue objValue;
- DbusUserObjPath obj_path("/xyz/openbmc_project/user/ldap/openldap");
+ DbusUserObjPath objPath("/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);
+ object.emplace(objPath, objValue);
- DbusUserObjPath object_path(
+ DbusUserObjPath objectPath(
"/xyz/openbmc_project/user/ldap/openldap/role_map/1");
std::string group = "ldapGroup";
std::string priv = "priv-admin";
@@ -63,7 +63,7 @@
std::string interface = "xyz.openbmc_project.User.PrivilegeMapperEntry";
objValue.emplace(interface, properties);
- object.emplace(object_path, objValue);
+ object.emplace(objectPath, objValue);
return object;
}
@@ -73,12 +73,12 @@
DbusUserObj object;
DbusUserObjValue objValue;
- DbusUserObjPath obj_path("/xyz/openbmc_project/user/ldap/openldap");
+ DbusUserObjPath objPath("/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);
+ object.emplace(objPath, objValue);
return object;
}
};
diff --git a/test/utils_test.cpp b/test/utils_test.cpp
index 7e152b6..5538449 100644
--- a/test/utils_test.cpp
+++ b/test/utils_test.cpp
@@ -9,8 +9,8 @@
{
namespace ldap
{
-constexpr auto LDAPscheme = "ldap";
-constexpr auto LDAPSscheme = "ldaps";
+constexpr auto ldapScheme = "ldap";
+constexpr auto ldapsScheme = "ldaps";
class TestUtil : public testing::Test
{
@@ -23,59 +23,59 @@
TEST_F(TestUtil, URIValidation)
{
- std::string ipaddress = "ldap://0.0.0.0";
- EXPECT_EQ(true, isValidLDAPURI(ipaddress.c_str(), LDAPscheme));
+ std::string ipAddress = "ldap://0.0.0.0";
+ EXPECT_EQ(true, isValidLDAPURI(ipAddress.c_str(), ldapScheme));
- ipaddress = "ldap://9.3.185.83";
- EXPECT_EQ(true, isValidLDAPURI(ipaddress.c_str(), LDAPscheme));
+ ipAddress = "ldap://9.3.185.83";
+ EXPECT_EQ(true, isValidLDAPURI(ipAddress.c_str(), ldapScheme));
- ipaddress = "ldaps://9.3.185.83";
- EXPECT_EQ(false, isValidLDAPURI(ipaddress.c_str(), LDAPscheme));
+ ipAddress = "ldaps://9.3.185.83";
+ EXPECT_EQ(false, isValidLDAPURI(ipAddress.c_str(), ldapScheme));
- ipaddress = "ldap://9.3.a.83";
- EXPECT_EQ(false, isValidLDAPURI(ipaddress.c_str(), LDAPscheme));
+ ipAddress = "ldap://9.3.a.83";
+ EXPECT_EQ(false, isValidLDAPURI(ipAddress.c_str(), ldapScheme));
- ipaddress = "ldap://9.3.185.a";
- EXPECT_EQ(false, isValidLDAPURI(ipaddress.c_str(), LDAPscheme));
+ ipAddress = "ldap://9.3.185.a";
+ EXPECT_EQ(false, isValidLDAPURI(ipAddress.c_str(), ldapScheme));
- ipaddress = "ldap://x.x.x.x";
- EXPECT_EQ(false, isValidLDAPURI(ipaddress.c_str(), LDAPscheme));
+ ipAddress = "ldap://x.x.x.x";
+ EXPECT_EQ(false, isValidLDAPURI(ipAddress.c_str(), ldapScheme));
- ipaddress = "ldaps://0.0.0.0";
- EXPECT_EQ(true, isValidLDAPURI(ipaddress.c_str(), LDAPSscheme));
+ ipAddress = "ldaps://0.0.0.0";
+ EXPECT_EQ(true, isValidLDAPURI(ipAddress.c_str(), ldapsScheme));
- ipaddress = "ldap://0.0.0.0";
- EXPECT_EQ(false, isValidLDAPURI(ipaddress.c_str(), LDAPSscheme));
+ ipAddress = "ldap://0.0.0.0";
+ EXPECT_EQ(false, isValidLDAPURI(ipAddress.c_str(), ldapsScheme));
- ipaddress = "ldaps://9.3.185.83";
- EXPECT_EQ(true, isValidLDAPURI(ipaddress.c_str(), LDAPSscheme));
+ ipAddress = "ldaps://9.3.185.83";
+ EXPECT_EQ(true, isValidLDAPURI(ipAddress.c_str(), ldapsScheme));
- ipaddress = "ldap://9.3.185.83";
- EXPECT_EQ(false, isValidLDAPURI(ipaddress.c_str(), LDAPSscheme));
+ ipAddress = "ldap://9.3.185.83";
+ EXPECT_EQ(false, isValidLDAPURI(ipAddress.c_str(), ldapsScheme));
- ipaddress = "ldaps://9.3.185.83";
- EXPECT_EQ(true, isValidLDAPURI(ipaddress.c_str(), LDAPSscheme));
+ ipAddress = "ldaps://9.3.185.83";
+ EXPECT_EQ(true, isValidLDAPURI(ipAddress.c_str(), ldapsScheme));
- ipaddress = "ldaps://9.3.185.a";
- EXPECT_EQ(false, isValidLDAPURI(ipaddress.c_str(), LDAPSscheme));
+ ipAddress = "ldaps://9.3.185.a";
+ EXPECT_EQ(false, isValidLDAPURI(ipAddress.c_str(), ldapsScheme));
- ipaddress = "ldaps://9.3.a.83";
- EXPECT_EQ(false, isValidLDAPURI(ipaddress.c_str(), LDAPSscheme));
+ ipAddress = "ldaps://9.3.a.83";
+ EXPECT_EQ(false, isValidLDAPURI(ipAddress.c_str(), ldapsScheme));
- ipaddress = "ldaps://x.x.x.x";
- EXPECT_EQ(false, isValidLDAPURI(ipaddress.c_str(), LDAPSscheme));
+ ipAddress = "ldaps://x.x.x.x";
+ EXPECT_EQ(false, isValidLDAPURI(ipAddress.c_str(), ldapsScheme));
- ipaddress = "ldap://9.3.185.83:70000";
- EXPECT_EQ(false, isValidLDAPURI(ipaddress.c_str(), LDAPscheme));
+ ipAddress = "ldap://9.3.185.83:70000";
+ EXPECT_EQ(false, isValidLDAPURI(ipAddress.c_str(), ldapScheme));
- ipaddress = "ldap://9.3.185.83:-3";
- EXPECT_EQ(false, isValidLDAPURI(ipaddress.c_str(), LDAPscheme));
+ ipAddress = "ldap://9.3.185.83:-3";
+ EXPECT_EQ(false, isValidLDAPURI(ipAddress.c_str(), ldapScheme));
- ipaddress = "ldap://9.3.185.83:221";
- EXPECT_EQ(true, isValidLDAPURI(ipaddress.c_str(), LDAPscheme));
+ ipAddress = "ldap://9.3.185.83:221";
+ EXPECT_EQ(true, isValidLDAPURI(ipAddress.c_str(), ldapScheme));
- ipaddress = "ldap://9.3.185.83:0";
- EXPECT_EQ(false, isValidLDAPURI(ipaddress.c_str(), LDAPscheme));
+ ipAddress = "ldap://9.3.185.83:0";
+ EXPECT_EQ(false, isValidLDAPURI(ipAddress.c_str(), ldapScheme));
}
} // namespace ldap
} // namespace phosphor
diff --git a/user_mgr.cpp b/user_mgr.cpp
index 83e9f3d..95fb421 100644
--- a/user_mgr.cpp
+++ b/user_mgr.cpp
@@ -340,8 +340,8 @@
std::string userObj(tempObjPath);
std::sort(groupNames.begin(), groupNames.end());
usersList.emplace(
- userName, std::move(std::make_unique<phosphor::user::Users>(
- bus, userObj.c_str(), groupNames, priv, enabled, *this)));
+ userName, std::make_unique<phosphor::user::Users>(
+ bus, userObj.c_str(), groupNames, priv, enabled, *this));
log<level::INFO>("User created successfully",
entry("USER_NAME=%s", userName.c_str()));
@@ -403,10 +403,9 @@
// InterfacesAdded. So first send out userRenamed signal.
this->userRenamed(userName, newUserName);
usersList.erase(userName);
- usersList.emplace(
- newUserName,
- std::move(std::make_unique<phosphor::user::Users>(
- bus, newUserObj.c_str(), groupNames, priv, enabled, *this)));
+ usersList.emplace(newUserName, std::make_unique<phosphor::user::Users>(
+ bus, newUserObj.c_str(), groupNames,
+ priv, enabled, *this));
return;
}
@@ -818,8 +817,8 @@
// Determine password validity per "chage" docs, where:
// spwd.sp_lstchg == 0 means password is expired, and
// spwd.sp_max == -1 means the password does not expire.
- constexpr long seconds_per_day = 60 * 60 * 24;
- long today = static_cast<long>(time(NULL)) / seconds_per_day;
+ constexpr long secondsPerDay = 60 * 60 * 24;
+ long today = static_cast<long>(time(NULL)) / secondsPerDay;
if ((spwd.sp_lstchg == 0) ||
((spwd.sp_max != -1) && ((spwd.sp_max + spwd.sp_lstchg) < today)))
{
@@ -1226,10 +1225,9 @@
tempObjPath /= user;
std::string objPath(tempObjPath);
std::sort(userGroups.begin(), userGroups.end());
- usersList.emplace(user,
- std::move(std::make_unique<phosphor::user::Users>(
- bus, objPath.c_str(), userGroups, userPriv,
- isUserEnabled(user), *this)));
+ usersList.emplace(user, std::make_unique<phosphor::user::Users>(
+ bus, objPath.c_str(), userGroups,
+ userPriv, isUserEnabled(user), *this));
}
}
}