diff options
author | Ernest Borowski <e.borowski@partner.samsung.com> | 2018-08-02 12:19:31 +0200 |
---|---|---|
committer | Krzysztof Jackiewicz <k.jackiewicz@samsung.com> | 2019-02-22 12:43:38 +0100 |
commit | 2a92e35ca020ca064ff162334efbfbfdadef8900 (patch) | |
tree | eefca10d410f9dc9835e14e7ffc6b75a55b45fda /tests | |
parent | 80c18bbbc7670f950e65f7a64b689b4946333890 (diff) | |
download | key-manager-2a92e35ca020ca064ff162334efbfbfdadef8900.tar.gz key-manager-2a92e35ca020ca064ff162334efbfbfdadef8900.tar.bz2 key-manager-2a92e35ca020ca064ff162334efbfbfdadef8900.zip |
Add test for listing aliases with password protection
statuses on old database schema
Change-Id: I2e9e409a385744a0ed694023872cbd4b37cce523
Diffstat (limited to 'tests')
-rw-r--r-- | tests/encryption-scheme/scheme-test.cpp | 66 | ||||
-rw-r--r-- | tests/encryption-scheme/scheme-test.h | 3 | ||||
-rw-r--r-- | tests/test_encryption-scheme.cpp | 14 |
3 files changed, 80 insertions, 3 deletions
diff --git a/tests/encryption-scheme/scheme-test.cpp b/tests/encryption-scheme/scheme-test.cpp index d851f42b..04319a2b 100644 --- a/tests/encryption-scheme/scheme-test.cpp +++ b/tests/encryption-scheme/scheme-test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 - 2018 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2015 - 2019 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -576,6 +576,70 @@ void SchemeTest::FillDb() } } +void SchemeTest::CheckAliasInfo() +{ + SwitchToUser(); + for (const auto &g : GROUPS) { + for (const auto &i : g.items) { + int ret; + bool encStatus = false; + Password pass = i.policy.password; + + if (pass.empty()) + pass = TEST_PASS; + else + pass = Password(); + + switch (i.type) { + case DataType::BINARY_DATA: { + ret = m_mgr->getDataEncryptionStatus(i.alias, encStatus); + BOOST_REQUIRE_MESSAGE(ret == CKM_API_SUCCESS, + "can not get data encryption status, ret: " + + std::to_string(ret)); + break; + } + + case DataType::KEY_AES: + case DataType::KEY_RSA_PRIVATE: + case DataType::KEY_RSA_PUBLIC: { + ret = m_mgr->getKeyEncryptionStatus(i.alias, encStatus); + BOOST_REQUIRE_MESSAGE(ret == CKM_API_SUCCESS, + "can not get key encryption status, ret: " + + std::to_string(ret)); + break; + } + + case DataType::CERTIFICATE: { + ret = m_mgr->getCertificateEncryptionStatus(i.alias, encStatus); + BOOST_REQUIRE_MESSAGE(ret == CKM_API_SUCCESS, + "can not get certificate encryption status, ret: " + + std::to_string(ret)); + break; + } + + case DataType::CHAIN_CERT_0: { + ret = m_mgr->getCertificateEncryptionStatus(i.alias, encStatus); + BOOST_REQUIRE_MESSAGE(ret == CKM_API_SUCCESS, + "can not get certificate encryption status, ret: " + + std::to_string(ret)); + ret = m_mgr->getKeyEncryptionStatus(i.alias, encStatus); + BOOST_REQUIRE_MESSAGE(ret == CKM_API_SUCCESS, + "can not get key encryption status, ret: " + + std::to_string(ret)); + break; + } + + default: + BOOST_FAIL("Unsupported data type " << i.type); + } + BOOST_REQUIRE_MESSAGE(encStatus == !i.policy.password.empty(), "item: " << + i.alias << " has wrong encryption status: " << encStatus); + + } + } +} + + void SchemeTest::ReadAll(bool useWrongPass) { SwitchToUser(); diff --git a/tests/encryption-scheme/scheme-test.h b/tests/encryption-scheme/scheme-test.h index d9880842..cd4f1a63 100644 --- a/tests/encryption-scheme/scheme-test.h +++ b/tests/encryption-scheme/scheme-test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2015 -2019 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,6 +105,7 @@ public: SchemeTest(); ~SchemeTest(); + void CheckAliasInfo(); void RemoveUserData(); void FillDb(); void ReadAll(bool useWrongPass = false); diff --git a/tests/test_encryption-scheme.cpp b/tests/test_encryption-scheme.cpp index ac552f55..e77c38b9 100644 --- a/tests/test_encryption-scheme.cpp +++ b/tests/test_encryption-scheme.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2015 -2019 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,6 +73,18 @@ BOOST_AUTO_TEST_CASE(T010_Check_old_scheme) test.CheckSchemeVersion(filter, OLD_ENC_SCHEME); } +BOOST_AUTO_TEST_CASE(T1111_Alias_Info_old_scheme) +{ + SchemeTest test; + test.RestoreDb(); + + ItemFilter filter; + test.CheckSchemeVersion(filter, OLD_ENC_SCHEME); + test.CheckAliasInfo(); + test.ReadAll(); + test.CheckAliasInfo(); +} + // Newly written data should use the new scheme BOOST_AUTO_TEST_CASE(T020_Check_new_scheme) { |