From c743d3c341db0656d5bfd7e8c0bcb2d12e00cbb6 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Fri, 2 Aug 2024 18:57:35 -0500 Subject: [PATCH] updated build system --- .../repertory_test/src/encryption_test.cpp | 138 ------------------ repertory/repertory_test/src/utils_test.cpp | 21 --- .../3rd_party/test/src/utils/common_test.cpp | 8 + .../3rd_party/test/src/utils/string_test.cpp | 13 ++ 4 files changed, 21 insertions(+), 159 deletions(-) delete mode 100644 repertory/repertory_test/src/encryption_test.cpp diff --git a/repertory/repertory_test/src/encryption_test.cpp b/repertory/repertory_test/src/encryption_test.cpp deleted file mode 100644 index f6a39c7c..00000000 --- a/repertory/repertory_test/src/encryption_test.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - Copyright <2018-2024> - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do - so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#include "test_common.hpp" - -#include "types/repertory.hpp" -#include "utils/collection.hpp" -#include "utils/encrypt.hpp" -#include "utils/file_utils.hpp" -#include "utils/string.hpp" - -namespace repertory { -static const std::string buffer = "cow moose dog chicken"; -static const std::string token = "moose"; - -static void test_encrypted_result(const data_buffer &result) { - EXPECT_EQ(buffer.size() + utils::encryption::encryption_header_size, - result.size()); - std::string data; - EXPECT_TRUE(utils::encryption::decrypt_data(token, result, data)); - EXPECT_EQ(buffer.size(), data.size()); - EXPECT_STREQ(buffer.c_str(), data.c_str()); -} - -TEST(encryption, generate_key) { - const auto key = utils::encryption::generate_key(token); - const auto str = utils::collection::to_hex_string(key); - EXPECT_STREQ( - "182072537ada59e4d6b18034a80302ebae935f66adbdf0f271d3d36309c2d481", - str.c_str()); -} - -TEST(encryption, encrypt_data_buffer) { - data_buffer result; - utils::encryption::encrypt_data(token, buffer, result); - test_encrypted_result(result); -} - -TEST(encryption, encrypt_data_buffer_with_key) { - const auto key = utils::encryption::generate_key(token); - data_buffer result; - utils::encryption::encrypt_data(key, buffer, result); - test_encrypted_result(result); -} - -TEST(encryption, encrypt_data_pointer) { - data_buffer result; - utils::encryption::encrypt_data( - token, reinterpret_cast(buffer.data()), - buffer.size(), result); - test_encrypted_result(result); -} - -TEST(encryption, encrypt_data_pointer_with_key) { - const auto key = utils::encryption::generate_key(token); - data_buffer result; - utils::encryption::encrypt_data( - key, reinterpret_cast(buffer.data()), - buffer.size(), result); - test_encrypted_result(result); -} - -TEST(encryption, decrypt_data_pointer) { - const auto key = utils::encryption::generate_key(token); - data_buffer result; - utils::encryption::encrypt_data( - key, reinterpret_cast(buffer.data()), - buffer.size(), result); - - std::string data; - EXPECT_TRUE(utils::encryption::decrypt_data(token, result.data(), - result.size(), data)); - - EXPECT_EQ(buffer.size(), data.size()); - EXPECT_STREQ(buffer.c_str(), data.c_str()); -} - -TEST(encryption, decrypt_data_buffer_with_key) { - const auto key = utils::encryption::generate_key(token); - data_buffer result; - utils::encryption::encrypt_data( - key, reinterpret_cast(buffer.data()), - buffer.size(), result); - - std::string data; - EXPECT_TRUE(utils::encryption::decrypt_data(key, result, data)); - - EXPECT_EQ(buffer.size(), data.size()); - EXPECT_STREQ(buffer.c_str(), data.c_str()); -} - -TEST(encryption, decrypt_data_pointer_with_key) { - const auto key = utils::encryption::generate_key(token); - data_buffer result; - utils::encryption::encrypt_data( - key, reinterpret_cast(buffer.data()), - buffer.size(), result); - - std::string data; - EXPECT_TRUE( - utils::encryption::decrypt_data(key, result.data(), result.size(), data)); - - EXPECT_EQ(buffer.size(), data.size()); - EXPECT_STREQ(buffer.c_str(), data.c_str()); -} - -TEST(encryption, decryption_failure) { - const auto key = utils::encryption::generate_key(token); - data_buffer result; - utils::encryption::encrypt_data( - key, reinterpret_cast(buffer.data()), - buffer.size(), result); - result[0U] = 0U; - result[1U] = 1U; - result[2U] = 2U; - - std::string data; - EXPECT_FALSE(utils::encryption::decrypt_data(key, result, data)); -} -} // namespace repertory diff --git a/repertory/repertory_test/src/utils_test.cpp b/repertory/repertory_test/src/utils_test.cpp index 7cdda42c..7a10a938 100644 --- a/repertory/repertory_test/src/utils_test.cpp +++ b/repertory/repertory_test/src/utils_test.cpp @@ -50,29 +50,8 @@ TEST(utils, convert_api_date) { } #endif -TEST(utils, create_uuid_string) { - const auto uuid1 = utils::create_uuid_string(); - const auto uuid2 = utils::create_uuid_string(); - ASSERT_EQ(36u, uuid1.size()); - ASSERT_EQ(36u, uuid2.size()); - ASSERT_STRNE(&uuid1[0], &uuid2[0]); -} - TEST(utils, generate_sha256) { const auto res = utils::file::generate_sha256(__FILE__); std::cout << res << std::endl; } - -TEST(utils, string_to_bool) { - EXPECT_TRUE(utils::string::to_bool("1")); - EXPECT_TRUE(utils::string::to_bool("-1")); - EXPECT_TRUE(utils::string::to_bool("0.1")); - EXPECT_TRUE(utils::string::to_bool("-0.1")); - EXPECT_TRUE(utils::string::to_bool("00000.1000000")); - EXPECT_TRUE(utils::string::to_bool("true")); - - EXPECT_FALSE(utils::string::to_bool("false")); - EXPECT_FALSE(utils::string::to_bool("0")); - EXPECT_FALSE(utils::string::to_bool("00000.00000")); -} } // namespace repertory diff --git a/support/3rd_party/test/src/utils/common_test.cpp b/support/3rd_party/test/src/utils/common_test.cpp index e8233582..512aa210 100644 --- a/support/3rd_party/test/src/utils/common_test.cpp +++ b/support/3rd_party/test/src/utils/common_test.cpp @@ -54,4 +54,12 @@ TEST(utils_common, version_less) { EXPECT_EQ(-1, utils::compare_version_strings("1.0.0.0", "1.0.1")); EXPECT_EQ(-1, utils::compare_version_strings("1.0.0.0", "1.0.1.0")); } + +TEST(utils_common, create_uuid_string) { + const auto uuid1 = utils::create_uuid_string(); + const auto uuid2 = utils::create_uuid_string(); + ASSERT_EQ(36U, uuid1.size()); + ASSERT_EQ(36U, uuid2.size()); + ASSERT_STRNE(uuid1.c_str(), uuid2.c_str()); +} } // namespace repertory diff --git a/support/3rd_party/test/src/utils/string_test.cpp b/support/3rd_party/test/src/utils/string_test.cpp index 87f284f5..2066c123 100644 --- a/support/3rd_party/test/src/utils/string_test.cpp +++ b/support/3rd_party/test/src/utils/string_test.cpp @@ -115,4 +115,17 @@ TEST(utils_string, is_numeric) { EXPECT_FALSE(utils::string::is_numeric("")); } + +TEST(utils_string, to_bool) { + EXPECT_TRUE(utils::string::to_bool("1")); + EXPECT_TRUE(utils::string::to_bool("-1")); + EXPECT_TRUE(utils::string::to_bool("0.1")); + EXPECT_TRUE(utils::string::to_bool("-0.1")); + EXPECT_TRUE(utils::string::to_bool("00000.1000000")); + EXPECT_TRUE(utils::string::to_bool("true")); + + EXPECT_FALSE(utils::string::to_bool("false")); + EXPECT_FALSE(utils::string::to_bool("0")); + EXPECT_FALSE(utils::string::to_bool("00000.00000")); +} } // namespace repertory