summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAKalinich-Luxoft <AKalinich@luxoft.com>2018-05-25 13:24:52 +0300
committerAndrii Kalinich <AKalinich@luxoft.com>2018-06-18 21:01:02 +0300
commitfb10b983d2f831c948ce4290170d6fa155dfe5bc (patch)
tree1d2f3407570eef7fb5ebff4693b589af0a88d387
parent5a364fb188e09e4fe15892a535b7e6c98f4edd9d (diff)
downloadsdl_core-fb10b983d2f831c948ce4290170d6fa155dfe5bc.tar.gz
Fixed affected mocks and UT's
Added new expectations for a security tests due to some changes in the security flow
-rw-r--r--src/components/include/test/security_manager/mock_security_manager_settings.h2
-rw-r--r--src/components/security_manager/test/crypto_manager_impl_test.cc7
-rw-r--r--src/components/security_manager/test/ssl_certificate_handshake_test.cc12
-rw-r--r--src/components/security_manager/test/ssl_context_test.cc20
4 files changed, 41 insertions, 0 deletions
diff --git a/src/components/include/test/security_manager/mock_security_manager_settings.h b/src/components/include/test/security_manager/mock_security_manager_settings.h
index 961b5e2ff8..b1c869cd1b 100644
--- a/src/components/include/test/security_manager/mock_security_manager_settings.h
+++ b/src/components/include/test/security_manager/mock_security_manager_settings.h
@@ -50,6 +50,8 @@ class MockCryptoManagerSettings
MOCK_CONST_METHOD0(certificate_data, const std::string&());
MOCK_CONST_METHOD0(ciphers_list, const std::string&());
MOCK_CONST_METHOD0(ca_cert_path, const std::string&());
+ MOCK_CONST_METHOD0(module_cert_path, const std::string&());
+ MOCK_CONST_METHOD0(module_key_path, const std::string&());
MOCK_CONST_METHOD0(update_before_hours, size_t());
MOCK_CONST_METHOD0(maximum_payload_size, size_t());
MOCK_CONST_METHOD0(force_protected_service, const std::vector<int>&());
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 46429ea0e9..47e63dc194 100644
--- a/src/components/security_manager/test/crypto_manager_impl_test.cc
+++ b/src/components/security_manager/test/crypto_manager_impl_test.cc
@@ -54,6 +54,9 @@ const std::string kAllCiphers = "ALL";
const std::string kCaCertPath = "";
const uint32_t kServiceNumber = 2u;
const size_t kMaxSizeVector = 1u;
+const std::string kCertPath = "certificate.crt";
+const std::string kPrivateKeyPath = "private.key";
+
#ifdef __QNXNTO__
const std::string kFordCipher = SSL3_TXT_RSA_DES_192_CBC3_SHA;
#else
@@ -118,6 +121,10 @@ class CryptoManagerTest : public testing::Test {
.WillByDefault(ReturnRef(cipher));
ON_CALL(*mock_security_manager_settings_, ca_cert_path())
.WillByDefault(ReturnRef(kCaCertPath));
+ ON_CALL(*mock_security_manager_settings_, module_cert_path())
+ .WillByDefault(ReturnRef(kCertPath));
+ ON_CALL(*mock_security_manager_settings_, module_key_path())
+ .WillByDefault(ReturnRef(kPrivateKeyPath));
ON_CALL(*mock_security_manager_settings_, verify_peer())
.WillByDefault(Return(false));
}
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 2423ab00b7..d5bb1ecaee 100644
--- a/src/components/security_manager/test/ssl_certificate_handshake_test.cc
+++ b/src/components/security_manager/test/ssl_certificate_handshake_test.cc
@@ -56,6 +56,10 @@ namespace custom_str = utils::custom_string;
namespace {
const std::string server_ca_cert_filename = "server";
const std::string client_ca_cert_filename = "client";
+const std::string client_cert_filename = "client.crt";
+const std::string server_cert_filename = "server.crt";
+const std::string client_key_filename = "client_private.key";
+const std::string server_key_filename = "server_private.key";
const std::string client_certificate = "client/client_credential.pem";
const std::string server_certificate = "server/spt_credential.pem";
const std::string server_unsigned_cert_file =
@@ -126,6 +130,10 @@ class SSLHandshakeTest : public testing::TestWithParam<Protocol> {
.WillByDefault(ReturnRef(server_ciphers_list_));
ON_CALL(*mock_server_manager_settings_, ca_cert_path())
.WillByDefault(ReturnRef(server_ca_certificate_path_));
+ ON_CALL(*mock_server_manager_settings_, module_cert_path())
+ .WillByDefault(ReturnRef(server_cert_filename));
+ ON_CALL(*mock_server_manager_settings_, module_key_path())
+ .WillByDefault(ReturnRef(server_key_filename));
ON_CALL(*mock_server_manager_settings_, verify_peer())
.WillByDefault(Return(verify_peer));
}
@@ -152,6 +160,10 @@ class SSLHandshakeTest : public testing::TestWithParam<Protocol> {
.WillByDefault(ReturnRef(client_ciphers_list_));
ON_CALL(*mock_client_manager_settings_, ca_cert_path())
.WillByDefault(ReturnRef(client_ca_certificate_path_));
+ ON_CALL(*mock_client_manager_settings_, module_cert_path())
+ .WillByDefault(ReturnRef(client_cert_filename));
+ ON_CALL(*mock_client_manager_settings_, module_key_path())
+ .WillByDefault(ReturnRef(client_key_filename));
ON_CALL(*mock_client_manager_settings_, verify_peer())
.WillByDefault(Return(verify_peer));
}
diff --git a/src/components/security_manager/test/ssl_context_test.cc b/src/components/security_manager/test/ssl_context_test.cc
index 7a4a9c3a87..20e509ebc6 100644
--- a/src/components/security_manager/test/ssl_context_test.cc
+++ b/src/components/security_manager/test/ssl_context_test.cc
@@ -50,6 +50,10 @@ using ::testing::NiceMock;
namespace {
const std::string kCaPath = "";
+const std::string kClientCertPath = "client_certificate.crt";
+const std::string kClientPrivateKeyPath = "client_private.key";
+const std::string kServerCertPath = "server_certificate.crt";
+const std::string kServerPrivateKeyPath = "server_private.key";
const uint8_t* kServerBuf;
const uint8_t* kClientBuf;
const std::string kAllCiphers = "ALL";
@@ -131,6 +135,10 @@ class SSLTest : public testing::Test {
.WillByDefault(ReturnRef(forced_unprotected_service_));
ON_CALL(*mock_crypto_manager_settings_, force_protected_service())
.WillByDefault(ReturnRef(forced_protected_service_));
+ ON_CALL(*mock_crypto_manager_settings_, module_cert_path())
+ .WillByDefault(ReturnRef(kServerCertPath));
+ ON_CALL(*mock_crypto_manager_settings_, module_key_path())
+ .WillByDefault(ReturnRef(kServerPrivateKeyPath));
const bool crypto_manager_initialization = crypto_manager_->Init();
EXPECT_TRUE(crypto_manager_initialization);
@@ -160,6 +168,10 @@ class SSLTest : public testing::Test {
.WillByDefault(ReturnRef(forced_unprotected_service_));
ON_CALL(*mock_client_manager_settings_, force_protected_service())
.WillByDefault(ReturnRef(forced_protected_service_));
+ ON_CALL(*mock_client_manager_settings_, module_cert_path())
+ .WillByDefault(ReturnRef(kClientCertPath));
+ ON_CALL(*mock_client_manager_settings_, module_key_path())
+ .WillByDefault(ReturnRef(kClientPrivateKeyPath));
const bool client_manager_initialization = client_manager_->Init();
EXPECT_TRUE(client_manager_initialization);
@@ -301,6 +313,10 @@ class SSLTestParam : public testing::TestWithParam<ProtocolAndCipher> {
.WillByDefault(ReturnRef(kCaPath));
ON_CALL(*mock_crypto_manager_settings_, verify_peer())
.WillByDefault(Return(false));
+ ON_CALL(*mock_crypto_manager_settings_, module_cert_path())
+ .WillByDefault(ReturnRef(kServerCertPath));
+ ON_CALL(*mock_crypto_manager_settings_, module_key_path())
+ .WillByDefault(ReturnRef(kServerPrivateKeyPath));
}
void SetClientInitialValues(security_manager::Protocol protocol,
@@ -321,6 +337,10 @@ class SSLTestParam : public testing::TestWithParam<ProtocolAndCipher> {
.WillByDefault(ReturnRef(kCaPath));
ON_CALL(*mock_client_manager_settings_, verify_peer())
.WillByDefault(Return(false));
+ ON_CALL(*mock_client_manager_settings_, module_cert_path())
+ .WillByDefault(ReturnRef(kClientCertPath));
+ ON_CALL(*mock_client_manager_settings_, module_key_path())
+ .WillByDefault(ReturnRef(kClientPrivateKeyPath));
}
utils::SharedPtr<NiceMock<security_manager_test::MockCryptoManagerSettings> >