2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

Extend TLS Stream unit suite with PROXYv2 related tests

This commit adds a set of tests which help to verify that TLS Stream
works as expected on top of PROXY Stream.
This commit is contained in:
Artem Boldariev 2023-05-09 19:49:40 +03:00
parent 4437096ba0
commit 2020dce326
5 changed files with 246 additions and 25 deletions

View File

@ -697,6 +697,12 @@ stream_noop_setup(void **state ISC_ATTR_UNUSED) {
return (r);
}
int
proxystream_noop_setup(void **state) {
stream_use_PROXY = true;
return (stream_noop_setup(state));
}
void
stream_noop(void **state ISC_ATTR_UNUSED) {
isc_result_t result = ISC_R_SUCCESS;
@ -719,6 +725,14 @@ stream_noop_teardown(void **state ISC_ATTR_UNUSED) {
return (teardown_netmgr_test(state));
}
int
proxystream_noop_teardown(void **state) {
int r = stream_noop_teardown(state);
stream_use_PROXY = false;
return (r);
}
static void
noresponse_readcb(isc_nmhandle_t *handle, isc_result_t eresult,
isc_region_t *region, void *cbarg) {
@ -784,6 +798,19 @@ stream_noresponse_setup(void **state ISC_ATTR_UNUSED) {
return (r);
}
int
proxystream_noresponse_setup(void **state) {
stream_use_PROXY = true;
return (stream_noresponse_setup(state));
}
int
proxystream_noresponse_teardown(void **state) {
int r = stream_noresponse_teardown(state);
stream_use_PROXY = false;
return (r);
}
void
stream_noresponse(void **state ISC_ATTR_UNUSED) {
isc_result_t result = ISC_R_SUCCESS;
@ -824,6 +851,19 @@ stream_timeout_recovery_setup(void **state ISC_ATTR_UNUSED) {
return (r);
}
int
proxystream_timeout_recovery_setup(void **state) {
stream_use_PROXY = true;
return (stream_timeout_recovery_setup(state));
}
int
proxystream_timeout_recovery_teardown(void **state) {
int r = stream_timeout_recovery_teardown(state);
stream_use_PROXY = false;
return (r);
}
void
stream_timeout_recovery(void **state ISC_ATTR_UNUSED) {
isc_result_t result = ISC_R_SUCCESS;
@ -876,6 +916,19 @@ stream_recv_one_setup(void **state ISC_ATTR_UNUSED) {
return (r);
}
int
proxystream_recv_one_setup(void **state) {
stream_use_PROXY = true;
return (stream_recv_one_setup(state));
}
int
proxystream_recv_one_teardown(void **state) {
int r = stream_recv_one_teardown(state);
stream_use_PROXY = false;
return (r);
}
void
stream_recv_one(void **state ISC_ATTR_UNUSED) {
isc_result_t result = ISC_R_SUCCESS;
@ -928,6 +981,19 @@ stream_recv_two_setup(void **state ISC_ATTR_UNUSED) {
return (r);
}
int
proxystream_recv_two_setup(void **state) {
stream_use_PROXY = true;
return (stream_recv_two_setup(state));
}
int
proxystream_recv_two_teardown(void **state) {
int r = stream_recv_two_teardown(state);
stream_use_PROXY = false;
return (r);
}
void
stream_recv_two(void **state ISC_ATTR_UNUSED) {
isc_result_t result = ISC_R_SUCCESS;
@ -968,6 +1034,19 @@ stream_recv_send_setup(void **state ISC_ATTR_UNUSED) {
return (r);
}
int
proxystream_recv_send_setup(void **state) {
stream_use_PROXY = true;
return (stream_recv_send_setup(state));
}
int
proxystream_recv_send_teardown(void **state) {
int r = stream_recv_send_teardown(state);
stream_use_PROXY = false;
return (r);
}
void
stream_recv_send(void **state ISC_ATTR_UNUSED) {
isc_result_t result = ISC_R_SUCCESS;

View File

@ -295,6 +295,11 @@ stream_noop(void **state ISC_ATTR_UNUSED);
int
stream_noop_teardown(void **state ISC_ATTR_UNUSED);
int
proxystream_noop_setup(void **state);
int
proxystream_noop_teardown(void **state);
int
stream_noresponse_setup(void **state ISC_ATTR_UNUSED);
void
@ -302,6 +307,11 @@ stream_noresponse(void **state ISC_ATTR_UNUSED);
int
stream_noresponse_teardown(void **state ISC_ATTR_UNUSED);
int
proxystream_noresponse_setup(void **state);
int
proxystream_noresponse_teardown(void **state);
int
stream_timeout_recovery_setup(void **state ISC_ATTR_UNUSED);
void
@ -309,6 +319,11 @@ stream_timeout_recovery(void **state ISC_ATTR_UNUSED);
int
stream_timeout_recovery_teardown(void **state ISC_ATTR_UNUSED);
int
proxystream_timeout_recovery_setup(void **state);
int
proxystream_timeout_recovery_teardown(void **state);
int
stream_recv_one_setup(void **state ISC_ATTR_UNUSED);
void
@ -316,6 +331,11 @@ stream_recv_one(void **state ISC_ATTR_UNUSED);
int
stream_recv_one_teardown(void **state ISC_ATTR_UNUSED);
int
proxystream_recv_one_setup(void **state);
int
proxystream_recv_one_teardown(void **state);
int
stream_recv_two_setup(void **state ISC_ATTR_UNUSED);
void
@ -323,6 +343,11 @@ stream_recv_two(void **state ISC_ATTR_UNUSED);
int
stream_recv_two_teardown(void **state ISC_ATTR_UNUSED);
int
proxystream_recv_two_setup(void **state);
int
proxystream_recv_two_teardown(void **state);
int
stream_recv_send_setup(void **state ISC_ATTR_UNUSED);
void
@ -332,6 +357,11 @@ stream_recv_send_teardown(void **state ISC_ATTR_UNUSED);
void
stream_recv_send_connect(void *arg);
int
proxystream_recv_send_setup(void **state);
int
proxystream_recv_send_teardown(void **state);
int
stream_shutdownconnect_setup(void **state ISC_ATTR_UNUSED);
void
@ -339,6 +369,11 @@ stream_shutdownconnect(void **state ISC_ATTR_UNUSED);
int
stream_shutdownconnect_teardown(void **state ISC_ATTR_UNUSED);
int
proxystream_shutdownconnect_setup(void **state);
int
proxystream_shutdownconnect_teardown(void **state);
int
stream_shutdownread_setup(void **state ISC_ATTR_UNUSED);
void
@ -346,5 +381,10 @@ stream_shutdownread(void **state ISC_ATTR_UNUSED);
int
stream_shutdownread_teardown(void **state ISC_ATTR_UNUSED);
int
proxystream_shutdownread_setup(void **state);
int
proxystream_shutdownread_teardown(void **state);
void
stop_listening(void *arg ISC_ATTR_UNUSED);

View File

@ -121,34 +121,38 @@ ISC_LOOP_TEST_IMPL(proxystream_recv_send_quota_sendback) {
ISC_TEST_LIST_START
/* Stream */
ISC_TEST_ENTRY_CUSTOM(proxystream_noop, stream_noop_setup, stream_noop_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_noresponse, stream_noresponse_setup,
stream_noresponse_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_shutdownconnect, stream_shutdownconnect_setup,
stream_shutdownconnect_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_shutdownread, stream_shutdownread_setup,
stream_shutdownread_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_noop, proxystream_noop_setup,
proxystream_noop_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_noresponse, proxystream_noresponse_setup,
proxystream_noresponse_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_shutdownconnect,
proxystream_shutdownconnect_setup,
proxystream_shutdownconnect_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_shutdownread, proxystream_shutdownread_setup,
proxystream_shutdownread_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_timeout_recovery,
stream_timeout_recovery_setup,
stream_timeout_recovery_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_recv_one, stream_recv_one_setup,
stream_recv_one_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_recv_two, stream_recv_two_setup,
stream_recv_two_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_recv_send, stream_recv_send_setup,
stream_recv_send_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_recv_send_sendback, stream_recv_send_setup,
stream_recv_send_teardown)
proxystream_timeout_recovery_setup,
proxystream_timeout_recovery_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_recv_one, proxystream_recv_one_setup,
proxystream_recv_one_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_recv_two, proxystream_recv_two_setup,
proxystream_recv_two_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_recv_send, proxystream_recv_send_setup,
proxystream_recv_send_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_recv_send_sendback,
proxystream_recv_send_setup,
proxystream_recv_send_teardown)
/* Stream Quota */
ISC_TEST_ENTRY_CUSTOM(proxystream_recv_one_quota, stream_recv_one_setup,
stream_recv_one_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_recv_two_quota, stream_recv_two_setup,
stream_recv_two_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_recv_send_quota, stream_recv_send_setup,
stream_recv_send_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_recv_one_quota, proxystream_recv_one_setup,
proxystream_recv_one_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_recv_two_quota, proxystream_recv_two_setup,
proxystream_recv_two_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_recv_send_quota, proxystream_recv_send_setup,
proxystream_recv_send_teardown)
ISC_TEST_ENTRY_CUSTOM(proxystream_recv_send_quota_sendback,
stream_recv_send_setup, stream_recv_send_teardown)
proxystream_recv_send_setup,
proxystream_recv_send_teardown)
ISC_TEST_LIST_END
@ -156,7 +160,6 @@ static int
proxystream_setup(void **state ISC_ATTR_UNUSED) {
stream_port = PROXYSTREAM_TEST_PORT;
stream_use_TLS = false;
stream_use_PROXY = true;
stream = true;
return (0);

View File

@ -59,6 +59,19 @@ stream_shutdownconnect_setup(void **state ISC_ATTR_UNUSED) {
return (r);
}
int
proxystream_shutdownconnect_setup(void **state) {
stream_use_PROXY = true;
return (stream_shutdownconnect_setup(state));
}
int
proxystream_shutdownconnect_teardown(void **state) {
int r = stream_shutdownconnect_teardown(state);
stream_use_PROXY = false;
return (r);
}
void
stream_shutdownconnect(void **state ISC_ATTR_UNUSED) {
isc_result_t result = stream_listen(stream_accept_cb, NULL, 128, NULL,
@ -148,6 +161,19 @@ stream_shutdownread_setup(void **state ISC_ATTR_UNUSED) {
return (r);
}
int
proxystream_shutdownread_setup(void **state) {
stream_use_PROXY = true;
return (stream_shutdownread_setup(state));
}
int
proxystream_shutdownread_teardown(void **state) {
int r = stream_shutdownread_teardown(state);
stream_use_PROXY = false;
return (r);
}
void
stream_shutdownread(void **state ISC_ATTR_UNUSED) {
isc_result_t result = stream_listen(stream_accept_cb, NULL, 128, NULL,

View File

@ -114,6 +114,44 @@ ISC_LOOP_TEST_IMPL(tls_recv_send_quota_sendback) {
stream_recv_send(arg);
}
/* PROXY tests */
ISC_LOOP_TEST_IMPL(proxy_tls_noop) { loop_test_tls_noop(arg); }
ISC_LOOP_TEST_IMPL(proxy_tls_noresponse) { loop_test_tls_noresponse(arg); }
ISC_LOOP_TEST_IMPL(proxy_tls_shutdownconnect) {
loop_test_tls_shutdownconnect(arg);
}
ISC_LOOP_TEST_IMPL(proxy_tls_shutdownread) { loop_test_tls_shutdownread(arg); }
ISC_LOOP_TEST_IMPL(proxy_tls_timeout_recovery) {
loop_test_tls_timeout_recovery(arg);
}
ISC_LOOP_TEST_IMPL(proxy_tls_recv_one) { loop_test_tls_recv_one(arg); }
ISC_LOOP_TEST_IMPL(proxy_tls_recv_two) { loop_test_tls_recv_two(arg); }
ISC_LOOP_TEST_IMPL(proxy_tls_recv_send) { loop_test_tls_recv_send(arg); }
ISC_LOOP_TEST_IMPL(proxy_tls_recv_send_sendback) {
loop_test_tls_recv_send(arg);
}
/* TLS quota */
ISC_LOOP_TEST_IMPL(proxy_tls_recv_one_quota) { loop_test_tls_recv_one(arg); }
ISC_LOOP_TEST_IMPL(proxy_tls_recv_two_quota) { loop_test_tls_recv_two(arg); }
ISC_LOOP_TEST_IMPL(proxy_tls_recv_send_quota) { loop_test_tls_recv_send(arg); }
ISC_LOOP_TEST_IMPL(proxy_tls_recv_send_quota_sendback) {
loop_test_tls_recv_send(arg);
}
ISC_TEST_LIST_START
/* TLS */
@ -145,6 +183,41 @@ ISC_TEST_ENTRY_CUSTOM(tls_recv_send_quota, stream_recv_send_setup,
ISC_TEST_ENTRY_CUSTOM(tls_recv_send_quota_sendback, stream_recv_send_setup,
stream_recv_send_teardown)
/* PROXY */
/* TLS */
ISC_TEST_ENTRY_CUSTOM(proxy_tls_noop, proxystream_noop_setup,
proxystream_noop_teardown)
ISC_TEST_ENTRY_CUSTOM(proxy_tls_noresponse, proxystream_noresponse_setup,
proxystream_noresponse_teardown)
ISC_TEST_ENTRY_CUSTOM(proxy_tls_shutdownconnect,
proxystream_shutdownconnect_setup,
proxystream_shutdownconnect_teardown)
ISC_TEST_ENTRY_CUSTOM(proxy_tls_shutdownread, proxystream_shutdownread_setup,
proxystream_shutdownread_teardown)
ISC_TEST_ENTRY_CUSTOM(proxy_tls_timeout_recovery,
proxystream_timeout_recovery_setup,
proxystream_timeout_recovery_teardown)
ISC_TEST_ENTRY_CUSTOM(proxy_tls_recv_one, proxystream_recv_one_setup,
proxystream_recv_one_teardown)
ISC_TEST_ENTRY_CUSTOM(proxy_tls_recv_two, proxystream_recv_two_setup,
proxystream_recv_two_teardown)
ISC_TEST_ENTRY_CUSTOM(proxy_tls_recv_send, proxystream_recv_send_setup,
proxystream_recv_send_teardown)
ISC_TEST_ENTRY_CUSTOM(proxy_tls_recv_send_sendback, proxystream_recv_send_setup,
proxystream_recv_send_teardown)
/* TLS quota */
ISC_TEST_ENTRY_CUSTOM(proxy_tls_recv_one_quota, proxystream_recv_one_setup,
proxystream_recv_one_teardown)
ISC_TEST_ENTRY_CUSTOM(proxy_tls_recv_two_quota, proxystream_recv_two_setup,
proxystream_recv_two_teardown)
ISC_TEST_ENTRY_CUSTOM(proxy_tls_recv_send_quota, proxystream_recv_send_setup,
proxystream_recv_send_teardown)
ISC_TEST_ENTRY_CUSTOM(proxy_tls_recv_send_quota_sendback,
proxystream_recv_send_setup,
proxystream_recv_send_teardown)
ISC_TEST_LIST_END
static int