summaryrefslogtreecommitdiff
path: root/src/components/security_manager
diff options
context:
space:
mode:
authorKozoriz <kozorizandriy@gmail.com>2015-12-25 10:47:42 +0200
committerKozoriz <kozorizandriy@gmail.com>2015-12-25 11:51:33 +0200
commit20f8cc306a3ea604285e3d195dbf7f71477393bb (patch)
treea9659ccec9799766413a2a95c2491b945260c280 /src/components/security_manager
parentb93eb346443e49ae3c1d32bc2d212eccc43fb7ec (diff)
downloadsdl_core-20f8cc306a3ea604285e3d195dbf7f71477393bb.tar.gz
Beautifiring mock and test files
Used beautifier for formating code in security_manager tests security_manager mocks protocol_handler mocks
Diffstat (limited to 'src/components/security_manager')
-rw-r--r--src/components/security_manager/test/crypto_manager_impl_test.cc16
-rw-r--r--src/components/security_manager/test/security_manager_test.cc624
-rw-r--r--src/components/security_manager/test/security_query_matcher.cc76
-rw-r--r--src/components/security_manager/test/security_query_test.cc108
-rw-r--r--src/components/security_manager/test/ssl_certificate_handshake_test.cc24
-rw-r--r--src/components/security_manager/test/ssl_context_test.cc50
6 files changed, 461 insertions, 437 deletions
diff --git a/src/components/security_manager/test/crypto_manager_impl_test.cc b/src/components/security_manager/test/crypto_manager_impl_test.cc
index 331eb5cfca..95ef11155f 100644
--- a/src/components/security_manager/test/crypto_manager_impl_test.cc
+++ b/src/components/security_manager/test/crypto_manager_impl_test.cc
@@ -30,6 +30,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#ifdef __QNXNTO__
+#include <openssl/ssl3.h>
+#else
+#include <openssl/tls1.h>
+#endif
+
#include <fstream>
#include <iostream>
#include <sstream>
@@ -38,12 +44,6 @@
#include "security_manager/crypto_manager_impl.h"
#ifdef __QNXNTO__
-#include <openssl/ssl3.h>
-#else
-#include <openssl/tls1.h>
-#endif
-
-#ifdef __QNXNTO__
#define FORD_CIPHER SSL3_TXT_RSA_DES_192_CBC3_SHA
#else
// Used cipher from ford protocol requirement
@@ -115,7 +115,7 @@ TEST_F(CryptoManagerTest, WrongInit) {
EXPECT_FALSE(crypto_manager->LastError().empty());
}
-//#ifndef __QNXNTO__
+// #ifndef __QNXNTO__
TEST_F(CryptoManagerTest, CorrectInit) {
bool is_initialyzed;
std::string error_string;
@@ -158,7 +158,7 @@ TEST_F(CryptoManagerTest, CorrectInit) {
error_string = crypto_manager->LastError();
EXPECT_TRUE(error_string.empty());
}
-//#endif // __QNX__
+// #endif // __QNX__
TEST_F(CryptoManagerTest, ReleaseSSLContext_Null) {
EXPECT_NO_THROW(crypto_manager->ReleaseSSLContext(NULL));
diff --git a/src/components/security_manager/test/security_manager_test.cc b/src/components/security_manager/test/security_manager_test.cc
index 7e086c9ab5..f516db1159 100644
--- a/src/components/security_manager/test/security_manager_test.cc
+++ b/src/components/security_manager/test/security_manager_test.cc
@@ -61,14 +61,14 @@ const ServiceType secureServiceType = kControl;
const uint32_t protocolVersion = PROTOCOL_VERSION_2;
const bool is_final = false;
-const uint8_t handshake_data[] = { 0x1, 0x2, 0x3, 0x4, 0x5 };
-const size_t handshake_data_size = sizeof(handshake_data)
- / sizeof(handshake_data[0]);
+const uint8_t handshake_data[] = {0x1, 0x2, 0x3, 0x4, 0x5};
+const size_t handshake_data_size =
+ sizeof(handshake_data) / sizeof(handshake_data[0]);
-uint8_t handshake_data_out[] = { 0x6, 0x7, 0x8 };
-uint8_t *handshake_data_out_pointer = handshake_data_out;
-const size_t handshake_data_out_size = sizeof(handshake_data_out)
- / sizeof(handshake_data_out[0]);
+uint8_t handshake_data_out[] = {0x6, 0x7, 0x8};
+uint8_t* handshake_data_out_pointer = handshake_data_out;
+const size_t handshake_data_out_size =
+ sizeof(handshake_data_out) / sizeof(handshake_data_out[0]);
using ::security_manager::SecurityQuery;
using security_manager_test::InternalErrorWithErrId;
@@ -94,8 +94,8 @@ class SecurityManagerTest : public ::testing::Test {
}
void SetMockCryptoManager() {
- EXPECT_CALL(mock_crypto_manager, IsCertificateUpdateRequired()).
- WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_crypto_manager, IsCertificateUpdateRequired())
+ .WillRepeatedly(Return(false));
security_manager_->set_crypto_manager(&mock_crypto_manager);
}
/*
@@ -143,12 +143,18 @@ class SecurityManagerTest : public ::testing::Test {
}
::utils::SharedPtr<SecurityManagerImpl> security_manager_;
// Strict mocks (same as all methods EXPECT_CALL().Times(0))
- testing::StrictMock<protocol_handler_test::MockSessionObserver> mock_session_observer;
- testing::StrictMock<protocol_handler_test::MockProtocolHandler> mock_protocol_handler;
- testing::StrictMock<security_manager_test::MockCryptoManager> mock_crypto_manager;
- testing::StrictMock<security_manager_test::MockSSLContext> mock_ssl_context_new;
- testing::StrictMock<security_manager_test::MockSSLContext> mock_ssl_context_exists;
- testing::StrictMock<security_manager_test::MockSecurityManagerListener> mock_sm_listener;
+ testing::StrictMock<protocol_handler_test::MockSessionObserver>
+ mock_session_observer;
+ testing::StrictMock<protocol_handler_test::MockProtocolHandler>
+ mock_protocol_handler;
+ testing::StrictMock<security_manager_test::MockCryptoManager>
+ mock_crypto_manager;
+ testing::StrictMock<security_manager_test::MockSSLContext>
+ mock_ssl_context_new;
+ testing::StrictMock<security_manager_test::MockSSLContext>
+ mock_ssl_context_exists;
+ testing::StrictMock<security_manager_test::MockSecurityManagerListener>
+ mock_sm_listener;
};
// Test Bodies
@@ -191,10 +197,10 @@ TEST_F(SecurityManagerTest, Listeners_NoListeners) {
security_manager_->AddListener(&mock_listener2);
security_manager_->RemoveListener(&mock_listener2);
- security_manager_->NotifyListenersOnHandshakeDone(key,
- SSLContext::Handshake_Result_Success);
- security_manager_->NotifyListenersOnHandshakeDone(key,
- SSLContext::Handshake_Result_Fail);
+ security_manager_->NotifyListenersOnHandshakeDone(
+ key, SSLContext::Handshake_Result_Success);
+ security_manager_->NotifyListenersOnHandshakeDone(
+ key, SSLContext::Handshake_Result_Fail);
}
/*
* Notifying two listeners
@@ -209,12 +215,14 @@ TEST_F(SecurityManagerTest, Listeners_Notifying) {
const SSLContext::HandshakeResult first_call_value =
SSLContext::Handshake_Result_Success;
// Expect call both listeners on 1st call
- EXPECT_CALL(mock_listener1, OnHandshakeDone(key, first_call_value)).
- // Emulate false (reject) result
- WillOnce(Return(false));
- EXPECT_CALL(mock_listener2, OnHandshakeDone(key, first_call_value)).
- // Emulate true (accept) result
- WillOnce(Return(true));
+ EXPECT_CALL(mock_listener1, OnHandshakeDone(key, first_call_value))
+ .
+ // Emulate false (reject) result
+ WillOnce(Return(false));
+ EXPECT_CALL(mock_listener2, OnHandshakeDone(key, first_call_value))
+ .
+ // Emulate true (accept) result
+ WillOnce(Return(true));
// First listener was not removed from listener list
// So this callback wil lbe either call.
@@ -223,9 +231,10 @@ TEST_F(SecurityManagerTest, Listeners_Notifying) {
const SSLContext::HandshakeResult second_call_value =
SSLContext::Handshake_Result_Fail;
// Expect call last listener on 2d call
- EXPECT_CALL(mock_listener1, OnHandshakeDone(key, second_call_value)).
- // Emulate false (reject) result
- WillOnce(Return(true));
+ EXPECT_CALL(mock_listener1, OnHandshakeDone(key, second_call_value))
+ .
+ // Emulate false (reject) result
+ WillOnce(Return(true));
// Expect no call 3d call
@@ -238,8 +247,8 @@ TEST_F(SecurityManagerTest, Listeners_Notifying) {
security_manager_->NotifyListenersOnHandshakeDone(key, second_call_value);
security_manager_->NotifyOnCertififcateUpdateRequired();
// 3nd call
- security_manager_->NotifyListenersOnHandshakeDone(key,
- SSLContext::Handshake_Result_Fail);
+ security_manager_->NotifyListenersOnHandshakeDone(
+ key, SSLContext::Handshake_Result_Fail);
security_manager_->NotifyOnCertififcateUpdateRequired();
}
@@ -251,14 +260,16 @@ TEST_F(SecurityManagerTest, SecurityManager_NULLCryptoManager) {
// Expect InternalError with ERROR_ID
uint32_t connection_id = 0;
uint8_t session_id = 0;
- //uint8_t protocol_version = 0;
+ // uint8_t protocol_version = 0;
EXPECT_CALL(mock_session_observer, PairFromKey(key, _, _));
- EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id,_)).
- WillOnce(Return(true));
+ EXPECT_CALL(mock_session_observer,
+ ProtocolVersionUsed(connection_id, session_id, _))
+ .WillOnce(Return(true));
- EXPECT_CALL(
- mock_protocol_handler,
- SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_NOT_SUPPORTED), is_final));
+ EXPECT_CALL(mock_protocol_handler,
+ SendMessageToMobileApp(
+ InternalErrorWithErrId(SecurityManager::ERROR_NOT_SUPPORTED),
+ is_final));
const SecurityQuery::QueryHeader header(SecurityQuery::REQUEST,
// It could be any query id
SecurityQuery::INVALID_QUERY_ID);
@@ -270,7 +281,7 @@ TEST_F(SecurityManagerTest, SecurityManager_NULLCryptoManager) {
*/
TEST_F(SecurityManagerTest, OnMobileMessageSent) {
const ::protocol_handler::RawMessagePtr rawMessagePtr(
- new ::protocol_handler::RawMessage(key, protocolVersion, NULL, 0));
+ new ::protocol_handler::RawMessage(key, protocolVersion, NULL, 0));
security_manager_->OnMobileMessageSent(rawMessagePtr);
}
/*
@@ -290,14 +301,17 @@ TEST_F(SecurityManagerTest, GetWrongServiceType) {
TEST_F(SecurityManagerTest, GetEmptyQuery) {
uint32_t connection_id = 0;
uint8_t session_id = 0;
- //uint8_t protocol_version = 0;
+ // uint8_t protocol_version = 0;
EXPECT_CALL(mock_session_observer, PairFromKey(key, _, _));
- EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id,_)).
- WillOnce(Return(true));
+ EXPECT_CALL(mock_session_observer,
+ ProtocolVersionUsed(connection_id, session_id, _))
+ .WillOnce(Return(true));
EXPECT_CALL(
- mock_protocol_handler,
- SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_INVALID_QUERY_SIZE), is_final));
+ mock_protocol_handler,
+ SendMessageToMobileApp(
+ InternalErrorWithErrId(SecurityManager::ERROR_INVALID_QUERY_SIZE),
+ is_final));
// Call with NULL data
call_OnMessageReceived(NULL, 0, secureServiceType);
}
@@ -308,17 +322,19 @@ TEST_F(SecurityManagerTest, GetWrongJSONSize) {
SetMockCryptoManager();
uint32_t connection_id = 0;
uint8_t session_id = 0;
- //uint8_t protocol_version = 0;
+ // uint8_t protocol_version = 0;
EXPECT_CALL(mock_session_observer, PairFromKey(key, _, _));
- EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id,_)).
- WillOnce(Return(true));
+ EXPECT_CALL(mock_session_observer,
+ ProtocolVersionUsed(connection_id, session_id, _))
+ .WillOnce(Return(true));
// Expect InternalError with ERROR_ID
EXPECT_CALL(
- mock_protocol_handler,
- SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_INVALID_QUERY_SIZE), is_final));
- SecurityQuery::QueryHeader header(
- SecurityQuery::REQUEST,
- SecurityQuery::INVALID_QUERY_ID);
+ mock_protocol_handler,
+ SendMessageToMobileApp(
+ InternalErrorWithErrId(SecurityManager::ERROR_INVALID_QUERY_SIZE),
+ is_final));
+ SecurityQuery::QueryHeader header(SecurityQuery::REQUEST,
+ SecurityQuery::INVALID_QUERY_ID);
header.json_size = 0x0FFFFFFF;
EmulateMobileMessage(header, NULL, 0);
}
@@ -329,17 +345,19 @@ TEST_F(SecurityManagerTest, GetInvalidQueryId) {
SetMockCryptoManager();
uint32_t connection_id = 0;
uint8_t session_id = 0;
- //uint8_t protocol_version = 0;
+ // uint8_t protocol_version = 0;
EXPECT_CALL(mock_session_observer, PairFromKey(key, _, _));
- EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id,_)).
- WillOnce(Return(true));
+ EXPECT_CALL(mock_session_observer,
+ ProtocolVersionUsed(connection_id, session_id, _))
+ .WillOnce(Return(true));
// Expect InternalError with ERROR_ID
EXPECT_CALL(
- mock_protocol_handler,
- SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_INVALID_QUERY_ID), is_final));
- const SecurityQuery::QueryHeader header(
- SecurityQuery::REQUEST,
- SecurityQuery::INVALID_QUERY_ID);
+ mock_protocol_handler,
+ SendMessageToMobileApp(
+ InternalErrorWithErrId(SecurityManager::ERROR_INVALID_QUERY_ID),
+ is_final));
+ const SecurityQuery::QueryHeader header(SecurityQuery::REQUEST,
+ SecurityQuery::INVALID_QUERY_ID);
const uint8_t data = 0;
EmulateMobileMessage(header, &data, 1);
}
@@ -351,10 +369,11 @@ TEST_F(SecurityManagerTest, CreateSSLContext_ServiceAlreadyProtected) {
SetMockCryptoManager();
// Return mock SSLContext
- EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl)).
- WillOnce(Return(&mock_ssl_context_new));
+ EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl))
+ .WillOnce(Return(&mock_ssl_context_new));
- const security_manager::SSLContext* rezult = security_manager_->CreateSSLContext(key);
+ const security_manager::SSLContext* rezult =
+ security_manager_->CreateSSLContext(key);
EXPECT_EQ(rezult, &mock_ssl_context_new);
}
/*
@@ -365,22 +384,24 @@ TEST_F(SecurityManagerTest, CreateSSLContext_ErrorCreateSSL) {
// Expect InternalError with ERROR_ID
uint32_t connection_id = 0;
uint8_t session_id = 0;
- //uint8_t protocol_version = 0;
+ // uint8_t protocol_version = 0;
EXPECT_CALL(mock_session_observer, PairFromKey(key, _, _));
- EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id,_)).
- WillOnce(Return(true));
+ EXPECT_CALL(mock_session_observer,
+ ProtocolVersionUsed(connection_id, session_id, _))
+ .WillOnce(Return(true));
EXPECT_CALL(
- mock_protocol_handler,
- SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_INTERNAL), is_final));
+ mock_protocol_handler,
+ SendMessageToMobileApp(
+ InternalErrorWithErrId(SecurityManager::ERROR_INTERNAL), is_final));
// Emulate SessionObserver and CryptoManager result
- EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl)).
- WillOnce(ReturnNull());
- EXPECT_CALL(mock_crypto_manager, CreateSSLContext()).
- WillOnce(ReturnNull());
+ EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl))
+ .WillOnce(ReturnNull());
+ EXPECT_CALL(mock_crypto_manager, CreateSSLContext()).WillOnce(ReturnNull());
- const security_manager::SSLContext* rezult = security_manager_->CreateSSLContext(key);
- EXPECT_EQ(NULL,rezult);
+ const security_manager::SSLContext* rezult =
+ security_manager_->CreateSSLContext(key);
+ EXPECT_EQ(NULL, rezult);
}
/*
* Shall send InternalError with SERVICE_NOT_FOUND
@@ -391,26 +412,30 @@ TEST_F(SecurityManagerTest, CreateSSLContext_SetSSLContextError) {
// Expect InternalError with ERROR_ID
uint32_t connection_id = 0;
uint8_t session_id = 0;
- //uint8_t protocol_version = 0;
+ // uint8_t protocol_version = 0;
EXPECT_CALL(mock_session_observer, PairFromKey(key, _, _));
- EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id,_)).
- WillOnce(Return(true));
+ EXPECT_CALL(mock_session_observer,
+ ProtocolVersionUsed(connection_id, session_id, _))
+ .WillOnce(Return(true));
EXPECT_CALL(
- mock_protocol_handler,
- SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_UNKNOWN_INTERNAL_ERROR), is_final));
+ mock_protocol_handler,
+ SendMessageToMobileApp(
+ InternalErrorWithErrId(SecurityManager::ERROR_UNKNOWN_INTERNAL_ERROR),
+ is_final));
// Emulate SessionObserver and CryptoManager result
- EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl)).
- WillOnce(ReturnNull());
- EXPECT_CALL(mock_crypto_manager, CreateSSLContext()).
- WillOnce(Return(&mock_ssl_context_new));
+ EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl))
+ .WillOnce(ReturnNull());
+ EXPECT_CALL(mock_crypto_manager, CreateSSLContext())
+ .WillOnce(Return(&mock_ssl_context_new));
EXPECT_CALL(mock_crypto_manager, ReleaseSSLContext(&mock_ssl_context_new));
- EXPECT_CALL(mock_session_observer, SetSSLContext(key, &mock_ssl_context_new)).
- WillOnce(Return(SecurityManager::ERROR_UNKNOWN_INTERNAL_ERROR));
+ EXPECT_CALL(mock_session_observer, SetSSLContext(key, &mock_ssl_context_new))
+ .WillOnce(Return(SecurityManager::ERROR_UNKNOWN_INTERNAL_ERROR));
- const security_manager::SSLContext* rezult = security_manager_->CreateSSLContext(key);
- EXPECT_EQ(NULL,rezult);
+ const security_manager::SSLContext* rezult =
+ security_manager_->CreateSSLContext(key);
+ EXPECT_EQ(NULL, rezult);
}
/*
* Shall protect connection on correct call CreateSSLContext
@@ -421,16 +446,18 @@ TEST_F(SecurityManagerTest, CreateSSLContext_Success) {
// Expect no notifying listeners - it will be done after handshake
// Emulate SessionObserver and CryptoManager result
- EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl)).
- WillOnce(ReturnNull()).
+ EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl))
+ .WillOnce(ReturnNull())
+ .
// additional check for debug code
WillOnce(Return(&mock_ssl_context_exists));
- EXPECT_CALL(mock_crypto_manager, CreateSSLContext()).
- WillOnce(Return(&mock_ssl_context_new));
- EXPECT_CALL(mock_session_observer, SetSSLContext(key, &mock_ssl_context_new)).
- WillOnce(Return(SecurityManager::ERROR_SUCCESS));
+ EXPECT_CALL(mock_crypto_manager, CreateSSLContext())
+ .WillOnce(Return(&mock_ssl_context_new));
+ EXPECT_CALL(mock_session_observer, SetSSLContext(key, &mock_ssl_context_new))
+ .WillOnce(Return(SecurityManager::ERROR_SUCCESS));
- const security_manager::SSLContext* rezult = security_manager_->CreateSSLContext(key);
+ const security_manager::SSLContext* rezult =
+ security_manager_->CreateSSLContext(key);
EXPECT_EQ(rezult, &mock_ssl_context_new);
}
/*
@@ -440,21 +467,24 @@ TEST_F(SecurityManagerTest, StartHandshake_ServiceStillUnprotected) {
SetMockCryptoManager();
uint32_t connection_id = 0;
uint8_t session_id = 0;
- //uint8_t protocol_version = 0;
+ // uint8_t protocol_version = 0;
EXPECT_CALL(mock_session_observer, PairFromKey(key, _, _));
- EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id,_)).
- WillOnce(Return(true));
+ EXPECT_CALL(mock_session_observer,
+ ProtocolVersionUsed(connection_id, session_id, _))
+ .WillOnce(Return(true));
// Expect InternalError with ERROR_INTERNAL
- EXPECT_CALL(mock_protocol_handler,
- SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_INTERNAL), is_final));
+ EXPECT_CALL(
+ mock_protocol_handler,
+ SendMessageToMobileApp(
+ InternalErrorWithErrId(SecurityManager::ERROR_INTERNAL), is_final));
// Expect notifying listeners (unsuccess)
EXPECT_CALL(mock_sm_listener,
- OnHandshakeDone(key, SSLContext::Handshake_Result_Fail)).
- WillOnce(Return(true));
+ OnHandshakeDone(key, SSLContext::Handshake_Result_Fail))
+ .WillOnce(Return(true));
// Emulate SessionObserver result
- EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl)).
- WillOnce(ReturnNull());
+ EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl))
+ .WillOnce(ReturnNull());
security_manager_->StartHandshake(key);
}
@@ -466,33 +496,35 @@ TEST_F(SecurityManagerTest, StartHandshake_SSLInternalError) {
uint32_t connection_id = 0;
uint8_t session_id = 0;
- //uint8_t protocol_version = 0;
+ // uint8_t protocol_version = 0;
EXPECT_CALL(mock_session_observer, PairFromKey(key, _, _));
+ EXPECT_CALL(mock_session_observer, GetHandshakeContext(key))
+ .WillOnce(Return(security_manager::SSLContext::HandshakeContext()));
EXPECT_CALL(mock_session_observer,
- GetHandshakeContext(key)).WillOnce(Return(security_manager::SSLContext::HandshakeContext()) );
- EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id,_)).
- WillOnce(Return(true));
+ ProtocolVersionUsed(connection_id, session_id, _))
+ .WillOnce(Return(true));
// Expect InternalError with ERROR_ID
EXPECT_CALL(
- mock_protocol_handler,
- SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_INTERNAL), is_final));
+ mock_protocol_handler,
+ SendMessageToMobileApp(
+ InternalErrorWithErrId(SecurityManager::ERROR_INTERNAL), is_final));
// Expect notifying listeners (unsuccess)
EXPECT_CALL(mock_sm_listener,
- OnHandshakeDone(key, SSLContext::Handshake_Result_Fail)).
- WillOnce(Return(true));
+ OnHandshakeDone(key, SSLContext::Handshake_Result_Fail))
+ .WillOnce(Return(true));
// Emulate SessionObserver result
- EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl)).
- WillOnce(Return(&mock_ssl_context_exists));
- EXPECT_CALL(mock_ssl_context_exists, IsInitCompleted()).
- WillOnce(Return(false));
+ EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl))
+ .WillOnce(Return(&mock_ssl_context_exists));
+ EXPECT_CALL(mock_ssl_context_exists, IsInitCompleted())
+ .WillOnce(Return(false));
EXPECT_CALL(mock_ssl_context_exists, SetHandshakeContext(_));
- EXPECT_CALL(mock_ssl_context_exists, StartHandshake(_, _)).
- WillOnce(DoAll(SetArgPointee<0>(handshake_data_out_pointer),
- SetArgPointee<1>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Fail)));
+ EXPECT_CALL(mock_ssl_context_exists, StartHandshake(_, _))
+ .WillOnce(
+ DoAll(SetArgPointee<0>(handshake_data_out_pointer),
+ SetArgPointee<1>(handshake_data_out_size),
+ Return(security_manager::SSLContext::Handshake_Result_Fail)));
security_manager_->StartHandshake(key);
}
@@ -503,62 +535,66 @@ TEST_F(SecurityManagerTest, StartHandshake_SSLInitIsNotComplete) {
SetMockCryptoManager();
uint32_t connection_id = 0;
uint8_t session_id = 0;
- //uint8_t protocol_version = 0;
+ // uint8_t protocol_version = 0;
EXPECT_CALL(mock_session_observer, PairFromKey(key, _, _));
+ EXPECT_CALL(mock_session_observer, GetHandshakeContext(key))
+ .Times(3)
+ .WillRepeatedly(Return(security_manager::SSLContext::HandshakeContext()));
EXPECT_CALL(mock_session_observer,
- GetHandshakeContext(key)).Times(3).WillRepeatedly(Return(security_manager::SSLContext::HandshakeContext()) );
- EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id,_)).
- WillOnce(Return(true));
+ ProtocolVersionUsed(connection_id, session_id, _))
+ .WillOnce(Return(true));
// Expect send one message (with correct pointer and size data)
EXPECT_CALL(mock_protocol_handler, SendMessageToMobileApp(_, is_final));
// Return mock SSLContext
- EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl)).Times(3).
- WillRepeatedly(Return(&mock_ssl_context_exists));
+ EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl))
+ .Times(3)
+ .WillRepeatedly(Return(&mock_ssl_context_exists));
// Expect initialization check on each call StartHandshake
- EXPECT_CALL(mock_ssl_context_exists, IsInitCompleted()).Times(3).
- WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_ssl_context_exists, IsInitCompleted())
+ .Times(3)
+ .WillRepeatedly(Return(false));
EXPECT_CALL(mock_ssl_context_exists, SetHandshakeContext(_)).Times(3);
// Emulate SSLContext::StartHandshake with different parameters
// Only on both correct - data and size shall be send message to mobile app
- EXPECT_CALL(mock_ssl_context_exists, StartHandshake(_, _)).
- WillOnce(DoAll(SetArgPointee<0>(handshake_data_out_pointer),
- SetArgPointee<1>(0),
- Return(security_manager::SSLContext::
- Handshake_Result_Success))).
- WillOnce(DoAll(SetArgPointee<0>((uint8_t*)NULL),
- SetArgPointee<1>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Success))).
- WillOnce(DoAll(SetArgPointee<0>(handshake_data_out_pointer),
- SetArgPointee<1>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Success)));
+ EXPECT_CALL(mock_ssl_context_exists, StartHandshake(_, _))
+ .WillOnce(DoAll(
+ SetArgPointee<0>(handshake_data_out_pointer), SetArgPointee<1>(0),
+ Return(security_manager::SSLContext::Handshake_Result_Success)))
+ .WillOnce(DoAll(
+ SetArgPointee<0>((uint8_t*)NULL),
+ SetArgPointee<1>(handshake_data_out_size),
+ Return(security_manager::SSLContext::Handshake_Result_Success)))
+ .WillOnce(DoAll(
+ SetArgPointee<0>(handshake_data_out_pointer),
+ SetArgPointee<1>(handshake_data_out_size),
+ Return(security_manager::SSLContext::Handshake_Result_Success)));
security_manager_->StartHandshake(key);
security_manager_->StartHandshake(key);
security_manager_->StartHandshake(key);
}
/*
- * Shall notify listeners on call StartHandshake after SSLContext initialization complete
+ * Shall notify listeners on call StartHandshake after SSLContext initialization
+ * complete
*/
TEST_F(SecurityManagerTest, StartHandshake_SSLInitIsComplete) {
SetMockCryptoManager();
// Expect no message send
// Expect notifying listeners (success)
EXPECT_CALL(mock_sm_listener,
- OnHandshakeDone(key, SSLContext::Handshake_Result_Success)).
- WillOnce(Return(true));
+ OnHandshakeDone(key, SSLContext::Handshake_Result_Success))
+ .WillOnce(Return(true));
// Emulate SessionObserver result
- EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl)).
- WillOnce(Return(&mock_ssl_context_exists));
- EXPECT_CALL(mock_ssl_context_exists, IsInitCompleted()).
- WillOnce(Return(true));
- EXPECT_CALL(mock_crypto_manager, IsCertificateUpdateRequired()).
- WillOnce(Return(false));
+ EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl))
+ .WillOnce(Return(&mock_ssl_context_exists));
+ EXPECT_CALL(mock_ssl_context_exists, IsInitCompleted())
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_crypto_manager, IsCertificateUpdateRequired())
+ .WillOnce(Return(false));
security_manager_->StartHandshake(key);
}
@@ -570,15 +606,18 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_WrongDataSize) {
SetMockCryptoManager();
uint32_t connection_id = 0;
uint8_t session_id = 0;
- //uint8_t protocol_version = 0;
+ // uint8_t protocol_version = 0;
EXPECT_CALL(mock_session_observer, PairFromKey(key, _, _));
- EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id,_)).
- WillOnce(Return(true));
+ EXPECT_CALL(mock_session_observer,
+ ProtocolVersionUsed(connection_id, session_id, _))
+ .WillOnce(Return(true));
// Expect InternalError with ERROR_ID
EXPECT_CALL(
- mock_protocol_handler,
- SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_INVALID_QUERY_SIZE), is_final));
+ mock_protocol_handler,
+ SendMessageToMobileApp(
+ InternalErrorWithErrId(SecurityManager::ERROR_INVALID_QUERY_SIZE),
+ is_final));
EmulateMobileMessageHandshake(NULL, 0);
}
/*
@@ -591,25 +630,28 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_ServiceNotProtected) {
// Expect InternalError with ERROR_ID
uint32_t connection_id = 0;
uint8_t session_id = 0;
- //uint8_t protocol_version = 0;
+ // uint8_t protocol_version = 0;
EXPECT_CALL(mock_session_observer, PairFromKey(key, _, _));
- EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id,_)).
- WillOnce(Return(true));
+ EXPECT_CALL(mock_session_observer,
+ ProtocolVersionUsed(connection_id, session_id, _))
+ .WillOnce(Return(true));
EXPECT_CALL(
- mock_protocol_handler,
- SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_SERVICE_NOT_PROTECTED), is_final));
+ mock_protocol_handler,
+ SendMessageToMobileApp(
+ InternalErrorWithErrId(SecurityManager::ERROR_SERVICE_NOT_PROTECTED),
+ is_final));
// Expect notifying listeners (unsuccess)
EXPECT_CALL(mock_sm_listener,
- OnHandshakeDone(key, SSLContext::Handshake_Result_Fail)).
- WillOnce(Return(true));
+ OnHandshakeDone(key, SSLContext::Handshake_Result_Fail))
+ .WillOnce(Return(true));
// Emulate SessionObserver result
- EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl)).
- WillOnce(ReturnNull());
+ EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl))
+ .WillOnce(ReturnNull());
const uint8_t data[] = {0x1, 0x2};
- EmulateMobileMessageHandshake(data, sizeof(data)/sizeof(data[0]));
+ EmulateMobileMessageHandshake(data, sizeof(data) / sizeof(data[0]));
}
/*
* Shall send InternallError on getting
@@ -624,52 +666,51 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_InvalidData) {
uint32_t connection_id = 0;
uint8_t session_id = 0;
- //uint8_t protocol_version = 0;
- EXPECT_CALL(mock_session_observer, PairFromKey(key, _, _)).
- Times(handshake_emulates);
- EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id,_)).
- Times(handshake_emulates).
- WillRepeatedly(Return(true));
+ // uint8_t protocol_version = 0;
+ EXPECT_CALL(mock_session_observer, PairFromKey(key, _, _))
+ .Times(handshake_emulates);
+ EXPECT_CALL(mock_session_observer,
+ ProtocolVersionUsed(connection_id, session_id, _))
+ .Times(handshake_emulates)
+ .WillRepeatedly(Return(true));
// Expect InternalError with ERROR_ID
EXPECT_CALL(
- mock_protocol_handler,
- SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_SSL_INVALID_DATA), is_final)).
- Times(handshake_emulates);
+ mock_protocol_handler,
+ SendMessageToMobileApp(
+ InternalErrorWithErrId(SecurityManager::ERROR_SSL_INVALID_DATA),
+ is_final)).Times(handshake_emulates);
// Expect notifying listeners (unsuccess)
EXPECT_CALL(mock_sm_listener,
- OnHandshakeDone(key, SSLContext::Handshake_Result_Fail)).
- WillOnce(Return(true));
+ OnHandshakeDone(key, SSLContext::Handshake_Result_Fail))
+ .WillOnce(Return(true));
// Emulate SessionObserver and CryptoManager result
- EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl)).
- Times(handshake_emulates).
- WillRepeatedly(Return(&mock_ssl_context_exists));
+ EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl))
+ .Times(handshake_emulates)
+ .WillRepeatedly(Return(&mock_ssl_context_exists));
// Emulate DoHandshakeStep fail logics
EXPECT_CALL(
- mock_ssl_context_exists, DoHandshakeStep(HandshakeStepEq(handshake_data,handshake_data_size),
- handshake_data_size, _, _)).
- WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer),
- SetArgPointee<3>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_AbnormalFail))).
- WillOnce(DoAll(SetArgPointee<2>((uint8_t*)NULL),
- SetArgPointee<3>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_AbnormalFail))).
- WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer),
- SetArgPointee<3>(0),
- Return(security_manager::SSLContext::
- Handshake_Result_AbnormalFail))).
- WillOnce(DoAll(SetArgPointee<2>((uint8_t*)NULL),
- SetArgPointee<3>(0),
- Return(security_manager::SSLContext::
- Handshake_Result_AbnormalFail)));
-
+ mock_ssl_context_exists,
+ DoHandshakeStep(HandshakeStepEq(handshake_data, handshake_data_size),
+ handshake_data_size, _, _))
+ .WillOnce(DoAll(
+ SetArgPointee<2>(handshake_data_out_pointer),
+ SetArgPointee<3>(handshake_data_out_size),
+ Return(security_manager::SSLContext::Handshake_Result_AbnormalFail)))
+ .WillOnce(DoAll(
+ SetArgPointee<2>((uint8_t*)NULL),
+ SetArgPointee<3>(handshake_data_out_size),
+ Return(security_manager::SSLContext::Handshake_Result_AbnormalFail)))
+ .WillOnce(DoAll(
+ SetArgPointee<2>(handshake_data_out_pointer), SetArgPointee<3>(0),
+ Return(security_manager::SSLContext::Handshake_Result_AbnormalFail)))
+ .WillOnce(DoAll(
+ SetArgPointee<2>((uint8_t*)NULL), SetArgPointee<3>(0),
+ Return(security_manager::SSLContext::Handshake_Result_AbnormalFail)));
// On each wrong handshake will be asked error
- EXPECT_CALL(mock_ssl_context_exists, LastError()).
- Times(handshake_emulates);
+ EXPECT_CALL(mock_ssl_context_exists, LastError()).Times(handshake_emulates);
// Emulate handshare #handshake_emulates times for 5 cases
EmulateMobileMessageHandshake(handshake_data, handshake_data_size,
@@ -686,44 +727,45 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_Answer) {
uint32_t connection_id = 0;
uint8_t session_id = 0;
- //uint8_t protocol_version = 0;
- EXPECT_CALL(mock_session_observer, PairFromKey(key, _, _)).
- Times(handshake_emulates);
- EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id,_)).
- Times(handshake_emulates).
- WillRepeatedly(Return(true));
+ // uint8_t protocol_version = 0;
+ EXPECT_CALL(mock_session_observer, PairFromKey(key, _, _))
+ .Times(handshake_emulates);
+ EXPECT_CALL(mock_session_observer,
+ ProtocolVersionUsed(connection_id, session_id, _))
+ .Times(handshake_emulates)
+ .WillRepeatedly(Return(true));
// Get size of raw message after
const size_t raw_message_size = 15;
- EXPECT_CALL(mock_protocol_handler, SendMessageToMobileApp(
- RawMessageEqSize(raw_message_size), is_final)).
- Times(handshake_emulates);
+ EXPECT_CALL(mock_protocol_handler,
+ SendMessageToMobileApp(RawMessageEqSize(raw_message_size),
+ is_final)).Times(handshake_emulates);
// Expect notifying listeners (unsuccess)
EXPECT_CALL(mock_sm_listener,
- OnHandshakeDone(key, SSLContext::Handshake_Result_Fail)).
- WillOnce(Return(true));
+ OnHandshakeDone(key, SSLContext::Handshake_Result_Fail))
+ .WillOnce(Return(true));
// Emulate SessionObserver and CryptoManager result
- EXPECT_CALL(mock_ssl_context_exists, IsInitCompleted()).
- Times(handshake_emulates).
- WillRepeatedly(Return(false));
- EXPECT_CALL(
- mock_session_observer, GetSSLContext(key, kControl)).
- Times(handshake_emulates).
- WillRepeatedly(Return(&mock_ssl_context_exists));
+ EXPECT_CALL(mock_ssl_context_exists, IsInitCompleted())
+ .Times(handshake_emulates)
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl))
+ .Times(handshake_emulates)
+ .WillRepeatedly(Return(&mock_ssl_context_exists));
// Emulate DoHandshakeStep correct logics
EXPECT_CALL(
- mock_ssl_context_exists, DoHandshakeStep(HandshakeStepEq(handshake_data,handshake_data_size),
- handshake_data_size, _, _)).
- WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer),
- SetArgPointee<3>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Success))).
- WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer),
- SetArgPointee<3>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Fail)));
+ mock_ssl_context_exists,
+ DoHandshakeStep(HandshakeStepEq(handshake_data, handshake_data_size),
+ handshake_data_size, _, _))
+ .WillOnce(DoAll(
+ SetArgPointee<2>(handshake_data_out_pointer),
+ SetArgPointee<3>(handshake_data_out_size),
+ Return(security_manager::SSLContext::Handshake_Result_Success)))
+ .WillOnce(
+ DoAll(SetArgPointee<2>(handshake_data_out_pointer),
+ SetArgPointee<3>(handshake_data_out_size),
+ Return(security_manager::SSLContext::Handshake_Result_Fail)));
EmulateMobileMessageHandshake(handshake_data, handshake_data_size,
handshake_emulates);
@@ -739,68 +781,68 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_HandshakeFinished) {
const int handshake_emulates = 6;
// Expect no errors
// Expect notifying listeners (success)
- EXPECT_CALL(mock_sm_listener, OnHandshakeDone(key,
- SSLContext::Handshake_Result_Success)).
- WillOnce(Return(true));
+ EXPECT_CALL(mock_sm_listener,
+ OnHandshakeDone(key, SSLContext::Handshake_Result_Success))
+ .WillOnce(Return(true));
// Emulate SessionObserver and CryptoManager result
- EXPECT_CALL(
- mock_session_observer, GetSSLContext(key, kControl)).
- Times(handshake_emulates).
- WillRepeatedly(Return(&mock_ssl_context_exists));
- EXPECT_CALL(
- mock_ssl_context_exists, IsInitCompleted()).
- Times(handshake_emulates).
- WillRepeatedly(Return(true));
+ EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl))
+ .Times(handshake_emulates)
+ .WillRepeatedly(Return(&mock_ssl_context_exists));
+ EXPECT_CALL(mock_ssl_context_exists, IsInitCompleted())
+ .Times(handshake_emulates)
+ .WillRepeatedly(Return(true));
EXPECT_CALL(
- mock_ssl_context_exists, DoHandshakeStep(HandshakeStepEq(handshake_data,handshake_data_size),
- handshake_data_size, _, _)).
- // two states with correct out data
- WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer),
- SetArgPointee<3>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Success))).
- WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer),
- SetArgPointee<3>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Fail))).
- // two states with with null pointer data
- WillOnce(DoAll(SetArgPointee<2>((uint8_t*)NULL),
- SetArgPointee<3>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Success))).
- WillOnce(DoAll(SetArgPointee<2>((uint8_t*)NULL),
- SetArgPointee<3>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Fail))).
- // two states with with null data size
- WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer),
- SetArgPointee<3>(0),
- Return(security_manager::SSLContext::
- Handshake_Result_Success))).
- WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer),
- SetArgPointee<3>(0),
- Return(security_manager::SSLContext::
- Handshake_Result_Success)));
+ mock_ssl_context_exists,
+ DoHandshakeStep(HandshakeStepEq(handshake_data, handshake_data_size),
+ handshake_data_size, _, _))
+ .
+ // two states with correct out data
+ WillOnce(DoAll(
+ SetArgPointee<2>(handshake_data_out_pointer),
+ SetArgPointee<3>(handshake_data_out_size),
+ Return(security_manager::SSLContext::Handshake_Result_Success)))
+ .WillOnce(
+ DoAll(SetArgPointee<2>(handshake_data_out_pointer),
+ SetArgPointee<3>(handshake_data_out_size),
+ Return(security_manager::SSLContext::Handshake_Result_Fail)))
+ .
+ // two states with with null pointer data
+ WillOnce(DoAll(
+ SetArgPointee<2>((uint8_t*)NULL),
+ SetArgPointee<3>(handshake_data_out_size),
+ Return(security_manager::SSLContext::Handshake_Result_Success)))
+ .WillOnce(
+ DoAll(SetArgPointee<2>((uint8_t*)NULL),
+ SetArgPointee<3>(handshake_data_out_size),
+ Return(security_manager::SSLContext::Handshake_Result_Fail)))
+ .
+ // two states with with null data size
+ WillOnce(DoAll(
+ SetArgPointee<2>(handshake_data_out_pointer), SetArgPointee<3>(0),
+ Return(security_manager::SSLContext::Handshake_Result_Success)))
+ .WillOnce(DoAll(
+ SetArgPointee<2>(handshake_data_out_pointer), SetArgPointee<3>(0),
+ Return(security_manager::SSLContext::Handshake_Result_Success)));
// Expect send two message (with correct pointer and size data)
uint32_t connection_id = 0;
uint8_t session_id = 0;
- //uint8_t protocol_version = 0;
- EXPECT_CALL(mock_session_observer, PairFromKey(key, _, _)).
- Times(2);
- EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id,_)).
- Times(2).
- WillRepeatedly(Return(true));
+ // uint8_t protocol_version = 0;
+ EXPECT_CALL(mock_session_observer, PairFromKey(key, _, _)).Times(2);
+ EXPECT_CALL(mock_session_observer,
+ ProtocolVersionUsed(connection_id, session_id, _))
+ .Times(2)
+ .WillRepeatedly(Return(true));
- EXPECT_CALL(
- mock_protocol_handler, SendMessageToMobileApp(_, is_final)).
- Times(2);
+ EXPECT_CALL(mock_protocol_handler, SendMessageToMobileApp(_, is_final))
+ .Times(2);
// Expect NO InternalError with ERROR_ID
- EmulateMobileMessageHandshake(handshake_data, handshake_data_size, handshake_emulates);
+ EmulateMobileMessageHandshake(handshake_data, handshake_data_size,
+ handshake_emulates);
}
/*
* Shall not any query on getting empty SEND_INTERNAL_ERROR
@@ -808,8 +850,8 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_HandshakeFinished) {
TEST_F(SecurityManagerTest, GetInternalError_NullData) {
SetMockCryptoManager();
- const SecurityQuery::QueryHeader header( SecurityQuery::NOTIFICATION,
- SecurityQuery::SEND_INTERNAL_ERROR, 0);
+ const SecurityQuery::QueryHeader header(
+ SecurityQuery::NOTIFICATION, SecurityQuery::SEND_INTERNAL_ERROR, 0);
EmulateMobileMessage(header, NULL, 0);
}
/*
@@ -818,10 +860,10 @@ TEST_F(SecurityManagerTest, GetInternalError_NullData) {
TEST_F(SecurityManagerTest, GetInternalError) {
SetMockCryptoManager();
- const SecurityQuery::QueryHeader header( SecurityQuery::NOTIFICATION,
- SecurityQuery::SEND_INTERNAL_ERROR, 0);
+ const SecurityQuery::QueryHeader header(
+ SecurityQuery::NOTIFICATION, SecurityQuery::SEND_INTERNAL_ERROR, 0);
const uint8_t data[] = {0x1, 0x2};
- EmulateMobileMessage(header, data, sizeof(data)/sizeof(data[0]));
+ EmulateMobileMessage(header, data, sizeof(data) / sizeof(data[0]));
}
/*
* Shall not send any query on getting SEND_INTERNAL_ERROR with error string
@@ -829,12 +871,11 @@ TEST_F(SecurityManagerTest, GetInternalError) {
TEST_F(SecurityManagerTest, GetInternalError_WithErrText) {
SetMockCryptoManager();
- SecurityQuery::QueryHeader header( SecurityQuery::NOTIFICATION,
- SecurityQuery::SEND_INTERNAL_ERROR, 0);
+ SecurityQuery::QueryHeader header(SecurityQuery::NOTIFICATION,
+ SecurityQuery::SEND_INTERNAL_ERROR, 0);
std::string error("JSON wrong string");
header.json_size = error.size();
- EmulateMobileMessage(header,
- reinterpret_cast<const uint8_t*>(error.c_str()),
+ EmulateMobileMessage(header, reinterpret_cast<const uint8_t*>(error.c_str()),
error.size());
}
/*
@@ -843,15 +884,14 @@ TEST_F(SecurityManagerTest, GetInternalError_WithErrText) {
TEST_F(SecurityManagerTest, GetInternalError_WithErrJSONText) {
SetMockCryptoManager();
- SecurityQuery::QueryHeader header( SecurityQuery::NOTIFICATION,
- SecurityQuery::SEND_INTERNAL_ERROR, 0);
+ SecurityQuery::QueryHeader header(SecurityQuery::NOTIFICATION,
+ SecurityQuery::SEND_INTERNAL_ERROR, 0);
std::string error(" { \"id\": 1 } ");
header.json_size = error.size();
- EmulateMobileMessage(header,
- reinterpret_cast<const uint8_t*>(error.c_str()),
+ EmulateMobileMessage(header, reinterpret_cast<const uint8_t*>(error.c_str()),
error.size());
}
-} // namespace security_manager_test
-} // namespace components
-} // namespace test
+} // namespace security_manager_test
+} // namespace components
+} // namespace test
diff --git a/src/components/security_manager/test/security_query_matcher.cc b/src/components/security_manager/test/security_query_matcher.cc
index 27ac9fb0db..9f6bc370e7 100644
--- a/src/components/security_manager/test/security_query_matcher.cc
+++ b/src/components/security_manager/test/security_query_matcher.cc
@@ -45,80 +45,76 @@ namespace security_manager_test {
* Check error id
*/
MATCHER_P(InternalErrorWithErrId, expectedErrorId,
- std::string(negation ? "is not" : "is")
- + " InternalError with selected error" ){
+ std::string(negation ? "is not" : "is") +
+ " InternalError with selected error") {
const size_t header_size =
- sizeof(security_manager::SecurityQuery::QueryHeader);
+ sizeof(security_manager::SecurityQuery::QueryHeader);
if (arg->data_size() <= header_size) {
*result_listener << "Size " << arg->data_size()
- << " bytes less or equal sizeof(QueryHeader)="
- << header_size;
+ << " bytes less or equal sizeof(QueryHeader)="
+ << header_size;
return false;
}
- const uint8_t *data = arg->data();
+ const uint8_t* data = arg->data();
const uint8_t query_type = data[0];
if (security_manager::SecurityQuery::NOTIFICATION != query_type) {
- *result_listener << "RawMessage is not notification, type=0x"
- << std::hex << static_cast<int>(query_type);
+ *result_listener << "RawMessage is not notification, type=0x" << std::hex
+ << static_cast<int>(query_type);
return false;
}
// Read Big-Endian number
- const uint32_t query_id = data[1] << 16 |
- data[2] << 8 |
- data[3];
+ const uint32_t query_id = data[1] << 16 | data[2] << 8 | data[3];
if (security_manager::SecurityQuery::SEND_INTERNAL_ERROR != query_id) {
- *result_listener << "Notification is not InternalError, id=0x"
- << std::hex << query_id;
+ *result_listener << "Notification is not InternalError, id=0x" << std::hex
+ << query_id;
return false;
}
- const uint32_t json_size = data[8] << 24 |
- data[9] << 16 |
- data[10] << 8 |
- data[11];
+ const uint32_t json_size =
+ data[8] << 24 | data[9] << 16 | data[10] << 8 | data[11];
if (header_size + json_size >= arg->data_size()) {
*result_listener << "InternalError contains only JSON data.";
return false;
}
// Read err_id as bin data number
- const uint8_t *err_id =
- reinterpret_cast<const uint8_t *>(data + header_size + json_size);
+ const uint8_t* err_id =
+ reinterpret_cast<const uint8_t*>(data + header_size + json_size);
if (expectedErrorId != *err_id) {
*result_listener << "InternalError id " << static_cast<int>(*err_id)
- << " and not equal error " << expectedErrorId;
+ << " and not equal error " << expectedErrorId;
return false;
}
return true;
}
-} // namespace security_manager_test
-} // namespace components
-} // namespace test
-/*
- * Matcher for checking QueryHeader equal in GTests
- */
+} // namespace security_manager_test
+} // namespace components
+} // namespace test
+ /*
+ * Matcher for checking QueryHeader equal in GTests
+ */
::testing::AssertionResult QueryHeader_EQ(
- const char *m_expr, const char *n_expr,
- const ::security_manager::SecurityQuery::QueryHeader &q1,
- const ::security_manager::SecurityQuery::QueryHeader &q2);
+ const char* m_expr, const char* n_expr,
+ const ::security_manager::SecurityQuery::QueryHeader& q1,
+ const ::security_manager::SecurityQuery::QueryHeader& q2);
::testing::AssertionResult QueryHeader_EQ(
- const char* m_expr, const char* n_expr,
- const ::security_manager::SecurityQuery::QueryHeader& q1,
- const ::security_manager::SecurityQuery::QueryHeader& q2) {
+ const char* m_expr, const char* n_expr,
+ const ::security_manager::SecurityQuery::QueryHeader& q1,
+ const ::security_manager::SecurityQuery::QueryHeader& q2) {
::testing::AssertionResult fail_result = ::testing::AssertionFailure();
fail_result << "(\"" << m_expr << " and \"" << n_expr << "\") are not equal "
<< " : different ";
if (q1.json_size != q2.json_size)
- return fail_result << "json_size_1=" << q1.json_size << ", json_size_2="
- << q2.json_size;
+ return fail_result << "json_size_1=" << q1.json_size
+ << ", json_size_2=" << q2.json_size;
if (q1.query_id != q2.query_id)
- return fail_result << "query_id_1=" << q1.query_id << ", query_id_2="
- << q2.query_id;
+ return fail_result << "query_id_1=" << q1.query_id
+ << ", query_id_2=" << q2.query_id;
if (q1.query_type != q2.query_type)
- return fail_result << "query_type_1=" << q1.query_type << ", query_type_2="
- << q2.query_type;
+ return fail_result << "query_type_1=" << q1.query_type
+ << ", query_type_2=" << q2.query_type;
if (q1.seq_number != q2.seq_number)
- return fail_result << "seq_number_1=" << q1.seq_number << ", seq_number_2="
- << q2.seq_number;
+ return fail_result << "seq_number_1=" << q1.seq_number
+ << ", seq_number_2=" << q2.seq_number;
return ::testing::AssertionSuccess();
}
diff --git a/src/components/security_manager/test/security_query_test.cc b/src/components/security_manager/test/security_query_test.cc
index c17c3bc393..d4ef95400f 100644
--- a/src/components/security_manager/test/security_query_test.cc
+++ b/src/components/security_manager/test/security_query_test.cc
@@ -40,7 +40,7 @@
#include "security_manager/mock_security_manager.h"
// Test values for compare after serialization and byteorder conversion
-#define SEQ_NUMBER 0x12345678u
+#define SEQ_NUMBER 0x12345678u
#define CONNECTION_KEY 0xABCDEF0u
namespace test {
@@ -69,7 +69,7 @@ class SecurityQueryTest : public ::testing::Test {
* Used for handling header and data array to byte array for serialization
*/
std::vector<uint8_t> DeserializeData(SecurityQuery::QueryHeader header,
- const uint8_t * const binary_data,
+ const uint8_t* const binary_data,
const size_t bin_data_size) const {
// convert to Big-Endian (network) order
const uint32_t query_id = header.query_id << 8;
@@ -92,8 +92,8 @@ class SecurityQueryTest : public ::testing::Test {
* for correct working on Mobile side (3*8 byte)
*/
TEST_F(SecurityQueryTest, Equal_RPCHeader) {
- ASSERT_EQ(sizeof(SecurityQuery::QueryHeader)*8,
- ::protocol_handler::ProtocolPayloadV2SizeBits());
+ ASSERT_EQ(sizeof(SecurityQuery::QueryHeader) * 8,
+ ::protocol_handler::ProtocolPayloadV2SizeBits());
}
/*
* Security QueryHeader default construction
@@ -108,16 +108,16 @@ TEST_F(SecurityQueryTest, QueryHeaderConstructor) {
*/
TEST_F(SecurityQueryTest, QueryHeaderConstructor2) {
SecurityQuery::QueryHeader new_header(SecurityQuery::NOTIFICATION,
- SecurityQuery::SEND_HANDSHAKE_DATA,
- SEQ_NUMBER);
+ SecurityQuery::SEND_HANDSHAKE_DATA,
+ SEQ_NUMBER);
ASSERT_EQ(new_header.query_type, SecurityQuery::NOTIFICATION);
ASSERT_EQ(new_header.query_id, SecurityQuery::SEND_HANDSHAKE_DATA);
ASSERT_EQ(new_header.seq_number, SEQ_NUMBER);
ASSERT_EQ(new_header.json_size, 0u);
SecurityQuery::QueryHeader new_header2(SecurityQuery::RESPONSE,
- SecurityQuery::SEND_INTERNAL_ERROR,
- SEQ_NUMBER + 1);
+ SecurityQuery::SEND_INTERNAL_ERROR,
+ SEQ_NUMBER + 1);
ASSERT_EQ(new_header2.query_type, SecurityQuery::RESPONSE);
ASSERT_EQ(new_header2.query_id, SecurityQuery::SEND_INTERNAL_ERROR);
ASSERT_EQ(new_header2.seq_number, SEQ_NUMBER + 1);
@@ -139,7 +139,7 @@ TEST_F(SecurityQueryTest, QueryConstructor) {
ASSERT_EQ(query.get_connection_key(), 0u);
ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
+ ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t*>(NULL));
ASSERT_TRUE(query.get_json_message().empty());
EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), invalid_header);
@@ -156,7 +156,7 @@ TEST_F(SecurityQueryTest, QueryConstructor2) {
ASSERT_EQ(query.get_connection_key(), CONNECTION_KEY);
ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
+ ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t*>(NULL));
ASSERT_TRUE(query.get_json_message().empty());
EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), init_header);
@@ -170,17 +170,14 @@ TEST_F(SecurityQueryTest, QueryConstructor2) {
*/
TEST_F(SecurityQueryTest, QueryConstructor3) {
uint8_t raw_data[] = {0x0, 0x1, 0x2};
- const size_t raw_data_size =
- sizeof(raw_data)/sizeof(raw_data[0]);
+ const size_t raw_data_size = sizeof(raw_data) / sizeof(raw_data[0]);
- SecurityQuery query(init_header,
- CONNECTION_KEY,
- raw_data, raw_data_size);
+ SecurityQuery query(init_header, CONNECTION_KEY, raw_data, raw_data_size);
ASSERT_EQ(query.get_connection_key(), CONNECTION_KEY);
ASSERT_EQ(query.get_data_size(), raw_data_size);
// query shall handle own array of byte data
- ASSERT_NE(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
+ ASSERT_NE(query.get_data(), reinterpret_cast<uint8_t*>(NULL));
for (size_t i = 0; i < raw_data_size; ++i) {
ASSERT_EQ(query.get_data()[i], raw_data[i]);
}
@@ -189,7 +186,7 @@ TEST_F(SecurityQueryTest, QueryConstructor3) {
// Deserialization shall return vector equal header + data array
const std::vector<uint8_t> vector =
- DeserializeData(init_header, raw_data, raw_data_size);
+ DeserializeData(init_header, raw_data, raw_data_size);
const std::vector<uint8_t> deserialize_vector = query.DeserializeQuery();
ASSERT_EQ(deserialize_vector, vector);
}
@@ -199,8 +196,7 @@ TEST_F(SecurityQueryTest, QueryConstructor3) {
TEST_F(SecurityQueryTest, Setters) {
const std::string str = "test example string";
uint8_t raw_data[] = {0x6, 0x7, 0x8};
- const size_t raw_data_size =
- sizeof(raw_data)/sizeof(raw_data[0]);
+ const size_t raw_data_size = sizeof(raw_data) / sizeof(raw_data[0]);
SecurityQuery query;
query.set_connection_key(CONNECTION_KEY);
@@ -211,7 +207,7 @@ TEST_F(SecurityQueryTest, Setters) {
ASSERT_EQ(query.get_connection_key(), CONNECTION_KEY);
ASSERT_EQ(query.get_data_size(), raw_data_size);
// query shall handle own array of byte data
- ASSERT_NE(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
+ ASSERT_NE(query.get_data(), reinterpret_cast<uint8_t*>(NULL));
for (size_t i = 0; i < raw_data_size; ++i) {
ASSERT_EQ(query.get_data()[i], raw_data[i]);
}
@@ -229,7 +225,7 @@ TEST_F(SecurityQueryTest, Parse_NullData) {
// check side-effects
ASSERT_EQ(query.get_connection_key(), 0u);
ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
+ ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t*>(NULL));
ASSERT_TRUE(query.get_json_message().empty());
EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), invalid_header);
}
@@ -246,7 +242,7 @@ TEST_F(SecurityQueryTest, Parse_LessHeaderData) {
// check side-effects
ASSERT_EQ(query.get_connection_key(), 0u);
ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
+ ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t*>(NULL));
ASSERT_TRUE(query.get_json_message().empty());
EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), invalid_header);
}
@@ -254,8 +250,7 @@ TEST_F(SecurityQueryTest, Parse_LessHeaderData) {
* SecurityQuery serializes data equal header size
*/
TEST_F(SecurityQueryTest, Parse_HeaderData) {
- const std::vector<uint8_t> vector =
- DeserializeData(init_header, NULL, 0u);
+ const std::vector<uint8_t> vector = DeserializeData(init_header, NULL, 0u);
SecurityQuery query;
const bool result = query.SerializeQuery(&vector[0], vector.size());
@@ -264,7 +259,7 @@ TEST_F(SecurityQueryTest, Parse_HeaderData) {
// check side-effects
ASSERT_EQ(query.get_connection_key(), 0u);
ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
+ ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t*>(NULL));
ASSERT_TRUE(query.get_json_message().empty());
EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), init_header);
@@ -278,8 +273,7 @@ TEST_F(SecurityQueryTest, Parse_HeaderData) {
TEST_F(SecurityQueryTest, Parse_HeaderDataWrong) {
// Wrong json size
init_header.json_size = 0x0FFFFFFF;
- const std::vector<uint8_t> vector =
- DeserializeData(init_header, NULL, 0u);
+ const std::vector<uint8_t> vector = DeserializeData(init_header, NULL, 0u);
SecurityQuery query;
const bool result = query.SerializeQuery(&vector[0], vector.size());
@@ -288,7 +282,7 @@ TEST_F(SecurityQueryTest, Parse_HeaderDataWrong) {
// check side-effects
ASSERT_EQ(query.get_connection_key(), 0u);
ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
+ ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t*>(NULL));
ASSERT_TRUE(query.get_json_message().empty());
EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), init_header);
@@ -302,17 +296,15 @@ TEST_F(SecurityQueryTest, Parse_HeaderDataWrong) {
*/
TEST_F(SecurityQueryTest, Parse_InvalidQuery) {
SecurityQuery::QueryHeader invalid_query_header(
- SecurityQuery::INVALID_QUERY_TYPE,
- SecurityQuery::INVALID_QUERY_ID,
+ SecurityQuery::INVALID_QUERY_TYPE, SecurityQuery::INVALID_QUERY_ID,
SEQ_NUMBER);
// some sample data
uint8_t raw_data[] = {0x6, 0x7, 0x8};
- const size_t raw_data_size =
- sizeof(raw_data)/sizeof(raw_data[0]);
+ const size_t raw_data_size = sizeof(raw_data) / sizeof(raw_data[0]);
const std::vector<uint8_t> vector =
- DeserializeData(invalid_query_header, raw_data, raw_data_size);
+ DeserializeData(invalid_query_header, raw_data, raw_data_size);
SecurityQuery query;
const bool result = query.SerializeQuery(&vector[0], vector.size());
@@ -321,9 +313,9 @@ TEST_F(SecurityQueryTest, Parse_InvalidQuery) {
EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), invalid_query_header);
ASSERT_EQ(query.get_data_size(), raw_data_size);
// query shall handle own array of byte data
- ASSERT_NE(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
+ ASSERT_NE(query.get_data(), reinterpret_cast<uint8_t*>(NULL));
for (size_t i = 0; i < raw_data_size; ++i) {
- ASSERT_EQ(query.get_data()[i], raw_data[+ i]);
+ ASSERT_EQ(query.get_data()[i], raw_data[+i]);
}
// check side-effects
ASSERT_EQ(query.get_connection_key(), 0u);
@@ -341,11 +333,10 @@ TEST_F(SecurityQueryTest, Parse_InvalidQuery_UnknownTypeId) {
SecurityQuery::QueryHeader invalid_type_id_header(
SecurityQuery::INVALID_QUERY_TYPE - 1,
// Use not enum value for additional testing
- SecurityQuery::INVALID_QUERY_ID - 1,
- SEQ_NUMBER);
+ SecurityQuery::INVALID_QUERY_ID - 1, SEQ_NUMBER);
const std::vector<uint8_t> vector =
- DeserializeData(invalid_type_id_header, NULL, 0u);
+ DeserializeData(invalid_type_id_header, NULL, 0u);
SecurityQuery query;
const bool result = query.SerializeQuery(&vector[0], vector.size());
@@ -353,10 +344,11 @@ TEST_F(SecurityQueryTest, Parse_InvalidQuery_UnknownTypeId) {
// Parse set all unknown types and ids to INVALID_QUERY_ID
invalid_type_id_header.query_type = SecurityQuery::INVALID_QUERY_TYPE;
invalid_type_id_header.query_id = SecurityQuery::INVALID_QUERY_ID;
- EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), invalid_type_id_header);
+ EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(),
+ invalid_type_id_header);
// check side-effects
ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
+ ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t*>(NULL));
ASSERT_EQ(query.get_connection_key(), 0u);
ASSERT_TRUE(query.get_json_message().empty());
}
@@ -368,10 +360,9 @@ TEST_F(SecurityQueryTest, Parse_InvalidQuery_UnknownId_Response) {
SecurityQuery::QueryHeader invalid_id_header(
SecurityQuery::RESPONSE,
// Use not enum value for additional testing
- SecurityQuery::INVALID_QUERY_ID - 2,
- SEQ_NUMBER);
+ SecurityQuery::INVALID_QUERY_ID - 2, SEQ_NUMBER);
const std::vector<uint8_t> vector =
- DeserializeData(invalid_id_header, NULL, 0u);
+ DeserializeData(invalid_id_header, NULL, 0u);
SecurityQuery query;
const bool result = query.SerializeQuery(&vector[0], vector.size());
@@ -381,7 +372,7 @@ TEST_F(SecurityQueryTest, Parse_InvalidQuery_UnknownId_Response) {
EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), invalid_id_header);
// check side-effects
ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
+ ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t*>(NULL));
ASSERT_EQ(query.get_connection_key(), 0u);
ASSERT_TRUE(query.get_json_message().empty());
}
@@ -391,16 +382,14 @@ TEST_F(SecurityQueryTest, Parse_InvalidQuery_UnknownId_Response) {
*/
TEST_F(SecurityQueryTest, Parse_Handshake) {
SecurityQuery::QueryHeader handshake_header(
- SecurityQuery::NOTIFICATION,
- SecurityQuery::SEND_HANDSHAKE_DATA,
+ SecurityQuery::NOTIFICATION, SecurityQuery::SEND_HANDSHAKE_DATA,
SEQ_NUMBER);
// some sample data
uint8_t raw_data[] = {0x6, 0x7, 0x8};
- const size_t raw_data_size =
- sizeof(raw_data)/sizeof(raw_data[0]);
+ const size_t raw_data_size = sizeof(raw_data) / sizeof(raw_data[0]);
const std::vector<uint8_t> vector =
- DeserializeData(handshake_header, raw_data, raw_data_size);
+ DeserializeData(handshake_header, raw_data, raw_data_size);
SecurityQuery query;
const bool result = query.SerializeQuery(&vector[0], vector.size());
@@ -408,9 +397,9 @@ TEST_F(SecurityQueryTest, Parse_Handshake) {
EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), handshake_header);
ASSERT_EQ(query.get_data_size(), raw_data_size);
// query shall handle own array of byte data
- ASSERT_NE(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
+ ASSERT_NE(query.get_data(), reinterpret_cast<uint8_t*>(NULL));
for (size_t i = 0; i < raw_data_size; ++i) {
- ASSERT_EQ(query.get_data()[i], raw_data[+ i]);
+ ASSERT_EQ(query.get_data()[i], raw_data[+i]);
}
// check side-effects
ASSERT_EQ(query.get_connection_key(), 0u);
@@ -427,23 +416,22 @@ TEST_F(SecurityQueryTest, Parse_Handshake) {
TEST_F(SecurityQueryTest, Parse_InternalError) {
std::string error_str = "{some error}";
SecurityQuery::QueryHeader internal_error_header(
- SecurityQuery::REQUEST,
- SecurityQuery::SEND_INTERNAL_ERROR,
- SEQ_NUMBER);
+ SecurityQuery::REQUEST, SecurityQuery::SEND_INTERNAL_ERROR, SEQ_NUMBER);
internal_error_header.json_size = error_str.size();
const uint8_t* raw_data = reinterpret_cast<const uint8_t*>(error_str.c_str());
const std::vector<uint8_t> vector =
- DeserializeData(internal_error_header, raw_data, error_str.size());
+ DeserializeData(internal_error_header, raw_data, error_str.size());
SecurityQuery query;
const bool result = query.SerializeQuery(&vector[0], vector.size());
ASSERT_TRUE(result);
- EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), internal_error_header);
+ EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(),
+ internal_error_header);
// check side-effects
ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
+ ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t*>(NULL));
ASSERT_EQ(query.get_connection_key(), 0u);
ASSERT_EQ(query.get_json_message(), error_str);
@@ -452,6 +440,6 @@ TEST_F(SecurityQueryTest, Parse_InternalError) {
ASSERT_EQ(deserialize_vector, vector);
}
-} // namespace security_manager_test
-} // namespace components
-} // namespace test
+} // namespace security_manager_test
+} // namespace components
+} // namespace test
diff --git a/src/components/security_manager/test/ssl_certificate_handshake_test.cc b/src/components/security_manager/test/ssl_certificate_handshake_test.cc
index f7bc1d62e5..1a02c5f543 100644
--- a/src/components/security_manager/test/ssl_certificate_handshake_test.cc
+++ b/src/components/security_manager/test/ssl_certificate_handshake_test.cc
@@ -85,10 +85,10 @@ class SSLHandshakeTest : public testing::Test {
}
bool InitServerManagers(security_manager::Protocol protocol,
- const std::string &cert_filename,
- const std::string &ciphers_list,
+ const std::string& cert_filename,
+ const std::string& ciphers_list,
const bool verify_peer,
- const std::string &cacertificate_path) {
+ const std::string& cacertificate_path) {
std::ifstream cert(cert_filename);
std::stringstream ss;
ss << cert.rdbuf();
@@ -113,10 +113,10 @@ class SSLHandshakeTest : public testing::Test {
}
bool InitClientManagers(security_manager::Protocol protocol,
- const std::string &cert_filename,
- const std::string &ciphers_list,
+ const std::string& cert_filename,
+ const std::string& ciphers_list,
const bool verify_peer,
- const std::string &cacertificate_path) {
+ const std::string& cacertificate_path) {
std::ifstream cert(cert_filename);
std::stringstream ss;
ss << cert.rdbuf();
@@ -245,13 +245,13 @@ class SSLHandshakeTest : public testing::Test {
FAIL() << "Expected client side handshake fail";
}
- security_manager::CryptoManager *server_manager;
- security_manager::CryptoManager *client_manager;
- security_manager::SSLContext *server_ctx;
- security_manager::SSLContext *client_ctx;
+ security_manager::CryptoManager* server_manager;
+ security_manager::CryptoManager* client_manager;
+ security_manager::SSLContext* server_ctx;
+ security_manager::SSLContext* client_ctx;
- const uint8_t *server_buf;
- const uint8_t *client_buf;
+ const uint8_t* server_buf;
+ const uint8_t* client_buf;
size_t server_buf_len;
size_t client_buf_len;
};
diff --git a/src/components/security_manager/test/ssl_context_test.cc b/src/components/security_manager/test/ssl_context_test.cc
index 762d8a0a9c..7bf60239d8 100644
--- a/src/components/security_manager/test/ssl_context_test.cc
+++ b/src/components/security_manager/test/ssl_context_test.cc
@@ -32,10 +32,10 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <openssl/ssl.h>
#include <fcntl.h>
#include <unistd.h>
#include <fstream>
-#include <openssl/ssl.h>
#include "gtest/gtest.h"
#include "security_manager/crypto_manager.h"
@@ -103,20 +103,20 @@ class SSLTest : public testing::Test {
client_manager->ReleaseSSLContext(client_ctx);
}
- static security_manager::CryptoManager *crypto_manager;
- static security_manager::CryptoManager *client_manager;
- security_manager::SSLContext *server_ctx;
- security_manager::SSLContext *client_ctx;
+ static security_manager::CryptoManager* crypto_manager;
+ static security_manager::CryptoManager* client_manager;
+ security_manager::SSLContext* server_ctx;
+ security_manager::SSLContext* client_ctx;
};
-security_manager::CryptoManager *SSLTest::crypto_manager;
-security_manager::CryptoManager *SSLTest::client_manager;
+security_manager::CryptoManager* SSLTest::crypto_manager;
+security_manager::CryptoManager* SSLTest::client_manager;
// TODO(EZAMAKHOV): Split to SSL/TLS1/TLS1_1/TLS1_2 tests
TEST_F(SSLTest, BrokenHandshake) {
- const uint8_t *server_buf;
- const uint8_t *client_buf;
+ const uint8_t* server_buf;
+ const uint8_t* client_buf;
size_t server_buf_len;
size_t client_buf_len;
ASSERT_EQ(security_manager::SSLContext::Handshake_Result_Success,
@@ -124,17 +124,17 @@ TEST_F(SSLTest, BrokenHandshake) {
ASSERT_FALSE(client_buf == NULL);
ASSERT_GT(client_buf_len, 0u);
// Broke 3 bytes for get abnormal fail of handshake
- const_cast<uint8_t *>(client_buf)[0] ^= 0xFF;
- const_cast<uint8_t *>(client_buf)[client_buf_len / 2] ^= 0xFF;
- const_cast<uint8_t *>(client_buf)[client_buf_len - 1] ^= 0xFF;
+ const_cast<uint8_t*>(client_buf)[0] ^= 0xFF;
+ const_cast<uint8_t*>(client_buf)[client_buf_len / 2] ^= 0xFF;
+ const_cast<uint8_t*>(client_buf)[client_buf_len - 1] ^= 0xFF;
ASSERT_EQ(security_manager::SSLContext::Handshake_Result_AbnormalFail,
server_ctx->DoHandshakeStep(client_buf, client_buf_len, &server_buf,
&server_buf_len));
}
TEST_F(SSLTest, Positive) {
- const uint8_t *server_buf;
- const uint8_t *client_buf;
+ const uint8_t* server_buf;
+ const uint8_t* client_buf;
size_t server_buf_len;
size_t client_buf_len;
@@ -168,28 +168,28 @@ TEST_F(SSLTest, Positive) {
EXPECT_TRUE(server_ctx->IsInitCompleted());
// Encrypt text on client side
- const uint8_t *text = reinterpret_cast<const uint8_t *>("abra");
- const uint8_t *encrypted_text = 0;
+ const uint8_t* text = reinterpret_cast<const uint8_t*>("abra");
+ const uint8_t* encrypted_text = 0;
size_t text_len = 4;
size_t encrypted_text_len;
EXPECT_TRUE(client_ctx->Encrypt(text, text_len, &encrypted_text,
&encrypted_text_len));
- ASSERT_NE(encrypted_text, reinterpret_cast<void *>(NULL));
+ ASSERT_NE(encrypted_text, reinterpret_cast<void*>(NULL));
ASSERT_GT(encrypted_text_len, 0u);
// Decrypt text on server side
EXPECT_TRUE(server_ctx->Decrypt(encrypted_text, encrypted_text_len, &text,
&text_len));
- ASSERT_NE(text, reinterpret_cast<void *>(NULL));
+ ASSERT_NE(text, reinterpret_cast<void*>(NULL));
ASSERT_GT(text_len, 0u);
- ASSERT_EQ(strncmp(reinterpret_cast<const char *>(text), "abra", 4), 0);
+ ASSERT_EQ(strncmp(reinterpret_cast<const char*>(text), "abra", 4), 0);
}
TEST_F(SSLTest, EcncryptionFail) {
- const uint8_t *server_buf;
- const uint8_t *client_buf;
+ const uint8_t* server_buf;
+ const uint8_t* client_buf;
size_t server_buf_len;
size_t client_buf_len;
ASSERT_EQ(security_manager::SSLContext::Handshake_Result_Success,
@@ -216,13 +216,13 @@ TEST_F(SSLTest, EcncryptionFail) {
EXPECT_TRUE(server_ctx->IsInitCompleted());
// Encrypt text on client side
- const uint8_t *text = reinterpret_cast<const uint8_t *>("abra");
- const uint8_t *encrypted_text = 0;
+ const uint8_t* text = reinterpret_cast<const uint8_t*>("abra");
+ const uint8_t* encrypted_text = 0;
size_t text_len = 4;
size_t encrypted_text_len;
EXPECT_TRUE(client_ctx->Encrypt(text, text_len, &encrypted_text,
&encrypted_text_len));
- ASSERT_NE(encrypted_text, reinterpret_cast<void *>(NULL));
+ ASSERT_NE(encrypted_text, reinterpret_cast<void*>(NULL));
ASSERT_GT(encrypted_text_len, 0u);
std::vector<uint8_t> broken(encrypted_text,
@@ -230,7 +230,7 @@ TEST_F(SSLTest, EcncryptionFail) {
// Broke message
broken[encrypted_text_len / 2] ^= 0xFF;
- const uint8_t *out_text;
+ const uint8_t* out_text;
size_t out_text_size;
// Decrypt broken text on server side
EXPECT_FALSE(server_ctx->Decrypt(&broken[0], broken.size(), &out_text,