| 1 |
/* |
| 2 |
* Copyright (C) Internet Systems Consortium, Inc. ("ISC") |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MPL-2.0 |
| 5 |
* |
| 6 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 7 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 8 |
* file, you can obtain one at https://mozilla.org/MPL/2.0/. |
| 9 |
* |
| 10 |
* See the COPYRIGHT file distributed with this work for additional |
| 11 |
* information regarding copyright ownership. |
| 12 |
*/ |
| 13 |
|
| 14 |
#include <inttypes.h> |
| 15 |
#include <sched.h> /* IWYU pragma: keep */ |
| 16 |
#include <setjmp.h> |
| 17 |
#include <stdarg.h> |
| 18 |
#include <stdbool.h> |
| 19 |
#include <stddef.h> |
| 20 |
#include <stdlib.h> |
| 21 |
#include <time.h> |
| 22 |
#include <unistd.h> |
| 23 |
|
| 24 |
/* |
| 25 |
* As a workaround, include an OpenSSL header file before including cmocka.h, |
| 26 |
* because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a |
| 27 |
* redefined malloc in cmocka.h. |
| 28 |
*/ |
| 29 |
#include <openssl/err.h> |
| 30 |
|
| 31 |
#define UNIT_TESTING |
| 32 |
#include <cmocka.h> |
| 33 |
|
| 34 |
#include <isc/async.h> |
| 35 |
#include <isc/atomic.h> |
| 36 |
#include <isc/buffer.h> |
| 37 |
#include <isc/condition.h> |
| 38 |
#include <isc/mutex.h> |
| 39 |
#include <isc/netmgr.h> |
| 40 |
#include <isc/nonce.h> |
| 41 |
#include <isc/os.h> |
| 42 |
#include <isc/refcount.h> |
| 43 |
#include <isc/sockaddr.h> |
| 44 |
#include <isc/thread.h> |
| 45 |
#include <isc/util.h> |
| 46 |
#include <isc/uv.h> |
| 47 |
|
| 48 |
#include "uv_wrap.h" |
| 49 |
#define KEEP_BEFORE |
| 50 |
|
| 51 |
#include "netmgr/http.c" |
| 52 |
#include "netmgr/netmgr-int.h" |
| 53 |
#include "netmgr/socket.c" |
| 54 |
|
| 55 |
#include <tests/isc.h> |
| 56 |
|
| 57 |
#define MAX_NM 2 |
| 58 |
|
| 59 |
static isc_sockaddr_t tcp_listen_addr; |
| 60 |
|
| 61 |
static uint64_t send_magic = 0; |
| 62 |
static uint64_t stop_magic = 0; |
| 63 |
|
| 64 |
static uv_buf_t send_msg = { .base = (char *)&send_magic, |
| 65 |
.len = sizeof(send_magic) }; |
| 66 |
|
| 67 |
static atomic_int_fast64_t active_cconnects = 0; |
| 68 |
static atomic_int_fast64_t nsends = 0; |
| 69 |
static atomic_int_fast64_t ssends = 0; |
| 70 |
static atomic_int_fast64_t sreads = 0; |
| 71 |
static atomic_int_fast64_t csends = 0; |
| 72 |
static atomic_int_fast64_t creads = 0; |
| 73 |
static atomic_int_fast64_t ctimeouts = 0; |
| 74 |
static atomic_int_fast64_t total_sends = 0; |
| 75 |
|
| 76 |
static int expected_ssends; |
| 77 |
static int expected_sreads; |
| 78 |
static int expected_csends; |
| 79 |
static int expected_cconnects; |
| 80 |
static int expected_creads; |
| 81 |
static int expected_ctimeouts; |
| 82 |
|
| 83 |
#define have_expected_ssends(v) ((v) >= expected_ssends && expected_ssends >= 0) |
| 84 |
#define have_expected_sreads(v) ((v) >= expected_sreads && expected_sreads >= 0) |
| 85 |
#define have_expected_csends(v) ((v) >= expected_csends && expected_csends >= 0) |
| 86 |
#define have_expected_cconnects(v) \ |
| 87 |
((v) >= expected_cconnects && expected_cconnects >= 0) |
| 88 |
#define have_expected_creads(v) ((v) >= expected_creads && expected_creads >= 0) |
| 89 |
#define have_expected_ctimeouts(v) \ |
| 90 |
((v) >= expected_ctimeouts && expected_ctimeouts >= 0) |
| 91 |
|
| 92 |
static bool noanswer = false; |
| 93 |
|
| 94 |
static atomic_bool POST = true; |
| 95 |
|
| 96 |
static atomic_bool use_TLS = false; |
| 97 |
static isc_tlsctx_t *server_tlsctx = NULL; |
| 98 |
static isc_tlsctx_t *client_tlsctx = NULL; |
| 99 |
static isc_tlsctx_client_session_cache_t *client_sess_cache = NULL; |
| 100 |
|
| 101 |
static isc_quota_t listener_quota; |
| 102 |
static atomic_bool check_listener_quota = false; |
| 103 |
|
| 104 |
static isc_nm_http_endpoints_t *endpoints = NULL; |
| 105 |
|
| 106 |
static atomic_bool use_PROXY = false; |
| 107 |
static atomic_bool use_PROXY_over_TLS = false; |
| 108 |
|
| 109 |
static isc_nm_t **nm = NULL; |
| 110 |
|
| 111 |
/* Timeout for soft-timeout tests (0.05 seconds) */ |
| 112 |
#define T_SOFT 50 |
| 113 |
#define T_CONNECT 30 * 1000 |
| 114 |
|
| 115 |
#define NSENDS 100 |
| 116 |
#define NWRITES 10 |
| 117 |
|
| 118 |
#define CHECK_RANGE_FULL(v) \ |
| 119 |
{ \ |
| 120 |
int __v = atomic_load(&v); \ |
| 121 |
assert_true(__v >= atomic_load(&total_sends)); \ |
| 122 |
} |
| 123 |
|
| 124 |
#define CHECK_RANGE_HALF(v) \ |
| 125 |
{ \ |
| 126 |
int __v = atomic_load(&v); \ |
| 127 |
assert_true(__v >= atomic_load(&total_sends) / 2); \ |
| 128 |
} |
| 129 |
|
| 130 |
/* Enable this to print values while running tests */ |
| 131 |
#undef PRINT_DEBUG |
| 132 |
#ifdef PRINT_DEBUG |
| 133 |
#define X(v) fprintf(stderr, #v " = %" PRIu64 "\n", atomic_load(&v)) |
| 134 |
#else |
| 135 |
#define X(v) |
| 136 |
#endif |
| 137 |
|
| 138 |
static isc_nm_proxy_type_t |
| 139 |
get_proxy_type(void) { |
| 140 |
if (!atomic_load(&use_PROXY)) { |
| 141 |
return ISC_NM_PROXY_NONE; |
| 142 |
} else if (atomic_load(&use_TLS) && atomic_load(&use_PROXY_over_TLS)) { |
| 143 |
return ISC_NM_PROXY_ENCRYPTED; |
| 144 |
} |
| 145 |
|
| 146 |
return ISC_NM_PROXY_PLAIN; |
| 147 |
} |
| 148 |
|
| 149 |
static void |
| 150 |
proxy_verify_unspec_endpoint(isc_nmhandle_t *handle) { |
| 151 |
isc_sockaddr_t real_local, real_peer, local, peer; |
| 152 |
|
| 153 |
if (isc_nm_is_proxy_unspec(handle)) { |
| 154 |
peer = isc_nmhandle_peeraddr(handle); |
| 155 |
local = isc_nmhandle_localaddr(handle); |
| 156 |
real_peer = isc_nmhandle_real_peeraddr(handle); |
| 157 |
real_local = isc_nmhandle_real_localaddr(handle); |
| 158 |
|
| 159 |
assert_true(isc_sockaddr_equal(&peer, &real_peer)); |
| 160 |
assert_true(isc_sockaddr_equal(&local, &real_local)); |
| 161 |
} |
| 162 |
} |
| 163 |
|
| 164 |
typedef struct csdata { |
| 165 |
isc_mem_t *mctx; |
| 166 |
isc_nm_recv_cb_t reply_cb; |
| 167 |
void *cb_arg; |
| 168 |
isc_region_t region; |
| 169 |
} csdata_t; |
| 170 |
|
| 171 |
static void |
| 172 |
connect_send_cb(isc_nmhandle_t *handle, isc_result_t result, void *arg) { |
| 173 |
csdata_t data; |
| 174 |
|
| 175 |
(void)atomic_fetch_sub(&active_cconnects, 1); |
| 176 |
memmove(&data, arg, sizeof(data)); |
| 177 |
isc_mem_put(data.mctx, arg, sizeof(data)); |
| 178 |
if (result != ISC_R_SUCCESS) { |
| 179 |
goto error; |
| 180 |
} |
| 181 |
|
| 182 |
REQUIRE(VALID_NMHANDLE(handle)); |
| 183 |
|
| 184 |
result = isc__nm_http_request(handle, &data.region, data.reply_cb, |
| 185 |
data.cb_arg); |
| 186 |
if (result != ISC_R_SUCCESS) { |
| 187 |
goto error; |
| 188 |
} |
| 189 |
|
| 190 |
isc_mem_putanddetach(&data.mctx, data.region.base, data.region.length); |
| 191 |
return; |
| 192 |
error: |
| 193 |
data.reply_cb(handle, result, NULL, data.cb_arg); |
| 194 |
isc_mem_putanddetach(&data.mctx, data.region.base, data.region.length); |
| 195 |
} |
| 196 |
|
| 197 |
static void |
| 198 |
connect_send_request(isc_nm_t *mgr, const char *uri, bool post, |
| 199 |
isc_region_t *region, isc_nm_recv_cb_t cb, void *cbarg, |
| 200 |
bool tls, unsigned int timeout) { |
| 201 |
isc_region_t copy; |
| 202 |
csdata_t *data = NULL; |
| 203 |
isc_tlsctx_t *ctx = NULL; |
| 204 |
|
| 205 |
copy = (isc_region_t){ .base = isc_mem_get(mgr->mctx, region->length), |
| 206 |
.length = region->length }; |
| 207 |
memmove(copy.base, region->base, region->length); |
| 208 |
data = isc_mem_get(mgr->mctx, sizeof(*data)); |
| 209 |
*data = (csdata_t){ .reply_cb = cb, .cb_arg = cbarg, .region = copy }; |
| 210 |
isc_mem_attach(mgr->mctx, &data->mctx); |
| 211 |
if (tls) { |
| 212 |
ctx = client_tlsctx; |
| 213 |
} |
| 214 |
|
| 215 |
isc_nm_httpconnect(mgr, NULL, &tcp_listen_addr, uri, post, |
| 216 |
connect_send_cb, data, ctx, client_sess_cache, |
| 217 |
timeout, get_proxy_type(), NULL); |
| 218 |
} |
| 219 |
|
| 220 |
static int |
| 221 |
setup_ephemeral_port(isc_sockaddr_t *addr, sa_family_t family) { |
| 222 |
isc_result_t result; |
| 223 |
socklen_t addrlen = sizeof(*addr); |
| 224 |
int fd; |
| 225 |
int r; |
| 226 |
|
| 227 |
isc_sockaddr_fromin6(addr, &in6addr_loopback, 0); |
| 228 |
|
| 229 |
fd = socket(AF_INET6, family, 0); |
| 230 |
if (fd < 0) { |
| 231 |
perror("setup_ephemeral_port: socket()"); |
| 232 |
return -1; |
| 233 |
} |
| 234 |
|
| 235 |
r = bind(fd, (const struct sockaddr *)&addr->type.sa, |
| 236 |
sizeof(addr->type.sin6)); |
| 237 |
if (r != 0) { |
| 238 |
perror("setup_ephemeral_port: bind()"); |
| 239 |
isc__nm_closesocket(fd); |
| 240 |
return r; |
| 241 |
} |
| 242 |
|
| 243 |
r = getsockname(fd, (struct sockaddr *)&addr->type.sa, &addrlen); |
| 244 |
if (r != 0) { |
| 245 |
perror("setup_ephemeral_port: getsockname()"); |
| 246 |
isc__nm_closesocket(fd); |
| 247 |
return r; |
| 248 |
} |
| 249 |
|
| 250 |
result = isc__nm_socket_reuse(fd, 1); |
| 251 |
if (result != ISC_R_SUCCESS && result != ISC_R_NOTIMPLEMENTED) { |
| 252 |
fprintf(stderr, |
| 253 |
"setup_ephemeral_port: isc__nm_socket_reuse(): %s", |
| 254 |
isc_result_totext(result)); |
| 255 |
close(fd); |
| 256 |
return -1; |
| 257 |
} |
| 258 |
|
| 259 |
result = isc__nm_socket_reuse_lb(fd); |
| 260 |
if (result != ISC_R_SUCCESS && result != ISC_R_NOTIMPLEMENTED) { |
| 261 |
fprintf(stderr, |
| 262 |
"setup_ephemeral_port: isc__nm_socket_reuse_lb(): %s", |
| 263 |
isc_result_totext(result)); |
| 264 |
close(fd); |
| 265 |
return -1; |
| 266 |
} |
| 267 |
|
| 268 |
#if IPV6_RECVERR |
| 269 |
#define setsockopt_on(socket, level, name) \ |
| 270 |
setsockopt(socket, level, name, &(int){ 1 }, sizeof(int)) |
| 271 |
|
| 272 |
r = setsockopt_on(fd, IPPROTO_IPV6, IPV6_RECVERR); |
| 273 |
if (r != 0) { |
| 274 |
perror("setup_ephemeral_port"); |
| 275 |
close(fd); |
| 276 |
return r; |
| 277 |
} |
| 278 |
#endif |
| 279 |
|
| 280 |
return fd; |
| 281 |
} |
| 282 |
|
| 283 |
/* Generic */ |
| 284 |
|
| 285 |
static void |
| 286 |
noop_read_cb(isc_nmhandle_t *handle, isc_result_t result, isc_region_t *region, |
| 287 |
void *cbarg) { |
| 288 |
UNUSED(handle); |
| 289 |
UNUSED(result); |
| 290 |
UNUSED(region); |
| 291 |
UNUSED(cbarg); |
| 292 |
} |
| 293 |
|
| 294 |
thread_local uint8_t tcp_buffer_storage[4096]; |
| 295 |
thread_local size_t tcp_buffer_length = 0; |
| 296 |
|
| 297 |
static int |
| 298 |
setup_test(void **state) { |
| 299 |
char *env_workers = getenv("ISC_TASK_WORKERS"); |
| 300 |
uv_os_sock_t tcp_listen_sock = -1; |
| 301 |
|
| 302 |
tcp_listen_addr = (isc_sockaddr_t){ .length = 0 }; |
| 303 |
tcp_listen_sock = setup_ephemeral_port(&tcp_listen_addr, SOCK_STREAM); |
| 304 |
if (tcp_listen_sock < 0) { |
| 305 |
return -1; |
| 306 |
} |
| 307 |
close(tcp_listen_sock); |
| 308 |
tcp_listen_sock = -1; |
| 309 |
|
| 310 |
if (env_workers != NULL) { |
| 311 |
workers = atoi(env_workers); |
| 312 |
} else { |
| 313 |
workers = isc_os_ncpus(); |
| 314 |
} |
| 315 |
INSIST(workers > 0); |
| 316 |
|
| 317 |
atomic_store(&total_sends, NSENDS * NWRITES); |
| 318 |
atomic_store(&nsends, atomic_load(&total_sends)); |
| 319 |
|
| 320 |
atomic_store(&csends, 0); |
| 321 |
atomic_store(&creads, 0); |
| 322 |
atomic_store(&sreads, 0); |
| 323 |
atomic_store(&ssends, 0); |
| 324 |
atomic_store(&ctimeouts, 0); |
| 325 |
atomic_store(&active_cconnects, 0); |
| 326 |
|
| 327 |
expected_cconnects = -1; |
| 328 |
expected_csends = -1; |
| 329 |
expected_creads = -1; |
| 330 |
expected_sreads = -1; |
| 331 |
expected_ssends = -1; |
| 332 |
expected_ctimeouts = -1; |
| 333 |
|
| 334 |
atomic_store(&POST, false); |
| 335 |
atomic_store(&use_TLS, false); |
| 336 |
atomic_store(&use_PROXY, false); |
| 337 |
atomic_store(&use_PROXY_over_TLS, false); |
| 338 |
|
| 339 |
noanswer = false; |
| 340 |
|
| 341 |
isc_nonce_buf(&send_magic, sizeof(send_magic)); |
| 342 |
isc_nonce_buf(&stop_magic, sizeof(stop_magic)); |
| 343 |
if (send_magic == stop_magic) { |
| 344 |
return -1; |
| 345 |
} |
| 346 |
|
| 347 |
setup_loopmgr(state); |
| 348 |
|
| 349 |
nm = isc_mem_cget(mctx, MAX_NM, sizeof(nm[0])); |
| 350 |
for (size_t i = 0; i < MAX_NM; i++) { |
| 351 |
isc_netmgr_create(mctx, loopmgr, &nm[i]); |
| 352 |
assert_non_null(nm[i]); |
| 353 |
} |
| 354 |
|
| 355 |
server_tlsctx = NULL; |
| 356 |
isc_tlsctx_createserver(NULL, NULL, &server_tlsctx); |
| 357 |
isc_tlsctx_enable_http2server_alpn(server_tlsctx); |
| 358 |
client_tlsctx = NULL; |
| 359 |
isc_tlsctx_createclient(&client_tlsctx); |
| 360 |
isc_tlsctx_enable_http2client_alpn(client_tlsctx); |
| 361 |
isc_tlsctx_client_session_cache_create( |
| 362 |
mctx, client_tlsctx, |
| 363 |
ISC_TLSCTX_CLIENT_SESSION_CACHE_DEFAULT_SIZE, |
| 364 |
&client_sess_cache); |
| 365 |
|
| 366 |
isc_quota_init(&listener_quota, 0); |
| 367 |
atomic_store(&check_listener_quota, false); |
| 368 |
|
| 369 |
INSIST(endpoints == NULL); |
| 370 |
endpoints = isc_nm_http_endpoints_new(mctx); |
| 371 |
|
| 372 |
*state = nm; |
| 373 |
|
| 374 |
return 0; |
| 375 |
} |
| 376 |
|
| 377 |
static int |
| 378 |
teardown_test(void **state ISC_ATTR_UNUSED) { |
| 379 |
for (size_t i = 0; i < MAX_NM; i++) { |
| 380 |
isc_netmgr_destroy(&nm[i]); |
| 381 |
assert_null(nm[i]); |
| 382 |
} |
| 383 |
isc_mem_cput(mctx, nm, MAX_NM, sizeof(nm[0])); |
| 384 |
|
| 385 |
teardown_loopmgr(state); |
| 386 |
|
| 387 |
if (server_tlsctx != NULL) { |
| 388 |
isc_tlsctx_free(&server_tlsctx); |
| 389 |
} |
| 390 |
if (client_tlsctx != NULL) { |
| 391 |
isc_tlsctx_free(&client_tlsctx); |
| 392 |
} |
| 393 |
|
| 394 |
isc_tlsctx_client_session_cache_detach(&client_sess_cache); |
| 395 |
|
| 396 |
isc_quota_destroy(&listener_quota); |
| 397 |
|
| 398 |
isc_nm_http_endpoints_detach(&endpoints); |
| 399 |
|
| 400 |
return 0; |
| 401 |
} |
| 402 |
|
| 403 |
thread_local size_t nwrites = NWRITES; |
| 404 |
|
| 405 |
static void |
| 406 |
sockaddr_to_url(isc_sockaddr_t *sa, const bool https, char *outbuf, |
| 407 |
size_t outbuf_len, const char *append) { |
| 408 |
isc_nm_http_makeuri(https, sa, NULL, 0, append, outbuf, outbuf_len); |
| 409 |
} |
| 410 |
|
| 411 |
static isc_quota_t * |
| 412 |
init_listener_quota(size_t nthreads) { |
| 413 |
isc_quota_t *quotap = NULL; |
| 414 |
if (atomic_load(&check_listener_quota)) { |
| 415 |
unsigned int max_quota = ISC_MAX(nthreads / 2, 1); |
| 416 |
isc_quota_max(&listener_quota, max_quota); |
| 417 |
quotap = &listener_quota; |
| 418 |
} |
| 419 |
return quotap; |
| 420 |
} |
| 421 |
|
| 422 |
static void |
| 423 |
doh_receive_reply_cb(isc_nmhandle_t *handle, isc_result_t eresult, |
| 424 |
isc_region_t *region, void *cbarg) { |
| 425 |
assert_non_null(handle); |
| 426 |
UNUSED(cbarg); |
| 427 |
UNUSED(region); |
| 428 |
|
| 429 |
if (eresult == ISC_R_SUCCESS) { |
| 430 |
if (atomic_load(&use_PROXY)) { |
| 431 |
assert_true(isc_nm_is_proxy_handle(handle)); |
| 432 |
} |
| 433 |
(void)atomic_fetch_sub(&nsends, 1); |
| 434 |
if (have_expected_csends(atomic_fetch_add(&csends, 1) + 1) || |
| 435 |
have_expected_creads(atomic_fetch_add(&creads, 1) + 1)) |
| 436 |
{ |
| 437 |
isc_loopmgr_shutdown(loopmgr); |
| 438 |
} |
| 439 |
} else { |
| 440 |
isc_loopmgr_shutdown(loopmgr); |
| 441 |
} |
| 442 |
} |
| 443 |
|
| 444 |
static void |
| 445 |
doh_reply_sent_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) { |
| 446 |
UNUSED(eresult); |
| 447 |
UNUSED(cbarg); |
| 448 |
|
| 449 |
assert_non_null(handle); |
| 450 |
|
| 451 |
if (eresult == ISC_R_SUCCESS) { |
| 452 |
atomic_fetch_add(&ssends, 1); |
| 453 |
} |
| 454 |
} |
| 455 |
|
| 456 |
static void |
| 457 |
doh_receive_request_cb(isc_nmhandle_t *handle, isc_result_t eresult, |
| 458 |
isc_region_t *region, void *cbarg) { |
| 459 |
uint64_t magic = 0; |
| 460 |
|
| 461 |
UNUSED(cbarg); |
| 462 |
assert_non_null(handle); |
| 463 |
|
| 464 |
if (eresult != ISC_R_SUCCESS) { |
| 465 |
return; |
| 466 |
} |
| 467 |
|
| 468 |
if (atomic_load(&use_PROXY)) { |
| 469 |
assert_true(isc_nm_is_proxy_handle(handle)); |
| 470 |
proxy_verify_unspec_endpoint(handle); |
| 471 |
} |
| 472 |
|
| 473 |
atomic_fetch_add(&sreads, 1); |
| 474 |
|
| 475 |
memmove(tcp_buffer_storage + tcp_buffer_length, region->base, |
| 476 |
region->length); |
| 477 |
tcp_buffer_length += region->length; |
| 478 |
|
| 479 |
while (tcp_buffer_length >= sizeof(magic)) { |
| 480 |
magic = *(uint64_t *)tcp_buffer_storage; |
| 481 |
assert_true(magic == stop_magic || magic == send_magic); |
| 482 |
|
| 483 |
tcp_buffer_length -= sizeof(magic); |
| 484 |
memmove(tcp_buffer_storage, tcp_buffer_storage + sizeof(magic), |
| 485 |
tcp_buffer_length); |
| 486 |
|
| 487 |
if (magic == send_magic) { |
| 488 |
if (!noanswer) { |
| 489 |
isc_nm_send(handle, region, doh_reply_sent_cb, |
| 490 |
NULL); |
| 491 |
} |
| 492 |
return; |
| 493 |
} else if (magic == stop_magic) { |
| 494 |
/* |
| 495 |
* We are done, so we don't send anything back. |
| 496 |
* There should be no more packets in the buffer. |
| 497 |
*/ |
| 498 |
assert_int_equal(tcp_buffer_length, 0); |
| 499 |
} |
| 500 |
} |
| 501 |
} |
| 502 |
|
| 503 |
ISC_LOOP_TEST_IMPL(mock_doh_uv_tcp_bind) { |
| 504 |
isc_nm_t *listen_nm = nm[0]; |
| 505 |
isc_result_t result = ISC_R_SUCCESS; |
| 506 |
isc_nmsocket_t *listen_sock = NULL; |
| 507 |
|
| 508 |
WILL_RETURN(uv_tcp_bind, UV_EADDRINUSE); |
| 509 |
|
| 510 |
result = isc_nm_http_endpoints_add(endpoints, ISC_NM_HTTP_DEFAULT_PATH, |
| 511 |
noop_read_cb, NULL); |
| 512 |
assert_int_equal(result, ISC_R_SUCCESS); |
| 513 |
result = isc_nm_listenhttp(listen_nm, ISC_NM_LISTEN_ALL, |
| 514 |
&tcp_listen_addr, 0, NULL, NULL, endpoints, |
| 515 |
0, false, &listen_sock); |
| 516 |
assert_int_not_equal(result, ISC_R_SUCCESS); |
| 517 |
assert_null(listen_sock); |
| 518 |
|
| 519 |
RESET_RETURN; |
| 520 |
|
| 521 |
isc_loopmgr_shutdown(loopmgr); |
| 522 |
} |
| 523 |
|
| 524 |
static void |
| 525 |
listen_sock_close(void *arg) { |
| 526 |
isc_nmsocket_t *listen_sock = arg; |
| 527 |
|
| 528 |
isc_nm_stoplistening(listen_sock); |
| 529 |
isc_nmsocket_close(&listen_sock); |
| 530 |
assert_null(listen_sock); |
| 531 |
} |
| 532 |
|
| 533 |
static void |
| 534 |
doh_noop(void *arg ISC_ATTR_UNUSED) { |
| 535 |
isc_nm_t *listen_nm = nm[0]; |
| 536 |
isc_nm_t *connect_nm = nm[1]; |
| 537 |
isc_result_t result = ISC_R_SUCCESS; |
| 538 |
isc_nmsocket_t *listen_sock = NULL; |
| 539 |
char req_url[256]; |
| 540 |
|
| 541 |
result = isc_nm_http_endpoints_add(endpoints, ISC_NM_HTTP_DEFAULT_PATH, |
| 542 |
noop_read_cb, NULL); |
| 543 |
assert_int_equal(result, ISC_R_SUCCESS); |
| 544 |
|
| 545 |
result = isc_nm_listenhttp(listen_nm, ISC_NM_LISTEN_ALL, |
| 546 |
&tcp_listen_addr, 0, NULL, NULL, endpoints, |
| 547 |
0, get_proxy_type(), &listen_sock); |
| 548 |
assert_int_equal(result, ISC_R_SUCCESS); |
| 549 |
isc_loop_teardown(mainloop, listen_sock_close, listen_sock); |
| 550 |
|
| 551 |
sockaddr_to_url(&tcp_listen_addr, false, req_url, sizeof(req_url), |
| 552 |
ISC_NM_HTTP_DEFAULT_PATH); |
| 553 |
connect_send_request(connect_nm, req_url, atomic_load(&POST), |
| 554 |
&(isc_region_t){ .base = (uint8_t *)send_msg.base, |
| 555 |
.length = send_msg.len }, |
| 556 |
noop_read_cb, NULL, atomic_load(&use_TLS), 30000); |
| 557 |
|
| 558 |
isc_loopmgr_shutdown(loopmgr); |
| 559 |
|
| 560 |
assert_int_equal(0, atomic_load(&csends)); |
| 561 |
assert_int_equal(0, atomic_load(&creads)); |
| 562 |
assert_int_equal(0, atomic_load(&sreads)); |
| 563 |
assert_int_equal(0, atomic_load(&ssends)); |
| 564 |
} |
| 565 |
|
| 566 |
ISC_LOOP_TEST_IMPL(doh_noop_POST) { |
| 567 |
atomic_store(&POST, true); |
| 568 |
doh_noop(arg); |
| 569 |
} |
| 570 |
|
| 571 |
ISC_LOOP_TEST_IMPL(doh_noop_GET) { |
| 572 |
atomic_store(&POST, false); |
| 573 |
doh_noop(arg); |
| 574 |
} |
| 575 |
|
| 576 |
static void |
| 577 |
doh_noresponse(void *arg ISC_ATTR_UNUSED) { |
| 578 |
isc_nm_t *listen_nm = nm[0]; |
| 579 |
isc_nm_t *connect_nm = nm[1]; |
| 580 |
isc_result_t result = ISC_R_SUCCESS; |
| 581 |
isc_nmsocket_t *listen_sock = NULL; |
| 582 |
char req_url[256]; |
| 583 |
|
| 584 |
result = isc_nm_http_endpoints_add(endpoints, ISC_NM_HTTP_DEFAULT_PATH, |
| 585 |
noop_read_cb, NULL); |
| 586 |
assert_int_equal(result, ISC_R_SUCCESS); |
| 587 |
|
| 588 |
result = isc_nm_listenhttp(listen_nm, ISC_NM_LISTEN_ALL, |
| 589 |
&tcp_listen_addr, 0, NULL, NULL, endpoints, |
| 590 |
0, get_proxy_type(), &listen_sock); |
| 591 |
assert_int_equal(result, ISC_R_SUCCESS); |
| 592 |
isc_loop_teardown(mainloop, listen_sock_close, listen_sock); |
| 593 |
|
| 594 |
sockaddr_to_url(&tcp_listen_addr, false, req_url, sizeof(req_url), |
| 595 |
ISC_NM_HTTP_DEFAULT_PATH); |
| 596 |
connect_send_request(connect_nm, req_url, atomic_load(&POST), |
| 597 |
&(isc_region_t){ .base = (uint8_t *)send_msg.base, |
| 598 |
.length = send_msg.len }, |
| 599 |
noop_read_cb, NULL, atomic_load(&use_TLS), 30000); |
| 600 |
|
| 601 |
isc_loopmgr_shutdown(loopmgr); |
| 602 |
} |
| 603 |
|
| 604 |
ISC_LOOP_TEST_IMPL(doh_noresponse_POST) { |
| 605 |
atomic_store(&POST, true); |
| 606 |
doh_noresponse(arg); |
| 607 |
} |
| 608 |
|
| 609 |
ISC_LOOP_TEST_IMPL(doh_noresponse_GET) { |
| 610 |
atomic_store(&POST, false); |
| 611 |
doh_noresponse(arg); |
| 612 |
} |
| 613 |
|
| 614 |
static void |
| 615 |
timeout_query_sent_cb(isc_nmhandle_t *handle, isc_result_t eresult, |
| 616 |
void *cbarg) { |
| 617 |
UNUSED(eresult); |
| 618 |
UNUSED(cbarg); |
| 619 |
|
| 620 |
assert_non_null(handle); |
| 621 |
|
| 622 |
if (eresult == ISC_R_SUCCESS) { |
| 623 |
atomic_fetch_add(&csends, 1); |
| 624 |
} |
| 625 |
|
| 626 |
isc_nmhandle_detach(&handle); |
| 627 |
} |
| 628 |
|
| 629 |
static void |
| 630 |
timeout_retry_cb(isc_nmhandle_t *handle, isc_result_t eresult, |
| 631 |
isc_region_t *region ISC_ATTR_UNUSED, |
| 632 |
void *arg ISC_ATTR_UNUSED) { |
| 633 |
assert_non_null(handle); |
| 634 |
|
| 635 |
atomic_fetch_add(&ctimeouts, 1); |
| 636 |
|
| 637 |
if (eresult == ISC_R_TIMEDOUT && atomic_load(&ctimeouts) < 5) { |
| 638 |
isc_nmhandle_settimeout(handle, T_SOFT); |
| 639 |
return; |
| 640 |
} |
| 641 |
|
| 642 |
isc_nmhandle_detach(&handle); |
| 643 |
isc_loopmgr_shutdown(loopmgr); |
| 644 |
} |
| 645 |
|
| 646 |
static void |
| 647 |
timeout_request_cb(isc_nmhandle_t *handle, isc_result_t result, void *arg) { |
| 648 |
isc_nmhandle_t *sendhandle = NULL; |
| 649 |
isc_nmhandle_t *readhandle = NULL; |
| 650 |
|
| 651 |
REQUIRE(VALID_NMHANDLE(handle)); |
| 652 |
|
| 653 |
if (result != ISC_R_SUCCESS) { |
| 654 |
return; |
| 655 |
} |
| 656 |
|
| 657 |
isc_nmhandle_attach(handle, &sendhandle); |
| 658 |
isc_nm_send(handle, |
| 659 |
&(isc_region_t){ .base = (uint8_t *)send_msg.base, |
| 660 |
.length = send_msg.len }, |
| 661 |
timeout_query_sent_cb, arg); |
| 662 |
|
| 663 |
isc_nmhandle_attach(handle, &readhandle); |
| 664 |
isc_nm_read(handle, timeout_retry_cb, NULL); |
| 665 |
} |
| 666 |
|
| 667 |
static void |
| 668 |
doh_timeout_recovery(void *arg ISC_ATTR_UNUSED) { |
| 669 |
isc_nm_t *listen_nm = nm[0]; |
| 670 |
isc_nmsocket_t *listen_sock = NULL; |
| 671 |
isc_nm_t *connect_nm = nm[1]; |
| 672 |
isc_result_t result = ISC_R_SUCCESS; |
| 673 |
isc_tlsctx_t *ctx = atomic_load(&use_TLS) ? server_tlsctx : NULL; |
| 674 |
char req_url[256]; |
| 675 |
|
| 676 |
result = isc_nm_http_endpoints_add(endpoints, ISC_NM_HTTP_DEFAULT_PATH, |
| 677 |
doh_receive_request_cb, NULL); |
| 678 |
assert_int_equal(result, ISC_R_SUCCESS); |
| 679 |
|
| 680 |
result = isc_nm_listenhttp(listen_nm, ISC_NM_LISTEN_ALL, |
| 681 |
&tcp_listen_addr, 0, NULL, NULL, endpoints, |
| 682 |
0, get_proxy_type(), &listen_sock); |
| 683 |
assert_int_equal(result, ISC_R_SUCCESS); |
| 684 |
isc_loop_teardown(mainloop, listen_sock_close, listen_sock); |
| 685 |
|
| 686 |
/* |
| 687 |
* Accept connections but don't send responses, forcing client |
| 688 |
* reads to time out. |
| 689 |
*/ |
| 690 |
noanswer = true; |
| 691 |
|
| 692 |
/* |
| 693 |
* Shorten all the TCP client timeouts to 0.05 seconds. |
| 694 |
* timeout_retry_cb() will give up after five timeouts. |
| 695 |
*/ |
| 696 |
isc_nm_settimeouts(connect_nm, T_SOFT, T_SOFT, T_SOFT, T_SOFT); |
| 697 |
sockaddr_to_url(&tcp_listen_addr, false, req_url, sizeof(req_url), |
| 698 |
ISC_NM_HTTP_DEFAULT_PATH); |
| 699 |
isc_nm_httpconnect(connect_nm, NULL, &tcp_listen_addr, req_url, |
| 700 |
atomic_load(&POST), timeout_request_cb, NULL, ctx, |
| 701 |
client_sess_cache, T_CONNECT, get_proxy_type(), |
| 702 |
NULL); |
| 703 |
} |
| 704 |
|
| 705 |
static int |
| 706 |
doh_timeout_recovery_teardown(void **state) { |
| 707 |
assert_true(atomic_load(&ctimeouts) == 5); |
| 708 |
return teardown_test(state); |
| 709 |
} |
| 710 |
|
| 711 |
ISC_LOOP_TEST_IMPL(doh_timeout_recovery_POST) { |
| 712 |
atomic_store(&POST, true); |
| 713 |
doh_timeout_recovery(arg); |
| 714 |
} |
| 715 |
|
| 716 |
ISC_LOOP_TEST_IMPL(doh_timeout_recovery_GET) { |
| 717 |
atomic_store(&POST, false); |
| 718 |
doh_timeout_recovery(arg); |
| 719 |
} |
| 720 |
|
| 721 |
static void |
| 722 |
doh_connect_thread(void *arg); |
| 723 |
|
| 724 |
static void |
| 725 |
doh_receive_send_reply_cb(isc_nmhandle_t *handle, isc_result_t eresult, |
| 726 |
isc_region_t *region, void *cbarg) { |
| 727 |
isc_nm_t *connect_nm = (isc_nm_t *)cbarg; |
| 728 |
|
| 729 |
if (eresult != ISC_R_SUCCESS) { |
| 730 |
return; |
| 731 |
} |
| 732 |
|
| 733 |
assert_non_null(handle); |
| 734 |
UNUSED(region); |
| 735 |
|
| 736 |
int_fast64_t sends = atomic_fetch_sub(&nsends, 1); |
| 737 |
atomic_fetch_add(&csends, 1); |
| 738 |
atomic_fetch_add(&creads, 1); |
| 739 |
if (sends > 0 && connect_nm != NULL) { |
| 740 |
size_t i; |
| 741 |
for (i = 0; i < NWRITES / 2; i++) { |
| 742 |
eresult = isc__nm_http_request( |
| 743 |
handle, |
| 744 |
&(isc_region_t){ |
| 745 |
.base = (uint8_t *)send_msg.base, |
| 746 |
.length = send_msg.len }, |
| 747 |
doh_receive_send_reply_cb, NULL); |
| 748 |
if (eresult == ISC_R_CANCELED) { |
| 749 |
break; |
| 750 |
} |
| 751 |
assert_true(eresult == ISC_R_SUCCESS); |
| 752 |
} |
| 753 |
|
| 754 |
isc_async_current(doh_connect_thread, connect_nm); |
| 755 |
} |
| 756 |
if (sends <= 0) { |
| 757 |
isc_loopmgr_shutdown(loopmgr); |
| 758 |
} |
| 759 |
} |
| 760 |
|
| 761 |
static void |
| 762 |
doh_connect_thread(void *arg) { |
| 763 |
isc_nm_t *connect_nm = (isc_nm_t *)arg; |
| 764 |
char req_url[256]; |
| 765 |
int64_t sends = atomic_load(&nsends); |
| 766 |
|
| 767 |
sockaddr_to_url(&tcp_listen_addr, atomic_load(&use_TLS), req_url, |
| 768 |
sizeof(req_url), ISC_NM_HTTP_DEFAULT_PATH); |
| 769 |
|
| 770 |
/* |
| 771 |
* We need to back off and slow down if we start getting |
| 772 |
* errors, to prevent a thundering herd problem. |
| 773 |
*/ |
| 774 |
int_fast64_t active = atomic_fetch_add(&active_cconnects, 1); |
| 775 |
if (active > workers) { |
| 776 |
atomic_fetch_sub(&active_cconnects, 1); |
| 777 |
return; |
| 778 |
} |
| 779 |
connect_send_request(connect_nm, req_url, atomic_load(&POST), |
| 780 |
&(isc_region_t){ .base = (uint8_t *)send_msg.base, |
| 781 |
.length = send_msg.len }, |
| 782 |
doh_receive_send_reply_cb, connect_nm, |
| 783 |
atomic_load(&use_TLS), 30000); |
| 784 |
|
| 785 |
if (sends <= 0) { |
| 786 |
isc_loopmgr_shutdown(loopmgr); |
| 787 |
} |
| 788 |
} |
| 789 |
|
| 790 |
static void |
| 791 |
doh_recv_one(void *arg ISC_ATTR_UNUSED) { |
| 792 |
isc_nm_t *listen_nm = nm[0]; |
| 793 |
isc_nm_t *connect_nm = nm[1]; |
| 794 |
isc_result_t result = ISC_R_SUCCESS; |
| 795 |
isc_nmsocket_t *listen_sock = NULL; |
| 796 |
char req_url[256]; |
| 797 |
isc_quota_t *quotap = init_listener_quota(workers); |
| 798 |
|
| 799 |
atomic_store(&total_sends, 1); |
| 800 |
expected_creads = 1; |
| 801 |
|
| 802 |
atomic_store(&nsends, atomic_load(&total_sends)); |
| 803 |
|
| 804 |
result = isc_nm_http_endpoints_add(endpoints, ISC_NM_HTTP_DEFAULT_PATH, |
| 805 |
doh_receive_request_cb, NULL); |
| 806 |
assert_int_equal(result, ISC_R_SUCCESS); |
| 807 |
|
| 808 |
result = isc_nm_listenhttp( |
| 809 |
listen_nm, ISC_NM_LISTEN_ALL, &tcp_listen_addr, 0, quotap, |
| 810 |
atomic_load(&use_TLS) ? server_tlsctx : NULL, endpoints, 0, |
| 811 |
get_proxy_type(), &listen_sock); |
| 812 |
assert_int_equal(result, ISC_R_SUCCESS); |
| 813 |
|
| 814 |
sockaddr_to_url(&tcp_listen_addr, atomic_load(&use_TLS), req_url, |
| 815 |
sizeof(req_url), ISC_NM_HTTP_DEFAULT_PATH); |
| 816 |
connect_send_request(connect_nm, req_url, atomic_load(&POST), |
| 817 |
&(isc_region_t){ .base = (uint8_t *)send_msg.base, |
| 818 |
.length = send_msg.len }, |
| 819 |
doh_receive_reply_cb, NULL, atomic_load(&use_TLS), |
| 820 |
30000); |
| 821 |
|
| 822 |
isc_loop_teardown(mainloop, listen_sock_close, listen_sock); |
| 823 |
} |
| 824 |
|
| 825 |
static int |
| 826 |
doh_recv_one_teardown(void **state) { |
| 827 |
X(total_sends); |
| 828 |
X(csends); |
| 829 |
X(creads); |
| 830 |
X(sreads); |
| 831 |
X(ssends); |
| 832 |
|
| 833 |
assert_int_equal(atomic_load(&csends), 1); |
| 834 |
assert_int_equal(atomic_load(&creads), 1); |
| 835 |
assert_int_equal(atomic_load(&sreads), 1); |
| 836 |
assert_int_equal(atomic_load(&ssends), 1); |
| 837 |
|
| 838 |
return teardown_test(state); |
| 839 |
} |
| 840 |
|
| 841 |
ISC_LOOP_TEST_IMPL(doh_recv_one_POST) { |
| 842 |
atomic_store(&POST, true); |
| 843 |
doh_recv_one(arg); |
| 844 |
} |
| 845 |
|
| 846 |
ISC_LOOP_TEST_IMPL(doh_recv_one_GET) { |
| 847 |
atomic_store(&POST, false); |
| 848 |
doh_recv_one(arg); |
| 849 |
} |
| 850 |
|
| 851 |
ISC_LOOP_TEST_IMPL(doh_recv_one_POST_TLS) { |
| 852 |
atomic_store(&use_TLS, true); |
| 853 |
atomic_store(&POST, true); |
| 854 |
doh_recv_one(arg); |
| 855 |
} |
| 856 |
|
| 857 |
ISC_LOOP_TEST_IMPL(doh_recv_one_GET_TLS) { |
| 858 |
atomic_store(&use_TLS, true); |
| 859 |
atomic_store(&POST, false); |
| 860 |
doh_recv_one(arg); |
| 861 |
} |
| 862 |
|
| 863 |
ISC_LOOP_TEST_IMPL(doh_recv_one_POST_quota) { |
| 864 |
atomic_store(&POST, true); |
| 865 |
atomic_store(&check_listener_quota, true); |
| 866 |
doh_recv_one(arg); |
| 867 |
} |
| 868 |
|
| 869 |
ISC_LOOP_TEST_IMPL(doh_recv_one_GET_quota) { |
| 870 |
atomic_store(&POST, false); |
| 871 |
atomic_store(&check_listener_quota, true); |
| 872 |
doh_recv_one(arg); |
| 873 |
} |
| 874 |
|
| 875 |
ISC_LOOP_TEST_IMPL(doh_recv_one_POST_TLS_quota) { |
| 876 |
atomic_store(&use_TLS, true); |
| 877 |
atomic_store(&POST, true); |
| 878 |
atomic_store(&check_listener_quota, true); |
| 879 |
doh_recv_one(arg); |
| 880 |
} |
| 881 |
|
| 882 |
ISC_LOOP_TEST_IMPL(doh_recv_one_GET_TLS_quota) { |
| 883 |
atomic_store(&use_TLS, true); |
| 884 |
atomic_store(&POST, false); |
| 885 |
atomic_store(&check_listener_quota, true); |
| 886 |
doh_recv_one(arg); |
| 887 |
} |
| 888 |
|
| 889 |
static void |
| 890 |
doh_connect_send_two_requests_cb(isc_nmhandle_t *handle, isc_result_t result, |
| 891 |
void *arg) { |
| 892 |
REQUIRE(VALID_NMHANDLE(handle)); |
| 893 |
if (result != ISC_R_SUCCESS) { |
| 894 |
return; |
| 895 |
} |
| 896 |
|
| 897 |
result = isc__nm_http_request( |
| 898 |
handle, |
| 899 |
&(isc_region_t){ .base = (uint8_t *)send_msg.base, |
| 900 |
.length = send_msg.len }, |
| 901 |
doh_receive_reply_cb, arg); |
| 902 |
if (result != ISC_R_SUCCESS) { |
| 903 |
return; |
| 904 |
} |
| 905 |
|
| 906 |
result = isc__nm_http_request( |
| 907 |
handle, |
| 908 |
&(isc_region_t){ .base = (uint8_t *)send_msg.base, |
| 909 |
.length = send_msg.len }, |
| 910 |
doh_receive_reply_cb, arg); |
| 911 |
if (result != ISC_R_SUCCESS) { |
| 912 |
return; |
| 913 |
} |
| 914 |
} |
| 915 |
|
| 916 |
static void |
| 917 |
doh_recv_two(void *arg ISC_ATTR_UNUSED) { |
| 918 |
isc_nm_t *listen_nm = nm[0]; |
| 919 |
isc_nm_t *connect_nm = nm[1]; |
| 920 |
isc_result_t result = ISC_R_SUCCESS; |
| 921 |
isc_nmsocket_t *listen_sock = NULL; |
| 922 |
char req_url[256]; |
| 923 |
isc_tlsctx_t *ctx = NULL; |
| 924 |
isc_quota_t *quotap = init_listener_quota(workers); |
| 925 |
|
| 926 |
atomic_store(&total_sends, 2); |
| 927 |
expected_creads = 2; |
| 928 |
|
| 929 |
atomic_store(&nsends, atomic_load(&total_sends)); |
| 930 |
|
| 931 |
result = isc_nm_http_endpoints_add(endpoints, ISC_NM_HTTP_DEFAULT_PATH, |
| 932 |
doh_receive_request_cb, NULL); |
| 933 |
assert_int_equal(result, ISC_R_SUCCESS); |
| 934 |
|
| 935 |
result = isc_nm_listenhttp( |
| 936 |
listen_nm, ISC_NM_LISTEN_ALL, &tcp_listen_addr, 0, quotap, |
| 937 |
atomic_load(&use_TLS) ? server_tlsctx : NULL, endpoints, 0, |
| 938 |
get_proxy_type(), &listen_sock); |
| 939 |
assert_int_equal(result, ISC_R_SUCCESS); |
| 940 |
|
| 941 |
sockaddr_to_url(&tcp_listen_addr, atomic_load(&use_TLS), req_url, |
| 942 |
sizeof(req_url), ISC_NM_HTTP_DEFAULT_PATH); |
| 943 |
|
| 944 |
if (atomic_load(&use_TLS)) { |
| 945 |
ctx = client_tlsctx; |
| 946 |
} |
| 947 |
|
| 948 |
isc_nm_httpconnect(connect_nm, NULL, &tcp_listen_addr, req_url, |
| 949 |
atomic_load(&POST), doh_connect_send_two_requests_cb, |
| 950 |
NULL, ctx, client_sess_cache, 5000, get_proxy_type(), |
| 951 |
NULL); |
| 952 |
|
| 953 |
isc_loop_teardown(mainloop, listen_sock_close, listen_sock); |
| 954 |
} |
| 955 |
|
| 956 |
static int |
| 957 |
doh_recv_two_teardown(void **state) { |
| 958 |
X(total_sends); |
| 959 |
X(csends); |
| 960 |
X(creads); |
| 961 |
X(sreads); |
| 962 |
X(ssends); |
| 963 |
|
| 964 |
assert_int_equal(atomic_load(&csends), 2); |
| 965 |
assert_int_equal(atomic_load(&creads), 2); |
| 966 |
assert_int_equal(atomic_load(&sreads), 2); |
| 967 |
assert_int_equal(atomic_load(&ssends), 2); |
| 968 |
|
| 969 |
return teardown_test(state); |
| 970 |
} |
| 971 |
|
| 972 |
ISC_LOOP_TEST_IMPL(doh_recv_two_POST) { |
| 973 |
atomic_store(&POST, true); |
| 974 |
doh_recv_two(arg); |
| 975 |
} |
| 976 |
|
| 977 |
ISC_LOOP_TEST_IMPL(doh_recv_two_GET) { |
| 978 |
atomic_store(&POST, false); |
| 979 |
doh_recv_two(arg); |
| 980 |
} |
| 981 |
|
| 982 |
ISC_LOOP_TEST_IMPL(doh_recv_two_POST_TLS) { |
| 983 |
atomic_store(&use_TLS, true); |
| 984 |
atomic_store(&POST, true); |
| 985 |
doh_recv_two(arg); |
| 986 |
} |
| 987 |
|
| 988 |
ISC_LOOP_TEST_IMPL(doh_recv_two_GET_TLS) { |
| 989 |
atomic_store(&use_TLS, true); |
| 990 |
atomic_store(&POST, false); |
| 991 |
doh_recv_two(arg); |
| 992 |
} |
| 993 |
|
| 994 |
ISC_LOOP_TEST_IMPL(doh_recv_two_POST_quota) { |
| 995 |
atomic_store(&POST, true); |
| 996 |
atomic_store(&check_listener_quota, true); |
| 997 |
doh_recv_two(arg); |
| 998 |
} |
| 999 |
|
| 1000 |
ISC_LOOP_TEST_IMPL(doh_recv_two_GET_quota) { |
| 1001 |
atomic_store(&POST, false); |
| 1002 |
atomic_store(&check_listener_quota, true); |
| 1003 |
doh_recv_two(arg); |
| 1004 |
} |
| 1005 |
|
| 1006 |
ISC_LOOP_TEST_IMPL(doh_recv_two_POST_TLS_quota) { |
| 1007 |
atomic_store(&use_TLS, true); |
| 1008 |
atomic_store(&POST, true); |
| 1009 |
atomic_store(&check_listener_quota, true); |
| 1010 |
doh_recv_two(arg); |
| 1011 |
} |
| 1012 |
|
| 1013 |
ISC_LOOP_TEST_IMPL(doh_recv_two_GET_TLS_quota) { |
| 1014 |
atomic_store(&use_TLS, true); |
| 1015 |
atomic_store(&POST, false); |
| 1016 |
atomic_store(&check_listener_quota, true); |
| 1017 |
doh_recv_two(arg); |
| 1018 |
} |
| 1019 |
|
| 1020 |
static void |
| 1021 |
doh_recv_send(void *arg ISC_ATTR_UNUSED) { |
| 1022 |
isc_nm_t *listen_nm = nm[0]; |
| 1023 |
isc_nm_t *connect_nm = nm[1]; |
| 1024 |
isc_result_t result = ISC_R_SUCCESS; |
| 1025 |
isc_nmsocket_t *listen_sock = NULL; |
| 1026 |
size_t nthreads = isc_loopmgr_nloops(loopmgr); |
| 1027 |
isc_quota_t *quotap = init_listener_quota(workers); |
| 1028 |
|
| 1029 |
atomic_store(&total_sends, 1000); |
| 1030 |
atomic_store(&nsends, 1000); |
| 1031 |
|
| 1032 |
result = isc_nm_http_endpoints_add(endpoints, ISC_NM_HTTP_DEFAULT_PATH, |
| 1033 |
doh_receive_request_cb, NULL); |
| 1034 |
assert_int_equal(result, ISC_R_SUCCESS); |
| 1035 |
|
| 1036 |
result = isc_nm_listenhttp( |
| 1037 |
listen_nm, ISC_NM_LISTEN_ALL, &tcp_listen_addr, 0, quotap, |
| 1038 |
atomic_load(&use_TLS) ? server_tlsctx : NULL, endpoints, 0, |
| 1039 |
get_proxy_type(), &listen_sock); |
| 1040 |
assert_int_equal(result, ISC_R_SUCCESS); |
| 1041 |
|
| 1042 |
for (size_t i = 0; i < nthreads; i++) { |
| 1043 |
isc_async_run(isc_loop_get(loopmgr, i), doh_connect_thread, |
| 1044 |
connect_nm); |
| 1045 |
} |
| 1046 |
|
| 1047 |
isc_loop_teardown(mainloop, listen_sock_close, listen_sock); |
| 1048 |
} |
| 1049 |
|
| 1050 |
static int |
| 1051 |
doh_recv_send_teardown(void **state) { |
| 1052 |
int res = teardown_test(state); |
| 1053 |
|
| 1054 |
X(total_sends); |
| 1055 |
X(csends); |
| 1056 |
X(creads); |
| 1057 |
X(sreads); |
| 1058 |
X(ssends); |
| 1059 |
|
| 1060 |
CHECK_RANGE_FULL(csends); |
| 1061 |
CHECK_RANGE_FULL(creads); |
| 1062 |
CHECK_RANGE_FULL(sreads); |
| 1063 |
CHECK_RANGE_FULL(ssends); |
| 1064 |
|
| 1065 |
return res; |
| 1066 |
} |
| 1067 |
|
| 1068 |
ISC_LOOP_TEST_IMPL(doh_recv_send_POST) { |
| 1069 |
atomic_store(&POST, true); |
| 1070 |
doh_recv_send(arg); |
| 1071 |
} |
| 1072 |
|
| 1073 |
ISC_LOOP_TEST_IMPL(doh_recv_send_GET) { |
| 1074 |
atomic_store(&POST, false); |
| 1075 |
doh_recv_send(arg); |
| 1076 |
} |
| 1077 |
|
| 1078 |
ISC_LOOP_TEST_IMPL(doh_recv_send_POST_TLS) { |
| 1079 |
atomic_store(&POST, true); |
| 1080 |
atomic_store(&use_TLS, true); |
| 1081 |
doh_recv_send(arg); |
| 1082 |
} |
| 1083 |
|
| 1084 |
ISC_LOOP_TEST_IMPL(doh_recv_send_GET_TLS) { |
| 1085 |
atomic_store(&POST, false); |
| 1086 |
atomic_store(&use_TLS, true); |
| 1087 |
doh_recv_send(arg); |
| 1088 |
} |
| 1089 |
|
| 1090 |
ISC_LOOP_TEST_IMPL(doh_recv_send_POST_quota) { |
| 1091 |
atomic_store(&POST, true); |
| 1092 |
atomic_store(&check_listener_quota, true); |
| 1093 |
doh_recv_send(arg); |
| 1094 |
} |
| 1095 |
|
| 1096 |
ISC_LOOP_TEST_IMPL(doh_recv_send_GET_quota) { |
| 1097 |
atomic_store(&POST, false); |
| 1098 |
atomic_store(&check_listener_quota, true); |
| 1099 |
doh_recv_send(arg); |
| 1100 |
} |
| 1101 |
|
| 1102 |
ISC_LOOP_TEST_IMPL(doh_recv_send_POST_TLS_quota) { |
| 1103 |
atomic_store(&POST, true); |
| 1104 |
atomic_store(&use_TLS, true); |
| 1105 |
atomic_store(&check_listener_quota, true); |
| 1106 |
doh_recv_send(arg); |
| 1107 |
} |
| 1108 |
|
| 1109 |
ISC_LOOP_TEST_IMPL(doh_recv_send_GET_TLS_quota) { |
| 1110 |
atomic_store(&POST, false); |
| 1111 |
atomic_store(&use_TLS, true); |
| 1112 |
atomic_store(&check_listener_quota, true); |
| 1113 |
doh_recv_send(arg); |
| 1114 |
} |
| 1115 |
|
| 1116 |
static int |
| 1117 |
doh_bad_connect_uri_teardown(void **state) { |
| 1118 |
X(total_sends); |
| 1119 |
X(csends); |
| 1120 |
X(creads); |
| 1121 |
X(sreads); |
| 1122 |
X(ssends); |
| 1123 |
|
| 1124 |
/* As we used an ill-formed URI, there ought to be an error. */ |
| 1125 |
assert_int_equal(atomic_load(&csends), 0); |
| 1126 |
assert_int_equal(atomic_load(&creads), 0); |
| 1127 |
assert_int_equal(atomic_load(&sreads), 0); |
| 1128 |
assert_int_equal(atomic_load(&ssends), 0); |
| 1129 |
|
| 1130 |
return teardown_test(state); |
| 1131 |
} |
| 1132 |
|
| 1133 |
/* See: GL #2858, !5319 */ |
| 1134 |
ISC_LOOP_TEST_IMPL(doh_bad_connect_uri) { |
| 1135 |
isc_nm_t *listen_nm = nm[0]; |
| 1136 |
isc_nm_t *connect_nm = nm[1]; |
| 1137 |
isc_result_t result = ISC_R_SUCCESS; |
| 1138 |
isc_nmsocket_t *listen_sock = NULL; |
| 1139 |
char req_url[256]; |
| 1140 |
isc_quota_t *quotap = init_listener_quota(workers); |
| 1141 |
|
| 1142 |
atomic_store(&total_sends, 1); |
| 1143 |
|
| 1144 |
atomic_store(&nsends, atomic_load(&total_sends)); |
| 1145 |
|
| 1146 |
result = isc_nm_http_endpoints_add(endpoints, ISC_NM_HTTP_DEFAULT_PATH, |
| 1147 |
doh_receive_request_cb, NULL); |
| 1148 |
assert_int_equal(result, ISC_R_SUCCESS); |
| 1149 |
|
| 1150 |
result = isc_nm_listenhttp( |
| 1151 |
listen_nm, ISC_NM_LISTEN_ALL, &tcp_listen_addr, 0, quotap, |
| 1152 |
server_tlsctx, endpoints, 0, get_proxy_type(), &listen_sock); |
| 1153 |
assert_int_equal(result, ISC_R_SUCCESS); |
| 1154 |
|
| 1155 |
/* |
| 1156 |
* "https://::1:XXXX/dns-query" is a bad URI, it should be |
| 1157 |
* "https://[::1]:XXXX/dns-query" |
| 1158 |
*/ |
| 1159 |
(void)snprintf(req_url, sizeof(req_url), "https://::1:%u/%s", |
| 1160 |
isc_sockaddr_getport(&tcp_listen_addr), |
| 1161 |
ISC_NM_HTTP_DEFAULT_PATH); |
| 1162 |
connect_send_request(connect_nm, req_url, atomic_load(&POST), |
| 1163 |
&(isc_region_t){ .base = (uint8_t *)send_msg.base, |
| 1164 |
.length = send_msg.len }, |
| 1165 |
doh_receive_reply_cb, NULL, true, 30000); |
| 1166 |
|
| 1167 |
isc_loop_teardown(mainloop, listen_sock_close, listen_sock); |
| 1168 |
} |
| 1169 |
|
| 1170 |
ISC_RUN_TEST_IMPL(doh_parse_GET_query_string) { |
| 1171 |
/* valid */ |
| 1172 |
{ |
| 1173 |
bool ret; |
| 1174 |
const char *queryp = NULL; |
| 1175 |
size_t len = 0; |
| 1176 |
char str[] = |
| 1177 |
"dns=AAABAAABAAAAAAAAAWE-" |
| 1178 |
"NjJjaGFyYWN0ZXJsYWJlbC1tYWtlcy1iYXNlNjR1cmwtZGlzdGluY3" |
| 1179 |
"QtZnJvbS1zdGFuZGFyZC1iYXNlNjQHZXhhbXBsZQNjb20AAAEAAQ"; |
| 1180 |
|
| 1181 |
ret = isc__nm_parse_httpquery(str, &queryp, &len); |
| 1182 |
assert_true(ret); |
| 1183 |
assert_non_null(queryp); |
| 1184 |
assert_true(len > 0); |
| 1185 |
assert_true(len == strlen(str) - 4); |
| 1186 |
assert_true(memcmp(queryp, str + 4, len) == 0); |
| 1187 |
} |
| 1188 |
/* valid */ |
| 1189 |
{ |
| 1190 |
bool ret; |
| 1191 |
const char *queryp = NULL; |
| 1192 |
size_t len = 0; |
| 1193 |
char str[] = |
| 1194 |
"?dns=AAABAAABAAAAAAAAAWE-" |
| 1195 |
"NjJjaGFyYWN0ZXJsYWJlbC1tYWtlcy1iYXNlNjR1cmwtZGlzdGluY3" |
| 1196 |
"QtZnJvbS1zdGFuZGFyZC1iYXNlNjQHZXhhbXBsZQNjb20AAAEAAQ&"; |
| 1197 |
|
| 1198 |
ret = isc__nm_parse_httpquery(str, &queryp, &len); |
| 1199 |
assert_true(ret); |
| 1200 |
assert_non_null(queryp); |
| 1201 |
assert_true(len > 0); |
| 1202 |
assert_true(len == strlen(str) - 6); |
| 1203 |
assert_true(memcmp(queryp, str + 5, len) == 0); |
| 1204 |
} |
| 1205 |
/* valid */ |
| 1206 |
{ |
| 1207 |
bool ret; |
| 1208 |
const char *queryp = NULL; |
| 1209 |
size_t len = 0; |
| 1210 |
char str[] = "?dns=123&dns=567"; |
| 1211 |
|
| 1212 |
ret = isc__nm_parse_httpquery(str, &queryp, &len); |
| 1213 |
assert_true(ret); |
| 1214 |
assert_non_null(queryp); |
| 1215 |
assert_true(len > 0); |
| 1216 |
assert_true(len == 3); |
| 1217 |
assert_true(memcmp(queryp, "567", 3) == 0); |
| 1218 |
} |
| 1219 |
/* valid */ |
| 1220 |
{ |
| 1221 |
bool ret; |
| 1222 |
const char *queryp = NULL; |
| 1223 |
size_t len = 0; |
| 1224 |
char str[] = "?name1=123&dns=567&name2=123&"; |
| 1225 |
|
| 1226 |
ret = isc__nm_parse_httpquery(str, &queryp, &len); |
| 1227 |
assert_true(ret); |
| 1228 |
assert_non_null(queryp); |
| 1229 |
assert_true(len > 0); |
| 1230 |
assert_true(len == 3); |
| 1231 |
assert_true(memcmp(queryp, "567", 3) == 0); |
| 1232 |
} |
| 1233 |
/* complex, but still valid */ |
| 1234 |
{ |
| 1235 |
bool ret; |
| 1236 |
const char *queryp = NULL; |
| 1237 |
size_t len = 0; |
| 1238 |
char str[] = |
| 1239 |
"?title=%D0%92%D1%96%D0%B4%D1%81%D0%BE%D1%82%D0%BA%D0%" |
| 1240 |
"BE%D0%B2%D0%B5_%D0%BA%D0%BE%D0%B4%D1%83%D0%B2%D0%B0%" |
| 1241 |
"D0%BD%D0%BD%D1%8F&dns=123&veaction=edit§ion=0"; |
| 1242 |
|
| 1243 |
ret = isc__nm_parse_httpquery(str, &queryp, &len); |
| 1244 |
assert_true(ret); |
| 1245 |
assert_non_null(queryp); |
| 1246 |
assert_true(len > 0); |
| 1247 |
assert_true(len == 3); |
| 1248 |
assert_true(memcmp(queryp, "123", 3) == 0); |
| 1249 |
} |
| 1250 |
/* invalid */ |
| 1251 |
{ |
| 1252 |
bool ret; |
| 1253 |
const char *queryp = NULL; |
| 1254 |
size_t len = 0; |
| 1255 |
char str[] = |
| 1256 |
"?title=%D0%92%D1%96%D0%B4%D1%81%D0%BE%D1%82%D0%BA%D0%" |
| 1257 |
"BE%D0%B2%D0%B5_%D0%BA%D0%BE%D0%B4%D1%83%D0%B2%D0%B0%" |
| 1258 |
"D0%BD%D0%BD%D1%8F&veaction=edit§ion=0"; |
| 1259 |
|
| 1260 |
ret = isc__nm_parse_httpquery(str, &queryp, &len); |
| 1261 |
assert_false(ret); |
| 1262 |
assert_null(queryp); |
| 1263 |
assert_true(len == 0); |
| 1264 |
} |
| 1265 |
/* invalid */ |
| 1266 |
{ |
| 1267 |
bool ret; |
| 1268 |
const char *queryp = NULL; |
| 1269 |
size_t len = 0; |
| 1270 |
char str[] = ""; |
| 1271 |
|
| 1272 |
ret = isc__nm_parse_httpquery(str, &queryp, &len); |
| 1273 |
assert_false(ret); |
| 1274 |
assert_null(queryp); |
| 1275 |
assert_true(len == 0); |
| 1276 |
} |
| 1277 |
/* invalid */ |
| 1278 |
{ |
| 1279 |
bool ret; |
| 1280 |
const char *queryp = NULL; |
| 1281 |
size_t len = 0; |
| 1282 |
char str[] = "?&"; |
| 1283 |
|
| 1284 |
ret = isc__nm_parse_httpquery(str, &queryp, &len); |
| 1285 |
assert_false(ret); |
| 1286 |
assert_null(queryp); |
| 1287 |
assert_true(len == 0); |
| 1288 |
} |
| 1289 |
/* invalid */ |
| 1290 |
{ |
| 1291 |
bool ret; |
| 1292 |
const char *queryp = NULL; |
| 1293 |
size_t len = 0; |
| 1294 |
char str[] = "?dns&"; |
| 1295 |
|
| 1296 |
ret = isc__nm_parse_httpquery(str, &queryp, &len); |
| 1297 |
assert_false(ret); |
| 1298 |
assert_null(queryp); |
| 1299 |
assert_true(len == 0); |
| 1300 |
} |
| 1301 |
/* invalid */ |
| 1302 |
{ |
| 1303 |
bool ret; |
| 1304 |
const char *queryp = NULL; |
| 1305 |
size_t len = 0; |
| 1306 |
char str[] = "?dns=&"; |
| 1307 |
|
| 1308 |
ret = isc__nm_parse_httpquery(str, &queryp, &len); |
| 1309 |
assert_false(ret); |
| 1310 |
assert_null(queryp); |
| 1311 |
assert_true(len == 0); |
| 1312 |
} |
| 1313 |
/* invalid */ |
| 1314 |
{ |
| 1315 |
bool ret; |
| 1316 |
const char *queryp = NULL; |
| 1317 |
size_t len = 0; |
| 1318 |
char str[] = "?dns=123&&"; |
| 1319 |
|
| 1320 |
ret = isc__nm_parse_httpquery(str, &queryp, &len); |
| 1321 |
assert_false(ret); |
| 1322 |
assert_null(queryp); |
| 1323 |
assert_true(len == 0); |
| 1324 |
} |
| 1325 |
/* valid */ |
| 1326 |
{ |
| 1327 |
bool ret; |
| 1328 |
const char *queryp = NULL; |
| 1329 |
size_t len = 0; |
| 1330 |
char str[] = "?dns=123%12&"; |
| 1331 |
|
| 1332 |
ret = isc__nm_parse_httpquery(str, &queryp, &len); |
| 1333 |
assert_true(ret); |
| 1334 |
assert_non_null(queryp); |
| 1335 |
assert_true(len > 0); |
| 1336 |
assert_true(len == 6); |
| 1337 |
assert_true(memcmp(queryp, "123%12", 6) == 0); |
| 1338 |
} |
| 1339 |
/* invalid */ |
| 1340 |
{ |
| 1341 |
bool ret; |
| 1342 |
const char *queryp = NULL; |
| 1343 |
size_t len = 0; |
| 1344 |
char str[] = "?dns=123%ZZ&"; |
| 1345 |
|
| 1346 |
ret = isc__nm_parse_httpquery(str, &queryp, &len); |
| 1347 |
assert_false(ret); |
| 1348 |
assert_null(queryp); |
| 1349 |
assert_true(len == 0); |
| 1350 |
} |
| 1351 |
/* invalid */ |
| 1352 |
{ |
| 1353 |
bool ret; |
| 1354 |
const char *queryp = NULL; |
| 1355 |
size_t len = 0; |
| 1356 |
char str[] = "?dns=123%%&"; |
| 1357 |
|
| 1358 |
ret = isc__nm_parse_httpquery(str, &queryp, &len); |
| 1359 |
assert_false(ret); |
| 1360 |
assert_null(queryp); |
| 1361 |
assert_true(len == 0); |
| 1362 |
} |
| 1363 |
/* invalid */ |
| 1364 |
{ |
| 1365 |
bool ret; |
| 1366 |
const char *queryp = NULL; |
| 1367 |
size_t len = 0; |
| 1368 |
char str[] = "?dns=123%AZ&"; |
| 1369 |
|
| 1370 |
ret = isc__nm_parse_httpquery(str, &queryp, &len); |
| 1371 |
assert_false(ret); |
| 1372 |
assert_null(queryp); |
| 1373 |
assert_true(len == 0); |
| 1374 |
} |
| 1375 |
/* valid */ |
| 1376 |
{ |
| 1377 |
bool ret; |
| 1378 |
const char *queryp = NULL; |
| 1379 |
size_t len = 0; |
| 1380 |
char str[] = "?dns=123%0AZ&"; |
| 1381 |
|
| 1382 |
ret = isc__nm_parse_httpquery(str, &queryp, &len); |
| 1383 |
assert_true(ret); |
| 1384 |
assert_non_null(queryp); |
| 1385 |
assert_true(len > 0); |
| 1386 |
assert_true(len == 7); |
| 1387 |
assert_true(memcmp(queryp, "123%0AZ", 7) == 0); |
| 1388 |
} |
| 1389 |
} |
| 1390 |
|
| 1391 |
ISC_RUN_TEST_IMPL(doh_base64url_to_base64) { |
| 1392 |
char *res; |
| 1393 |
size_t res_len = 0; |
| 1394 |
/* valid */ |
| 1395 |
{ |
| 1396 |
char test[] = "YW55IGNhcm5hbCBwbGVhc3VyZS4"; |
| 1397 |
char res_test[] = "YW55IGNhcm5hbCBwbGVhc3VyZS4="; |
| 1398 |
|
| 1399 |
res = isc__nm_base64url_to_base64(mctx, test, strlen(test), |
| 1400 |
&res_len); |
| 1401 |
assert_non_null(res); |
| 1402 |
assert_true(res_len == strlen(res_test)); |
| 1403 |
assert_true(strcmp(res, res_test) == 0); |
| 1404 |
isc_mem_free(mctx, res); |
| 1405 |
} |
| 1406 |
/* valid */ |
| 1407 |
{ |
| 1408 |
char test[] = "YW55IGNhcm5hbCBwbGVhcw"; |
| 1409 |
char res_test[] = "YW55IGNhcm5hbCBwbGVhcw=="; |
| 1410 |
|
| 1411 |
res = isc__nm_base64url_to_base64(mctx, test, strlen(test), |
| 1412 |
&res_len); |
| 1413 |
assert_non_null(res); |
| 1414 |
assert_true(res_len == strlen(res_test)); |
| 1415 |
assert_true(strcmp(res, res_test) == 0); |
| 1416 |
isc_mem_free(mctx, res); |
| 1417 |
} |
| 1418 |
/* valid */ |
| 1419 |
{ |
| 1420 |
char test[] = "YW55IGNhcm5hbCBwbGVhc3Vy"; |
| 1421 |
char res_test[] = "YW55IGNhcm5hbCBwbGVhc3Vy"; |
| 1422 |
|
| 1423 |
res = isc__nm_base64url_to_base64(mctx, test, strlen(test), |
| 1424 |
&res_len); |
| 1425 |
assert_non_null(res); |
| 1426 |
assert_true(res_len == strlen(res_test)); |
| 1427 |
assert_true(strcmp(res, res_test) == 0); |
| 1428 |
isc_mem_free(mctx, res); |
| 1429 |
} |
| 1430 |
/* valid */ |
| 1431 |
{ |
| 1432 |
char test[] = "YW55IGNhcm5hbCBwbGVhc3U"; |
| 1433 |
char res_test[] = "YW55IGNhcm5hbCBwbGVhc3U="; |
| 1434 |
|
| 1435 |
res = isc__nm_base64url_to_base64(mctx, test, strlen(test), |
| 1436 |
&res_len); |
| 1437 |
assert_non_null(res); |
| 1438 |
assert_true(res_len == strlen(res_test)); |
| 1439 |
assert_true(strcmp(res, res_test) == 0); |
| 1440 |
isc_mem_free(mctx, res); |
| 1441 |
} |
| 1442 |
/* valid */ |
| 1443 |
{ |
| 1444 |
char test[] = "YW55IGNhcm5hbCBwbGVhcw"; |
| 1445 |
char res_test[] = "YW55IGNhcm5hbCBwbGVhcw=="; |
| 1446 |
|
| 1447 |
res = isc__nm_base64url_to_base64(mctx, test, strlen(test), |
| 1448 |
&res_len); |
| 1449 |
assert_non_null(res); |
| 1450 |
assert_true(res_len == strlen(res_test)); |
| 1451 |
assert_true(strcmp(res, res_test) == 0); |
| 1452 |
isc_mem_free(mctx, res); |
| 1453 |
} |
| 1454 |
/* valid */ |
| 1455 |
{ |
| 1456 |
char test[] = "PDw_Pz8-Pg"; |
| 1457 |
char res_test[] = "PDw/Pz8+Pg=="; |
| 1458 |
|
| 1459 |
res = isc__nm_base64url_to_base64(mctx, test, strlen(test), |
| 1460 |
&res_len); |
| 1461 |
assert_non_null(res); |
| 1462 |
assert_true(res_len == strlen(res_test)); |
| 1463 |
assert_true(strcmp(res, res_test) == 0); |
| 1464 |
isc_mem_free(mctx, res); |
| 1465 |
} |
| 1466 |
/* valid */ |
| 1467 |
{ |
| 1468 |
char test[] = "PDw_Pz8-Pg"; |
| 1469 |
char res_test[] = "PDw/Pz8+Pg=="; |
| 1470 |
|
| 1471 |
res = isc__nm_base64url_to_base64(mctx, test, strlen(test), |
| 1472 |
NULL); |
| 1473 |
assert_non_null(res); |
| 1474 |
assert_true(strcmp(res, res_test) == 0); |
| 1475 |
isc_mem_free(mctx, res); |
| 1476 |
} |
| 1477 |
/* invalid */ |
| 1478 |
{ |
| 1479 |
char test[] = "YW55IGNhcm5hbCBwbGVhcw"; |
| 1480 |
res_len = 0; |
| 1481 |
|
| 1482 |
res = isc__nm_base64url_to_base64(mctx, test, 0, &res_len); |
| 1483 |
assert_null(res); |
| 1484 |
assert_true(res_len == 0); |
| 1485 |
} |
| 1486 |
/* invalid */ |
| 1487 |
{ |
| 1488 |
char test[] = ""; |
| 1489 |
res_len = 0; |
| 1490 |
|
| 1491 |
res = isc__nm_base64url_to_base64(mctx, test, strlen(test), |
| 1492 |
&res_len); |
| 1493 |
assert_null(res); |
| 1494 |
assert_true(res_len == 0); |
| 1495 |
} |
| 1496 |
/* invalid */ |
| 1497 |
{ |
| 1498 |
char test[] = "PDw_Pz8-Pg=="; |
| 1499 |
res_len = 0; |
| 1500 |
|
| 1501 |
res = isc__nm_base64url_to_base64(mctx, test, strlen(test), |
| 1502 |
&res_len); |
| 1503 |
assert_null(res); |
| 1504 |
assert_true(res_len == 0); |
| 1505 |
} |
| 1506 |
/* invalid */ |
| 1507 |
{ |
| 1508 |
char test[] = "PDw_Pz8-Pg%3D%3D"; /* percent encoded "==" at the |
| 1509 |
end */ |
| 1510 |
res_len = 0; |
| 1511 |
|
| 1512 |
res = isc__nm_base64url_to_base64(mctx, test, strlen(test), |
| 1513 |
&res_len); |
| 1514 |
assert_null(res); |
| 1515 |
assert_true(res_len == 0); |
| 1516 |
} |
| 1517 |
/* invalid */ |
| 1518 |
{ |
| 1519 |
res_len = 0; |
| 1520 |
|
| 1521 |
res = isc__nm_base64url_to_base64(mctx, NULL, 31231, &res_len); |
| 1522 |
assert_null(res); |
| 1523 |
assert_true(res_len == 0); |
| 1524 |
} |
| 1525 |
} |
| 1526 |
|
| 1527 |
ISC_RUN_TEST_IMPL(doh_base64_to_base64url) { |
| 1528 |
char *res; |
| 1529 |
size_t res_len = 0; |
| 1530 |
/* valid */ |
| 1531 |
{ |
| 1532 |
char res_test[] = "YW55IGNhcm5hbCBwbGVhc3VyZS4"; |
| 1533 |
char test[] = "YW55IGNhcm5hbCBwbGVhc3VyZS4="; |
| 1534 |
|
| 1535 |
res = isc__nm_base64_to_base64url(mctx, test, strlen(test), |
| 1536 |
&res_len); |
| 1537 |
assert_non_null(res); |
| 1538 |
assert_true(res_len == strlen(res_test)); |
| 1539 |
assert_true(strcmp(res, res_test) == 0); |
| 1540 |
isc_mem_free(mctx, res); |
| 1541 |
} |
| 1542 |
/* valid */ |
| 1543 |
{ |
| 1544 |
char res_test[] = "YW55IGNhcm5hbCBwbGVhcw"; |
| 1545 |
char test[] = "YW55IGNhcm5hbCBwbGVhcw=="; |
| 1546 |
|
| 1547 |
res = isc__nm_base64_to_base64url(mctx, test, strlen(test), |
| 1548 |
&res_len); |
| 1549 |
assert_non_null(res); |
| 1550 |
assert_true(res_len == strlen(res_test)); |
| 1551 |
assert_true(strcmp(res, res_test) == 0); |
| 1552 |
isc_mem_free(mctx, res); |
| 1553 |
} |
| 1554 |
/* valid */ |
| 1555 |
{ |
| 1556 |
char res_test[] = "YW55IGNhcm5hbCBwbGVhc3Vy"; |
| 1557 |
char test[] = "YW55IGNhcm5hbCBwbGVhc3Vy"; |
| 1558 |
|
| 1559 |
res = isc__nm_base64_to_base64url(mctx, test, strlen(test), |
| 1560 |
&res_len); |
| 1561 |
assert_non_null(res); |
| 1562 |
assert_true(res_len == strlen(res_test)); |
| 1563 |
assert_true(strcmp(res, res_test) == 0); |
| 1564 |
isc_mem_free(mctx, res); |
| 1565 |
} |
| 1566 |
/* valid */ |
| 1567 |
{ |
| 1568 |
char res_test[] = "YW55IGNhcm5hbCBwbGVhc3U"; |
| 1569 |
char test[] = "YW55IGNhcm5hbCBwbGVhc3U="; |
| 1570 |
|
| 1571 |
res = isc__nm_base64_to_base64url(mctx, test, strlen(test), |
| 1572 |
&res_len); |
| 1573 |
assert_non_null(res); |
| 1574 |
assert_true(res_len == strlen(res_test)); |
| 1575 |
assert_true(strcmp(res, res_test) == 0); |
| 1576 |
isc_mem_free(mctx, res); |
| 1577 |
} |
| 1578 |
/* valid */ |
| 1579 |
{ |
| 1580 |
char res_test[] = "YW55IGNhcm5hbCBwbGVhcw"; |
| 1581 |
char test[] = "YW55IGNhcm5hbCBwbGVhcw=="; |
| 1582 |
|
| 1583 |
res = isc__nm_base64_to_base64url(mctx, test, strlen(test), |
| 1584 |
&res_len); |
| 1585 |
assert_non_null(res); |
| 1586 |
assert_true(res_len == strlen(res_test)); |
| 1587 |
assert_true(strcmp(res, res_test) == 0); |
| 1588 |
isc_mem_free(mctx, res); |
| 1589 |
} |
| 1590 |
/* valid */ |
| 1591 |
{ |
| 1592 |
char res_test[] = "PDw_Pz8-Pg"; |
| 1593 |
char test[] = "PDw/Pz8+Pg=="; |
| 1594 |
|
| 1595 |
res = isc__nm_base64_to_base64url(mctx, test, strlen(test), |
| 1596 |
&res_len); |
| 1597 |
assert_non_null(res); |
| 1598 |
assert_true(res_len == strlen(res_test)); |
| 1599 |
assert_true(strcmp(res, res_test) == 0); |
| 1600 |
isc_mem_free(mctx, res); |
| 1601 |
} |
| 1602 |
/* valid */ |
| 1603 |
{ |
| 1604 |
char res_test[] = "PDw_Pz8-Pg"; |
| 1605 |
char test[] = "PDw/Pz8+Pg=="; |
| 1606 |
|
| 1607 |
res = isc__nm_base64_to_base64url(mctx, test, strlen(test), |
| 1608 |
NULL); |
| 1609 |
assert_non_null(res); |
| 1610 |
assert_true(strcmp(res, res_test) == 0); |
| 1611 |
isc_mem_free(mctx, res); |
| 1612 |
} |
| 1613 |
/* invalid */ |
| 1614 |
{ |
| 1615 |
char test[] = "YW55IGNhcm5hbCBwbGVhcw"; |
| 1616 |
res_len = 0; |
| 1617 |
|
| 1618 |
res = isc__nm_base64_to_base64url(mctx, test, 0, &res_len); |
| 1619 |
assert_null(res); |
| 1620 |
assert_true(res_len == 0); |
| 1621 |
} |
| 1622 |
/* invalid */ |
| 1623 |
{ |
| 1624 |
char test[] = ""; |
| 1625 |
res_len = 0; |
| 1626 |
|
| 1627 |
res = isc__nm_base64_to_base64url(mctx, test, strlen(test), |
| 1628 |
&res_len); |
| 1629 |
assert_null(res); |
| 1630 |
assert_true(res_len == 0); |
| 1631 |
} |
| 1632 |
/* invalid */ |
| 1633 |
{ |
| 1634 |
char test[] = "PDw_Pz8-Pg=="; |
| 1635 |
res_len = 0; |
| 1636 |
|
| 1637 |
res = isc__nm_base64_to_base64url(mctx, test, strlen(test), |
| 1638 |
&res_len); |
| 1639 |
assert_null(res); |
| 1640 |
assert_true(res_len == 0); |
| 1641 |
} |
| 1642 |
/* invalid */ |
| 1643 |
{ |
| 1644 |
char test[] = "PDw_Pz8-Pg%3D%3D"; /* percent encoded "==" at the |
| 1645 |
end */ |
| 1646 |
res_len = 0; |
| 1647 |
|
| 1648 |
res = isc__nm_base64_to_base64url(mctx, test, strlen(test), |
| 1649 |
&res_len); |
| 1650 |
assert_null(res); |
| 1651 |
assert_true(res_len == 0); |
| 1652 |
} |
| 1653 |
/* invalid */ |
| 1654 |
{ |
| 1655 |
res_len = 0; |
| 1656 |
|
| 1657 |
res = isc__nm_base64_to_base64url(mctx, NULL, 31231, &res_len); |
| 1658 |
assert_null(res); |
| 1659 |
assert_true(res_len == 0); |
| 1660 |
} |
| 1661 |
} |
| 1662 |
|
| 1663 |
ISC_RUN_TEST_IMPL(doh_path_validation) { |
| 1664 |
assert_true(isc_nm_http_path_isvalid("/")); |
| 1665 |
assert_true(isc_nm_http_path_isvalid(ISC_NM_HTTP_DEFAULT_PATH)); |
| 1666 |
assert_false(isc_nm_http_path_isvalid("laaaa")); |
| 1667 |
assert_false(isc_nm_http_path_isvalid("")); |
| 1668 |
assert_false(isc_nm_http_path_isvalid("//")); |
| 1669 |
assert_true(isc_nm_http_path_isvalid("/lala///")); |
| 1670 |
assert_true(isc_nm_http_path_isvalid("/lalaaaaaa")); |
| 1671 |
assert_true(isc_nm_http_path_isvalid("/lalaaa/la/la/la")); |
| 1672 |
assert_true(isc_nm_http_path_isvalid("/la/a")); |
| 1673 |
assert_true(isc_nm_http_path_isvalid("/la+la")); |
| 1674 |
assert_true(isc_nm_http_path_isvalid("/la&la/la*la/l-a_/la!/la\'")); |
| 1675 |
assert_true(isc_nm_http_path_isvalid("/la/(la)/la")); |
| 1676 |
assert_true(isc_nm_http_path_isvalid("/la,la,la")); |
| 1677 |
assert_true(isc_nm_http_path_isvalid("/la-'la'-la")); |
| 1678 |
assert_true(isc_nm_http_path_isvalid("/la:la=la")); |
| 1679 |
assert_true(isc_nm_http_path_isvalid("/l@l@l@")); |
| 1680 |
assert_false(isc_nm_http_path_isvalid("/#lala")); |
| 1681 |
assert_true(isc_nm_http_path_isvalid("/lala;la")); |
| 1682 |
assert_false( |
| 1683 |
isc_nm_http_path_isvalid("la&la/laalaala*lala/l-al_a/lal!/")); |
| 1684 |
assert_true(isc_nm_http_path_isvalid("/Lal/lAla.jpg")); |
| 1685 |
|
| 1686 |
/* had to replace ? with ! because it does not verify a query string */ |
| 1687 |
assert_true(isc_nm_http_path_isvalid("/watch!v=oavMtUWDBTM")); |
| 1688 |
assert_false(isc_nm_http_path_isvalid("/watch?v=dQw4w9WgXcQ")); |
| 1689 |
assert_true(isc_nm_http_path_isvalid("/datatracker.ietf.org/doc/html/" |
| 1690 |
"rfc2616")); |
| 1691 |
assert_true(isc_nm_http_path_isvalid("/doc/html/rfc8484")); |
| 1692 |
assert_true(isc_nm_http_path_isvalid("/123")); |
| 1693 |
} |
| 1694 |
|
| 1695 |
ISC_RUN_TEST_IMPL(doh_connect_makeuri) { |
| 1696 |
struct in_addr localhostv4 = { .s_addr = ntohl(INADDR_LOOPBACK) }; |
| 1697 |
isc_sockaddr_t sa; |
| 1698 |
char uri[256]; |
| 1699 |
|
| 1700 |
/* Firstly, test URI generation using isc_sockaddr_t */ |
| 1701 |
isc_sockaddr_fromin(&sa, &localhostv4, 0); |
| 1702 |
uri[0] = '\0'; |
| 1703 |
isc_nm_http_makeuri(true, &sa, NULL, 0, ISC_NM_HTTP_DEFAULT_PATH, uri, |
| 1704 |
sizeof(uri)); |
| 1705 |
assert_true(strcmp("https://127.0.0.1:443/dns-query", uri) == 0); |
| 1706 |
|
| 1707 |
uri[0] = '\0'; |
| 1708 |
isc_nm_http_makeuri(false, &sa, NULL, 0, ISC_NM_HTTP_DEFAULT_PATH, uri, |
| 1709 |
sizeof(uri)); |
| 1710 |
assert_true(strcmp("http://127.0.0.1:80/dns-query", uri) == 0); |
| 1711 |
|
| 1712 |
/* |
| 1713 |
* The port value should be ignored, because we can get one from |
| 1714 |
* the isc_sockaddr_t object. |
| 1715 |
*/ |
| 1716 |
uri[0] = '\0'; |
| 1717 |
isc_nm_http_makeuri(true, &sa, NULL, 44343, ISC_NM_HTTP_DEFAULT_PATH, |
| 1718 |
uri, sizeof(uri)); |
| 1719 |
assert_true(strcmp("https://127.0.0.1:443/dns-query", uri) == 0); |
| 1720 |
|
| 1721 |
uri[0] = '\0'; |
| 1722 |
isc_nm_http_makeuri(false, &sa, NULL, 8080, ISC_NM_HTTP_DEFAULT_PATH, |
| 1723 |
uri, sizeof(uri)); |
| 1724 |
assert_true(strcmp("http://127.0.0.1:80/dns-query", uri) == 0); |
| 1725 |
|
| 1726 |
/* IPv6 */ |
| 1727 |
isc_sockaddr_fromin6(&sa, &in6addr_loopback, 0); |
| 1728 |
uri[0] = '\0'; |
| 1729 |
isc_nm_http_makeuri(true, &sa, NULL, 0, ISC_NM_HTTP_DEFAULT_PATH, uri, |
| 1730 |
sizeof(uri)); |
| 1731 |
assert_true(strcmp("https://[::1]:443/dns-query", uri) == 0); |
| 1732 |
|
| 1733 |
uri[0] = '\0'; |
| 1734 |
isc_nm_http_makeuri(false, &sa, NULL, 0, ISC_NM_HTTP_DEFAULT_PATH, uri, |
| 1735 |
sizeof(uri)); |
| 1736 |
assert_true(strcmp("http://[::1]:80/dns-query", uri) == 0); |
| 1737 |
|
| 1738 |
/* |
| 1739 |
* The port value should be ignored, because we can get one from |
| 1740 |
* the isc_sockaddr_t object. |
| 1741 |
*/ |
| 1742 |
uri[0] = '\0'; |
| 1743 |
isc_nm_http_makeuri(true, &sa, NULL, 44343, ISC_NM_HTTP_DEFAULT_PATH, |
| 1744 |
uri, sizeof(uri)); |
| 1745 |
assert_true(strcmp("https://[::1]:443/dns-query", uri) == 0); |
| 1746 |
|
| 1747 |
uri[0] = '\0'; |
| 1748 |
isc_nm_http_makeuri(false, &sa, NULL, 8080, ISC_NM_HTTP_DEFAULT_PATH, |
| 1749 |
uri, sizeof(uri)); |
| 1750 |
assert_true(strcmp("http://[::1]:80/dns-query", uri) == 0); |
| 1751 |
|
| 1752 |
/* Try to set the port numbers. */ |
| 1753 |
isc_sockaddr_setport(&sa, 44343); |
| 1754 |
uri[0] = '\0'; |
| 1755 |
isc_nm_http_makeuri(true, &sa, NULL, 0, ISC_NM_HTTP_DEFAULT_PATH, uri, |
| 1756 |
sizeof(uri)); |
| 1757 |
assert_true(strcmp("https://[::1]:44343/dns-query", uri) == 0); |
| 1758 |
|
| 1759 |
isc_sockaddr_setport(&sa, 8080); |
| 1760 |
uri[0] = '\0'; |
| 1761 |
isc_nm_http_makeuri(false, &sa, NULL, 0, ISC_NM_HTTP_DEFAULT_PATH, uri, |
| 1762 |
sizeof(uri)); |
| 1763 |
assert_true(strcmp("http://[::1]:8080/dns-query", uri) == 0); |
| 1764 |
|
| 1765 |
/* |
| 1766 |
* Try to make a URI using a hostname and a port number. The |
| 1767 |
* isc_sockaddr_t object will be ignored. |
| 1768 |
*/ |
| 1769 |
isc_sockaddr_any(&sa); |
| 1770 |
uri[0] = '\0'; |
| 1771 |
isc_nm_http_makeuri(true, &sa, "example.com", 0, |
| 1772 |
ISC_NM_HTTP_DEFAULT_PATH, uri, sizeof(uri)); |
| 1773 |
assert_true(strcmp("https://example.com:443/dns-query", uri) == 0); |
| 1774 |
|
| 1775 |
uri[0] = '\0'; |
| 1776 |
isc_nm_http_makeuri(false, &sa, "example.com", 0, |
| 1777 |
ISC_NM_HTTP_DEFAULT_PATH, uri, sizeof(uri)); |
| 1778 |
assert_true(strcmp("http://example.com:80/dns-query", uri) == 0); |
| 1779 |
|
| 1780 |
/* Try to set the port numbers. */ |
| 1781 |
isc_sockaddr_setport(&sa, 443); |
| 1782 |
uri[0] = '\0'; |
| 1783 |
isc_nm_http_makeuri(true, &sa, "example.com", 44343, |
| 1784 |
ISC_NM_HTTP_DEFAULT_PATH, uri, sizeof(uri)); |
| 1785 |
assert_true(strcmp("https://example.com:44343/dns-query", uri) == 0); |
| 1786 |
|
| 1787 |
isc_sockaddr_setport(&sa, 80); |
| 1788 |
uri[0] = '\0'; |
| 1789 |
isc_nm_http_makeuri(false, &sa, "example.com", 8080, |
| 1790 |
ISC_NM_HTTP_DEFAULT_PATH, uri, sizeof(uri)); |
| 1791 |
assert_true(strcmp("http://example.com:8080/dns-query", uri) == 0); |
| 1792 |
|
| 1793 |
/* IPv4 as the hostname - nothing fancy here */ |
| 1794 |
uri[0] = '\0'; |
| 1795 |
isc_nm_http_makeuri(false, NULL, "127.0.0.1", 8080, |
| 1796 |
ISC_NM_HTTP_DEFAULT_PATH, uri, sizeof(uri)); |
| 1797 |
assert_true(strcmp("http://127.0.0.1:8080/dns-query", uri) == 0); |
| 1798 |
|
| 1799 |
uri[0] = '\0'; |
| 1800 |
isc_nm_http_makeuri(true, NULL, "127.0.0.1", 44343, |
| 1801 |
ISC_NM_HTTP_DEFAULT_PATH, uri, sizeof(uri)); |
| 1802 |
assert_true(strcmp("https://127.0.0.1:44343/dns-query", uri) == 0); |
| 1803 |
|
| 1804 |
/* |
| 1805 |
* A peculiar edge case: IPv6 given as the hostname (notice |
| 1806 |
* the brackets) |
| 1807 |
*/ |
| 1808 |
uri[0] = '\0'; |
| 1809 |
isc_nm_http_makeuri(false, NULL, "::1", 8080, ISC_NM_HTTP_DEFAULT_PATH, |
| 1810 |
uri, sizeof(uri)); |
| 1811 |
assert_true(strcmp("http://[::1]:8080/dns-query", uri) == 0); |
| 1812 |
|
| 1813 |
uri[0] = '\0'; |
| 1814 |
isc_nm_http_makeuri(true, NULL, "[::1]", 44343, |
| 1815 |
ISC_NM_HTTP_DEFAULT_PATH, uri, sizeof(uri)); |
| 1816 |
assert_true(strcmp("https://[::1]:44343/dns-query", uri) == 0); |
| 1817 |
} |
| 1818 |
|
| 1819 |
/* PROXY */ |
| 1820 |
ISC_LOOP_TEST_IMPL(proxy_doh_noop_POST) { |
| 1821 |
atomic_store(&POST, true); |
| 1822 |
atomic_store(&use_PROXY, true); |
| 1823 |
doh_noop(arg); |
| 1824 |
} |
| 1825 |
|
| 1826 |
ISC_LOOP_TEST_IMPL(proxy_doh_noop_GET) { |
| 1827 |
atomic_store(&use_PROXY, true); |
| 1828 |
doh_noop(arg); |
| 1829 |
} |
| 1830 |
|
| 1831 |
ISC_LOOP_TEST_IMPL(proxy_doh_noresponse_POST) { |
| 1832 |
atomic_store(&POST, true); |
| 1833 |
atomic_store(&use_PROXY, true); |
| 1834 |
doh_noresponse(arg); |
| 1835 |
} |
| 1836 |
|
| 1837 |
ISC_LOOP_TEST_IMPL(proxy_doh_noresponse_GET) { |
| 1838 |
atomic_store(&use_PROXY, true); |
| 1839 |
doh_noresponse(arg); |
| 1840 |
} |
| 1841 |
|
| 1842 |
ISC_LOOP_TEST_IMPL(proxy_doh_timeout_recovery_POST) { |
| 1843 |
atomic_store(&POST, true); |
| 1844 |
atomic_store(&use_PROXY, true); |
| 1845 |
doh_timeout_recovery(arg); |
| 1846 |
} |
| 1847 |
|
| 1848 |
ISC_LOOP_TEST_IMPL(proxy_doh_timeout_recovery_GET) { |
| 1849 |
atomic_store(&use_PROXY, true); |
| 1850 |
doh_timeout_recovery(arg); |
| 1851 |
} |
| 1852 |
|
| 1853 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_one_POST) { |
| 1854 |
atomic_store(&POST, true); |
| 1855 |
atomic_store(&use_PROXY, true); |
| 1856 |
doh_recv_one(arg); |
| 1857 |
} |
| 1858 |
|
| 1859 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_one_GET) { |
| 1860 |
atomic_store(&use_PROXY, true); |
| 1861 |
doh_recv_one(arg); |
| 1862 |
} |
| 1863 |
|
| 1864 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_one_POST_TLS) { |
| 1865 |
atomic_store(&POST, true); |
| 1866 |
atomic_store(&use_TLS, true); |
| 1867 |
atomic_store(&use_PROXY, true); |
| 1868 |
doh_recv_one(arg); |
| 1869 |
} |
| 1870 |
|
| 1871 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_one_GET_TLS) { |
| 1872 |
atomic_store(&use_TLS, true); |
| 1873 |
atomic_store(&use_PROXY, true); |
| 1874 |
doh_recv_one(arg); |
| 1875 |
} |
| 1876 |
|
| 1877 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_one_POST_quota) { |
| 1878 |
atomic_store(&POST, true); |
| 1879 |
atomic_store(&use_PROXY, true); |
| 1880 |
atomic_store(&check_listener_quota, true); |
| 1881 |
doh_recv_one(arg); |
| 1882 |
} |
| 1883 |
|
| 1884 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_one_GET_quota) { |
| 1885 |
atomic_store(&use_PROXY, true); |
| 1886 |
atomic_store(&check_listener_quota, true); |
| 1887 |
doh_recv_one(arg); |
| 1888 |
} |
| 1889 |
|
| 1890 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_one_GET_TLS_quota) { |
| 1891 |
atomic_store(&use_TLS, true); |
| 1892 |
atomic_store(&use_PROXY, true); |
| 1893 |
atomic_store(&check_listener_quota, true); |
| 1894 |
doh_recv_one(arg); |
| 1895 |
} |
| 1896 |
|
| 1897 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_one_POST_TLS_quota) { |
| 1898 |
atomic_store(&POST, true); |
| 1899 |
atomic_store(&use_TLS, true); |
| 1900 |
atomic_store(&use_PROXY, true); |
| 1901 |
atomic_store(&check_listener_quota, true); |
| 1902 |
doh_recv_one(arg); |
| 1903 |
} |
| 1904 |
|
| 1905 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_two_POST) { |
| 1906 |
atomic_store(&POST, true); |
| 1907 |
atomic_store(&use_PROXY, true); |
| 1908 |
doh_recv_two(arg); |
| 1909 |
} |
| 1910 |
|
| 1911 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_two_GET) { |
| 1912 |
; |
| 1913 |
atomic_store(&use_PROXY, true); |
| 1914 |
doh_recv_two(arg); |
| 1915 |
} |
| 1916 |
|
| 1917 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_two_POST_TLS) { |
| 1918 |
atomic_store(&POST, true); |
| 1919 |
atomic_store(&use_TLS, true); |
| 1920 |
atomic_store(&use_PROXY, true); |
| 1921 |
doh_recv_two(arg); |
| 1922 |
} |
| 1923 |
|
| 1924 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_two_GET_TLS) { |
| 1925 |
atomic_store(&use_TLS, true); |
| 1926 |
atomic_store(&use_PROXY, true); |
| 1927 |
doh_recv_two(arg); |
| 1928 |
} |
| 1929 |
|
| 1930 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_two_POST_quota) { |
| 1931 |
atomic_store(&POST, true); |
| 1932 |
atomic_store(&use_PROXY, true); |
| 1933 |
atomic_store(&check_listener_quota, true); |
| 1934 |
doh_recv_two(arg); |
| 1935 |
} |
| 1936 |
|
| 1937 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_two_GET_quota) { |
| 1938 |
atomic_store(&use_PROXY, true); |
| 1939 |
atomic_store(&check_listener_quota, true); |
| 1940 |
doh_recv_two(arg); |
| 1941 |
} |
| 1942 |
|
| 1943 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_two_POST_TLS_quota) { |
| 1944 |
atomic_store(&POST, true); |
| 1945 |
atomic_store(&use_TLS, true); |
| 1946 |
atomic_store(&use_PROXY, true); |
| 1947 |
atomic_store(&check_listener_quota, true); |
| 1948 |
doh_recv_two(arg); |
| 1949 |
} |
| 1950 |
|
| 1951 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_two_GET_TLS_quota) { |
| 1952 |
atomic_store(&use_TLS, true); |
| 1953 |
atomic_store(&use_PROXY, true); |
| 1954 |
atomic_store(&check_listener_quota, true); |
| 1955 |
doh_recv_two(arg); |
| 1956 |
} |
| 1957 |
|
| 1958 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_send_POST) { |
| 1959 |
atomic_store(&POST, true); |
| 1960 |
atomic_store(&use_PROXY, true); |
| 1961 |
doh_recv_send(arg); |
| 1962 |
} |
| 1963 |
|
| 1964 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_send_GET) { |
| 1965 |
atomic_store(&use_PROXY, true); |
| 1966 |
doh_recv_send(arg); |
| 1967 |
} |
| 1968 |
|
| 1969 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_send_POST_TLS) { |
| 1970 |
atomic_store(&POST, true); |
| 1971 |
atomic_store(&use_TLS, true); |
| 1972 |
atomic_store(&use_PROXY, true); |
| 1973 |
doh_recv_send(arg); |
| 1974 |
} |
| 1975 |
|
| 1976 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_send_GET_TLS) { |
| 1977 |
atomic_store(&use_TLS, true); |
| 1978 |
atomic_store(&use_PROXY, true); |
| 1979 |
doh_recv_send(arg); |
| 1980 |
} |
| 1981 |
|
| 1982 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_send_POST_quota) { |
| 1983 |
atomic_store(&POST, true); |
| 1984 |
atomic_store(&use_PROXY, true); |
| 1985 |
atomic_store(&check_listener_quota, true); |
| 1986 |
doh_recv_send(arg); |
| 1987 |
} |
| 1988 |
|
| 1989 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_send_GET_quota) { |
| 1990 |
atomic_store(&use_PROXY, true); |
| 1991 |
atomic_store(&check_listener_quota, true); |
| 1992 |
doh_recv_send(arg); |
| 1993 |
} |
| 1994 |
|
| 1995 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_send_POST_TLS_quota) { |
| 1996 |
atomic_store(&POST, true); |
| 1997 |
atomic_store(&use_TLS, true); |
| 1998 |
atomic_store(&use_PROXY, true); |
| 1999 |
atomic_store(&check_listener_quota, true); |
| 2000 |
doh_recv_send(arg); |
| 2001 |
} |
| 2002 |
|
| 2003 |
ISC_LOOP_TEST_IMPL(proxy_doh_recv_send_GET_TLS_quota) { |
| 2004 |
atomic_store(&use_TLS, true); |
| 2005 |
atomic_store(&use_PROXY, true); |
| 2006 |
atomic_store(&check_listener_quota, true); |
| 2007 |
doh_recv_send(arg); |
| 2008 |
} |
| 2009 |
|
| 2010 |
/* PROXY over TLS */ |
| 2011 |
|
| 2012 |
ISC_LOOP_TEST_IMPL(proxytls_doh_recv_one_POST_TLS) { |
| 2013 |
atomic_store(&POST, true); |
| 2014 |
atomic_store(&use_TLS, true); |
| 2015 |
atomic_store(&use_PROXY, true); |
| 2016 |
atomic_store(&use_PROXY_over_TLS, true); |
| 2017 |
doh_recv_one(arg); |
| 2018 |
} |
| 2019 |
|
| 2020 |
ISC_LOOP_TEST_IMPL(proxytls_doh_recv_one_GET_TLS) { |
| 2021 |
atomic_store(&use_TLS, true); |
| 2022 |
atomic_store(&use_PROXY, true); |
| 2023 |
atomic_store(&use_PROXY_over_TLS, true); |
| 2024 |
doh_recv_one(arg); |
| 2025 |
} |
| 2026 |
|
| 2027 |
ISC_LOOP_TEST_IMPL(proxytls_doh_recv_one_GET_TLS_quota) { |
| 2028 |
atomic_store(&use_TLS, true); |
| 2029 |
atomic_store(&use_PROXY, true); |
| 2030 |
atomic_store(&use_PROXY_over_TLS, true); |
| 2031 |
atomic_store(&check_listener_quota, true); |
| 2032 |
doh_recv_one(arg); |
| 2033 |
} |
| 2034 |
|
| 2035 |
ISC_LOOP_TEST_IMPL(proxytls_doh_recv_one_POST_TLS_quota) { |
| 2036 |
atomic_store(&POST, true); |
| 2037 |
atomic_store(&use_TLS, true); |
| 2038 |
atomic_store(&use_PROXY, true); |
| 2039 |
atomic_store(&use_PROXY_over_TLS, true); |
| 2040 |
atomic_store(&check_listener_quota, true); |
| 2041 |
doh_recv_one(arg); |
| 2042 |
} |
| 2043 |
|
| 2044 |
ISC_LOOP_TEST_IMPL(proxytls_doh_recv_two_POST_TLS) { |
| 2045 |
atomic_store(&POST, true); |
| 2046 |
atomic_store(&use_TLS, true); |
| 2047 |
atomic_store(&use_PROXY, true); |
| 2048 |
atomic_store(&use_PROXY_over_TLS, true); |
| 2049 |
doh_recv_two(arg); |
| 2050 |
} |
| 2051 |
|
| 2052 |
ISC_LOOP_TEST_IMPL(proxytls_doh_recv_two_GET_TLS) { |
| 2053 |
atomic_store(&use_TLS, true); |
| 2054 |
atomic_store(&use_PROXY, true); |
| 2055 |
atomic_store(&use_PROXY_over_TLS, true); |
| 2056 |
doh_recv_two(arg); |
| 2057 |
} |
| 2058 |
|
| 2059 |
ISC_LOOP_TEST_IMPL(proxytls_doh_recv_two_POST_TLS_quota) { |
| 2060 |
atomic_store(&POST, true); |
| 2061 |
atomic_store(&use_TLS, true); |
| 2062 |
atomic_store(&use_PROXY, true); |
| 2063 |
atomic_store(&use_PROXY_over_TLS, true); |
| 2064 |
atomic_store(&check_listener_quota, true); |
| 2065 |
doh_recv_two(arg); |
| 2066 |
} |
| 2067 |
|
| 2068 |
ISC_LOOP_TEST_IMPL(proxytls_doh_recv_two_GET_TLS_quota) { |
| 2069 |
atomic_store(&use_TLS, true); |
| 2070 |
atomic_store(&use_PROXY, true); |
| 2071 |
atomic_store(&use_PROXY_over_TLS, true); |
| 2072 |
atomic_store(&check_listener_quota, true); |
| 2073 |
doh_recv_two(arg); |
| 2074 |
} |
| 2075 |
|
| 2076 |
ISC_LOOP_TEST_IMPL(proxytls_doh_recv_send_POST_TLS) { |
| 2077 |
atomic_store(&POST, true); |
| 2078 |
atomic_store(&use_TLS, true); |
| 2079 |
atomic_store(&use_PROXY, true); |
| 2080 |
atomic_store(&use_PROXY_over_TLS, true); |
| 2081 |
doh_recv_send(arg); |
| 2082 |
} |
| 2083 |
|
| 2084 |
ISC_LOOP_TEST_IMPL(proxytls_doh_recv_send_GET_TLS) { |
| 2085 |
atomic_store(&use_TLS, true); |
| 2086 |
atomic_store(&use_PROXY, true); |
| 2087 |
atomic_store(&use_PROXY_over_TLS, true); |
| 2088 |
doh_recv_send(arg); |
| 2089 |
} |
| 2090 |
|
| 2091 |
ISC_LOOP_TEST_IMPL(proxytls_doh_recv_send_POST_TLS_quota) { |
| 2092 |
atomic_store(&POST, true); |
| 2093 |
atomic_store(&use_TLS, true); |
| 2094 |
atomic_store(&use_PROXY, true); |
| 2095 |
atomic_store(&use_PROXY_over_TLS, true); |
| 2096 |
atomic_store(&check_listener_quota, true); |
| 2097 |
doh_recv_send(arg); |
| 2098 |
} |
| 2099 |
|
| 2100 |
ISC_LOOP_TEST_IMPL(proxytls_doh_recv_send_GET_TLS_quota) { |
| 2101 |
atomic_store(&use_TLS, true); |
| 2102 |
atomic_store(&use_PROXY, true); |
| 2103 |
atomic_store(&use_PROXY_over_TLS, true); |
| 2104 |
atomic_store(&check_listener_quota, true); |
| 2105 |
doh_recv_send(arg); |
| 2106 |
} |
| 2107 |
|
| 2108 |
ISC_TEST_LIST_START |
| 2109 |
|
| 2110 |
ISC_TEST_ENTRY_CUSTOM(mock_doh_uv_tcp_bind, setup_test, teardown_test) |
| 2111 |
ISC_TEST_ENTRY(doh_parse_GET_query_string) |
| 2112 |
ISC_TEST_ENTRY(doh_base64url_to_base64) |
| 2113 |
ISC_TEST_ENTRY(doh_base64_to_base64url) |
| 2114 |
ISC_TEST_ENTRY(doh_path_validation) |
| 2115 |
ISC_TEST_ENTRY(doh_connect_makeuri) |
| 2116 |
ISC_TEST_ENTRY_CUSTOM(doh_noop_POST, setup_test, teardown_test) |
| 2117 |
ISC_TEST_ENTRY_CUSTOM(doh_noop_GET, setup_test, teardown_test) |
| 2118 |
ISC_TEST_ENTRY_CUSTOM(doh_noresponse_POST, setup_test, teardown_test) |
| 2119 |
ISC_TEST_ENTRY_CUSTOM(doh_noresponse_GET, setup_test, teardown_test) |
| 2120 |
ISC_TEST_ENTRY_CUSTOM(doh_timeout_recovery_POST, setup_test, |
| 2121 |
doh_timeout_recovery_teardown) |
| 2122 |
ISC_TEST_ENTRY_CUSTOM(doh_timeout_recovery_GET, setup_test, |
| 2123 |
doh_timeout_recovery_teardown) |
| 2124 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_one_POST, setup_test, doh_recv_one_teardown) |
| 2125 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_one_GET, setup_test, doh_recv_one_teardown) |
| 2126 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_one_POST_TLS, setup_test, doh_recv_one_teardown) |
| 2127 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_one_GET_TLS, setup_test, doh_recv_one_teardown) |
| 2128 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_one_POST_quota, setup_test, |
| 2129 |
doh_recv_one_teardown) |
| 2130 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_one_GET_quota, setup_test, doh_recv_one_teardown) |
| 2131 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_one_POST_TLS_quota, setup_test, |
| 2132 |
doh_recv_one_teardown) |
| 2133 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_one_GET_TLS_quota, setup_test, |
| 2134 |
doh_recv_one_teardown) |
| 2135 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_two_POST, setup_test, doh_recv_two_teardown) |
| 2136 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_two_GET, setup_test, doh_recv_two_teardown) |
| 2137 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_two_POST_TLS, setup_test, doh_recv_two_teardown) |
| 2138 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_two_GET_TLS, setup_test, doh_recv_two_teardown) |
| 2139 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_two_POST_quota, setup_test, |
| 2140 |
doh_recv_two_teardown) |
| 2141 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_two_GET_quota, setup_test, doh_recv_two_teardown) |
| 2142 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_two_POST_TLS_quota, setup_test, |
| 2143 |
doh_recv_two_teardown) |
| 2144 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_two_GET_TLS_quota, setup_test, |
| 2145 |
doh_recv_two_teardown) |
| 2146 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_send_GET, setup_test, doh_recv_send_teardown) |
| 2147 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_send_POST, setup_test, doh_recv_send_teardown) |
| 2148 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_send_GET_TLS, setup_test, doh_recv_send_teardown) |
| 2149 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_send_POST_TLS, setup_test, |
| 2150 |
doh_recv_send_teardown) |
| 2151 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_send_GET_quota, setup_test, |
| 2152 |
doh_recv_send_teardown) |
| 2153 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_send_POST_quota, setup_test, |
| 2154 |
doh_recv_send_teardown) |
| 2155 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_send_GET_TLS_quota, setup_test, |
| 2156 |
doh_recv_send_teardown) |
| 2157 |
ISC_TEST_ENTRY_CUSTOM(doh_recv_send_POST_TLS_quota, setup_test, |
| 2158 |
doh_recv_send_teardown) |
| 2159 |
ISC_TEST_ENTRY_CUSTOM(doh_bad_connect_uri, setup_test, |
| 2160 |
doh_bad_connect_uri_teardown) |
| 2161 |
/* PROXY */ |
| 2162 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_noop_POST, setup_test, teardown_test) |
| 2163 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_noop_GET, setup_test, teardown_test) |
| 2164 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_noresponse_POST, setup_test, teardown_test) |
| 2165 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_noresponse_GET, setup_test, teardown_test) |
| 2166 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_timeout_recovery_POST, setup_test, |
| 2167 |
doh_timeout_recovery_teardown) |
| 2168 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_timeout_recovery_GET, setup_test, |
| 2169 |
doh_timeout_recovery_teardown) |
| 2170 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_one_POST, setup_test, |
| 2171 |
doh_recv_one_teardown) |
| 2172 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_one_GET, setup_test, doh_recv_one_teardown) |
| 2173 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_one_POST_TLS, setup_test, |
| 2174 |
doh_recv_one_teardown) |
| 2175 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_one_GET_TLS, setup_test, |
| 2176 |
doh_recv_one_teardown) |
| 2177 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_one_POST_quota, setup_test, |
| 2178 |
doh_recv_one_teardown) |
| 2179 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_one_GET_quota, setup_test, |
| 2180 |
doh_recv_one_teardown) |
| 2181 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_one_POST_TLS_quota, setup_test, |
| 2182 |
doh_recv_one_teardown) |
| 2183 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_one_GET_TLS_quota, setup_test, |
| 2184 |
doh_recv_one_teardown) |
| 2185 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_two_POST, setup_test, |
| 2186 |
doh_recv_two_teardown) |
| 2187 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_two_GET, setup_test, doh_recv_two_teardown) |
| 2188 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_two_POST_TLS, setup_test, |
| 2189 |
doh_recv_two_teardown) |
| 2190 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_two_GET_TLS, setup_test, |
| 2191 |
doh_recv_two_teardown) |
| 2192 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_two_POST_quota, setup_test, |
| 2193 |
doh_recv_two_teardown) |
| 2194 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_two_GET_quota, setup_test, |
| 2195 |
doh_recv_two_teardown) |
| 2196 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_two_POST_TLS_quota, setup_test, |
| 2197 |
doh_recv_two_teardown) |
| 2198 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_two_GET_TLS_quota, setup_test, |
| 2199 |
doh_recv_two_teardown) |
| 2200 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_send_GET, setup_test, |
| 2201 |
doh_recv_send_teardown) |
| 2202 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_send_POST, setup_test, |
| 2203 |
doh_recv_send_teardown) |
| 2204 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_send_GET_TLS, setup_test, |
| 2205 |
doh_recv_send_teardown) |
| 2206 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_send_POST_TLS, setup_test, |
| 2207 |
doh_recv_send_teardown) |
| 2208 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_send_GET_quota, setup_test, |
| 2209 |
doh_recv_send_teardown) |
| 2210 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_send_POST_quota, setup_test, |
| 2211 |
doh_recv_send_teardown) |
| 2212 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_send_GET_TLS_quota, setup_test, |
| 2213 |
doh_recv_send_teardown) |
| 2214 |
ISC_TEST_ENTRY_CUSTOM(proxy_doh_recv_send_POST_TLS_quota, setup_test, |
| 2215 |
doh_recv_send_teardown) |
| 2216 |
/* PROXY over TLS */ |
| 2217 |
ISC_TEST_ENTRY_CUSTOM(proxytls_doh_recv_one_POST_TLS, setup_test, |
| 2218 |
doh_recv_one_teardown) |
| 2219 |
ISC_TEST_ENTRY_CUSTOM(proxytls_doh_recv_one_GET_TLS, setup_test, |
| 2220 |
doh_recv_one_teardown) |
| 2221 |
ISC_TEST_ENTRY_CUSTOM(proxytls_doh_recv_one_POST_TLS_quota, setup_test, |
| 2222 |
doh_recv_one_teardown) |
| 2223 |
ISC_TEST_ENTRY_CUSTOM(proxytls_doh_recv_one_GET_TLS_quota, setup_test, |
| 2224 |
doh_recv_one_teardown) |
| 2225 |
ISC_TEST_ENTRY_CUSTOM(proxytls_doh_recv_two_POST_TLS, setup_test, |
| 2226 |
doh_recv_two_teardown) |
| 2227 |
ISC_TEST_ENTRY_CUSTOM(proxytls_doh_recv_two_GET_TLS, setup_test, |
| 2228 |
doh_recv_two_teardown) |
| 2229 |
ISC_TEST_ENTRY_CUSTOM(proxytls_doh_recv_two_POST_TLS_quota, setup_test, |
| 2230 |
doh_recv_two_teardown) |
| 2231 |
ISC_TEST_ENTRY_CUSTOM(proxytls_doh_recv_two_GET_TLS_quota, setup_test, |
| 2232 |
doh_recv_two_teardown) |
| 2233 |
ISC_TEST_ENTRY_CUSTOM(proxytls_doh_recv_send_GET_TLS, setup_test, |
| 2234 |
doh_recv_send_teardown) |
| 2235 |
ISC_TEST_ENTRY_CUSTOM(proxytls_doh_recv_send_POST_TLS, setup_test, |
| 2236 |
doh_recv_send_teardown) |
| 2237 |
ISC_TEST_ENTRY_CUSTOM(proxytls_doh_recv_send_GET_TLS_quota, setup_test, |
| 2238 |
doh_recv_send_teardown) |
| 2239 |
ISC_TEST_ENTRY_CUSTOM(proxytls_doh_recv_send_POST_TLS_quota, setup_test, |
| 2240 |
doh_recv_send_teardown) |
| 2241 |
ISC_TEST_LIST_END |
| 2242 |
|
| 2243 |
ISC_TEST_MAIN |