diff options
Diffstat (limited to 'tests/unit_tests')
-rw-r--r-- | tests/unit_tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tests/unit_tests/base58.cpp | 2 | ||||
-rw-r--r-- | tests/unit_tests/block_reward.cpp | 2 | ||||
-rw-r--r-- | tests/unit_tests/blockchain_db.cpp | 2 | ||||
-rw-r--r-- | tests/unit_tests/canonical_amounts.cpp | 2 | ||||
-rw-r--r-- | tests/unit_tests/checkpoints.cpp | 2 | ||||
-rw-r--r-- | tests/unit_tests/decompose_amount_into_digits.cpp | 2 | ||||
-rw-r--r-- | tests/unit_tests/hardfork.cpp | 2 | ||||
-rw-r--r-- | tests/unit_tests/http.cpp (renamed from tests/unit_tests/http_auth.cpp) | 34 | ||||
-rw-r--r-- | tests/unit_tests/parse_amount.cpp | 2 | ||||
-rw-r--r-- | tests/unit_tests/serialization.cpp | 4 | ||||
-rw-r--r-- | tests/unit_tests/test_tx_utils.cpp (renamed from tests/unit_tests/test_format_utils.cpp) | 2 | ||||
-rw-r--r-- | tests/unit_tests/varint.cpp | 4 |
13 files changed, 39 insertions, 25 deletions
diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt index 08c8213e4..e70ed1a24 100644 --- a/tests/unit_tests/CMakeLists.txt +++ b/tests/unit_tests/CMakeLists.txt @@ -42,14 +42,14 @@ set(unit_tests_sources epee_levin_protocol_handler_async.cpp fee.cpp get_xtype_from_string.cpp - http_auth.cpp + http.cpp main.cpp mnemonics.cpp mul_div.cpp parse_amount.cpp serialization.cpp slow_memmem.cpp - test_format_utils.cpp + test_tx_utils.cpp test_peerlist.cpp test_protocol_pack.cpp thread_group.cpp diff --git a/tests/unit_tests/base58.cpp b/tests/unit_tests/base58.cpp index 53f7f2673..d2c767956 100644 --- a/tests/unit_tests/base58.cpp +++ b/tests/unit_tests/base58.cpp @@ -33,7 +33,7 @@ #include <cstdint> #include "common/base58.cpp" -#include "cryptonote_core/cryptonote_basic_impl.h" +#include "cryptonote_basic/cryptonote_basic_impl.h" #include "serialization/binary_utils.h" using namespace tools; diff --git a/tests/unit_tests/block_reward.cpp b/tests/unit_tests/block_reward.cpp index 5d93c3084..f8a944770 100644 --- a/tests/unit_tests/block_reward.cpp +++ b/tests/unit_tests/block_reward.cpp @@ -30,7 +30,7 @@ #include "gtest/gtest.h" -#include "cryptonote_core/cryptonote_basic_impl.h" +#include "cryptonote_basic/cryptonote_basic_impl.h" using namespace cryptonote; diff --git a/tests/unit_tests/blockchain_db.cpp b/tests/unit_tests/blockchain_db.cpp index 127a15b44..8fc10be10 100644 --- a/tests/unit_tests/blockchain_db.cpp +++ b/tests/unit_tests/blockchain_db.cpp @@ -40,7 +40,7 @@ #ifdef BERKELEY_DB #include "blockchain_db/berkeleydb/db_bdb.h" #endif -#include "cryptonote_core/cryptonote_format_utils.h" +#include "cryptonote_basic/cryptonote_format_utils.h" using namespace cryptonote; using epee::string_tools::pod_to_hex; diff --git a/tests/unit_tests/canonical_amounts.cpp b/tests/unit_tests/canonical_amounts.cpp index 9bef58d4b..c5a27d47d 100644 --- a/tests/unit_tests/canonical_amounts.cpp +++ b/tests/unit_tests/canonical_amounts.cpp @@ -29,7 +29,7 @@ // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers #include "gtest/gtest.h" -#include "cryptonote_core/cryptonote_format_utils.h" +#include "cryptonote_basic/cryptonote_format_utils.h" static const uint64_t valid_decomposed_outputs[] = { (uint64_t)1, (uint64_t)2, (uint64_t)3, (uint64_t)4, (uint64_t)5, (uint64_t)6, (uint64_t)7, (uint64_t)8, (uint64_t)9, // 1 piconero diff --git a/tests/unit_tests/checkpoints.cpp b/tests/unit_tests/checkpoints.cpp index b1d251d26..bc18c2b9e 100644 --- a/tests/unit_tests/checkpoints.cpp +++ b/tests/unit_tests/checkpoints.cpp @@ -30,7 +30,7 @@ #include "gtest/gtest.h" -#include "cryptonote_core/checkpoints.cpp" +#include "cryptonote_basic/checkpoints.cpp" using namespace cryptonote; diff --git a/tests/unit_tests/decompose_amount_into_digits.cpp b/tests/unit_tests/decompose_amount_into_digits.cpp index e40208113..b1fa79aa1 100644 --- a/tests/unit_tests/decompose_amount_into_digits.cpp +++ b/tests/unit_tests/decompose_amount_into_digits.cpp @@ -33,7 +33,7 @@ #include <cstdint> #include <vector> -#include "cryptonote_core/cryptonote_format_utils.h" +#include "cryptonote_basic/cryptonote_format_utils.h" #define VEC_FROM_ARR(vec) \ std::vector<uint64_t> vec; \ diff --git a/tests/unit_tests/hardfork.cpp b/tests/unit_tests/hardfork.cpp index 2682f15d3..81cf32c8b 100644 --- a/tests/unit_tests/hardfork.cpp +++ b/tests/unit_tests/hardfork.cpp @@ -32,7 +32,7 @@ #include "gtest/gtest.h" #include "blockchain_db/lmdb/db_lmdb.h" -#include "cryptonote_core/hardfork.h" +#include "cryptonote_basic/hardfork.h" using namespace cryptonote; diff --git a/tests/unit_tests/http_auth.cpp b/tests/unit_tests/http.cpp index 97954642f..3513fa327 100644 --- a/tests/unit_tests/http_auth.cpp +++ b/tests/unit_tests/http.cpp @@ -109,7 +109,7 @@ http::http_response_info make_response(const auth_responses& choices) std::string out{" DIGEST "}; write_fields(out, choice); - response.m_additional_fields.push_back( + response.m_header_info.m_etc_fields.push_back( std::make_pair(u8"WWW-authenticate", std::move(out)) ); } @@ -510,7 +510,7 @@ TEST(HTTP_Server_Auth, MD5_sess_auth) TEST(HTTP_Auth, DogFood) { - const auto add_field = [] (http::http_request_info& request, http::http_client_auth& client) + const auto add_auth_field = [] (http::http_request_info& request, http::http_client_auth& client) { auto field = client.get_auth_field(request.m_http_method_str, request.m_URI); EXPECT_TRUE(bool(field)); @@ -529,19 +529,21 @@ TEST(HTTP_Auth, DogFood) request.m_http_method_str = "GET"; request.m_URI = "/FOO"; - const auto response = server.get_response(request); + auto response = server.get_response(request); ASSERT_TRUE(bool(response)); EXPECT_TRUE(is_unauthorized(*response)); + EXPECT_TRUE(response->m_header_info.m_etc_fields.empty()); + response->m_header_info.m_etc_fields = response->m_additional_fields; EXPECT_EQ(http::http_client_auth::kSuccess, client.handle_401(*response)); - EXPECT_TRUE(add_field(request, client)); + EXPECT_TRUE(add_auth_field(request, client)); EXPECT_FALSE(bool(server.get_response(request))); for (unsigned i = 0; i < 1000; ++i) { request.m_http_method_str += std::to_string(i); request.m_header_info.m_etc_fields.clear(); - EXPECT_TRUE(add_field(request, client)); + EXPECT_TRUE(add_auth_field(request, client)); EXPECT_FALSE(bool(server.get_response(request))); } @@ -549,11 +551,13 @@ TEST(HTTP_Auth, DogFood) request.m_header_info.m_etc_fields.clear(); client = http::http_client_auth{user}; EXPECT_EQ(http::http_client_auth::kSuccess, client.handle_401(*response)); - EXPECT_TRUE(add_field(request, client)); + EXPECT_TRUE(add_auth_field(request, client)); - const auto response2 = server.get_response(request); + auto response2 = server.get_response(request); ASSERT_TRUE(bool(response2)); EXPECT_TRUE(is_unauthorized(*response2)); + EXPECT_TRUE(response2->m_header_info.m_etc_fields.empty()); + response2->m_header_info.m_etc_fields = response2->m_additional_fields; const auth_responses parsed1 = parse_response(*response); const auth_responses parsed2 = parse_response(*response2); @@ -564,7 +568,7 @@ TEST(HTTP_Auth, DogFood) // with stale=true client should reset request.m_header_info.m_etc_fields.clear(); EXPECT_EQ(http::http_client_auth::kSuccess, client.handle_401(*response2)); - EXPECT_TRUE(add_field(request, client)); + EXPECT_TRUE(add_auth_field(request, client)); EXPECT_FALSE(bool(server.get_response(request))); // client should give up if stale=false @@ -654,7 +658,7 @@ TEST(HTTP_Client_Auth, MD5) EXPECT_EQ(http::http_client_auth::kBadPassword, auth.handle_401(response)); - response.m_additional_fields.front().second.append(u8"," + write_fields({{u8"stale", u8"TRUE"}})); + response.m_header_info.m_etc_fields.front().second.append(u8"," + write_fields({{u8"stale", u8"TRUE"}})); EXPECT_EQ(http::http_client_auth::kSuccess, auth.handle_401(response)); } @@ -718,7 +722,17 @@ TEST(HTTP_Client_Auth, MD5_auth) } EXPECT_EQ(http::http_client_auth::kBadPassword, auth.handle_401(response)); - response.m_additional_fields.back().second.append(u8"," + write_fields({{u8"stale", u8"trUe"}})); + response.m_header_info.m_etc_fields.back().second.append(u8"," + write_fields({{u8"stale", u8"trUe"}})); EXPECT_EQ(http::http_client_auth::kSuccess, auth.handle_401(response)); } + +TEST(HTTP, Add_Field) +{ + std::string str{"leading text"}; + epee::net_utils::http::add_field(str, "foo", "bar"); + epee::net_utils::http::add_field(str, std::string("bar"), std::string("foo")); + epee::net_utils::http::add_field(str, {"moarbars", "moarfoo"}); + + EXPECT_STREQ("leading textfoo: bar\r\nbar: foo\r\nmoarbars: moarfoo\r\n", str.c_str()); +} diff --git a/tests/unit_tests/parse_amount.cpp b/tests/unit_tests/parse_amount.cpp index 6c61d63f1..23e7eb292 100644 --- a/tests/unit_tests/parse_amount.cpp +++ b/tests/unit_tests/parse_amount.cpp @@ -30,7 +30,7 @@ #include "gtest/gtest.h" -#include "cryptonote_core/cryptonote_format_utils.h" +#include "cryptonote_basic/cryptonote_format_utils.h" using namespace cryptonote; diff --git a/tests/unit_tests/serialization.cpp b/tests/unit_tests/serialization.cpp index 1083dd4cc..5b8486a19 100644 --- a/tests/unit_tests/serialization.cpp +++ b/tests/unit_tests/serialization.cpp @@ -35,8 +35,8 @@ #include <vector> #include <boost/foreach.hpp> #include <boost/archive/portable_binary_iarchive.hpp> -#include "cryptonote_core/cryptonote_basic.h" -#include "cryptonote_core/cryptonote_basic_impl.h" +#include "cryptonote_basic/cryptonote_basic.h" +#include "cryptonote_basic/cryptonote_basic_impl.h" #include "ringct/rctSigs.h" #include "serialization/serialization.h" #include "serialization/binary_archive.h" diff --git a/tests/unit_tests/test_format_utils.cpp b/tests/unit_tests/test_tx_utils.cpp index 463d62529..91d5d5d67 100644 --- a/tests/unit_tests/test_format_utils.cpp +++ b/tests/unit_tests/test_tx_utils.cpp @@ -33,7 +33,7 @@ #include <vector> #include "common/util.h" -#include "cryptonote_core/cryptonote_format_utils.h" +#include "cryptonote_core/cryptonote_tx_utils.h" namespace { diff --git a/tests/unit_tests/varint.cpp b/tests/unit_tests/varint.cpp index a483cbd5f..a87eeb14b 100644 --- a/tests/unit_tests/varint.cpp +++ b/tests/unit_tests/varint.cpp @@ -34,8 +34,8 @@ #include <iostream> #include <vector> #include <boost/foreach.hpp> -#include "cryptonote_core/cryptonote_basic.h" -#include "cryptonote_core/cryptonote_basic_impl.h" +#include "cryptonote_basic/cryptonote_basic.h" +#include "cryptonote_basic/cryptonote_basic_impl.h" #include "serialization/serialization.h" #include "serialization/binary_archive.h" #include "serialization/json_archive.h" |