summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacobkeeler <jacob.keeler@livioradio.com>2018-03-21 09:32:36 -0400
committerjacobkeeler <jacob.keeler@livioradio.com>2018-03-21 10:58:46 -0400
commit45322709633a4bf669f11b402c96df725de7242f (patch)
tree2f94e5d5a865febe519e510b5c585d6c792f4778
parentb1927448cb248f8731c53054ebc8f7907aadde1e (diff)
downloadsdl_core-fix/security_off_build.tar.gz
Fix build issues and test failures when building with ENABLE_SECURITY=OFFfix/security_off_build
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h14
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc18
-rw-r--r--src/components/application_manager/test/CMakeLists.txt5
-rw-r--r--src/components/application_manager/test/policy_handler_test.cc8
-rw-r--r--src/components/connection_handler/include/connection_handler/connection.h14
-rw-r--r--src/components/connection_handler/include/connection_handler/connection_handler_impl.h8
-rw-r--r--src/components/connection_handler/src/connection.cc4
-rw-r--r--src/components/connection_handler/src/connection_handler_impl.cc14
-rw-r--r--src/components/connection_handler/test/connection_handler_impl_test.cc59
-rw-r--r--src/components/connection_handler/test/connection_test.cc2
-rw-r--r--src/components/include/connection_handler/connection_handler_observer.h14
-rw-r--r--src/components/include/protocol_handler/session_observer.h20
-rw-r--r--src/components/include/test/connection_handler/mock_connection_handler_observer.h2
-rw-r--r--src/components/include/test/protocol_handler/mock_session_observer.h6
-rw-r--r--src/components/protocol_handler/CMakeLists.txt9
-rw-r--r--src/components/protocol_handler/src/protocol_handler_impl.cc28
-rw-r--r--src/components/protocol_handler/test/protocol_handler_tm_test.cc2
-rw-r--r--src/components/transport_manager/src/transport_manager_impl.cc5
18 files changed, 136 insertions, 96 deletions
diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h
index 78fe938568..3e7fab60fb 100644
--- a/src/components/application_manager/include/application_manager/application_manager_impl.h
+++ b/src/components/application_manager/include/application_manager/application_manager_impl.h
@@ -922,6 +922,13 @@ class ApplicationManagerImpl
const protocol_handler::ServiceType& type,
const connection_handler::CloseSessionReason& close_reason) OVERRIDE;
+ /**
+ * @brief Check if application with specified app_id has NAVIGATION HMI type
+ * @param app_id id of application to check
+ * @return true if application is navi otherwise returns false
+ */
+ bool CheckAppIsNavi(const uint32_t app_id) const OVERRIDE;
+
#ifdef ENABLE_SECURITY
/**
* @brief Notification about protection result
@@ -953,13 +960,6 @@ class ApplicationManagerImpl
*/
security_manager::SSLContext::HandshakeContext GetHandshakeContext(
uint32_t key) const OVERRIDE;
-
- /**
- * @brief Check if application with specified app_id has NAVIGATION HMI type
- * @param app_id id of application to check
- * @return true if application is navi otherwise returns false
- */
- bool CheckAppIsNavi(const uint32_t app_id) const OVERRIDE;
#endif // ENABLE_SECURITY
/**
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index a2703aca75..f16c21ea84 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -1636,6 +1636,15 @@ void ApplicationManagerImpl::OnServiceEndedCallback(
}
}
+bool ApplicationManagerImpl::CheckAppIsNavi(const uint32_t app_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ ApplicationSharedPtr app = application(app_id);
+ if (app) {
+ return app->is_navi();
+ }
+ return false;
+}
+
#ifdef ENABLE_SECURITY
bool ApplicationManagerImpl::OnHandshakeDone(
uint32_t connection_key,
@@ -1681,15 +1690,6 @@ ApplicationManagerImpl::GetHandshakeContext(uint32_t key) const {
}
return SSLContext::HandshakeContext();
}
-
-bool ApplicationManagerImpl::CheckAppIsNavi(const uint32_t app_id) const {
- LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = application(app_id);
- if (app) {
- return app->is_navi();
- }
- return false;
-}
#endif // ENABLE_SECURITY
void ApplicationManagerImpl::set_hmi_message_handler(
diff --git a/src/components/application_manager/test/CMakeLists.txt b/src/components/application_manager/test/CMakeLists.txt
index 3e9010e22c..90059e4d98 100644
--- a/src/components/application_manager/test/CMakeLists.txt
+++ b/src/components/application_manager/test/CMakeLists.txt
@@ -101,11 +101,14 @@ set(LIBRARIES
MediaManager
Resumption
ProtocolHandler
- SecurityManager
bson -L${BSON_LIBS_DIRECTORY}
emhashmap -L${EMHASHMAP_LIBS_DIRECTORY}
)
+if (ENABLE_SECURITY)
+ list(APPEND LIBRARIES SecurityManager)
+endif()
+
if (${CMAKE_SYSTEM_NAME} MATCHES "QNX")
list(REMOVE_ITEM LIBRARIES dl)
endif()
diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc
index 66efe45e30..77500fd238 100644
--- a/src/components/application_manager/test/policy_handler_test.cc
+++ b/src/components/application_manager/test/policy_handler_test.cc
@@ -40,8 +40,10 @@
#include "connection_handler/connection_handler_impl.h"
#include "application_manager/application_manager_impl.h"
#include "application_manager/application_impl.h"
+#ifdef ENABLE_SECURITY
#include "security_manager/mock_security_manager.h"
#include "security_manager/mock_crypto_manager.h"
+#endif // ENABLE_SECURITY
#include "application_manager/mock_message_helper.h"
#include "connection_handler/mock_connection_handler_settings.h"
#include "transport_manager/mock_transport_manager.h"
@@ -1601,6 +1603,7 @@ TEST_F(PolicyHandlerTest, OnGetListOfPermissions_GroupPermissions_SUCCESS) {
policy_handler_.OnGetListOfPermissions(app_id, corr_id);
}
+#ifdef ENABLE_SECURITY
TEST_F(PolicyHandlerTest, RetrieveCertificate) {
// Arrange
EnablePolicyAndPolicyManagerMock();
@@ -1609,6 +1612,7 @@ TEST_F(PolicyHandlerTest, RetrieveCertificate) {
.WillOnce(Return(test_certificate));
EXPECT_EQ(test_certificate, policy_handler_.RetrieveCertificate());
}
+#endif // ENABLE_SECURITY
TEST_F(PolicyHandlerTest, OnSnapshotCreated_UrlNotAdded) {
EnablePolicyAndPolicyManagerMock();
@@ -1826,6 +1830,7 @@ TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_PredatePolicyNotAllowed) {
policy_handler_.OnDeviceConsentChanged(kPolicyAppId_, is_allowed);
}
+#ifdef ENABLE_SECURITY
#ifdef EXTERNAL_PROPRIETARY_MODE
TEST_F(PolicyHandlerTest, OnCertificateUpdated) {
const std::string app_storage = "storage";
@@ -1851,7 +1856,8 @@ TEST_F(PolicyHandlerTest, OnCertificateUpdated) {
EXPECT_CALL(policy_handler_observer, OnCertificateUpdated(cert_data));
policy_handler_.OnCertificateUpdated(cert_data);
}
-#endif
+#endif // EXTERNAL_PROPRIETARY_MODE
+#endif // ENABLE_SECURITY
TEST_F(PolicyHandlerTest, GetAppIdForSending_WithoutApps) {
// Arrange
diff --git a/src/components/connection_handler/include/connection_handler/connection.h b/src/components/connection_handler/include/connection_handler/connection.h
index b0f9586046..9b72d60776 100644
--- a/src/components/connection_handler/include/connection_handler/connection.h
+++ b/src/components/connection_handler/include/connection_handler/connection.h
@@ -212,6 +212,13 @@ class Connection {
void SetProtectionFlag(const uint8_t session_id,
const protocol_handler::ServiceType& service_type);
+#endif // ENABLE_SECURITY
+ /**
+ * @brief Returns map of sessions which have been opened in
+ * current connection.
+ */
+ const SessionMap session_map() const;
+
/**
* @brief Check if session contains service with specified service type
* @param session_id id of session to check
@@ -222,13 +229,6 @@ class Connection {
const uint8_t session_id,
const protocol_handler::ServiceType& service_type) const;
-#endif // ENABLE_SECURITY
- /**
- * @brief Returns map of sessions which have been opened in
- * current connection.
- */
- const SessionMap session_map() const;
-
/**
* @brief Close session
* @param session_id session id
diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h
index 3aa304aabc..66b2d7cf16 100644
--- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h
+++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h
@@ -350,6 +350,10 @@ class ConnectionHandlerImpl
const uint32_t& key,
const protocol_handler::ServiceType& service_type) OVERRIDE;
+ security_manager::SSLContext::HandshakeContext GetHandshakeContext(
+ uint32_t key) const OVERRIDE;
+#endif // ENABLE_SECURITY
+
/**
* @brief Check if session contains service with specified service type
* @param connection_key unique id of session to check
@@ -360,10 +364,6 @@ class ConnectionHandlerImpl
const uint32_t connection_key,
const protocol_handler::ServiceType& service_type) const OVERRIDE;
- security_manager::SSLContext::HandshakeContext GetHandshakeContext(
- uint32_t key) const OVERRIDE;
-#endif // ENABLE_SECURITY
-
/**
* \brief Get device handle by mac address
* \param mac_address uniq address
diff --git a/src/components/connection_handler/src/connection.cc b/src/components/connection_handler/src/connection.cc
index d494611643..16b88c4164 100644
--- a/src/components/connection_handler/src/connection.cc
+++ b/src/components/connection_handler/src/connection.cc
@@ -314,6 +314,8 @@ void Connection::SetProtectionFlag(
}
}
+#endif // ENABLE_SECURITY
+
bool Connection::SessionServiceExists(
const uint8_t session_id,
const protocol_handler::ServiceType& service_type) const {
@@ -330,8 +332,6 @@ bool Connection::SessionServiceExists(
return session.FindService(service_type);
}
-#endif // ENABLE_SECURITY
-
ConnectionHandle Connection::connection_handle() const {
return connection_handle_;
}
diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc
index 7ea9efa1cc..109e41b836 100644
--- a/src/components/connection_handler/src/connection_handler_impl.cc
+++ b/src/components/connection_handler/src/connection_handler_impl.cc
@@ -878,6 +878,13 @@ void ConnectionHandlerImpl::SetProtectionFlag(
connection.SetProtectionFlag(session_id, service_type);
}
+security_manager::SSLContext::HandshakeContext
+ConnectionHandlerImpl::GetHandshakeContext(uint32_t key) const {
+ return connection_handler_observer_->GetHandshakeContext(key);
+}
+
+#endif // ENABLE_SECURITY
+
bool ConnectionHandlerImpl::SessionServiceExists(
const uint32_t connection_key,
const protocol_handler::ServiceType& service_type) const {
@@ -896,13 +903,6 @@ bool ConnectionHandlerImpl::SessionServiceExists(
return connection.SessionServiceExists(session_id, service_type);
}
-security_manager::SSLContext::HandshakeContext
-ConnectionHandlerImpl::GetHandshakeContext(uint32_t key) const {
- return connection_handler_observer_->GetHandshakeContext(key);
-}
-
-#endif // ENABLE_SECURITY
-
void ConnectionHandlerImpl::StartDevicesDiscovery() {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/connection_handler/test/connection_handler_impl_test.cc b/src/components/connection_handler/test/connection_handler_impl_test.cc
index a951598917..d0b9ce4ae4 100644
--- a/src/components/connection_handler/test/connection_handler_impl_test.cc
+++ b/src/components/connection_handler/test/connection_handler_impl_test.cc
@@ -37,8 +37,10 @@
#include "connection_handler/connection_handler_impl.h"
#include "protocol/common.h"
// TODO(EZamakhov): move security test
+#ifdef ENABLE_SECURITY
#include "security_manager/mock_security_manager.h"
#include "security_manager/mock_ssl_context.h"
+#endif // ENABLE_SECURITY
#include "protocol_handler/mock_protocol_handler.h"
#include "connection_handler/mock_connection_handler_observer.h"
#include "connection_handler/mock_connection_handler_settings.h"
@@ -175,7 +177,7 @@ class ConnectionHandlerTest : public ::testing::Test {
ASSERT_FALSE(connection_list.empty());
ConnectionList::const_iterator conn_it = connection_list.find(connectionId);
ASSERT_NE(conn_it, connection_list.end());
- const Connection& connection = *connection_list.begin()->second;
+ const Connection& connection = *conn_it->second;
const SessionMap& session_map = connection.session_map();
SessionMap::const_iterator sess_it = session_map.find(session_id);
@@ -206,7 +208,7 @@ class ConnectionHandlerTest : public ::testing::Test {
ASSERT_FALSE(connection_list.empty());
ConnectionList::const_iterator conn_it = connection_list.find(connectionId);
ASSERT_NE(conn_it, connection_list.end());
- const Connection& connection = *connection_list.begin()->second;
+ const Connection& connection = *conn_it->second;
const SessionMap& session_map = connection.session_map();
ASSERT_FALSE(session_map.empty());
@@ -223,7 +225,9 @@ class ConnectionHandlerTest : public ::testing::Test {
ASSERT_EQ(serv_it, service_list.end());
}
}
- // Check Service Wrapper
+
+// Check Service Wrapper
+#ifdef ENABLE_SECURITY
void CheckService(const int connectionId,
const int session_id,
const ::protocol_handler::ServiceType serviceId,
@@ -235,16 +239,14 @@ class ConnectionHandlerTest : public ::testing::Test {
ASSERT_FALSE(connection_list.empty());
ConnectionList::const_iterator conn_it = connection_list.find(connectionId);
ASSERT_NE(conn_it, connection_list.end());
- const Connection& connection = *connection_list.begin()->second;
+ const Connection& connection = *conn_it->second;
const SessionMap& session_map = connection.session_map();
ASSERT_FALSE(session_map.empty());
SessionMap::const_iterator sess_it = session_map.find(session_id);
ASSERT_NE(sess_it, session_map.end());
const Session& session = sess_it->second;
-#ifdef ENABLE_SECURITY
ASSERT_EQ(session.ssl_context, ssl_context);
-#endif // ENABLE_SECURITY
const ServiceList& service_list = session.service_list;
ASSERT_FALSE(service_list.empty());
ServiceList::const_iterator serv_it =
@@ -253,14 +255,39 @@ class ConnectionHandlerTest : public ::testing::Test {
const Service& service = *serv_it;
EXPECT_EQ(PROTECTION_OFF, service.is_protected_);
-#ifdef ENABLE_SECURITY
if (is_protected) {
// Emulate success protection - check enable service flag
const uint32_t connection_key_ =
connection_handler_->KeyFromPair(connectionId, session_id);
connection_handler_->SetProtectionFlag(connection_key_, serviceId);
}
+ }
#endif // ENABLE_SECURITY
+
+ void CheckService(const int connectionId,
+ const int session_id,
+ const ::protocol_handler::ServiceType serviceId) {
+ // Check all tree to find Service and check own protected value
+ const ConnectionList& connection_list =
+ connection_handler_->getConnectionList();
+ ASSERT_FALSE(connection_list.empty());
+ ConnectionList::const_iterator conn_it = connection_list.find(connectionId);
+ ASSERT_NE(conn_it, connection_list.end());
+ const Connection& connection = *conn_it->second;
+
+ const SessionMap& session_map = connection.session_map();
+ ASSERT_FALSE(session_map.empty());
+ SessionMap::const_iterator sess_it = session_map.find(session_id);
+ ASSERT_NE(sess_it, session_map.end());
+ const Session& session = sess_it->second;
+ const ServiceList& service_list = session.service_list;
+ ASSERT_FALSE(service_list.empty());
+ ServiceList::const_iterator serv_it =
+ std::find(service_list.begin(), service_list.end(), serviceId);
+ ASSERT_NE(serv_it, service_list.end());
+
+ const Service& service = *serv_it;
+ EXPECT_EQ(PROTECTION_OFF, service.is_protected_);
}
void ChangeProtocol(const int connectionId,
@@ -1482,8 +1509,7 @@ TEST_F(ConnectionHandlerTest,
connection_handler_->OnSessionStartedCallback(
uid_, 0, kRpc, PROTECTION_OFF, static_cast<BsonObject*>(NULL));
EXPECT_NE(0u, positive_context.new_session_id_);
- CheckService(
- uid_, positive_context.new_session_id_, kRpc, NULL, PROTECTION_OFF);
+ CheckService(uid_, positive_context.new_session_id_, kRpc);
EXPECT_EQ(SessionHash(uid_, positive_context.new_session_id_),
positive_context.hash_id_);
}
@@ -1525,10 +1551,10 @@ TEST_F(ConnectionHandlerTest,
EXPECT_NE(0u, positive_context.new_session_id_);
EXPECT_EQ(SessionHash(uid_, positive_context.new_session_id_),
positive_context.hash_id_);
-
+#ifdef ENABLE_SECURITY
// Protection steal FALSE because of APPlink Protocol implementation
- CheckService(
- uid_, positive_context.new_session_id_, kRpc, NULL, PROTECTION_OFF);
+ CheckService(uid_, positive_context.new_session_id_, kRpc);
+#endif // ENABLE_SECURITY
}
TEST_F(ConnectionHandlerTest,
@@ -1634,8 +1660,6 @@ TEST_F(ConnectionHandlerTest,
#else
EXPECT_EQ(0u, positive_context.new_session_id_);
EXPECT_EQ(protocol_handler::HASH_ID_WRONG, positive_context.hash_id_);
- CheckService(
- uid_, positive_context.new_session_id_, kAudio, NULL, PROTECTION_OFF);
#endif // ENABLE_SECURITY
}
@@ -1667,7 +1691,6 @@ TEST_F(ConnectionHandlerTest, SessionStarted_DealyProtect) {
EXPECT_EQ(0u, context_new.new_session_id_);
// Post protection nedd no hash
EXPECT_EQ(protocol_handler::HASH_ID_WRONG, context_new.hash_id_);
- CheckService(uid_, context_new.new_session_id_, kRpc, NULL, PROTECTION_OFF);
#endif // ENABLE_SECURITY
// Start Audio session without protection
@@ -1678,8 +1701,7 @@ TEST_F(ConnectionHandlerTest, SessionStarted_DealyProtect) {
static_cast<BsonObject*>(NULL));
EXPECT_EQ(out_context_.new_session_id_, context_second.new_session_id_);
EXPECT_EQ(protocol_handler::HASH_ID_NOT_SUPPORTED, context_second.hash_id_);
- CheckService(
- uid_, context_second.new_session_id_, kAudio, NULL, PROTECTION_OFF);
+ CheckService(uid_, context_second.new_session_id_, kAudio);
// Start Audio protection
connection_handler_->OnSessionStartedCallback(uid_,
@@ -1695,8 +1717,6 @@ TEST_F(ConnectionHandlerTest, SessionStarted_DealyProtect) {
#else
EXPECT_EQ(0u, context_third.new_session_id_);
EXPECT_EQ(protocol_handler::HASH_ID_WRONG, context_third.hash_id_);
- CheckService(
- uid_, context_third.new_session_id_, kAudio, NULL, PROTECTION_OFF);
#endif // ENABLE_SECURITY
}
@@ -1718,7 +1738,6 @@ TEST_F(ConnectionHandlerTest, SessionStarted_DealyProtectBulk) {
CheckService(uid_, new_context.new_session_id_, kRpc, NULL, PROTECTION_ON);
#else
EXPECT_EQ(0u, new_context.new_session_id_);
- CheckService(uid_, new_context.new_session_id_, kRpc, NULL, PROTECTION_OFF);
#endif // ENABLE_SECURITY
}
diff --git a/src/components/connection_handler/test/connection_test.cc b/src/components/connection_handler/test/connection_test.cc
index 5fd6b40e0e..de21dd1e97 100644
--- a/src/components/connection_handler/test/connection_test.cc
+++ b/src/components/connection_handler/test/connection_test.cc
@@ -40,8 +40,10 @@
#include "protocol/service_type.h"
#include "connection_handler/mock_connection_handler_settings.h"
#include "transport_manager/mock_transport_manager.h"
+#ifdef ENABLE_SECURITY
#include "security_manager/mock_security_manager.h"
#include "security_manager/mock_ssl_context.h"
+#endif // ENABLE_SECURITY
#define EXPECT_RETURN_TRUE true
#define EXPECT_RETURN_FALSE false
diff --git a/src/components/include/connection_handler/connection_handler_observer.h b/src/components/include/connection_handler/connection_handler_observer.h
index 1bd919f30e..b4c04c17c9 100644
--- a/src/components/include/connection_handler/connection_handler_observer.h
+++ b/src/components/include/connection_handler/connection_handler_observer.h
@@ -140,6 +140,13 @@ class ConnectionHandlerObserver {
*/
virtual void OnDeviceSwitchingFinish(const std::string& device_uid) = 0;
+ /**
+ * @brief Check if application with specified app_id has NAVIGATION HMI type
+ * @param app_id id of application to check
+ * @return true if application is navi otherwise returns false
+ */
+ virtual bool CheckAppIsNavi(const uint32_t app_id) const = 0;
+
#ifdef ENABLE_SECURITY
/**
* @brief Get unique handshake context by application id
@@ -149,13 +156,6 @@ class ConnectionHandlerObserver {
*/
virtual security_manager::SSLContext::HandshakeContext GetHandshakeContext(
uint32_t key) const = 0;
-
- /**
- * @brief Check if application with specified app_id has NAVIGATION HMI type
- * @param app_id id of application to check
- * @return true if application is navi otherwise returns false
- */
- virtual bool CheckAppIsNavi(const uint32_t app_id) const = 0;
#endif // ENABLE_SECURITY
protected:
/**
diff --git a/src/components/include/protocol_handler/session_observer.h b/src/components/include/protocol_handler/session_observer.h
index ccf000a18d..3482c6569c 100644
--- a/src/components/include/protocol_handler/session_observer.h
+++ b/src/components/include/protocol_handler/session_observer.h
@@ -297,6 +297,16 @@ class SessionObserver {
uint8_t session_id,
uint8_t& protocol_version) const = 0;
+ /**
+ * @brief Check if session contains service with specified service type
+ * @param connection_key unique id of session to check
+ * @param service_type type of service to check
+ * @return true if session contains service with specified service type
+ */
+ virtual bool SessionServiceExists(
+ const uint32_t connection_key,
+ const protocol_handler::ServiceType& service_type) const = 0;
+
#ifdef ENABLE_SECURITY
/**
* \brief Sets crypto context of connection
@@ -327,16 +337,6 @@ class SessionObserver {
const uint32_t& key,
const protocol_handler::ServiceType& service_type) = 0;
- /**
- * @brief Check if session contains service with specified service type
- * @param connection_key unique id of session to check
- * @param service_type type of service to check
- * @return true if session contains service with specified service type
- */
- virtual bool SessionServiceExists(
- const uint32_t connection_key,
- const protocol_handler::ServiceType& service_type) const = 0;
-
virtual security_manager::SSLContext::HandshakeContext GetHandshakeContext(
uint32_t key) const = 0;
#endif // ENABLE_SECURITY
diff --git a/src/components/include/test/connection_handler/mock_connection_handler_observer.h b/src/components/include/test/connection_handler/mock_connection_handler_observer.h
index f1c605eaca..a96498028d 100644
--- a/src/components/include/test/connection_handler/mock_connection_handler_observer.h
+++ b/src/components/include/test/connection_handler/mock_connection_handler_observer.h
@@ -63,9 +63,11 @@ class MockConnectionHandlerObserver
void(const int32_t& session_key,
const protocol_handler::ServiceType& type,
const connection_handler::CloseSessionReason& close_reason));
+#ifdef ENABLE_SECURITY
MOCK_CONST_METHOD1(
GetHandshakeContext,
security_manager::SSLContext::HandshakeContext(uint32_t key));
+#endif // ENABLE_SECURITY
MOCK_METHOD2(OnDeviceSwitchingStart,
void(const connection_handler::Device& device_from,
diff --git a/src/components/include/test/protocol_handler/mock_session_observer.h b/src/components/include/test/protocol_handler/mock_session_observer.h
index 3d54b97fad..86f521bfb7 100644
--- a/src/components/include/test/protocol_handler/mock_session_observer.h
+++ b/src/components/include/test/protocol_handler/mock_session_observer.h
@@ -115,6 +115,9 @@ class MockSessionObserver : public ::protocol_handler::SessionObserver {
bool(uint32_t connection_id,
uint8_t session_id,
uint8_t& protocol_version));
+ MOCK_CONST_METHOD2(SessionServiceExists,
+ bool(const uint32_t connection_key,
+ const protocol_handler::ServiceType& service_type));
#ifdef ENABLE_SECURITY
MOCK_METHOD2(SetSSLContext,
@@ -126,9 +129,6 @@ class MockSessionObserver : public ::protocol_handler::SessionObserver {
MOCK_METHOD2(SetProtectionFlag,
void(const uint32_t& key,
const protocol_handler::ServiceType& service_type));
- MOCK_CONST_METHOD2(SessionServiceExists,
- bool(const uint32_t connection_key,
- const protocol_handler::ServiceType& service_type));
MOCK_CONST_METHOD1(
GetHandshakeContext,
security_manager::SSLContext::HandshakeContext(uint32_t key));
diff --git a/src/components/protocol_handler/CMakeLists.txt b/src/components/protocol_handler/CMakeLists.txt
index ebecff2402..ed3aaaf24c 100644
--- a/src/components/protocol_handler/CMakeLists.txt
+++ b/src/components/protocol_handler/CMakeLists.txt
@@ -42,7 +42,14 @@ set(PATHS
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
)
-collect_sources(SOURCES "${PATHS}")
+
+if (ENABLE_SECURITY)
+ set(EXCLUDE_PATHS)
+else()
+ set(EXCLUDE_PATHS handshake_handler.cc)
+endif()
+
+collect_sources(SOURCES "${PATHS}" "${EXCLUDE_PATHS}")
set(LIBRARIES
ProtocolLibrary
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc
index 47d546657f..762b986782 100644
--- a/src/components/protocol_handler/src/protocol_handler_impl.cc
+++ b/src/components/protocol_handler/src/protocol_handler_impl.cc
@@ -75,11 +75,11 @@ ProtocolHandlerImpl::ProtocolHandlerImpl(
,
#ifdef ENABLE_SECURITY
security_manager_(NULL)
+ , is_ptu_triggered_(false)
,
#endif // ENABLE_SECURITY
- is_ptu_triggered_(false)
- , raw_ford_messages_from_mobile_(
- "PH FromMobile", this, threads::ThreadOptions(kStackSize))
+ raw_ford_messages_from_mobile_(
+ "PH FromMobile", this, threads::ThreadOptions(kStackSize))
, raw_ford_messages_to_mobile_(
"PH ToMobile", this, threads::ThreadOptions(kStackSize))
, start_session_frame_map_lock_()
@@ -1252,13 +1252,13 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
logger_,
"Protocol version:" << static_cast<int>(packet.protocol_version()));
const ServiceType service_type = ServiceTypeFromByte(packet.service_type());
- const uint8_t protocol_version = packet.protocol_version();
#ifdef ENABLE_SECURITY
const bool protection =
- // Protocolo version 1 is not support protection
- (protocol_version > PROTOCOL_VERSION_1) ? packet.protection_flag()
- : false;
+ // Protocol version 1 is not support protection
+ (packet.protocol_version() > PROTOCOL_VERSION_1)
+ ? packet.protection_flag()
+ : false;
#else
const bool protection = false;
#endif // ENABLE_SECURITY
@@ -1274,7 +1274,7 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
<< static_cast<int32_t>(service_type) << " type.");
SendStartSessionNAck(connection_id,
packet.session_id(),
- protocol_version,
+ packet.protocol_version(),
packet.service_type());
return RESULT_OK;
}
@@ -1323,7 +1323,7 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
if (!rejectedParams.empty()) {
SendStartSessionNAck(connection_id,
packet.session_id(),
- protocol_version,
+ packet.protocol_version(),
packet.service_type(),
rejectedParams);
} else if (ssl_context->IsInitCompleted()) {
@@ -1383,7 +1383,7 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
std::string("protocolVersion"));
SendStartSessionNAck(connection_id,
packet.session_id(),
- protocol_version,
+ packet.protocol_version(),
packet.service_type(),
rejectedParams);
}
@@ -1408,7 +1408,6 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
logger_,
"Protocol version:" << static_cast<int>(packet->protocol_version()));
const ServiceType service_type = ServiceTypeFromByte(packet->service_type());
- const uint8_t protocol_version = packet->protocol_version();
BsonObject bson_obj;
if (packet->data() != NULL) {
bson_obj = bson_object_from_bytes(packet->data());
@@ -1418,9 +1417,10 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
#ifdef ENABLE_SECURITY
const bool protection =
- // Protocolo version 1 is not support protection
- (protocol_version > PROTOCOL_VERSION_1) ? packet->protection_flag()
- : false;
+ // Protocol version 1 is not support protection
+ (packet->protocol_version() > PROTOCOL_VERSION_1)
+ ? packet->protection_flag()
+ : false;
#else
const bool protection = false;
#endif // ENABLE_SECURITY
diff --git a/src/components/protocol_handler/test/protocol_handler_tm_test.cc b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
index cb11eca887..77de1705da 100644
--- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc
+++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
@@ -41,8 +41,10 @@
#include "protocol_handler/mock_protocol_handler_settings.h"
#include "protocol_handler/mock_session_observer.h"
#include "connection_handler/mock_connection_handler.h"
+#ifdef ENABLE_SECURITY
#include "security_manager/mock_security_manager.h"
#include "security_manager/mock_ssl_context.h"
+#endif // ENABLE_SECURITY
#include "transport_manager/mock_transport_manager.h"
#include "utils/make_shared.h"
#include "utils/test_async_waiter.h"
diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc
index e9933e3c82..a364220a64 100644
--- a/src/components/transport_manager/src/transport_manager_impl.cc
+++ b/src/components/transport_manager/src/transport_manager_impl.cc
@@ -435,11 +435,10 @@ int TransportManagerImpl::AddTransportAdapter(
return E_ADAPTER_EXISTS;
}
- auto listener =
- new TransportAdapterListenerImpl(this, transport_adapter);
+ auto listener = new TransportAdapterListenerImpl(this, transport_adapter);
transport_adapter->AddListener(listener);
-
+
if (transport_adapter->IsInitialised() ||
transport_adapter->Init() == TransportAdapter::OK) {
transport_adapter_listeners_[transport_adapter] = listener;