clang-tidy: enable clang-tidy
Enable the first check: readability-identifier-naming
Also fixed all check failures. The renaming is done by clang-tidy
automatically.
Tested:
1. compiles, no clang-tidy failures
2. tested on QEMU, Redfish is working correctly
3. tested on s7106, Redfish is working correctly; certificates can be
retrieved.
Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I3c5c9ca734146a94f4e0433ed8c1ae84173288c5
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/argument.cpp b/argument.cpp
index ba4ebbc..5733e09 100644
--- a/argument.cpp
+++ b/argument.cpp
@@ -22,7 +22,7 @@
CLI11_PARSE(app, argc, argv);
phosphor::certs::CertificateType type =
phosphor::certs::stringToCertificateType(arguments.typeStr);
- if (type == phosphor::certs::CertificateType::Unsupported)
+ if (type == phosphor::certs::CertificateType::unsupported)
{
std::cerr << "type not specified or invalid." << std::endl;
return 1;
diff --git a/certificate.cpp b/certificate.cpp
index 5ebb4f7..bf20845 100644
--- a/certificate.cpp
+++ b/certificate.cpp
@@ -171,10 +171,10 @@
{
const internal::X509Ptr cert = loadCert(certSrcFilePath);
unsigned long hash = X509_subject_name_hash(cert.get());
- static constexpr auto CERT_HASH_LENGTH = 9;
- char hashBuf[CERT_HASH_LENGTH];
+ static constexpr auto certHashLength = 9;
+ char hashBuf[certHashLength];
- snprintf(hashBuf, CERT_HASH_LENGTH, "%08lx", hash);
+ snprintf(hashBuf, certHashLength, "%08lx", hash);
const std::string certHash(hashBuf);
for (size_t i = 0; i < maxNumAuthorityCertificates; ++i)
@@ -218,7 +218,7 @@
std::string
Certificate::generateCertFilePath(const std::string& certSrcFilePath)
{
- if (certType == CertificateType::Authority)
+ if (certType == CertificateType::authority)
{
return generateAuthCertFilePath(certSrcFilePath);
}
@@ -245,17 +245,17 @@
"Private key does not match the Certificate"));
};
};
- typeFuncMap[CertificateType::Server] = installHelper;
- typeFuncMap[CertificateType::Client] = installHelper;
- typeFuncMap[CertificateType::Authority] = [](const std::string&) {};
+ typeFuncMap[CertificateType::server] = installHelper;
+ typeFuncMap[CertificateType::client] = installHelper;
+ typeFuncMap[CertificateType::authority] = [](const std::string&) {};
auto appendPrivateKey = [this](const std::string& filePath) {
checkAndAppendPrivateKey(filePath);
};
- appendKeyMap[CertificateType::Server] = appendPrivateKey;
- appendKeyMap[CertificateType::Client] = appendPrivateKey;
- appendKeyMap[CertificateType::Authority] = [](const std::string&) {};
+ appendKeyMap[CertificateType::server] = appendPrivateKey;
+ appendKeyMap[CertificateType::client] = appendPrivateKey;
+ appendKeyMap[CertificateType::authority] = [](const std::string&) {};
// Generate certificate file path
certFilePath = generateCertFilePath(uploadPath);
@@ -392,7 +392,7 @@
{
log<level::INFO>("Certificate install ", entry("PEM_STR=%s", pem.data()));
- if (certType != CertificateType::Authority)
+ if (certType != CertificateType::authority)
{
log<level::ERR>("Bulk install error: Unsupported Type; only authority "
"supports bulk install",
@@ -446,7 +446,7 @@
void Certificate::storageUpdate()
{
- if (certType == CertificateType::Authority)
+ if (certType == CertificateType::authority)
{
// Create symbolic link in the certificate directory
std::string certFileX509Path;
@@ -495,8 +495,8 @@
char issuerBuffer[maxKeySize] = {0};
BIOMemPtr issuerBio(BIO_new(BIO_s_mem()), BIO_free);
// This pointer cannot be freed independantly.
- X509_NAME* issuer_name = X509_get_issuer_name(&cert);
- X509_NAME_print_ex(issuerBio.get(), issuer_name, 0, XN_FLAG_SEP_COMMA_PLUS);
+ X509_NAME* issuerName = X509_get_issuer_name(&cert);
+ X509_NAME_print_ex(issuerBio.get(), issuerName, 0, XN_FLAG_SEP_COMMA_PLUS);
BIO_read(issuerBio.get(), issuerBuffer, maxKeySize);
issuer(issuerBuffer);
diff --git a/certificate.hpp b/certificate.hpp
index cb4eba6..e6d22d1 100644
--- a/certificate.hpp
+++ b/certificate.hpp
@@ -21,21 +21,21 @@
// Certificate types
enum class CertificateType
{
- Authority,
- Server,
- Client,
- Unsupported,
+ authority,
+ server,
+ client,
+ unsupported,
};
inline constexpr const char* certificateTypeToString(CertificateType type)
{
switch (type)
{
- case CertificateType::Authority:
+ case CertificateType::authority:
return "authority";
- case CertificateType::Server:
+ case CertificateType::server:
return "server";
- case CertificateType::Client:
+ case CertificateType::client:
return "client";
default:
return "unsupported";
@@ -46,17 +46,17 @@
{
if (type == "authority")
{
- return CertificateType::Authority;
+ return CertificateType::authority;
}
if (type == "server")
{
- return CertificateType::Server;
+ return CertificateType::server;
}
if (type == "client")
{
- return CertificateType::Client;
+ return CertificateType::client;
}
- return CertificateType::Unsupported;
+ return CertificateType::unsupported;
}
namespace internal
diff --git a/certs_manager.cpp b/certs_manager.cpp
index 936b470..0d0a87a 100644
--- a/certs_manager.cpp
+++ b/certs_manager.cpp
@@ -145,7 +145,7 @@
fs::path certDirectory;
try
{
- if (certType == CertificateType::Authority)
+ if (certType == CertificateType::authority)
{
certDirectory = certInstallPath;
}
@@ -174,7 +174,7 @@
}
// Generating RSA private key file if certificate type is server/client
- if (certType != CertificateType::Authority)
+ if (certType != CertificateType::authority)
{
createRSAPrivateKeyFile();
}
@@ -183,7 +183,7 @@
createCertificates();
// watch is not required for authority certificates
- if (certType != CertificateType::Authority)
+ if (certType != CertificateType::authority)
{
// watch for certificate file create/replace
certWatchPtr = std::make_unique<
@@ -251,11 +251,11 @@
std::string Manager::install(const std::string filePath)
{
- if (certType != CertificateType::Authority && !installedCerts.empty())
+ if (certType != CertificateType::authority && !installedCerts.empty())
{
elog<NotAllowed>(NotAllowedReason("Certificate already exist"));
}
- else if (certType == CertificateType::Authority &&
+ else if (certType == CertificateType::authority &&
installedCerts.size() >= maxNumAuthorityCertificates)
{
elog<NotAllowed>(NotAllowedReason("Certificates limit reached"));
@@ -282,7 +282,7 @@
std::vector<sdbusplus::message::object_path>
Manager::installAll(const std::string filePath)
{
- if (certType != CertificateType::Authority)
+ if (certType != CertificateType::authority)
{
elog<NotAllowed>(
NotAllowedReason("The InstallAll interface is only allowed for "
@@ -385,7 +385,7 @@
// deletion of certificates
installedCerts.clear();
// If the authorities list exists, delete it as well
- if (certType == CertificateType::Authority)
+ if (certType == CertificateType::authority)
{
if (fs::path authoritiesList =
fs::path(certInstallPath) / defaultAuthoritiesListFileName;
@@ -487,11 +487,11 @@
eventSource.set_enabled(Enabled::On);
if (si->si_status != 0)
{
- this->createCSRObject(Status::FAILURE);
+ this->createCSRObject(Status::failure);
}
else
{
- this->createCSRObject(Status::SUCCESS);
+ this->createCSRObject(Status::success);
}
};
try
@@ -779,7 +779,7 @@
return pKey;
#else
- auto holder_of_key = [](EVP_PKEY* key) {
+ auto holderOfKey = [](EVP_PKEY* key) {
return std::unique_ptr<EVP_PKEY, decltype(&::EVP_PKEY_free)>{
key, &::EVP_PKEY_free};
};
@@ -807,7 +807,7 @@
}
// Move parameters to RAII holder.
- auto pparms = holder_of_key(params);
+ auto pparms = holderOfKey(params);
// Create new context for key.
ctx.reset(EVP_PKEY_CTX_new_from_pkey(nullptr, params, nullptr));
@@ -825,7 +825,7 @@
elog<InternalFailure>();
}
- return holder_of_key(pKey);
+ return holderOfKey(pKey);
#endif
}
@@ -919,7 +919,7 @@
{
auto certObjectPath = objectPath + '/';
- if (certType == CertificateType::Authority)
+ if (certType == CertificateType::authority)
{
// Check whether install path is a directory.
if (!fs::is_directory(certInstallPath))
@@ -1050,7 +1050,7 @@
void Manager::storageUpdate()
{
- if (certType == CertificateType::Authority)
+ if (certType == CertificateType::authority)
{
// Remove symbolic links in the certificate directory
for (auto& certPath : fs::directory_iterator(certInstallPath))
diff --git a/certs_manager.hpp b/certs_manager.hpp
index 02ea9bb..064d801 100644
--- a/certs_manager.hpp
+++ b/certs_manager.hpp
@@ -231,7 +231,7 @@
* @return Pointer to EC private key
*/
std::unique_ptr<EVP_PKEY, decltype(&::EVP_PKEY_free)>
- generateECKeyPair(const std::string& p_KeyCurveId);
+ generateECKeyPair(const std::string& pKeyCurveId);
/** @brief Write private key data to file
*
diff --git a/csr.cpp b/csr.cpp
index 5caed9d..5f400e5 100644
--- a/csr.cpp
+++ b/csr.cpp
@@ -43,7 +43,7 @@
std::string CSR::csr()
{
- if (csrStatus == Status::FAILURE)
+ if (csrStatus == Status::failure)
{
log<level::ERR>("Failure in Generating CSR");
elog<InternalFailure>();
diff --git a/csr.hpp b/csr.hpp
index 05d5ba6..e891681 100644
--- a/csr.hpp
+++ b/csr.hpp
@@ -8,8 +8,8 @@
enum class Status
{
- SUCCESS,
- FAILURE,
+ success,
+ failure,
};
namespace internal
diff --git a/test/certs_manager_test.cpp b/test/certs_manager_test.cpp
index da08996..9caa9d3 100644
--- a/test/certs_manager_test.cpp
+++ b/test/certs_manager_test.cpp
@@ -197,8 +197,8 @@
}
unsigned long hash = X509_subject_name_hash(cert.get());
- static constexpr auto AUTH_CERT_HASH_LENGTH = 9;
- char hashBuf[AUTH_CERT_HASH_LENGTH];
+ static constexpr auto authCertHashLength = 9;
+ char hashBuf[authCertHashLength];
sprintf(hashBuf, "%08lx", hash);
return std::string(hashBuf);
}
@@ -271,7 +271,7 @@
TEST_F(TestCertificates, InvokeServerInstall)
{
std::string endpoint("https");
- CertificateType type = CertificateType::Server;
+ CertificateType type = CertificateType::server;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyPath(installPath);
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
@@ -294,7 +294,7 @@
TEST_F(TestCertificates, InvokeClientInstall)
{
std::string endpoint("ldap");
- CertificateType type = CertificateType::Server;
+ CertificateType type = CertificateType::server;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyPath(installPath);
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
@@ -317,7 +317,7 @@
TEST_F(TestCertificates, InvokeAuthorityInstall)
{
std::string endpoint("ldap");
- CertificateType type = CertificateType::Authority;
+ CertificateType type = CertificateType::authority;
std::string verifyDir(certDir);
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
auto objPath = std::string(objectNamePrefix) + '/' +
@@ -360,7 +360,7 @@
TEST_F(TestCertificates, InvokeAuthorityInstallNeverExpiredRootCert)
{
std::string endpoint("ldap");
- CertificateType type = CertificateType::Authority;
+ CertificateType type = CertificateType::authority;
std::string verifyDir(certDir);
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
auto objPath = std::string(objectNamePrefix) + '/' +
@@ -401,7 +401,7 @@
TEST_F(TestCertificates, InvokeInstallSameCertTwice)
{
std::string endpoint("ldap");
- CertificateType type = CertificateType::Authority;
+ CertificateType type = CertificateType::authority;
std::string verifyDir(certDir);
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
auto objPath = std::string(objectNamePrefix) + '/' +
@@ -457,7 +457,7 @@
TEST_F(TestCertificates, InvokeInstallSameSubjectTwice)
{
std::string endpoint("ldap");
- CertificateType type = CertificateType::Authority;
+ CertificateType type = CertificateType::authority;
std::string verifyDir(certDir);
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
auto objPath = std::string(objectNamePrefix) + '/' +
@@ -515,7 +515,7 @@
TEST_F(TestCertificates, InvokeInstallAuthCertLimit)
{
std::string endpoint("ldap");
- CertificateType type = CertificateType::Authority;
+ CertificateType type = CertificateType::authority;
std::string verifyDir(certDir);
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
auto objPath = std::string(objectNamePrefix) + '/' +
@@ -591,7 +591,7 @@
TEST_F(TestCertificates, CompareInstalledCertificate)
{
std::string endpoint("ldap");
- CertificateType type = CertificateType::Client;
+ CertificateType type = CertificateType::client;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyPath(installPath);
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
@@ -615,7 +615,7 @@
TEST_F(TestCertificates, TestNoCertificateFile)
{
std::string endpoint("ldap");
- CertificateType type = CertificateType::Client;
+ CertificateType type = CertificateType::client;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyPath(installPath);
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
@@ -648,7 +648,7 @@
TEST_F(TestCertificates, TestReplaceCertificate)
{
std::string endpoint("ldap");
- CertificateType type = CertificateType::Server;
+ CertificateType type = CertificateType::server;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyPath(installPath);
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
@@ -678,7 +678,7 @@
TEST_F(TestCertificates, TestAuthorityReplaceCertificate)
{
std::string endpoint("ldap");
- CertificateType type = CertificateType::Authority;
+ CertificateType type = CertificateType::authority;
std::string verifyDir(certDir);
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
auto objPath = std::string(objectNamePrefix) + '/' +
@@ -688,9 +688,9 @@
bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
ManagerInTest manager(bus, event, objPath.c_str(), type, verifyUnit,
certDir);
- constexpr const unsigned int REPLACE_ITERATIONS = 10;
+ constexpr const unsigned int replaceIterations = 10;
EXPECT_CALL(manager, reloadOrReset(Eq(ManagerInTest::unitToRestartInTest)))
- .Times(REPLACE_ITERATIONS + 1)
+ .Times(replaceIterations + 1)
.WillRepeatedly(Return());
MainApp mainApp(&manager);
mainApp.install(certificateFile);
@@ -698,7 +698,7 @@
std::vector<std::unique_ptr<Certificate>>& certs =
manager.getCertificates();
- for (unsigned int i = 0; i < REPLACE_ITERATIONS; i++)
+ for (unsigned int i = 0; i < replaceIterations; i++)
{
// Certificate successfully installed
EXPECT_FALSE(certs.empty());
@@ -728,7 +728,7 @@
TEST_F(TestCertificates, TestStorageDeleteCertificate)
{
std::string endpoint("ldap");
- CertificateType type = CertificateType::Authority;
+ CertificateType type = CertificateType::authority;
std::string verifyDir(certDir);
std::string verifyUnit((ManagerInTest::unitToRestartInTest));
auto objPath = std::string(objectNamePrefix) + '/' +
@@ -781,7 +781,7 @@
TEST_F(TestCertificates, TestEmptyCertificateFile)
{
std::string endpoint("ldap");
- CertificateType type = CertificateType::Client;
+ CertificateType type = CertificateType::client;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyPath(installPath);
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
@@ -818,7 +818,7 @@
TEST_F(TestCertificates, TestInvalidCertificateFile)
{
std::string endpoint("ldap");
- CertificateType type = CertificateType::Client;
+ CertificateType type = CertificateType::client;
std::ofstream ofs;
ofs.open(certificateFile, std::ofstream::out);
@@ -905,7 +905,7 @@
TEST_F(TestInvalidCertificate, TestMissingPrivateKey)
{
std::string endpoint("ldap");
- CertificateType type = CertificateType::Client;
+ CertificateType type = CertificateType::client;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyPath(installPath);
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
@@ -937,7 +937,7 @@
TEST_F(TestInvalidCertificate, TestMissingCeritificate)
{
std::string endpoint("ldap");
- CertificateType type = CertificateType::Client;
+ CertificateType type = CertificateType::client;
std::string installPath(certDir + "/" + keyFile);
std::string verifyPath(installPath);
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
@@ -972,7 +972,7 @@
using NotAllowed =
sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed;
std::string endpoint("ldap");
- CertificateType type = CertificateType::Client;
+ CertificateType type = CertificateType::client;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyPath(installPath);
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
@@ -1005,10 +1005,10 @@
{
std::string endpoint("https");
std::string unit;
- CertificateType type = CertificateType::Server;
+ CertificateType type = CertificateType::server;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyPath(installPath);
- std::string CSRPath(certDir + "/" + CSRFile);
+ std::string csrPath(certDir + "/" + CSRFile);
std::string privateKeyPath(certDir + "/" + privateKeyFile);
std::vector<std::string> alternativeNames{"localhost1", "localhost2"};
std::string challengePassword("Password");
@@ -1036,7 +1036,7 @@
Manager manager(bus, event, objPath.c_str(), type, std::move(unit),
std::move(installPath));
Status status;
- CSR csr(bus, objPath.c_str(), CSRPath.c_str(), status);
+ CSR csr(bus, objPath.c_str(), csrPath.c_str(), status);
MainApp mainApp(&manager, &csr);
mainApp.generateCSR(alternativeNames, challengePassword, city, commonName,
contactPerson, country, email, givenName, initials,
@@ -1045,7 +1045,7 @@
unstructuredName);
std::string csrData("");
// generateCSR takes considerable time to create CSR and privateKey Files
- EXPECT_FALSE(fs::exists(CSRPath));
+ EXPECT_FALSE(fs::exists(csrPath));
EXPECT_FALSE(fs::exists(privateKeyPath));
EXPECT_THROW(
{
@@ -1061,7 +1061,7 @@
InternalFailure);
// wait for 10 sec to get CSR and privateKey Files generated
sleep(10);
- EXPECT_TRUE(fs::exists(CSRPath));
+ EXPECT_TRUE(fs::exists(csrPath));
EXPECT_TRUE(fs::exists(privateKeyPath));
csrData = csr.csr();
ASSERT_NE("", csrData.c_str());
@@ -1074,10 +1074,10 @@
{
std::string endpoint("https");
std::string unit;
- CertificateType type = CertificateType::Server;
+ CertificateType type = CertificateType::server;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyPath(installPath);
- std::string CSRPath(certDir + "/" + CSRFile);
+ std::string csrPath(certDir + "/" + CSRFile);
std::string privateKeyPath(certDir + "/" + privateKeyFile);
std::vector<std::string> alternativeNames{"localhost1", "localhost2"};
std::string challengePassword("Password");
@@ -1103,7 +1103,7 @@
Manager manager(bus, event, objPath.c_str(), type, std::move(unit),
std::move(installPath));
Status status;
- CSR csr(bus, objPath.c_str(), CSRPath.c_str(), status);
+ CSR csr(bus, objPath.c_str(), csrPath.c_str(), status);
MainApp mainApp(&manager, &csr);
mainApp.generateCSR(alternativeNames, challengePassword, city, commonName,
contactPerson, country, email, givenName, initials,
@@ -1111,7 +1111,7 @@
organization, organizationalUnit, state, surname,
unstructuredName);
sleep(10);
- EXPECT_TRUE(fs::exists(CSRPath));
+ EXPECT_TRUE(fs::exists(csrPath));
EXPECT_TRUE(fs::exists(privateKeyPath));
}
@@ -1122,10 +1122,10 @@
{
std::string endpoint("https");
std::string unit;
- CertificateType type = CertificateType::Server;
+ CertificateType type = CertificateType::server;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyPath(installPath);
- std::string CSRPath(certDir + "/" + CSRFile);
+ std::string csrPath(certDir + "/" + CSRFile);
std::string privateKeyPath(certDir + "/" + privateKeyFile);
std::vector<std::string> alternativeNames{"localhost1", "localhost2"};
std::string challengePassword("Password");
@@ -1151,14 +1151,14 @@
Manager manager(bus, event, objPath.c_str(), type, std::move(unit),
std::move(installPath));
Status status;
- CSR csr(bus, objPath.c_str(), CSRPath.c_str(), status);
+ CSR csr(bus, objPath.c_str(), csrPath.c_str(), status);
MainApp mainApp(&manager, &csr);
mainApp.generateCSR(alternativeNames, challengePassword, city, commonName,
contactPerson, country, email, givenName, initials,
keyBitLength, keyCurveId, keyPairAlgorithm, keyUsage,
organization, organizationalUnit, state, surname,
unstructuredName);
- EXPECT_FALSE(fs::exists(CSRPath));
+ EXPECT_FALSE(fs::exists(csrPath));
EXPECT_FALSE(fs::exists(privateKeyPath));
}
@@ -1169,10 +1169,10 @@
{
std::string endpoint("https");
std::string unit;
- CertificateType type = CertificateType::Server;
+ CertificateType type = CertificateType::server;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyPath(installPath);
- std::string CSRPath(certDir + "/" + CSRFile);
+ std::string csrPath(certDir + "/" + CSRFile);
std::string privateKeyPath(certDir + "/" + privateKeyFile);
std::vector<std::string> alternativeNames{"localhost1", "localhost2"};
std::string challengePassword("Password");
@@ -1198,14 +1198,14 @@
Manager manager(bus, event, objPath.c_str(), type, std::move(unit),
std::move(installPath));
Status status;
- CSR csr(bus, objPath.c_str(), CSRPath.c_str(), status);
+ CSR csr(bus, objPath.c_str(), csrPath.c_str(), status);
MainApp mainApp(&manager, &csr);
mainApp.generateCSR(alternativeNames, challengePassword, city, commonName,
contactPerson, country, email, givenName, initials,
keyBitLength, keyCurveId, keyPairAlgorithm, keyUsage,
organization, organizationalUnit, state, surname,
unstructuredName);
- EXPECT_FALSE(fs::exists(CSRPath));
+ EXPECT_FALSE(fs::exists(csrPath));
EXPECT_FALSE(fs::exists(privateKeyPath));
}
@@ -1215,10 +1215,10 @@
{
std::string endpoint("https");
std::string unit;
- CertificateType type = CertificateType::Server;
+ CertificateType type = CertificateType::server;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyPath(installPath);
- std::string CSRPath(certDir + "/" + CSRFile);
+ std::string csrPath(certDir + "/" + CSRFile);
std::string privateKeyPath(certDir + "/" + privateKeyFile);
std::vector<std::string> alternativeNames{"localhost1", "localhost2"};
std::string challengePassword("Password");
@@ -1244,7 +1244,7 @@
Manager manager(bus, event, objPath.c_str(), type, std::move(unit),
std::move(installPath));
Status status;
- CSR csr(bus, objPath.c_str(), CSRPath.c_str(), status);
+ CSR csr(bus, objPath.c_str(), csrPath.c_str(), status);
MainApp mainApp(&manager, &csr);
mainApp.generateCSR(alternativeNames, challengePassword, city, commonName,
contactPerson, country, email, givenName, initials,
@@ -1252,7 +1252,7 @@
organization, organizationalUnit, state, surname,
unstructuredName);
sleep(10);
- EXPECT_TRUE(fs::exists(CSRPath));
+ EXPECT_TRUE(fs::exists(csrPath));
EXPECT_TRUE(fs::exists(privateKeyPath));
}
@@ -1262,10 +1262,10 @@
{
std::string endpoint("https");
std::string unit;
- CertificateType type = CertificateType::Server;
+ CertificateType type = CertificateType::server;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyPath(installPath);
- std::string CSRPath(certDir + "/" + CSRFile);
+ std::string csrPath(certDir + "/" + CSRFile);
std::string privateKeyPath(certDir + "/" + privateKeyFile);
std::vector<std::string> alternativeNames{"localhost1", "localhost2"};
std::string challengePassword("Password");
@@ -1291,17 +1291,17 @@
Manager manager(bus, event, objPath.c_str(), type, std::move(unit),
std::move(installPath));
Status status;
- CSR csr(bus, objPath.c_str(), CSRPath.c_str(), status);
+ CSR csr(bus, objPath.c_str(), csrPath.c_str(), status);
MainApp mainApp(&manager, &csr);
mainApp.generateCSR(alternativeNames, challengePassword, city, commonName,
contactPerson, country, email, givenName, initials,
keyBitLength, keyCurveId, keyPairAlgorithm, keyUsage,
organization, organizationalUnit, state, surname,
unstructuredName);
- std::cout << "CSRPath: " << CSRPath << std::endl
+ std::cout << "CSRPath: " << csrPath << std::endl
<< "privateKeyPath: " << privateKeyPath << std::endl;
sleep(10);
- EXPECT_TRUE(fs::exists(CSRPath));
+ EXPECT_TRUE(fs::exists(csrPath));
EXPECT_TRUE(fs::exists(privateKeyPath));
}
@@ -1312,10 +1312,10 @@
{
std::string endpoint("https");
std::string unit;
- CertificateType type = CertificateType::Server;
+ CertificateType type = CertificateType::server;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyPath(installPath);
- std::string CSRPath(certDir + "/" + CSRFile);
+ std::string csrPath(certDir + "/" + CSRFile);
std::string privateKeyPath(certDir + "/" + privateKeyFile);
std::vector<std::string> alternativeNames{"localhost1", "localhost2"};
std::string challengePassword("Password");
@@ -1341,14 +1341,14 @@
Manager manager(bus, event, objPath.c_str(), type, std::move(unit),
std::move(installPath));
Status status;
- CSR csr(bus, objPath.c_str(), CSRPath.c_str(), status);
+ CSR csr(bus, objPath.c_str(), csrPath.c_str(), status);
MainApp mainApp(&manager, &csr);
mainApp.generateCSR(alternativeNames, challengePassword, city, commonName,
contactPerson, country, email, givenName, initials,
keyBitLength, keyCurveId, keyPairAlgorithm, keyUsage,
organization, organizationalUnit, state, surname,
unstructuredName);
- EXPECT_FALSE(fs::exists(CSRPath));
+ EXPECT_FALSE(fs::exists(csrPath));
EXPECT_FALSE(fs::exists(privateKeyPath));
}
@@ -1358,10 +1358,10 @@
{
std::string endpoint("https");
std::string unit;
- CertificateType type = CertificateType::Server;
+ CertificateType type = CertificateType::server;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyPath(installPath);
- std::string CSRPath(certDir + "/" + CSRFile);
+ std::string csrPath(certDir + "/" + CSRFile);
std::string privateKeyPath(certDir + "/" + privateKeyFile);
std::vector<std::string> alternativeNames{"localhost1", "localhost2"};
std::string challengePassword("Password");
@@ -1391,14 +1391,14 @@
fs::remove(rsaPrivateKeyFilePath);
Status status;
- CSR csr(bus, objPath.c_str(), CSRPath.c_str(), status);
+ CSR csr(bus, objPath.c_str(), csrPath.c_str(), status);
MainApp mainApp(&manager, &csr);
mainApp.generateCSR(alternativeNames, challengePassword, city, commonName,
contactPerson, country, email, givenName, initials,
keyBitLength, keyCurveId, keyPairAlgorithm, keyUsage,
organization, organizationalUnit, state, surname,
unstructuredName);
- EXPECT_FALSE(fs::exists(CSRPath));
+ EXPECT_FALSE(fs::exists(csrPath));
EXPECT_FALSE(fs::exists(privateKeyPath));
}
@@ -1409,10 +1409,10 @@
{
std::string endpoint("https");
std::string unit;
- CertificateType type = CertificateType::Server;
+ CertificateType type = CertificateType::server;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyPath(installPath);
- std::string CSRPath(certDir + "/" + CSRFile);
+ std::string csrPath(certDir + "/" + CSRFile);
std::string privateKeyPath(certDir + "/" + privateKeyFile);
std::vector<std::string> alternativeNames{"localhost1", "localhost2"};
std::string challengePassword("Password");
@@ -1438,7 +1438,7 @@
Manager manager(bus, event, objPath.c_str(), type, std::move(unit),
std::move(installPath));
Status status;
- CSR csr(bus, objPath.c_str(), CSRPath.c_str(), status);
+ CSR csr(bus, objPath.c_str(), csrPath.c_str(), status);
MainApp mainApp(&manager, &csr);
mainApp.generateCSR(alternativeNames, challengePassword, city, commonName,
contactPerson, country, email, givenName, initials,
@@ -1446,7 +1446,7 @@
organization, organizationalUnit, state, surname,
unstructuredName);
sleep(10);
- EXPECT_TRUE(fs::exists(CSRPath));
+ EXPECT_TRUE(fs::exists(csrPath));
EXPECT_TRUE(fs::exists(privateKeyPath));
}
@@ -1454,7 +1454,7 @@
TEST_F(TestCertificates, TestGenerateRSAPrivateKeyFile)
{
std::string endpoint("https");
- CertificateType type = CertificateType::Server;
+ CertificateType type = CertificateType::server;
std::string installPath(certDir + "/" + certificateFile);
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
auto objPath = std::string(objectNamePrefix) + '/' +
@@ -1606,7 +1606,7 @@
{
std::string endpoint("ldap");
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
- CertificateType type = CertificateType::Authority;
+ CertificateType type = CertificateType::authority;
std::string object = std::string(objectNamePrefix) + '/' +
certificateTypeToString(type) + '/' + endpoint;
@@ -1634,7 +1634,7 @@
{
std::string endpoint("ldap");
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
- CertificateType type = CertificateType::Authority;
+ CertificateType type = CertificateType::authority;
std::string object = std::string(objectNamePrefix) + '/' +
certificateTypeToString(type) + '/' + endpoint;
@@ -1686,7 +1686,7 @@
{
std::string endpoint("ldap");
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
- CertificateType type = CertificateType::Authority;
+ CertificateType type = CertificateType::authority;
std::string object = std::string(objectNamePrefix) + '/' +
certificateTypeToString(type) + '/' + endpoint;
@@ -1714,7 +1714,7 @@
TEST_F(AuthoritiesListTest, InstallAllWrongManagerType)
{
std::string endpoint("ldap");
- CertificateType type = CertificateType::Server;
+ CertificateType type = CertificateType::server;
std::string object = std::string(objectNamePrefix) + '/' +
certificateTypeToString(type) + '/' + endpoint;
@@ -1727,7 +1727,7 @@
EXPECT_THROW(serverManager.installAll(sourceAuthoritiesListFile),
sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed);
- type = CertificateType::Client;
+ type = CertificateType::client;
object = std::string(objectNamePrefix) + '/' +
certificateTypeToString(type) + '/' + endpoint;
ManagerInTest clientManager(bus, event, object.c_str(), type, "",
@@ -1740,7 +1740,7 @@
{
std::string endpoint("ldap");
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
- CertificateType type = CertificateType::Authority;
+ CertificateType type = CertificateType::authority;
std::string object = std::string(objectNamePrefix) + '/' +
certificateTypeToString(type) + '/' + endpoint;
@@ -1764,7 +1764,7 @@
{
std::string endpoint("ldap");
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
- CertificateType type = CertificateType::Authority;
+ CertificateType type = CertificateType::authority;
std::string object = std::string(objectNamePrefix) + '/' +
certificateTypeToString(type) + '/' + endpoint;
@@ -1783,7 +1783,7 @@
{
std::string endpoint("ldap");
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
- CertificateType type = CertificateType::Authority;
+ CertificateType type = CertificateType::authority;
std::string object = std::string(objectNamePrefix) + '/' +
certificateTypeToString(type) + '/' + endpoint;
@@ -1802,7 +1802,7 @@
{
std::string endpoint("ldap");
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
- CertificateType type = CertificateType::Authority;
+ CertificateType type = CertificateType::authority;
std::string object = std::string(objectNamePrefix) + '/' +
certificateTypeToString(type) + '/' + endpoint;
@@ -1828,7 +1828,7 @@
{
std::string endpoint("ldap");
std::string verifyUnit(ManagerInTest::unitToRestartInTest);
- CertificateType type = CertificateType::Authority;
+ CertificateType type = CertificateType::authority;
std::string object = std::string(objectNamePrefix) + '/' +
certificateTypeToString(type) + '/' + endpoint;
diff --git a/x509_utils.cpp b/x509_utils.cpp
index ba1a2ef..4c8cc3a 100644
--- a/x509_utils.cpp
+++ b/x509_utils.cpp
@@ -217,10 +217,10 @@
{
unsigned long subjectNameHash = X509_subject_name_hash(&cert);
unsigned long issuerSerialHash = X509_issuer_and_serial_hash(&cert);
- static constexpr auto CERT_ID_LENGTH = 17;
- char idBuff[CERT_ID_LENGTH];
+ static constexpr auto certIdLength = 17;
+ char idBuff[certIdLength];
- snprintf(idBuff, CERT_ID_LENGTH, "%08lx%08lx", subjectNameHash,
+ snprintf(idBuff, certIdLength, "%08lx%08lx", subjectNameHash,
issuerSerialHash);
return {idBuff};