diff --git a/test/common/http/BUILD b/test/common/http/BUILD index ee91fd614c683..d138a97587059 100644 --- a/test/common/http/BUILD +++ b/test/common/http/BUILD @@ -214,7 +214,8 @@ envoy_cc_test( ], shard_count = 3, deps = [ - ":ip_detection_extensions_lib", + ":custom_header_extension_lib", + ":xff_extension_lib", "//source/common/http:conn_manager_lib", "//source/common/http:context_lib", "//source/extensions/access_loggers/common:file_access_log_lib", @@ -239,7 +240,8 @@ envoy_cc_test( name = "conn_manager_utility_test", srcs = ["conn_manager_utility_test.cc"], deps = [ - ":ip_detection_extensions_lib", + ":custom_header_extension_lib", + ":xff_extension_lib", "//source/common/common:random_generator_lib", "//source/common/event:dispatcher_lib", "//source/common/http:conn_manager_lib", @@ -497,11 +499,19 @@ envoy_cc_fuzz_test( ) envoy_cc_test_library( - name = "ip_detection_extensions_lib", - srcs = ["ip_detection_extensions.cc"], - hdrs = ["ip_detection_extensions.h"], + name = "custom_header_extension_lib", + srcs = ["custom_header_extension.cc"], + hdrs = ["custom_header_extension.h"], deps = [ "//source/extensions/http/original_ip_detection/custom_header:custom_header_lib", + ], +) + +envoy_cc_test_library( + name = "xff_extension_lib", + srcs = ["xff_extension.cc"], + hdrs = ["xff_extension.h"], + deps = [ "//source/extensions/http/original_ip_detection/xff:xff_lib", ], ) diff --git a/test/common/http/conn_manager_impl_test_2.cc b/test/common/http/conn_manager_impl_test_2.cc index f660286015139..3c71e80667695 100644 --- a/test/common/http/conn_manager_impl_test_2.cc +++ b/test/common/http/conn_manager_impl_test_2.cc @@ -1,5 +1,5 @@ #include "test/common/http/conn_manager_impl_test_base.h" -#include "test/common/http/ip_detection_extensions.h" +#include "test/common/http/custom_header_extension.h" #include "test/test_common/logging.h" #include "test/test_common/test_runtime.h" diff --git a/test/common/http/conn_manager_impl_test_base.cc b/test/common/http/conn_manager_impl_test_base.cc index cd9fa25b98e67..92e74ac4c97a5 100644 --- a/test/common/http/conn_manager_impl_test_base.cc +++ b/test/common/http/conn_manager_impl_test_base.cc @@ -2,7 +2,7 @@ #include "extensions/request_id/uuid/config.h" -#include "test/common/http/ip_detection_extensions.h" +#include "test/common/http/xff_extension.h" using testing::AtLeast; using testing::InSequence; diff --git a/test/common/http/conn_manager_utility_test.cc b/test/common/http/conn_manager_utility_test.cc index 7dc2a957ebad9..0ad8b25fc127c 100644 --- a/test/common/http/conn_manager_utility_test.cc +++ b/test/common/http/conn_manager_utility_test.cc @@ -14,7 +14,8 @@ #include "extensions/request_id/uuid/config.h" -#include "test/common/http/ip_detection_extensions.h" +#include "test/common/http/custom_header_extension.h" +#include "test/common/http/xff_extension.h" #include "test/mocks/http/mocks.h" #include "test/mocks/local_info/mocks.h" #include "test/mocks/network/mocks.h" diff --git a/test/common/http/ip_detection_extensions.cc b/test/common/http/custom_header_extension.cc similarity index 74% rename from test/common/http/ip_detection_extensions.cc rename to test/common/http/custom_header_extension.cc index 95c2abec84888..33bb73e363064 100644 --- a/test/common/http/ip_detection_extensions.cc +++ b/test/common/http/custom_header_extension.cc @@ -1,14 +1,9 @@ -#include "ip_detection_extensions.h" +#include "test/common/http/custom_header_extension.h" #include "extensions/http/original_ip_detection/custom_header/custom_header.h" -#include "extensions/http/original_ip_detection/xff/xff.h" namespace Envoy { -Http::OriginalIPDetectionSharedPtr getXFFExtension(uint32_t hops) { - return std::make_shared(hops); -} - Http::OriginalIPDetectionSharedPtr getCustomHeaderExtension(const std::string& header_name) { return std::make_shared< Extensions::Http::OriginalIPDetection::CustomHeader::CustomHeaderIPDetection>(header_name); diff --git a/test/common/http/ip_detection_extensions.h b/test/common/http/custom_header_extension.h similarity index 86% rename from test/common/http/ip_detection_extensions.h rename to test/common/http/custom_header_extension.h index 32863f20a1a10..638f291eb0f45 100644 --- a/test/common/http/ip_detection_extensions.h +++ b/test/common/http/custom_header_extension.h @@ -5,7 +5,6 @@ // This helper is used to escape namespace pollution issues. namespace Envoy { -Http::OriginalIPDetectionSharedPtr getXFFExtension(uint32_t hops); Http::OriginalIPDetectionSharedPtr getCustomHeaderExtension(const std::string& header_name); Http::OriginalIPDetectionSharedPtr getCustomHeaderExtension(const std::string& header_name, diff --git a/test/common/http/xff_extension.cc b/test/common/http/xff_extension.cc new file mode 100644 index 0000000000000..3cca217790578 --- /dev/null +++ b/test/common/http/xff_extension.cc @@ -0,0 +1,11 @@ +#include "test/common/http/xff_extension.h" + +#include "extensions/http/original_ip_detection/xff/xff.h" + +namespace Envoy { + +Http::OriginalIPDetectionSharedPtr getXFFExtension(uint32_t hops) { + return std::make_shared(hops); +} + +} // namespace Envoy diff --git a/test/common/http/xff_extension.h b/test/common/http/xff_extension.h new file mode 100644 index 0000000000000..a8b203848452a --- /dev/null +++ b/test/common/http/xff_extension.h @@ -0,0 +1,10 @@ +#pragma once + +#include "envoy/http/original_ip_detection.h" + +// This helper is used to escape namespace pollution issues. +namespace Envoy { + +Http::OriginalIPDetectionSharedPtr getXFFExtension(uint32_t hops); + +} // namespace Envoy