|
OpenVPN
|
#include <stdlib.h>#include <stdarg.h>#include <setjmp.h>#include <cmocka.h>#include "push.h"#include "options_util.h"#include "multi.h"#include "push_util.c"
Go to the source code of this file.
Macros | |
| #define | PUSH_BUNDLE_SIZE_TEST 184 |
| #define | expect_control_channel_strings(res) |
Functions | |
| static void | reset_route_counters (void) |
| bool | apply_push_options (struct context *c, struct options *options, struct buffer *buf, uint64_t permission_mask, uint64_t *option_types_found, struct env_set *es, bool is_update) |
| int | process_incoming_push_msg (struct context *c, const struct buffer *buffer, bool honor_received_options, uint64_t permission_mask, uint64_t *option_types_found) |
| const char * | tls_common_name (const struct tls_multi *multi, const bool null) |
| Returns the common name field for the given tunnel. | |
| bool | send_control_channel_string (struct context *c, const char *str, msglvl_t msglevel) |
| struct multi_instance * | lookup_by_cid (struct multi_context *m, const unsigned long cid) |
| bool | mroute_extract_openvpn_sockaddr (struct mroute_addr *addr, const struct openvpn_sockaddr *osaddr, bool use_port) |
| static void | test_incoming_push_message_basic (void **state) |
| static void | test_incoming_push_message_error1 (void **state) |
| static void | test_incoming_push_message_error2 (void **state) |
| static void | test_incoming_push_message_1 (void **state) |
| static void | test_incoming_push_message_bad_format (void **state) |
| static void | test_incoming_push_message_not_updatable_option (void **state) |
| static void | test_incoming_push_message_mix (void **state) |
| static void | test_incoming_push_message_mix2 (void **state) |
| static void | test_incoming_push_continuation_route_accumulation (void **state) |
| Test that routes accumulate correctly across multiple continuation messages. | |
| static void | test_send_push_msg0 (void **state) |
| static void | test_send_push_msg1 (void **state) |
| static void | test_send_push_msg2 (void **state) |
| static void | test_send_push_msg3 (void **state) |
| static void | test_send_push_msg4 (void **state) |
| static void | test_send_push_msg5 (void **state) |
| static void | test_send_push_msg6 (void **state) |
| static void | test_send_push_msg7 (void **state) |
| static void | test_send_push_msg8 (void **state) |
| static void | test_send_push_msg9 (void **state) |
| static void | test_send_push_msg10 (void **state) |
| static void | test_send_push_msg11 (void **state) |
| static void | test_send_push_msg12 (void **state) |
| static void | test_send_push_msg13 (void **state) |
| static void | test_send_push_msg14 (void **state) |
| static int | setup2 (void **state) |
| static int | teardown2 (void **state) |
| static int | setup (void **state) |
| static int | teardown (void **state) |
| int | main (void) |
Variables | |
| static int | route_reset_count = 0 |
| static int | route_add_count = 0 |
| char * | r0 [] |
| char * | r1 [] |
| char * | r3 [] |
| char * | r4 [] |
| char * | r5 [] |
| char * | r6 [] |
| char * | r7 [] |
| char * | r8 [] |
| char * | r9 [] |
| char * | r11 [] |
| char * | r12 [] |
| char * | r13 [] |
| char * | r14 [] |
| const char * | msg0 = "redirect-gateway local,route 192.168.1.0 255.255.255.0" |
| const char * | msg1 |
| const char * | msg2 = "" |
| const char * | msg3 = ",," |
| const char * | msg4 |
| const char * | msg5 |
| const char * | msg6 |
| const char * | msg7 = ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,," |
| const char * | msg8 |
| const char * | msg9 = "," |
| const char * | msg10 |
| const char * | msg11 |
| const char * | msg12 = "a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,,,,,,a,abc" |
| const char * | msg13 = "a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,,,,,,a," |
| const char * | msg14 = "a,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,a" |
| #define expect_control_channel_strings | ( | res | ) |
Definition at line 454 of file test_push_update_msg.c.
| #define PUSH_BUNDLE_SIZE_TEST 184 |
Definition at line 452 of file test_push_update_msg.c.
| bool apply_push_options | ( | struct context * | c, |
| struct options * | options, | ||
| struct buffer * | buf, | ||
| uint64_t | permission_mask, | ||
| uint64_t * | option_types_found, | ||
| struct env_set * | es, | ||
| bool | is_update | ||
| ) |
Definition at line 30 of file test_push_update_msg.c.
References add_option(), apply_pull_filter(), buf_parse(), check_push_update_option_flags(), CLEAR, D_PUSH_ERRORS, es, options::gc, buffer::len, M_OPTERR, MAX_PARMS, OPT_P_U_ROUTE, OPTION_PARM_SIZE, parse_line(), options::pull_filter_list, options::push_continuation, PUSH_OPT_OPTIONAL, PUSH_OPT_TO_REMOVE, options::push_update_options_found, remove_option(), route_add_count, route_reset_count, SIZE, and update_option().
Referenced by process_incoming_push_reply(), and process_push_update().
| struct multi_instance * lookup_by_cid | ( | struct multi_context * | m, |
| const unsigned long | cid | ||
| ) |
Definition at line 137 of file test_push_update_msg.c.
References multi_context::instances.
| int main | ( | void | ) |
Definition at line 643 of file test_push_update_msg.c.
References setup(), setup2(), teardown(), teardown2(), test_incoming_push_continuation_route_accumulation(), test_incoming_push_message_1(), test_incoming_push_message_bad_format(), test_incoming_push_message_basic(), test_incoming_push_message_error1(), test_incoming_push_message_error2(), test_incoming_push_message_mix(), test_incoming_push_message_mix2(), test_incoming_push_message_not_updatable_option(), test_send_push_msg0(), test_send_push_msg1(), test_send_push_msg10(), test_send_push_msg11(), test_send_push_msg12(), test_send_push_msg13(), test_send_push_msg14(), test_send_push_msg2(), test_send_push_msg3(), test_send_push_msg4(), test_send_push_msg5(), test_send_push_msg6(), test_send_push_msg7(), test_send_push_msg8(), and test_send_push_msg9().
| bool mroute_extract_openvpn_sockaddr | ( | struct mroute_addr * | addr, |
| const struct openvpn_sockaddr * | osaddr, | ||
| bool | use_port | ||
| ) |
Definition at line 143 of file test_push_update_msg.c.
| int process_incoming_push_msg | ( | struct context * | c, |
| const struct buffer * | buffer, | ||
| bool | honor_received_options, | ||
| uint64_t | permission_mask, | ||
| uint64_t * | option_types_found | ||
| ) |
Definition at line 91 of file test_push_update_msg.c.
References buf_string_compare_advance(), buffer::len, process_push_update(), PUSH_MSG_ERROR, PUSH_MSG_REPLY, PUSH_MSG_REQUEST, push_reply_cmd, and push_update_cmd.
Referenced by test_incoming_push_continuation_route_accumulation(), test_incoming_push_message_1(), test_incoming_push_message_bad_format(), test_incoming_push_message_basic(), test_incoming_push_message_error1(), test_incoming_push_message_error2(), test_incoming_push_message_mix(), test_incoming_push_message_mix2(), and test_incoming_push_message_not_updatable_option().
|
static |
Definition at line 23 of file test_push_update_msg.c.
References route_add_count, and route_reset_count.
Referenced by test_incoming_push_continuation_route_accumulation().
Definition at line 130 of file test_push_update_msg.c.
References buffer::len.
|
static |
Definition at line 625 of file test_push_update_msg.c.
References context::options, options::pull, and options::route_nopull.
Referenced by main().
|
static |
Definition at line 599 of file test_push_update_msg.c.
References context::c2, multi_instance::context, options::disable_dco, multi_context::instances, context::options, tls_multi::peer_info, context_2::tls_multi, and multi_context::top.
Referenced by main().
|
static |
Definition at line 635 of file test_push_update_msg.c.
Referenced by main().
|
static |
Definition at line 613 of file test_push_update_msg.c.
References multi_context::instances.
Referenced by main().
|
static |
Test that routes accumulate correctly across multiple continuation messages.
This test exposes a bug where update_options_found is reset to 0 for each continuation message, causing routes to be reset on each message instead of accumulating.
Expected behavior: routes should only be reset ONCE (when the first route is received), then all subsequent routes should accumulate.
Current bug: routes are reset on the first route of EACH continuation message.
Definition at line 296 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, process_incoming_push_msg(), pull_permission_mask(), PUSH_MSG_CONTINUATION, PUSH_MSG_UPDATE, reset_route_counters(), route_add_count, and route_reset_count.
Referenced by main().
|
static |
Definition at line 203 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, process_incoming_push_msg(), pull_permission_mask(), and PUSH_MSG_UPDATE.
Referenced by main().
|
static |
Definition at line 219 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, process_incoming_push_msg(), pull_permission_mask(), and PUSH_MSG_ERROR.
Referenced by main().
|
static |
Definition at line 154 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, process_incoming_push_msg(), pull_permission_mask(), and PUSH_MSG_UPDATE.
Referenced by main().
|
static |
Definition at line 171 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, process_incoming_push_msg(), pull_permission_mask(), and PUSH_MSG_ERROR.
Referenced by main().
|
static |
Definition at line 187 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, process_incoming_push_msg(), pull_permission_mask(), and PUSH_MSG_ERROR.
Referenced by main().
|
static |
Definition at line 251 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, process_incoming_push_msg(), pull_permission_mask(), and PUSH_MSG_UPDATE.
Referenced by main().
|
static |
Definition at line 268 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, process_incoming_push_msg(), pull_permission_mask(), and PUSH_MSG_UPDATE.
Referenced by main().
|
static |
Definition at line 235 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, process_incoming_push_msg(), pull_permission_mask(), and PUSH_MSG_ERROR.
Referenced by main().
|
static |
Definition at line 464 of file test_push_update_msg.c.
References expect_control_channel_strings, msg0, PUSH_BUNDLE_SIZE_TEST, r0, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 473 of file test_push_update_msg.c.
References expect_control_channel_strings, msg1, PUSH_BUNDLE_SIZE_TEST, r1, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 553 of file test_push_update_msg.c.
References msg10, PUSH_BUNDLE_SIZE_TEST, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 561 of file test_push_update_msg.c.
References expect_control_channel_strings, msg11, PUSH_BUNDLE_SIZE_TEST, r11, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 570 of file test_push_update_msg.c.
References expect_control_channel_strings, msg12, PUSH_BUNDLE_SIZE_TEST, r12, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 579 of file test_push_update_msg.c.
References expect_control_channel_strings, msg13, PUSH_BUNDLE_SIZE_TEST, r13, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 588 of file test_push_update_msg.c.
References expect_control_channel_strings, msg14, PUSH_BUNDLE_SIZE_TEST, r14, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 482 of file test_push_update_msg.c.
References msg2, PUSH_BUNDLE_SIZE_TEST, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 490 of file test_push_update_msg.c.
References expect_control_channel_strings, msg3, PUSH_BUNDLE_SIZE_TEST, r3, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 499 of file test_push_update_msg.c.
References expect_control_channel_strings, msg4, PUSH_BUNDLE_SIZE_TEST, r4, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 508 of file test_push_update_msg.c.
References expect_control_channel_strings, msg5, PUSH_BUNDLE_SIZE_TEST, r5, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 517 of file test_push_update_msg.c.
References expect_control_channel_strings, msg6, PUSH_BUNDLE_SIZE_TEST, r6, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 526 of file test_push_update_msg.c.
References expect_control_channel_strings, msg7, PUSH_BUNDLE_SIZE_TEST, r7, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 535 of file test_push_update_msg.c.
References expect_control_channel_strings, msg8, PUSH_BUNDLE_SIZE_TEST, r8, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 544 of file test_push_update_msg.c.
References expect_control_channel_strings, msg9, PUSH_BUNDLE_SIZE_TEST, r9, send_push_update(), and UPT_BY_CID.
Referenced by main().
| const char * tls_common_name | ( | const struct tls_multi * | multi, |
| const bool | null | ||
| ) |
Returns the common name field for the given tunnel.
| multi | The tunnel to return the common name for |
| null | Whether null may be returned. If not, "UNDEF" will be returned. |
Definition at line 116 of file test_push_update_msg.c.
References buffer::len.
| const char* msg0 = "redirect-gateway local,route 192.168.1.0 255.255.255.0" |
Definition at line 415 of file test_push_update_msg.c.
Referenced by test_send_push_msg0().
| const char* msg1 |
Definition at line 416 of file test_push_update_msg.c.
Referenced by test_send_push_msg1(), and ValidateOptions().
| const char* msg10 |
Definition at line 431 of file test_push_update_msg.c.
Referenced by test_send_push_msg10().
| const char* msg11 |
Definition at line 440 of file test_push_update_msg.c.
Referenced by test_send_push_msg11().
| const char* msg12 = "a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,,,,,,a,abc" |
Definition at line 446 of file test_push_update_msg.c.
Referenced by test_send_push_msg12().
| const char* msg13 = "a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,,,,,,a," |
Definition at line 448 of file test_push_update_msg.c.
Referenced by test_send_push_msg13().
| const char* msg14 = "a,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,a" |
Definition at line 450 of file test_push_update_msg.c.
Referenced by test_send_push_msg14().
| const char* msg2 = "" |
Definition at line 418 of file test_push_update_msg.c.
Referenced by test_send_push_msg2(), and ValidateOptions().
| const char* msg3 = ",," |
Definition at line 419 of file test_push_update_msg.c.
Referenced by test_send_push_msg3().
| const char* msg4 |
Definition at line 420 of file test_push_update_msg.c.
Referenced by test_send_push_msg4().
| const char* msg5 |
Definition at line 422 of file test_push_update_msg.c.
Referenced by test_send_push_msg5().
| const char* msg6 |
Definition at line 424 of file test_push_update_msg.c.
Referenced by test_send_push_msg6().
| const char* msg7 = ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,," |
Definition at line 426 of file test_push_update_msg.c.
Referenced by test_send_push_msg7().
| const char* msg8 |
Definition at line 427 of file test_push_update_msg.c.
Referenced by test_send_push_msg8().
| const char* msg9 = "," |
Definition at line 429 of file test_push_update_msg.c.
Referenced by test_send_push_msg9().
| char* r0[] |
Definition at line 344 of file test_push_update_msg.c.
Referenced by test_send_push_msg0().
| char* r1[] |
Definition at line 348 of file test_push_update_msg.c.
Referenced by add_block_local_item(), and test_send_push_msg1().
| char* r11[] |
Definition at line 391 of file test_push_update_msg.c.
Referenced by test_send_push_msg11().
| char* r12[] |
Definition at line 399 of file test_push_update_msg.c.
Referenced by test_send_push_msg12().
| char* r13[] |
Definition at line 404 of file test_push_update_msg.c.
Referenced by test_send_push_msg13().
| char* r14[] |
Definition at line 408 of file test_push_update_msg.c.
Referenced by test_send_push_msg14().
| char* r3[] |
Definition at line 354 of file test_push_update_msg.c.
Referenced by test_send_push_msg3().
| char* r4[] |
Definition at line 358 of file test_push_update_msg.c.
Referenced by test_send_push_msg4().
| char* r5[] |
Definition at line 364 of file test_push_update_msg.c.
Referenced by test_send_push_msg5().
| char* r6[] |
Definition at line 370 of file test_push_update_msg.c.
Referenced by add_route_connected_v6_net(), add_route_ipv6(), delete_route_connected_v6_net(), delete_route_ipv6(), delete_routes_v6(), init_route_ipv6(), init_route_ipv6_list(), route_ipv6_clear_host_bits(), setenv_route_ipv6(), setenv_routes_ipv6(), and test_send_push_msg6().
| char* r7[] |
Definition at line 376 of file test_push_update_msg.c.
Referenced by test_send_push_msg7().
| char* r8[] |
Definition at line 381 of file test_push_update_msg.c.
Referenced by test_send_push_msg8().
| char* r9[] |
Definition at line 387 of file test_push_update_msg.c.
Referenced by test_send_push_msg9().
|
static |
Definition at line 20 of file test_push_update_msg.c.
Referenced by apply_push_options(), reset_route_counters(), and test_incoming_push_continuation_route_accumulation().
|
static |
Definition at line 19 of file test_push_update_msg.c.
Referenced by apply_push_options(), reset_route_counters(), and test_incoming_push_continuation_route_accumulation().