RestRequest(const std::string& host);
/**
+ * @brief Not copy constructible
+ */
+ RestRequest(const RestRequest&) = delete;
+
+ /**
+ * @brief Can not be assined
+ * @return
+ */
+ RestRequest& operator=(const RestRequest&) = delete;
+
+ /**
* @brief Destructor
*/
~RestRequest();
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
-#if !defined(__TIZEN__) && defined(INSTALL_DIR)
-# define INSTALL_PREFIX(x) MAKE_STRING(x)
-# define MAKE_STRING(x) #x
-# define CONF_PREFIX INSTALL_PREFIX(INSTALL_DIR)
-#else
-# define CONF_PREFIX
+#define STRINGIFY(x) MAKE_STRING(x)
+#define MAKE_STRING(x) #x
+
+#if !defined(NWMANAGER_CONFIG_FILE)
+# error "NWMANAGER_CONFIG_FILE must be defined"
#endif
+#define CONFIG_FILE STRINGIFY(NWMANAGER_CONFIG_FILE)
+
using namespace NetworkManager;
#define TAG "NetworkManager"
// nmdaemon configuration path
const std::string INI_FILE_PATH
{
- CONF_PREFIX "/etc/nmdaemon/nmdaemon.conf"
+ CONFIG_FILE
};
// default iotcloud IP (local SRK server)
const std::string DEFAULT_CLOUD_IP
{
FN_VISIT
if (ctx != nullptr && *ctx != nullptr) {
- if ((*ctx)->context != nullptr) {
- delete(*ctx)->context;
+ SecurityContext* sec_context = (*ctx)->context;
+
+ if (sec_context != nullptr) {
+ delete sec_context;
}
+
delete *ctx;
*ctx = nullptr;
}
{
IotResourceServer::IotResourceServer(const std::string& uri, const std::string& type)
- : IotResourceServer(uri, type,
-{
- OC::DEFAULT_INTERFACE
-})
+ : IotResourceServer(uri, type, {OC::DEFAULT_INTERFACE})
{
}
pResponse->setResponseResult(ehResult);
pResponse->setResourceRepresentation(OCRepresentation{});
- OCPlatform::sendResponse(pResponse);
+ OCStackResult sendResult = OCPlatform::sendResponse(pResponse);
+
+ if (OC_STACK_OK != sendResult) {
+ LOG_E(TAG, "Send response error: %d", sendResult);
+ }
}
} else {
LOG_E(TAG, "Invalid request");
extern std::string TEST_ACCOUNT_LOGIN;
extern std::string TEST_ACCOUNT_PASSWORD;
-class test_IoT_Fixture: public ::testing::Test
+class Test_IoT_Fixture: public ::testing::Test
{
public:
void SetUp() override {
* 3. Sign out
* 4. Check signedIn flag is false
*/
-TEST_F(test_IoT_Fixture, signInCorrect)
+TEST_F(Test_IoT_Fixture, signInCorrect)
{
try {
ASSERT_TRUE(iotivity->isSignedIn());
ASSERT_FALSE(NMD::makeReport("1", "sim", 0, "report data").empty());
}
-TEST_F(test_IoT_Fixture, findResourceWork)
+TEST_F(Test_IoT_Fixture, findResourceWork)
{
ASSERT_NO_THROW(iotivity->findResource(false, "", OC_RSRVD_WELL_KNOWN_URI, CT_DEFAULT));
ASSERT_NO_THROW(iotivity->findResourceList(false, "", OC_RSRVD_WELL_KNOWN_URI, CT_DEFAULT));
}
-TEST_F(test_IoT_Fixture, findDevicesWork)
+TEST_F(Test_IoT_Fixture, findDevicesWork)
{
ASSERT_NO_THROW(iotivity->findDevices(true, CT_DEFAULT, OC_RSRVD_WELL_KNOWN_URI));
ASSERT_NO_THROW(iotivity->findDevices(false, CT_DEFAULT, OC_RSRVD_WELL_KNOWN_URI));
}
-TEST_F(test_IoT_Fixture, publishResourcesWork)
+TEST_F(Test_IoT_Fixture, publishResourcesWork)
{
ResourceHandles rhandles;
ASSERT_NO_THROW(iotivity->publishResources(rhandles));
ASSERT_NO_THROW(iotivity->unPublishAllResources());
}
-TEST_F(test_IoT_Fixture, registerDeviceInfoWork)
+TEST_F(Test_IoT_Fixture, registerDeviceInfoWork)
{
ASSERT_NO_THROW(iotivity->registerDeviceInfo("test_device", "test_device", "test_device"));
}
/*
-TEST_F(test_IoT_Fixture, registerDeviceInfoWork)
+TEST_F(Test_IoT_Fixture, registerDeviceInfoWork)
{
ASSERT_NO_THROW(iotivity->registerDeviceInfo("test_device", "test_device", "test_device"));
}
}
};
-class test_commandhandler_fixture : public ::testing::Test
+class Test_commandhandler_fixture : public ::testing::Test
{
public:
void SetUp() {
/**
* Test CommandHandler class UNOWN command for standard working mode
*/
-TEST_F(test_commandhandler_fixture, test_unOwnTask_standard)
+TEST_F(Test_commandhandler_fixture, test_unOwnTask_standard)
{
MainThreadMock main_thread;
/**
* Test CommandHandler class UNOWN command for primitive working mode
*/
-TEST_F(test_commandhandler_fixture, test_unOwnTask_primitive)
+TEST_F(Test_commandhandler_fixture, test_unOwnTask_primitive)
{
MainThreadMock main_thread;
/**
* Test CommandHandler class UNOWN command for hub working mode
*/
-TEST_F(test_commandhandler_fixture, test_unOwnTask_hub)
+TEST_F(Test_commandhandler_fixture, test_unOwnTask_hub)
{
MainThreadMock main_thread;
const std::string test_executable_package_name = test_executable + ".1.2.3.4.rpm";
}
-TEST(test_commandhandler, test_uninstallTask)
+TEST(Test_commandhandler, test_uninstallTask)
{
try {
IoTivity::cleanUp();
/**
* Test check report sender functional
*/
-TEST(test_emo, DISABLED_server)
+TEST(Test_emo, DISABLED_server)
{
OCPersistentStorage ps{client_open, fread, fwrite, fclose, unlink};
PlatformConfig cfg{ServiceType::InProc, ModeType::Both, "0.0.0.0", 0, QualityOfService::HighQos, &ps};
/**
* Test check report sender functional
*/
-TEST(test_emo, DISABLED_client)
+TEST(Test_emo, DISABLED_client)
{
OCPersistentStorage ps{client_open, fread, fwrite, fclose, unlink};
PlatformConfig cfg{ServiceType::InProc, ModeType::Both, "0.0.0.0", 0, QualityOfService::HighQos, &ps};
ASSERT_NO_THROW(NM_resetDeviceList(dev_list));
const char* uid = nullptr;
while (nullptr != (uid = NM_deviceListEnum(dev_list))) {
- if (uid != std::string{"2e19d28f-2ba1-9a3a-e157-7e50d9d4f022"}) continue;
+
+ if (uid != std::string{"1c3356cf-a8b2-ed03-1357-8604a8079653"}) continue;
+// if (uid != std::string{"2e19d28f-2ba1-9a3a-e157-7e50d9d4f022"}) continue;
NM_DeviceInfo info;
ASSERT_EQ(EC_OK, NM_getDeviceInfo(dev_list, uid, &info));
if (strcmp(info.name, "unknown") != 0) {
EXPECT_TRUE(reader.parse(received, received_json));
EXPECT_NE(0u, received_json.size()) << "Empty reports received";
- int i = 0;
- for (; (unsigned)i < received_json.size(); i++) {
- Json::Value recv = received_json[i];
-
- if (recv["name"].asString() == sent_json["name"].asString()) {
- EXPECT_EQ(sent_json["data"]["some_data"].asString(), recv["data"]["some_data"].asString());
- EXPECT_EQ(sent_json["date"].asString(), recv["date"].asString());
- EXPECT_EQ(sent_json["did"].asString(), recv["did"].asString());
- EXPECT_EQ(sent_json["result"].asInt(), recv["result"].asInt());
- break;
- }
- }
-
- EXPECT_NE(i, received_json.size());
+ EXPECT_EQ(Json::arrayValue, received_json["dac"].type());
+ EXPECT_EQ(Json::arrayValue, received_json["smack"].type());
+ EXPECT_EQ(Json::arrayValue, received_json["syscall"].type());
} catch (std::exception& e) {
std::cout << e.what() << std::endl;
EXPECT_TRUE(false) << "Exception: " << e.what();
ASSERT_EQ(EC_NULL_POINTER, NM_getDevicePolicy(ctx, IoTivity::getInstance()->getDeviceID().c_str(), "", nullptr));
ASSERT_NE(nullptr, policy_recv);
- ASSERT_EQ(policy, policy_recv);
+ EXPECT_EQ(policy, policy_recv);
ASSERT_NO_THROW(NM_freeCharBuffer(policy_recv));
}
std::string stringToPublish("test");
try {
- MqClient pubMqHandler(cloud_host);
+ auto pubMqHandler = iot->getMqHandler();
for (int i = 0; i <= 10; i++) {
OCRepresentation rep;
rep["message"] = stringToPublish + std::to_string(i);
- pubMqHandler.publish("/loopPublish", rep);
+ pubMqHandler->publish("/loopPublish", rep);
}
} catch (NMexception& e) {
ADD_FAILURE() << e.what() << " " << e.errorCode();
using namespace NetworkManager;
-TEST(test_MqTopic, test_constructor_string)
+TEST(Test_MqTopic, test_constructor_string)
{
const std::string name{"/parent/topic_mid/topic_top"};
ASSERT_EQ(MqTopic::DEFAULT_MQ_BROKER_URI_ROOT + name, topic.getName());
}
-TEST(test_MqTopic, test_constructor_iterator)
+TEST(Test_MqTopic, test_constructor_iterator)
{
const std::string t1 = "/parent";
const std::string t2 = "/mid";
ASSERT_EQ(t1 + t2 + t3 + t4, topic4.getSubName());
}
-TEST(test_MqTopic, test_split)
+TEST(Test_MqTopic, test_split)
{
const std::string t1 = "/parent";
const std::string t2 = "/mid";
return res == 0 && (info.st_mode & S_IFMT) == S_IFREG;
}
-TEST(test_nmd_utils, config_cycle_write_read_delete)
+TEST(Test_nmd_utils, config_cycle_write_read_delete)
{
cfg_file_path_name = current_path() + testFileName;
ASSERT_NE(0, std::remove(cfg_file_path_name.c_str()));
}
-TEST(test_nmd_utils, read_config_not_config_file)
+TEST(Test_nmd_utils, read_config_not_config_file)
{
cfg_file_path_name = current_path() + testFileName;
ofstream out(cfg_file_path_name);
remove(cfg_file_path_name.c_str());
}
-TEST(test_nmd_utils, delete_config_with_file_that_does_not_exist)
+TEST(Test_nmd_utils, delete_config_with_file_that_does_not_exist)
{
cfg_file_path_name = current_path() + testFileName;
ASSERT_NO_THROW(delete_config());
}
-TEST(test_nmd_utils, write_log)
+TEST(Test_nmd_utils, write_log)
{
/* Set log filepath */
log_file_path_name = current_path() + testFileName;
remove(log_file_path_name.c_str());
}
-TEST(test_nmd_utils, test_clear_hub_cache)
+TEST(Test_nmd_utils, test_clear_hub_cache)
{
hub_file_path_name = "/tmp/test_hub_file_path_name.dat";
ofstream out(hub_file_path_name);
ASSERT_FALSE(fexists(hub_file_path_name)) << "Test file exists but must not";
}
-TEST(test_nmd_utils, test_clear_hub_cache_file_not_exists)
+TEST(Test_nmd_utils, test_clear_hub_cache_file_not_exists)
{
ASSERT_FALSE(fexists(hub_file_path_name)) << "Test file exists but must not";
ASSERT_NO_THROW(clear_hub_cache());
* 3. Search for owned devices
* 4. Iterate thoughout the list and print devices info
*/
-TEST(test_REST, test_get)
+TEST(Test_REST, test_get)
{
try {
RestRequest request("http://example.com");
/**
* @brief TEST RestService::getAuthCode
*/
-TEST(test_REST, test_getAuthCode)
+TEST(Test_REST, test_getAuthCode)
{
try {
RestService service(TEST_DSM_SERVER_URL);
/**
* @brief TEST RestRequest with not existing HTTP address
*/
-TEST(test_REST, test_get_wrong_address)
+TEST(Test_REST, test_get_wrong_address)
{
RestRequest request("sdfgkadg.adg.ag.asdg.afg");
RestRequest::QueryParameters params = {{"user", "anon"}, {"id", "3"}};
ASSERT_THROW(request.get(params, "/", response), NMexception);
}
-TEST(test_REST, test_RestRequest_addHeader_empty)
+TEST(Test_REST, test_RestRequest_addHeader_empty)
{
RestRequest request("http://example.com");
ASSERT_THROW(request.addHeader("", "sdfvsdf"), std::runtime_error);
/**
* @brief TEST RestService::policyUseCase
*/
-TEST(test_REST, test_policyUseCase)
+TEST(Test_REST, test_policyUseCase)
{
try {
RestService service(TEST_DSM_SERVER_URL);