Skip to content

Commit 6031151

Browse files
author
Kevin Dorosh
committed
Add tests to ensure we disconnect invalid requests after valid signature
Signed-off-by: Kevin Dorosh <kevin.dorosh@solo.io>
1 parent c86edef commit 6031151

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc

+25
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,19 @@ TEST_P(ProxyProtocolTest, V2ShortV4) {
608608
expectProxyProtoError();
609609
}
610610

611+
TEST_P(ProxyProtocolTest, V2ShortV4WithAllowNoProxyProtocol) {
612+
// An ipv4/tcp connection that has incorrect addr-len encoded
613+
constexpr uint8_t buffer[] = {0x0d, 0x0a, 0x0d, 0x0a, 0x00, 0x0d, 0x0a, 0x51, 0x55, 0x49,
614+
0x54, 0x0a, 0x21, 0x21, 0x00, 0x04, 0x00, 0x08, 0x00, 0x02,
615+
'm', 'o', 'r', 'e', ' ', 'd', 'a', 't', 'a'};
616+
envoy::extensions::filters::listener::proxy_protocol::v3::ProxyProtocol proto_config;
617+
proto_config.set_allow_requests_without_proxy_protocol(true);
618+
connect(false, &proto_config);
619+
620+
write(buffer, sizeof(buffer));
621+
expectProxyProtoError();
622+
}
623+
611624
TEST_P(ProxyProtocolTest, V2ShortAddrV4) {
612625
// An ipv4/tcp connection that has insufficient header-length encoded
613626
constexpr uint8_t buffer[] = {0x0d, 0x0a, 0x0d, 0x0a, 0x00, 0x0d, 0x0a, 0x51, 0x55, 0x49,
@@ -691,6 +704,18 @@ TEST_P(ProxyProtocolTest, V1TooLong) {
691704
expectProxyProtoError();
692705
}
693706

707+
TEST_P(ProxyProtocolTest, V1TooLongWithAllowNoProxyProtocol) {
708+
constexpr uint8_t buffer[] = {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '};
709+
envoy::extensions::filters::listener::proxy_protocol::v3::ProxyProtocol proto_config;
710+
proto_config.set_allow_requests_without_proxy_protocol(true);
711+
connect(false, &proto_config);
712+
write("PROXY TCP4 1.2.3.4 2.3.4.5 100 100");
713+
for (size_t i = 0; i < 256; i += sizeof(buffer)) {
714+
write(buffer, sizeof(buffer));
715+
}
716+
expectProxyProtoError();
717+
}
718+
694719
TEST_P(ProxyProtocolTest, V2ParseExtensions) {
695720
// A well-formed ipv4/tcp with a pair of TLV extensions is accepted
696721
constexpr uint8_t buffer[] = {0x0d, 0x0a, 0x0d, 0x0a, 0x00, 0x0d, 0x0a, 0x51, 0x55, 0x49,

0 commit comments

Comments
 (0)