32 "route 192.168.0.0 255.255.255.0\n"
33 "route 10.0.0.0 255.0.0.0\n"
40 "redirect-private\n");
45 "option2 \"arg with space\"\n"
46 "option2 \"arg with more space\"\n"
49 "option10 something else\n");
58 const std::string extra_option(
"unfiltered-option");
65 dst.
extend(src, &route_nopull_enabled);
68 ASSERT_EQ(1u, dst.size())
69 <<
"Too few options have been filtered by --route-nopull" << std::endl
73 ASSERT_TRUE(dst.
exists(extra_option))
74 <<
"The wrong options have been filtered by --route-nopull:" << std::endl
75 <<
"expected: " << extra_option <<
" got: " << dst[0].ref(0) << std::endl
84 const std::string extra_option(
"unfiltered-option");
91 dst.
extend(src, &route_nopull_disabled);
94 ASSERT_EQ(src.size(), dst.size())
95 <<
"Too many options have been filtered by --route-nopull" << std::endl
112 dst.
extend(src, &filter_none);
115 ASSERT_EQ(src.size(), dst.size())
116 <<
"Not all options have been accepted by --pull-filter" << std::endl
164 ASSERT_EQ(2u, dst.size())
165 <<
"Too many options have been accepted by --pull-filter" << std::endl
191 dst.
extend(src, &filter_all);
194 ASSERT_EQ(0u, dst.size())
195 <<
"Not all options have been ignored by --pull-filter" << std::endl
220 "pull-filter accept \"option3 arg1 arg2\"\n"
221 "pull-filter ignore option",
232 dst.
extend(src, &accept_opt3);
235 ASSERT_EQ(2u, dst.size())
236 <<
"Not all option3's have been accepted by --pull-filter" << std::endl
244 "pull-filter accept \"option2 \\\"arg with space\\\"\"\n"
245 "pull-filter ignore option",
256 dst.
extend(src, &accept_opt2_single_space);
259 ASSERT_EQ(1u, dst.size())
260 <<
"Too many options have been accepted by --pull-filter" << std::endl
264 ASSERT_EQ(dst[0].ref(1),
"arg with space")
265 <<
"Too many options have been accepted by --pull-filter" << std::endl
273 "pull-filter ignore \"route 1.2.3.4\"\n"
274 "pull-filter ignore route-\n"
276 "pull-filter accept route\n",
287 dst.
extend(src, &override_route_nopull);
290 ASSERT_EQ(2u, dst.size())
291 <<
"Expected two route option to be accepted" << std::endl
295 ASSERT_EQ(dst[0].ref(0),
"route")
296 << dst[0].ref(0) <<
" instead of route option has been accepted" << std::endl
298 ASSERT_EQ(dst[1].ref(0),
"route")
299 << dst[1].ref(0) <<
" instead of route option has been accepted" << std::endl
301 ASSERT_EQ(3u, dst[0].size())
302 <<
"The host route option has been accepted, expected network route" << std::endl
304 ASSERT_EQ(3u, dst[1].size())
305 <<
"The host route option has been accepted, expected network route" << std::endl
314 const std::string opt =
"dns server -1 address ::1";
std::string stopCollecting()
void parse_from_config(const std::string &str, Limits *lim)
void extend(const OptionList &other, FilterBase *filt=nullptr)
bool exists(const std::string &name) const
openvpn::LogOutputCollector * testLog
TEST(PushedOptionsFilter, RouteNopullEnabled)
const std::string pull_filter_options("option1 arg1\n" "option1 arg2\n" "option2 \"arg with space\"\n" "option2 \"arg with more space\"\n" "option3 arg1 arg2\n" "option3 arg1 arg2\n" "option10 something else\n")
const std::string nopull_options("ip-win32\n" "tap-sleep\n" "block-ipv6\n" "client-nat\n" "register-dns\n" "dhcp-renew\n" "dhcp-option\n" "dhcp-release\n" "dhcp-pre-release\n" "route 1.2.3.4\n" "route 192.168.0.0 255.255.255.0\n" "route 10.0.0.0 255.0.0.0\n" "route-ipv6\n" "route-delay\n" "route-metric\n" "route-method\n" "redirect-gateway\n" "redirect-private\n")