summaryrefslogtreecommitdiff
path: root/src/components/security_manager/test/security_manager_test.cc
diff options
context:
space:
mode:
authorKozoriz <kozorizandriy@gmail.com>2015-12-23 10:24:46 +0200
committerKozoriz <kozorizandriy@gmail.com>2015-12-23 10:24:46 +0200
commit526af62f7b91aa7568c9bba6148a3e9bc096bf1c (patch)
treefa1bebbe7eb477b0cfe59c881504048c6953f621 /src/components/security_manager/test/security_manager_test.cc
parente67dc283748da1abc2ed9c404c870bddb1c4d957 (diff)
downloadsdl_core-526af62f7b91aa7568c9bba6148a3e9bc096bf1c.tar.gz
Update of all tests in security_manager_test.cc
All tests copied from pasa. (28/28) All works.
Diffstat (limited to 'src/components/security_manager/test/security_manager_test.cc')
-rw-r--r--src/components/security_manager/test/security_manager_test.cc180
1 files changed, 107 insertions, 73 deletions
diff --git a/src/components/security_manager/test/security_manager_test.cc b/src/components/security_manager/test/security_manager_test.cc
index 30f81ee62e..57de881d5c 100644
--- a/src/components/security_manager/test/security_manager_test.cc
+++ b/src/components/security_manager/test/security_manager_test.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Ford Motor Company
+ * Copyright (c) 2015, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,14 +37,13 @@
#include "protocol/common.h"
#include "security_manager/security_manager_impl.h"
-#include "protocol_handler_mock.h"
-#include "protocol_observer_mock.h"
-#include "include/security_manager_mock.h"
+#include "protocol_handler/mock_protocol_handler.h"
+#include "protocol_handler/mock_session_observer.h"
#include "transport_manager_mock.h"
-
-// TODO(EZamakhov): add test on get correct/wrong InternalError
-// TODO(EZamakhov): check connection_key the same and seq_number
-// TODO(EZamakhov): check ::SendData with correct query_id and query_type
+#include "security_manager/mock_security_manager.h"
+#include "security_manager/mock_ssl_context.h"
+#include "security_manager/mock_crypto_manager.h"
+#include "security_manager/mock_security_manager_listener.h"
namespace test {
namespace components {
@@ -91,10 +90,12 @@ class SecurityManagerTest : public ::testing::Test {
}
void TearDown() OVERRIDE {
// Wait call methods in thread
- usleep(100000);
+ testing::Mock::AsyncVerifyAndClearExpectations(10000);
}
- void SetMockCryptoManger() {
+ void SetMockCryptoManager() {
+ EXPECT_CALL(mock_crypto_manager, IsCertificateUpdateRequired()).
+ WillRepeatedly(Return(false));
security_manager_->set_crypto_manager(&mock_crypto_manager);
}
/*
@@ -130,7 +131,7 @@ class SecurityManagerTest : public ::testing::Test {
/*
* Wrapper for fast emulate recieve Handshake
*/
- void EmulateMobileMessageHandShake(const uint8_t* const data,
+ void EmulateMobileMessageHandshake(const uint8_t* const data,
const uint32_t data_size,
const int repeat_count = 1) {
const SecurityQuery::QueryHeader header(SecurityQuery::NOTIFICATION,
@@ -142,12 +143,12 @@ 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::SessionObserverMock> mock_session_observer;
- testing::StrictMock<protocol_handler_test::ProtocolHandlerMock> mock_protocol_handler;
- testing::StrictMock<security_manager_test::CryptoManagerMock> mock_crypto_manager;
- testing::StrictMock<security_manager_test::SSLContextMock> mock_ssl_context_new;
- testing::StrictMock<security_manager_test::SSLContextMock> mock_ssl_context_exists;
- testing::StrictMock<security_manager_test::SMListenerMock> 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
@@ -186,12 +187,14 @@ TEST_F(SecurityManagerTest, Listeners_NoListeners) {
security_manager_->RemoveListener(&mock_sm_listener);
// Expect no calls
- testing::StrictMock<SMListenerMock> mock_listener2;
+ testing::StrictMock<MockSecurityManagerListener> mock_listener2;
security_manager_->AddListener(&mock_listener2);
security_manager_->RemoveListener(&mock_listener2);
- security_manager_->NotifyListenersOnHandshakeDone(key, true);
- security_manager_->NotifyListenersOnHandshakeDone(key, false);
+ security_manager_->NotifyListenersOnHandshakeDone(key,
+ SSLContext::Handshake_Result_Success);
+ security_manager_->NotifyListenersOnHandshakeDone(key,
+ SSLContext::Handshake_Result_Fail);
}
/*
* Notifying two listeners
@@ -200,10 +203,11 @@ TEST_F(SecurityManagerTest, Listeners_Notifying) {
// Check correct removing listener
security_manager_->RemoveListener(&mock_sm_listener);
- testing::StrictMock<SMListenerMock> mock_listener1;
- testing::StrictMock<SMListenerMock> mock_listener2;
+ testing::StrictMock<MockSecurityManagerListener> mock_listener1;
+ testing::StrictMock<MockSecurityManagerListener> mock_listener2;
- const bool first_call_value = true;
+ 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
@@ -212,7 +216,12 @@ TEST_F(SecurityManagerTest, Listeners_Notifying) {
// Emulate true (accept) result
WillOnce(Return(true));
- const bool second_call_value = false;
+ // First listener was not removed from listener list
+ // So this callback wil lbe either call.
+ EXPECT_CALL(mock_listener1, OnCertificateUpdateRequired());
+
+ 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
@@ -224,11 +233,16 @@ TEST_F(SecurityManagerTest, Listeners_Notifying) {
security_manager_->AddListener(&mock_listener2);
// 1st call
security_manager_->NotifyListenersOnHandshakeDone(key, first_call_value);
+ security_manager_->NotifyOnCertififcateUpdateRequired();
// 2nd call
security_manager_->NotifyListenersOnHandshakeDone(key, second_call_value);
+ security_manager_->NotifyOnCertififcateUpdateRequired();
// 3nd call
- security_manager_->NotifyListenersOnHandshakeDone(key, false);
+ security_manager_->NotifyListenersOnHandshakeDone(key,
+ SSLContext::Handshake_Result_Fail);
+ security_manager_->NotifyOnCertififcateUpdateRequired();
}
+
/*
* SecurityManager with NULL CryptoManager shall send
* InternallError (ERROR_NOT_SUPPORTED) on any Query
@@ -281,7 +295,7 @@ TEST_F(SecurityManagerTest, GetEmptyQuery) {
EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id,_)).
WillOnce(Return(true));
- EXPECT_CALL(
+ EXPECT_CALL(
mock_protocol_handler,
SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_INVALID_QUERY_SIZE), is_final));
// Call with NULL data
@@ -291,7 +305,7 @@ TEST_F(SecurityManagerTest, GetEmptyQuery) {
* Shall send InternallError on null data recieved
*/
TEST_F(SecurityManagerTest, GetWrongJSONSize) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
uint32_t connection_id = 0;
uint8_t session_id = 0;
//uint8_t protocol_version = 0;
@@ -312,7 +326,7 @@ TEST_F(SecurityManagerTest, GetWrongJSONSize) {
* Shall send InternallError on INVALID_QUERY_ID
*/
TEST_F(SecurityManagerTest, GetInvalidQueryId) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
uint32_t connection_id = 0;
uint8_t session_id = 0;
//uint8_t protocol_version = 0;
@@ -334,7 +348,7 @@ TEST_F(SecurityManagerTest, GetInvalidQueryId) {
* CreateSSLContext for already protected connections
*/
TEST_F(SecurityManagerTest, CreateSSLContext_ServiceAlreadyProtected) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
// Return mock SSLContext
EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl)).
@@ -347,7 +361,7 @@ TEST_F(SecurityManagerTest, CreateSSLContext_ServiceAlreadyProtected) {
* Shall send Internall Error on error create SSL
*/
TEST_F(SecurityManagerTest, CreateSSLContext_ErrorCreateSSL) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
// Expect InternalError with ERROR_ID
uint32_t connection_id = 0;
uint8_t session_id = 0;
@@ -365,15 +379,15 @@ TEST_F(SecurityManagerTest, CreateSSLContext_ErrorCreateSSL) {
EXPECT_CALL(mock_crypto_manager, CreateSSLContext()).
WillOnce(ReturnNull());
- const bool rezult = security_manager_->CreateSSLContext(key);
- EXPECT_FALSE(rezult);
+ const security_manager::SSLContext* rezult = security_manager_->CreateSSLContext(key);
+ EXPECT_EQ(NULL,rezult);
}
/*
* Shall send InternalError with SERVICE_NOT_FOUND
* on getting any Error with call SetSSLContext
*/
TEST_F(SecurityManagerTest, CreateSSLContext_SetSSLContextError) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
// Expect InternalError with ERROR_ID
uint32_t connection_id = 0;
uint8_t session_id = 0;
@@ -384,7 +398,7 @@ TEST_F(SecurityManagerTest, CreateSSLContext_SetSSLContextError) {
EXPECT_CALL(
mock_protocol_handler,
- SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_UNKWOWN_INTERNAL_ERROR), is_final));
+ SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_UNKNOWN_INTERNAL_ERROR), is_final));
// Emulate SessionObserver and CryptoManager result
EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl)).
@@ -393,16 +407,16 @@ TEST_F(SecurityManagerTest, CreateSSLContext_SetSSLContextError) {
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_UNKWOWN_INTERNAL_ERROR));
+ WillOnce(Return(SecurityManager::ERROR_UNKNOWN_INTERNAL_ERROR));
- const bool rezult = security_manager_->CreateSSLContext(key);
- EXPECT_FALSE(rezult);
+ const security_manager::SSLContext* rezult = security_manager_->CreateSSLContext(key);
+ EXPECT_EQ(NULL,rezult);
}
/*
* Shall protect connection on correct call CreateSSLContext
*/
TEST_F(SecurityManagerTest, CreateSSLContext_Success) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
// Expect no Errors
// Expect no notifying listeners - it will be done after handshake
@@ -416,14 +430,14 @@ TEST_F(SecurityManagerTest, CreateSSLContext_Success) {
EXPECT_CALL(mock_session_observer, SetSSLContext(key, &mock_ssl_context_new)).
WillOnce(Return(SecurityManager::ERROR_SUCCESS));
- const bool rezult = security_manager_->CreateSSLContext(key);
- EXPECT_TRUE(rezult);
+ const security_manager::SSLContext* rezult = security_manager_->CreateSSLContext(key);
+ EXPECT_EQ(rezult, &mock_ssl_context_new);
}
/*
* Shall send InternallError on call StartHandshake for uprotected service
*/
TEST_F(SecurityManagerTest, StartHandshake_ServiceStillUnprotected) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
uint32_t connection_id = 0;
uint8_t session_id = 0;
//uint8_t protocol_version = 0;
@@ -434,7 +448,9 @@ TEST_F(SecurityManagerTest, StartHandshake_ServiceStillUnprotected) {
EXPECT_CALL(mock_protocol_handler,
SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_INTERNAL), is_final));
// Expect notifying listeners (unsuccess)
- EXPECT_CALL(mock_sm_listener, OnHandshakeDone(key, false)).WillOnce(Return(true));
+ EXPECT_CALL(mock_sm_listener,
+ OnHandshakeDone(key, SSLContext::Handshake_Result_Fail)).
+ WillOnce(Return(true));
// Emulate SessionObserver result
EXPECT_CALL(mock_session_observer, GetSSLContext(key, kControl)).
@@ -446,12 +462,14 @@ TEST_F(SecurityManagerTest, StartHandshake_ServiceStillUnprotected) {
* Shall send InternallError on SSL error and notify listeners
*/
TEST_F(SecurityManagerTest, StartHandshake_SSLInternalError) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
uint32_t connection_id = 0;
uint8_t session_id = 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, ProtocolVersionUsed(connection_id, session_id,_)).
WillOnce(Return(true));
@@ -460,13 +478,16 @@ TEST_F(SecurityManagerTest, StartHandshake_SSLInternalError) {
mock_protocol_handler,
SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_INTERNAL), is_final));
// Expect notifying listeners (unsuccess)
- EXPECT_CALL(mock_sm_listener, OnHandshakeDone(key, false)).WillOnce(Return(true));
+ EXPECT_CALL(mock_sm_listener,
+ 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_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),
@@ -479,11 +500,13 @@ TEST_F(SecurityManagerTest, StartHandshake_SSLInternalError) {
* Shall send data on call StartHandshake
*/
TEST_F(SecurityManagerTest, StartHandshake_SSLInitIsNotComplete) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
uint32_t connection_id = 0;
uint8_t session_id = 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, ProtocolVersionUsed(connection_id, session_id,_)).
WillOnce(Return(true));
@@ -496,6 +519,7 @@ TEST_F(SecurityManagerTest, StartHandshake_SSLInitIsNotComplete) {
// 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, SetHandshakeContext(_)).Times(3);
// Emulate SSLContext::StartHandshake with different parameters
// Only on both correct - data and size shall be send message to mobile app
@@ -521,10 +545,11 @@ TEST_F(SecurityManagerTest, StartHandshake_SSLInitIsNotComplete) {
* Shall notify listeners on call StartHandshake after SSLContext initialization complete
*/
TEST_F(SecurityManagerTest, StartHandshake_SSLInitIsComplete) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
// Expect no message send
// Expect notifying listeners (success)
- EXPECT_CALL(mock_sm_listener, OnHandshakeDone(key, true)).
+ EXPECT_CALL(mock_sm_listener,
+ OnHandshakeDone(key, SSLContext::Handshake_Result_Success)).
WillOnce(Return(true));
// Emulate SessionObserver result
@@ -532,6 +557,8 @@ TEST_F(SecurityManagerTest, StartHandshake_SSLInitIsComplete) {
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);
}
@@ -540,7 +567,7 @@ TEST_F(SecurityManagerTest, StartHandshake_SSLInitIsComplete) {
* getting SEND_HANDSHAKE_DATA with NULL data
*/
TEST_F(SecurityManagerTest, ProccessHandshakeData_WrongDataSize) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
uint32_t connection_id = 0;
uint8_t session_id = 0;
//uint8_t protocol_version = 0;
@@ -552,7 +579,7 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_WrongDataSize) {
EXPECT_CALL(
mock_protocol_handler,
SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_INVALID_QUERY_SIZE), is_final));
- EmulateMobileMessageHandShake(NULL, 0);
+ EmulateMobileMessageHandshake(NULL, 0);
}
/*
* Shall send InternallError on
@@ -560,7 +587,7 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_WrongDataSize) {
* for service which is not protected
*/
TEST_F(SecurityManagerTest, ProccessHandshakeData_ServiceNotProtected) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
// Expect InternalError with ERROR_ID
uint32_t connection_id = 0;
uint8_t session_id = 0;
@@ -573,7 +600,8 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_ServiceNotProtected) {
mock_protocol_handler,
SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_SERVICE_NOT_PROTECTED), is_final));
// Expect notifying listeners (unsuccess)
- EXPECT_CALL(mock_sm_listener, OnHandshakeDone(key, false)).
+ EXPECT_CALL(mock_sm_listener,
+ OnHandshakeDone(key, SSLContext::Handshake_Result_Fail)).
WillOnce(Return(true));
// Emulate SessionObserver result
@@ -581,7 +609,7 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_ServiceNotProtected) {
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
@@ -589,7 +617,7 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_ServiceNotProtected) {
* data (DoHandshakeStep return NULL pointer)
*/
TEST_F(SecurityManagerTest, ProccessHandshakeData_InvalidData) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
// Count handshake calls
const int handshake_emulates = 4;
@@ -609,7 +637,8 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_InvalidData) {
SendMessageToMobileApp( InternalErrorWithErrId( SecurityManager::ERROR_SSL_INVALID_DATA), is_final)).
Times(handshake_emulates);
// Expect notifying listeners (unsuccess)
- EXPECT_CALL(mock_sm_listener, OnHandshakeDone(key, false)).
+ EXPECT_CALL(mock_sm_listener,
+ OnHandshakeDone(key, SSLContext::Handshake_Result_Fail)).
WillOnce(Return(true));
// Emulate SessionObserver and CryptoManager result
@@ -618,7 +647,8 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_InvalidData) {
WillRepeatedly(Return(&mock_ssl_context_exists));
// Emulate DoHandshakeStep fail logics
EXPECT_CALL(
- mock_ssl_context_exists, DoHandshakeStep(_, handshake_data_size, _, _)).
+ 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::
@@ -642,7 +672,7 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_InvalidData) {
Times(handshake_emulates);
// Emulate handshare #handshake_emulates times for 5 cases
- EmulateMobileMessageHandShake(handshake_data, handshake_data_size,
+ EmulateMobileMessageHandshake(handshake_data, handshake_data_size,
handshake_emulates);
}
/*
@@ -650,7 +680,7 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_InvalidData) {
* with correct handshake data Check Fail and sussecc states
*/
TEST_F(SecurityManagerTest, ProccessHandshakeData_Answer) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
// Count handshake calls
const int handshake_emulates = 2;
@@ -663,13 +693,14 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_Answer) {
Times(handshake_emulates).
WillRepeatedly(Return(true));
- // Expect InternalError with ERROR_ID
+ // Get size of raw message after
+ const size_t raw_message_size = 15;
EXPECT_CALL(mock_protocol_handler, SendMessageToMobileApp(
- // FIXME : !!!
- _, is_final)).
+ RawMessageEqSize(raw_message_size), is_final)).
Times(handshake_emulates);
// Expect notifying listeners (unsuccess)
- EXPECT_CALL(mock_sm_listener, OnHandshakeDone(key, false)).
+ EXPECT_CALL(mock_sm_listener,
+ OnHandshakeDone(key, SSLContext::Handshake_Result_Fail)).
WillOnce(Return(true));
// Emulate SessionObserver and CryptoManager result
@@ -683,7 +714,8 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_Answer) {
// Emulate DoHandshakeStep correct logics
EXPECT_CALL(
- mock_ssl_context_exists, DoHandshakeStep(_, handshake_data_size, _, _)).
+ 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::
@@ -693,7 +725,7 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_Answer) {
Return(security_manager::SSLContext::
Handshake_Result_Fail)));
- EmulateMobileMessageHandShake(handshake_data, handshake_data_size,
+ EmulateMobileMessageHandshake(handshake_data, handshake_data_size,
handshake_emulates);
}
/*
@@ -701,13 +733,14 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_Answer) {
* and return handshake data
* Check Fail and sussecc states
*/
-TEST_F(SecurityManagerTest, ProccessHandshakeData_HandShakeFinished) {
- SetMockCryptoManger();
+TEST_F(SecurityManagerTest, ProccessHandshakeData_HandshakeFinished) {
+ SetMockCryptoManager();
// Count handshake calls
const int handshake_emulates = 6;
// Expect no errors
// Expect notifying listeners (success)
- EXPECT_CALL(mock_sm_listener, OnHandshakeDone(key, true)).
+ EXPECT_CALL(mock_sm_listener, OnHandshakeDone(key,
+ SSLContext::Handshake_Result_Success)).
WillOnce(Return(true));
// Emulate SessionObserver and CryptoManager result
@@ -719,9 +752,10 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_HandShakeFinished) {
mock_ssl_context_exists, IsInitCompleted()).
Times(handshake_emulates).
WillRepeatedly(Return(true));
- // FIXME(EZamakhov): add DoHandshakeStep matcher for compare handshake data
+
EXPECT_CALL(
- mock_ssl_context_exists, DoHandshakeStep(_, handshake_data_size, _, _)).
+ 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),
@@ -766,13 +800,13 @@ TEST_F(SecurityManagerTest, ProccessHandshakeData_HandShakeFinished) {
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
*/
TEST_F(SecurityManagerTest, GetInternalError_NullData) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
const SecurityQuery::QueryHeader header( SecurityQuery::NOTIFICATION,
SecurityQuery::SEND_INTERNAL_ERROR, 0);
@@ -782,7 +816,7 @@ TEST_F(SecurityManagerTest, GetInternalError_NullData) {
* Shall not send any query on getting SEND_INTERNAL_ERROR
*/
TEST_F(SecurityManagerTest, GetInternalError) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
const SecurityQuery::QueryHeader header( SecurityQuery::NOTIFICATION,
SecurityQuery::SEND_INTERNAL_ERROR, 0);
@@ -793,7 +827,7 @@ TEST_F(SecurityManagerTest, GetInternalError) {
* Shall not send any query on getting SEND_INTERNAL_ERROR with error string
*/
TEST_F(SecurityManagerTest, GetInternalError_WithErrText) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
SecurityQuery::QueryHeader header( SecurityQuery::NOTIFICATION,
SecurityQuery::SEND_INTERNAL_ERROR, 0);
@@ -807,7 +841,7 @@ TEST_F(SecurityManagerTest, GetInternalError_WithErrText) {
* Shall not send any query on getting SEND_INTERNAL_ERROR with error string
*/
TEST_F(SecurityManagerTest, GetInternalError_WithErrJSONText) {
- SetMockCryptoManger();
+ SetMockCryptoManager();
SecurityQuery::QueryHeader header( SecurityQuery::NOTIFICATION,
SecurityQuery::SEND_INTERNAL_ERROR, 0);