Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions test/extensions/filters/listener/tls_inspector/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,34 @@ envoy_cc_library(
"//source/common/common:assert_lib",
],
)

envoy_cc_test(
name = "tls_inspector_integration_test",
srcs = [
"tls_inspector_integration_test.cc",
],
data = [
"//test/config/integration/certs",
],
deps = [
"//source/common/config:api_version_lib",
"//source/common/event:dispatcher_includes",
"//source/common/event:dispatcher_lib",
"//source/common/network:utility_lib",
"//source/extensions/access_loggers/file:config",
"//source/extensions/filters/listener/tls_inspector:config",
"//source/extensions/filters/listener/tls_inspector:tls_inspector_lib",
"//source/extensions/filters/network/echo:config",
"//source/extensions/transport_sockets/tls:config",
"//source/extensions/transport_sockets/tls:context_config_lib",
"//source/extensions/transport_sockets/tls:context_lib",
"//test/integration:integration_lib",
"//test/mocks/runtime:runtime_mocks",
"//test/mocks/secret:secret_mocks",
"//test/test_common:utility_lib",
"@envoy_api//envoy/config/bootstrap/v3:pkg_cc_proto",
"@envoy_api//envoy/config/cluster/v3:pkg_cc_proto",
"@envoy_api//envoy/config/core/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/access_loggers/file/v3:pkg_cc_proto",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
namespace Envoy {
namespace {

class ListenerFilterIntegrationTest : public testing::TestWithParam<Network::Address::IpVersion>,
public BaseIntegrationTest {
class TlsInspectorIntegrationTest : public testing::TestWithParam<Network::Address::IpVersion>,
public BaseIntegrationTest {
public:
ListenerFilterIntegrationTest()
TlsInspectorIntegrationTest()
: BaseIntegrationTest(GetParam(), ConfigHelper::baseConfig() + R"EOF(
filter_chains:
filters:
- name: envoy.filters.network.echo
)EOF") {}

~ListenerFilterIntegrationTest() override = default;
~TlsInspectorIntegrationTest() override = default;
std::string appendMatcher(const std::string& listener_filter, bool disabled) {
if (disabled) {
return listener_filter +
Expand All @@ -49,9 +49,9 @@ class ListenerFilterIntegrationTest : public testing::TestWithParam<Network::Add
}
}

void initializeWithListenerFilter(bool ssl_client, const std::string& log_format,
absl::optional<bool> listener_filter_disabled = absl::nullopt,
bool enable_ja3_fingerprinting = false) {
void initializeWithTlsInspector(bool ssl_client, const std::string& log_format,
absl::optional<bool> listener_filter_disabled = absl::nullopt,
bool enable_ja3_fingerprinting = false) {
config_helper_.renameListener("echo");
std::string tls_inspector_config = ConfigHelper::tlsInspectorFilter(enable_ja3_fingerprinting);
if (listener_filter_disabled.has_value()) {
Expand Down Expand Up @@ -91,8 +91,8 @@ class ListenerFilterIntegrationTest : public testing::TestWithParam<Network::Add
const Ssl::ClientSslTransportOptions& ssl_options = {},
const std::string& curves_list = "",
bool enable_ja3_fingerprinting = false) {
initializeWithListenerFilter(ssl_client, log_format, listener_filter_disabled,
enable_ja3_fingerprinting);
initializeWithTlsInspector(ssl_client, log_format, listener_filter_disabled,
enable_ja3_fingerprinting);

// Set up the SSL client.
Network::Address::InstanceConstSharedPtr address =
Expand Down Expand Up @@ -140,23 +140,23 @@ class ListenerFilterIntegrationTest : public testing::TestWithParam<Network::Add
};

// Each listener filter is enabled by default.
TEST_P(ListenerFilterIntegrationTest, AllListenerFiltersAreEnabledByDefault) {
TEST_P(TlsInspectorIntegrationTest, AllListenerFiltersAreEnabledByDefault) {
setupConnections(/*listener_filter_disabled=*/false, /*expect_connection_open=*/true,
/*ssl_client=*/true);
client_->close(Network::ConnectionCloseType::NoFlush);
EXPECT_THAT(waitForAccessLog(listener_access_log_name_), testing::Eq("-"));
}

// The tls_inspector is disabled. The ALPN won't be sniffed out and no filter chain is matched.
TEST_P(ListenerFilterIntegrationTest, DisabledTlsInspectorFailsFilterChainFind) {
TEST_P(TlsInspectorIntegrationTest, DisabledTlsInspectorFailsFilterChainFind) {
setupConnections(/*listener_filter_disabled=*/true, /*expect_connection_open=*/false,
/*ssl_client=*/true);
EXPECT_THAT(waitForAccessLog(listener_access_log_name_),
testing::Eq(StreamInfo::ResponseCodeDetails::get().FilterChainNotFound));
}

// trigger the tls inspect filter timeout, and continue create new connection after timeout
TEST_P(ListenerFilterIntegrationTest, ContinueOnListenerTimeout) {
TEST_P(TlsInspectorIntegrationTest, ContinueOnListenerTimeout) {
setupConnections(/*listener_filter_disabled=*/false, /*expect_connection_open=*/true,
/*ssl_client=*/false);
// The length of tls hello message is defined as `TLS_MAX_CLIENT_HELLO = 64 * 1024`
Expand All @@ -171,7 +171,7 @@ TEST_P(ListenerFilterIntegrationTest, ContinueOnListenerTimeout) {
}

// The `JA3` fingerprint is correct in the access log.
TEST_P(ListenerFilterIntegrationTest, JA3FingerprintIsSet) {
TEST_P(TlsInspectorIntegrationTest, JA3FingerprintIsSet) {
// These TLS options will create a client hello message with
// `JA3` fingerprint:
// `771,49199,23-65281-10-11-35-16-13,23,0`
Expand All @@ -189,7 +189,7 @@ TEST_P(ListenerFilterIntegrationTest, JA3FingerprintIsSet) {
testing::Eq("71d1f47d1125ac53c3c6a4863c087cfe"));
}

INSTANTIATE_TEST_SUITE_P(IpVersions, ListenerFilterIntegrationTest,
INSTANTIATE_TEST_SUITE_P(IpVersions, TlsInspectorIntegrationTest,
testing::ValuesIn(TestEnvironment::getIpVersionsForTest()),
TestUtility::ipTestParamsToString);
} // namespace
Expand Down
31 changes: 0 additions & 31 deletions test/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1702,37 +1702,6 @@ envoy_cc_test(
],
)

envoy_cc_test(
name = "listener_filter_integration_test",
srcs = [
"listener_filter_integration_test.cc",
],
data = [
"//test/config/integration/certs",
],
deps = [
":integration_lib",
"//source/common/config:api_version_lib",
"//source/common/event:dispatcher_includes",
"//source/common/event:dispatcher_lib",
"//source/common/network:utility_lib",
"//source/extensions/access_loggers/file:config",
"//source/extensions/filters/listener/tls_inspector:config",
"//source/extensions/filters/listener/tls_inspector:tls_inspector_lib",
"//source/extensions/filters/network/echo:config",
"//source/extensions/transport_sockets/tls:config",
"//source/extensions/transport_sockets/tls:context_config_lib",
"//source/extensions/transport_sockets/tls:context_lib",
"//test/mocks/runtime:runtime_mocks",
"//test/mocks/secret:secret_mocks",
"//test/test_common:utility_lib",
"@envoy_api//envoy/config/bootstrap/v3:pkg_cc_proto",
"@envoy_api//envoy/config/cluster/v3:pkg_cc_proto",
"@envoy_api//envoy/config/core/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/access_loggers/file/v3:pkg_cc_proto",
],
)

envoy_cc_test(
name = "cx_limit_integration_test",
srcs = ["cx_limit_integration_test.cc"],
Expand Down