Add PROXY header handling unit test suite

The commit adds a fairly comprehensive unit test suite for our new
PROXYv2 handling code. The unit tests suite ensures both the
correctness of the code and ensures that the part responsible for
handling incoming headers is very strict regarding what to accept as
valid.
This commit is contained in:
Artem Boldariev 2023-03-03 16:43:15 +02:00
parent 2c76717881
commit 7d9a8ddc00
3 changed files with 1281 additions and 0 deletions

View file

@ -34,6 +34,7 @@ check_PROGRAMS = \
mutex_test \
netaddr_test \
parse_test \
proxyheader_test \
quota_test \
radix_test \
random_test \
@ -101,6 +102,16 @@ md_test_LDADD = \
$(LDADD) \
$(OPENSSL_LIBS)
proxyheader_test_CPPFLAGS = \
$(AM_CPPFLAGS)
proxyheader_test_LDADD = \
$(LDADD)
proxyheader_test_SOURCES = \
proxyheader_test.c \
proxyheader_test_data.h
random_test_LDADD = \
$(LDADD) \
-lm

1209
tests/isc/proxyheader_test.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,61 @@
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* SPDX-License-Identifier: MPL-2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#pragma once
static char proxy_v2_header[] = { 0x0d, 0x0a, 0x0d, 0x0a, 0x00, 0x0d, 0x0a,
0x51, 0x55, 0x49, 0x54, 0x0a, 0x21, 0x11,
0x00, 0x0c, 0x7f, 0x00, 0x00, 0x01, 0x7f,
0x00, 0x00, 0x42, 0xdd, 0xd0, 0x2e, 0x6b };
static char proxy_v2_header_with_TLS[] = {
0x0d, 0x0a, 0x0d, 0x0a, 0x00, 0x0d, 0x0a, 0x51, 0x55, 0x49, 0x54, 0x0a,
0x21, 0x11, 0x00, 0x1e, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x43,
0x9b, 0x4a, 0x2e, 0x6b, 0x20, 0x00, 0x0f, 0x01, 0x00, 0x00, 0x00, 0x00,
0x21, 0x00, 0x07, 0x54, 0x4c, 0x53, 0x76, 0x31, 0x2e, 0x32
};
static char proxy_v2_header_with_TLS_CN[] = {
0x0d, 0x0a, 0x0d, 0x0a, 0x00, 0x0d, 0x0a, 0x51, 0x55, 0x49, 0x54, 0x0a,
0x21, 0x11, 0x00, 0x2a, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x43,
0x9d, 0xd2, 0x2e, 0x6b, 0x20, 0x00, 0x1b, 0x07, 0x00, 0x00, 0x00, 0x00,
0x21, 0x00, 0x07, 0x54, 0x4c, 0x53, 0x76, 0x31, 0x2e, 0x32, 0x22, 0x00,
0x09, 0x6d, 0x71, 0x74, 0x74, 0x75, 0x73, 0x65, 0x72, 0x31
};
/*
* SRC ADDR: /run/src.sock
* DST ADDR: /run/dst.sock
*/
static char proxy_v2_header_with_AF_UNIX[] = {
0x0d, 0x0a, 0x0d, 0x0a, 0x00, 0x0d, 0x0a, 0x51, 0x55, 0x49, 0x54, 0x0a,
0x21, 0x32, 0x00, 0xd8, 0x2f, 0x72, 0x75, 0x6e, 0x2f, 0x73, 0x72, 0x63,
0x2e, 0x73, 0x6f, 0x63, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x2f, 0x72, 0x75, 0x6e, 0x2f, 0x64, 0x73, 0x74,
0x2e, 0x73, 0x6f, 0x63, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};