summaryrefslogtreecommitdiff
path: root/src/test/test_policy.c
diff options
context:
space:
mode:
authorteor (Tim Wilson-Brown) <teor2345@gmail.com>2016-01-22 15:10:18 +1100
committerteor (Tim Wilson-Brown) <teor2345@gmail.com>2016-01-29 07:16:32 +1100
commit77a9de0d48e61e6762e65f6099c9a424544eb0ad (patch)
treebd79d43ad9ccb3942cd4c2d1c1699c94e86b7ef2 /src/test/test_policy.c
parent3a00215c35b01909a2db24132ab800298d61b647 (diff)
downloadtor-77a9de0d48e61e6762e65f6099c9a424544eb0ad.tar.gz
tor-77a9de0d48e61e6762e65f6099c9a424544eb0ad.zip
Automatically use IPv6 when ClientUseIPv4 is 0
Consequential changes to log messages: * it's no longer possible to disable both IPv4 and IPv6, * refactor common string out of remaining log messages
Diffstat (limited to 'src/test/test_policy.c')
-rw-r--r--src/test/test_policy.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/test/test_policy.c b/src/test/test_policy.c
index 1daa38ecf2..2e87f13fc0 100644
--- a/src/test/test_policy.c
+++ b/src/test/test_policy.c
@@ -1310,7 +1310,8 @@ test_policies_fascist_firewall_allows_address(void *arg)
tt_assert(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 0, 0)
== 0);
- /* Test the function's address matching with everything off */
+ /* Test the function's address matching with ClientUseIPv4 0.
+ * This means "use IPv6" regardless of the other settings. */
memset(&mock_options, 0, sizeof(or_options_t));
mock_options.ClientUseIPv4 = 0;
mock_options.ClientUseIPv6 = 0;
@@ -1319,7 +1320,7 @@ test_policies_fascist_firewall_allows_address(void *arg)
tt_assert(fascist_firewall_allows_address(&ipv4_addr, port, policy, 0, 0)
== 0);
tt_assert(fascist_firewall_allows_address(&ipv6_addr, port, policy, 0, 0)
- == 0);
+ == 1);
tt_assert(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 0, 0)
== 0);
tt_assert(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 0, 0)
@@ -1596,7 +1597,8 @@ test_policies_fascist_firewall_choose_address(void *arg)
FIREWALL_DIR_CONNECTION, 1)
== &ipv6_dir_ap);
- /* Choose an address with everything off */
+ /* Choose an address with ClientUseIPv4 0.
+ * This means "use IPv6" regardless of the other settings. */
memset(&mock_options, 0, sizeof(or_options_t));
mock_options.ClientUseIPv4 = 0;
mock_options.ClientUseIPv6 = 0;
@@ -1604,16 +1606,16 @@ test_policies_fascist_firewall_choose_address(void *arg)
tt_assert(fascist_firewall_choose_address(&ipv4_or_ap, &ipv6_or_ap, 0,
FIREWALL_OR_CONNECTION, 0)
- == NULL);
+ == &ipv6_or_ap);
tt_assert(fascist_firewall_choose_address(&ipv4_or_ap, &ipv6_or_ap, 0,
FIREWALL_OR_CONNECTION, 1)
- == NULL);
+ == &ipv6_or_ap);
tt_assert(fascist_firewall_choose_address(&ipv4_dir_ap, &ipv6_dir_ap, 0,
FIREWALL_DIR_CONNECTION, 0)
- == NULL);
+ == &ipv6_dir_ap);
tt_assert(fascist_firewall_choose_address(&ipv4_dir_ap, &ipv6_dir_ap, 0,
FIREWALL_DIR_CONNECTION, 1)
- == NULL);
+ == &ipv6_dir_ap);
/* Choose from unusual inputs */
memset(&mock_options, 0, sizeof(or_options_t));