summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclaiff <claiff@mail.ru>2022-09-20 12:42:33 +0300
committerclaiff <claiff@mail.ru>2022-09-20 12:42:54 +0300
commitf78293531000cdbf366e938b54ac986d73b2d8d8 (patch)
tree26b135dcff7eecfc5bc685710c26926d63b79271
parentfad16676449bc8abd28f071880ab77351e124437 (diff)
downloadopenbmc-f78293531000cdbf366e938b54ac986d73b2d8d8.tar.xz
fix problem with boolean settings
-rw-r--r--meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0017-update-smtp.patch124
-rw-r--r--meta-ibs/meta-cp2-5422/recipes-support/smtp/smtp.bb10
2 files changed, 41 insertions, 93 deletions
diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0017-update-smtp.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0017-update-smtp.patch
index 33ffdfd7b8..bddd20eb58 100644
--- a/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0017-update-smtp.patch
+++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0017-update-smtp.patch
@@ -1,20 +1,21 @@
-From 6f909553ae9526dea232731e440b2ae4d844e000 Mon Sep 17 00:00:00 2001
+From bca2ba057ca525a92d4370b2b287263c19bb20ea Mon Sep 17 00:00:00 2001
From: claiff <claiff@mail.ru>
Date: Fri, 16 Sep 2022 12:15:45 +0300
Subject: [PATCH] update smtp
+Signed-off-by: claiff <claiff@mail.ru>
---
meson.build | 4 +-
- .../include/utils/smtp/add_mails_parser.hpp | 22 ++
- .../utils/smtp/delete_mails_parser.hpp | 22 ++
+ .../include/utils/smtp/add_mails_parser.hpp | 22 +++
+ .../utils/smtp/delete_mails_parser.hpp | 22 +++
...ers_parser.hpp => set_settings_parser.hpp} | 10 +-
- redfish-core/lib/smtp.hpp | 226 +++++++++++++++---
- .../src/utils/smtp/add_mails_parser.cpp | 22 ++
- .../utils/smtp/change_parameters_parser.cpp | 62 -----
- .../src/utils/smtp/delete_mails_parser.cpp | 23 ++
- .../src/utils/smtp/set_settings_parser.cpp | 96 ++++++++
+ redfish-core/lib/smtp.hpp | 184 ++++++++++++++----
+ .../src/utils/smtp/add_mails_parser.cpp | 22 +++
+ .../utils/smtp/change_parameters_parser.cpp | 62 ------
+ .../src/utils/smtp/delete_mails_parser.cpp | 23 +++
+ .../src/utils/smtp/set_settings_parser.cpp | 88 +++++++++
redfish-core/ut/smtp_reader_parser_test.cpp | 6 +-
- 10 files changed, 387 insertions(+), 106 deletions(-)
+ 10 files changed, 335 insertions(+), 108 deletions(-)
create mode 100644 redfish-core/include/utils/smtp/add_mails_parser.hpp
create mode 100644 redfish-core/include/utils/smtp/delete_mails_parser.hpp
rename redfish-core/include/utils/smtp/{change_parameters_parser.hpp => set_settings_parser.hpp} (63%)
@@ -24,7 +25,7 @@ Subject: [PATCH] update smtp
create mode 100644 redfish-core/src/utils/smtp/set_settings_parser.cpp
diff --git a/meson.build b/meson.build
-index c1d253fb..d7ce2c44 100644
+index 7e01c9df..2f204764 100644
--- a/meson.build
+++ b/meson.build
@@ -376,7 +376,9 @@ srcfiles_bmcweb = [
@@ -132,12 +133,15 @@ index ee18b57b..46db143a 100644
};
}
diff --git a/redfish-core/lib/smtp.hpp b/redfish-core/lib/smtp.hpp
-index 1bd798f7..dd49f982 100644
+index 1bd798f7..49ac9340 100644
--- a/redfish-core/lib/smtp.hpp
+++ b/redfish-core/lib/smtp.hpp
-@@ -5,17 +5,24 @@
- #include <iostream>
+@@ -2,20 +2,25 @@
+ #include <registries/privilege_registry.hpp>
+ #include <query.hpp>
+-#include <iostream>
+-
#include "utils/smtp/send_message_parser.hpp"
-#include "utils/smtp/change_parameters_parser.hpp"
+#include "utils/smtp/set_settings_parser.hpp"
@@ -164,7 +168,7 @@ index 1bd798f7..dd49f982 100644
{
static constexpr char FIRST_DELIMITER = '&';
static constexpr int ZERO_POSITION = 0;
-@@ -23,15 +30,19 @@ namespace redfish
+@@ -23,7 +28,7 @@ namespace redfish
auto position = function_with_parameters.find(FIRST_DELIMITER);
if( position == std::string::npos )
{
@@ -173,20 +177,7 @@ index 1bd798f7..dd49f982 100644
}
return function_with_parameters.substr( ZERO_POSITION, position );
}
-
- inline void SendMail( std::string const& function_with_parameters, std::shared_ptr<bmcweb::AsyncResp> const& asyncResp )
- {
-+ std::cout << "SendMail" << std::endl;
- auto parsing_result = parser::SendMessage{function_with_parameters};
--
-+ std::cout << "GetMethodName" << parsing_result.GetMethodName() << std::endl;
-+ std::cout << "GetFrom" << parsing_result.GetFrom() << std::endl;
-+ std::cout << "GetSubject" << parsing_result.GetSubject() << std::endl;
-+ std::cout << "GetText" << parsing_result.GetText() << std::endl;
- crow::connections::systemBus->async_method_call([asyncResp](const boost::system::error_code& error_code, bool result){
- if (error_code.value() == EBADR ||
- error_code == boost::system::errc::host_unreachable)
-@@ -48,19 +59,24 @@ namespace redfish
+@@ -48,18 +53,16 @@ namespace redfish
}
asyncResp->res.jsonValue["result"] = result;
},
@@ -204,20 +195,11 @@ index 1bd798f7..dd49f982 100644
+ inline void SetSettings( std::string const& function_with_parameters, std::shared_ptr<bmcweb::AsyncResp> const& asyncResp )
{
- auto parsing_result = parser::ChangeParameters{function_with_parameters};
--
-+ std::cout << "SetSettings" << std::endl;
+ auto parsing_result = parser::SetSettings{function_with_parameters};
-+ std::cout << "GetMethodName" << parsing_result.GetMethodName() << std::endl;
-+ std::cout << "GetIsNeedAuth" << parsing_result.GetIsNeedAuth() << std::endl;
-+ std::cout << "GetIsNeedSsl" << parsing_result.GetIsNeedSsl() << std::endl;
-+ std::cout << "GetUser" << parsing_result.GetUser() << std::endl;
-+ std::cout << "GetPassword" << parsing_result.GetPassword() << std::endl;
-+ std::cout << "GetHost" << parsing_result.GetHost() << std::endl;
-+ std::cout << "GetPort" << parsing_result.GetPort() << std::endl;
+
crow::connections::systemBus->async_method_call([asyncResp](const boost::system::error_code& error_code, bool result){
if (error_code.value() == EBADR ||
- error_code == boost::system::errc::host_unreachable)
-@@ -77,13 +93,129 @@ namespace redfish
+@@ -77,13 +80,114 @@ namespace redfish
}
asyncResp->res.jsonValue["result"] = result;
},
@@ -234,7 +216,6 @@ index 1bd798f7..dd49f982 100644
+
+ inline void GetSettings( std::shared_ptr<bmcweb::AsyncResp> const& asyncResp )
+ {
-+ std::cout << "GetSettings" << std::endl;
+ crow::connections::systemBus->async_method_call([asyncResp](const boost::system::error_code& error_code, std::string const& result ){
+ if (error_code.value() == EBADR ||
+ error_code == boost::system::errc::host_unreachable)
@@ -249,7 +230,6 @@ index 1bd798f7..dd49f982 100644
+ std::cout << "respHandler DBus error" << std::endl;
+ return;
+ }
-+ std::cout << "result" << std::endl;
+ auto parsing_result = parser::SetSettings{result};
+ asyncResp->res.jsonValue["host"] = parsing_result.GetHost();
+ asyncResp->res.jsonValue["is_need_auth"] = parsing_result.GetIsNeedAuth();
@@ -264,7 +244,6 @@ index 1bd798f7..dd49f982 100644
+
+ inline void GetMails( std::shared_ptr<bmcweb::AsyncResp> const& asyncResp )
+ {
-+ std::cout << "GetMails" << std::endl;
+ crow::connections::systemBus->async_method_call([asyncResp](const boost::system::error_code& error_code, std::list<std::string> const& mails){
+ if (error_code.value() == EBADR ||
+ error_code == boost::system::errc::host_unreachable)
@@ -287,13 +266,7 @@ index 1bd798f7..dd49f982 100644
+
+ inline void AddMails( std::string const& function_with_parameters, std::shared_ptr<bmcweb::AsyncResp> const& asyncResp )
+ {
-+ std::cout << "AddMails" << std::endl;
+ auto parsing_result = parser::AddMails{function_with_parameters};
-+ std::cout << "parsing_result.GetMethodName() " << parsing_result.GetMethodName() << std::endl;
-+ for(const auto& mail : parsing_result.GetMails())
-+ {
-+ std::cout << "parsing_result.GetMails() " << mail << std::endl;
-+ }
+
+ crow::connections::systemBus->async_method_call([asyncResp](const boost::system::error_code& error_code, bool result){
+ if (error_code.value() == EBADR ||
@@ -318,13 +291,7 @@ index 1bd798f7..dd49f982 100644
+
+ inline void DeleteMails( std::string const& function_with_parameters, std::shared_ptr<bmcweb::AsyncResp> const& asyncResp )
+ {
-+ std::cout << "DeleteMails" << std::endl;
+ auto parsing_result = parser::DeleteMails{function_with_parameters};
-+ std::cout << "parsing_result.GetMethodName()" << parsing_result.GetMethodName() << std::endl;
-+ for(const auto& mail : parsing_result.GetDeleteMails())
-+ {
-+ std::cout << "parsing_result.GetDeleteMails() " << mail << std::endl;
-+ }
+ crow::connections::systemBus->async_method_call([asyncResp](const boost::system::error_code& error_code, bool result){
+ if (error_code.value() == EBADR ||
+ error_code == boost::system::errc::host_unreachable)
@@ -348,10 +315,11 @@ index 1bd798f7..dd49f982 100644
}
inline void FillResp(crow::Response& resp, const dbus::utility::DBusPropertiesMap& properties)
-@@ -130,23 +262,23 @@ namespace redfish
+@@ -129,24 +233,6 @@ namespace redfish
+ {
return;
}
-
+-
- crow::connections::systemBus->async_method_call([asyncResp](const boost::system::error_code& error_code,
- const dbus::utility::DBusPropertiesMap& properties)
- {
@@ -361,33 +329,18 @@ index 1bd798f7..dd49f982 100644
- messages::internalError(asyncResp->res);
- return;
- }
-+// crow::connections::systemBus->async_method_call([asyncResp](const boost::system::error_code& error_code,
-+// const dbus::utility::DBusPropertiesMap& properties)
-+// {
-+// if (error_code)
-+// {
-+// BMCWEB_LOG_DEBUG << "DBUS response error " << error_code;
-+// messages::internalError(asyncResp->res);
-+// return;
-+// }
-
+-
- FillResp(asyncResp->res, properties);
- }, SERVICE_PATH, OBJECT_PATH, "org.freedesktop.DBus.Properties",
- "GetAll", "xyz.openbmc_project.SMTP");
-+// FillResp(asyncResp->res, properties);
-+// }, SERVICE_PATH, OBJECT_PATH, "org.freedesktop.DBus.Properties",
-+// "GetAll", "xyz.openbmc_project.SMTP");
-
+-
- asyncResp->res.jsonValue["@odata.type"] ="#SmtpCollection";
- asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Smtp";
- asyncResp->res.jsonValue["Name"] = "Smtp Collection";
-+// asyncResp->res.jsonValue["@odata.type"] ="#SmtpCollection";
-+// asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Smtp";
-+// asyncResp->res.jsonValue["Name"] = "Smtp Collection";
});
}
-@@ -162,29 +294,47 @@ namespace redfish
+@@ -162,29 +248,47 @@ namespace redfish
const std::string& function_with_parameters)
{
static constexpr std::string_view SEND_MAIL_METHOD_NAME = "SendMail";
@@ -414,9 +367,8 @@ index 1bd798f7..dd49f982 100644
- asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Smtp/" + *function_name;
+ asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Smtp/" + function_name;
asyncResp->res.jsonValue["Name"] = "Smtp Collection";
--
+
- if(*function_name == SEND_MAIL_METHOD_NAME)
-+ std::cout << "function_name " << function_name << std::endl;
+ if(function_name == SEND_MAIL_METHOD_NAME)
{
smtp::SendMail(function_with_parameters, asyncResp);
@@ -572,10 +524,10 @@ index 00000000..ead3bbfb
+}
diff --git a/redfish-core/src/utils/smtp/set_settings_parser.cpp b/redfish-core/src/utils/smtp/set_settings_parser.cpp
new file mode 100644
-index 00000000..d5071b05
+index 00000000..d184b183
--- /dev/null
+++ b/redfish-core/src/utils/smtp/set_settings_parser.cpp
-@@ -0,0 +1,96 @@
+@@ -0,0 +1,88 @@
+#include "utils/smtp/set_settings_parser.hpp"
+#include <iostream>
+
@@ -585,17 +537,9 @@ index 00000000..d5071b05
+ {
+ static const std::string DELIMITER_ON_LINE = "&";
+ auto parsed_data = ParseLine(function_with_parameters, DELIMITER_ON_LINE);
-+ std::cout << "aaaa" <<std::endl;
-+ for(auto const& d : parsed_data)
-+ {
-+ std::cout << d <<std::endl;
-+ }
++
+ auto params = BuildParams( parsed_data );
-+ std::cout << "qqqq" <<std::endl;
-+ for(const auto& dd: params)
-+ {
-+ std::cout << dd.first << ":"<< dd.second << std::endl;
-+ }
++
+ FillParams( params );
+ }
+
@@ -673,7 +617,7 @@ index 00000000..d5071b05
+ }
+}
diff --git a/redfish-core/ut/smtp_reader_parser_test.cpp b/redfish-core/ut/smtp_reader_parser_test.cpp
-index 67a6645c..85ca25dc 100644
+index 67a6645c..0b8544dc 100644
--- a/redfish-core/ut/smtp_reader_parser_test.cpp
+++ b/redfish-core/ut/smtp_reader_parser_test.cpp
@@ -1,5 +1,5 @@
@@ -688,7 +632,7 @@ index 67a6645c..85ca25dc 100644
TEST(SmtpReaderParser, ChangeParameters)
{
- smtp::parser::ChangeParameters message_parser{"ChangeParameters&user=claiff@mail.ru&password=32311&host=smtp.mail.ru&port=465"};
-+ smtp::parser::SetSettings message_parser{"ChangeParameters&user=claiff@mail.ru&password=32311&host=smtp.mail.ru&port=465&is_need_auth=true&is_need_ssl=true"};
++ smtp::parser::SetSettings message_parser{"SetSettings&username=claiff@mail.ru&password=32311&host=smtp.mail.ru&port=465&is_need_auth=true&is_need_ssl=true"};
EXPECT_EQ(message_parser.GetUser(), "claiff@mail.ru");
EXPECT_EQ(message_parser.GetPassword(), "32311");
EXPECT_EQ(message_parser.GetHost(), "smtp.mail.ru");
diff --git a/meta-ibs/meta-cp2-5422/recipes-support/smtp/smtp.bb b/meta-ibs/meta-cp2-5422/recipes-support/smtp/smtp.bb
index da02a97905..0e3e72ce9c 100644
--- a/meta-ibs/meta-cp2-5422/recipes-support/smtp/smtp.bb
+++ b/meta-ibs/meta-cp2-5422/recipes-support/smtp/smtp.bb
@@ -8,7 +8,7 @@ LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
SRC_URI = "git://git@git.sila.ru/srv/pub/scm/git/openbmc/obmc-sila-smtp.git;branch=master;protocol=ssh"
-SRCREV = "7e156f58e74baaf4f1d7ccb4df629e6e1a26a32e"
+SRCREV = "629929ebbe386277c25740bc0f4971aac38444d0"
S = "${WORKDIR}/git"
@@ -22,8 +22,12 @@ do_install:append() {
install -m 0744 ${WORKDIR}/mails.txt ${D}/var/lib/smtp/
}
-inherit cmake systemd
+inherit cmake systemd pkgconfig
-DEPENDS = "boost systemd sdbusplus curl"
+DEPENDS = "boost \
+ systemd \
+ sdbusplus \
+ curl \
+ phosphor-logging"
SYSTEMD_SERVICE:${PN} = "xyz.openbmc_project.SMTP.service"