]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/recursordist/test-rpzloader_cc.cc
Fix warnings about dup/missing prototypes
[thirdparty/pdns.git] / pdns / recursordist / test-rpzloader_cc.cc
1 #define BOOST_TEST_RPZ_LOADER
2 #define BOOST_TEST_RPZ_LOADER
3 #ifdef HAVE_CONFIG_H
4 #include "config.h"
5 #endif
6
7 #include "rpzloader.hh"
8 #include "syncres.hh"
9
10 #include <boost/test/unit_test.hpp>
11
12 // Provide stubs for some symbols
13 bool g_logRPZChanges{false};
14 ComboAddress getQueryLocalAddress(int family, uint16_t port)
15 {
16 cerr << "getQueryLocalAddress() STUBBED IN TEST!" << endl;
17 BOOST_ASSERT(false);
18 return ComboAddress();
19 }
20
21 BOOST_AUTO_TEST_SUITE(rpzloader_cc)
22
23 BOOST_AUTO_TEST_CASE(test_rpz_loader)
24 {
25
26 string tests[][2] = {
27 {"32.3.2.168.192", "192.168.2.3/32"},
28 {"27.73.2.168.192", "192.168.2.64/27"},
29 {"24.0.2.168.192", "192.168.2.0/24"},
30 {"128.57.zz.1.0.db8.2001", "2001:db8:0:1::57/128"},
31 {"48.zz.1.0.db8.2001", "2001:db8::/48"},
32 {"128.5.C0A8.FFFF.0.1.0.db8.2001", "2001:db8:0:1:0:ffff:c0a8:5/128"},
33
34 {"21.0.248.44.5", "5.44.248.0/21"},
35 {"64.0.0.0.0.0.1.0.0.", "0:0:1::/64"},
36 {"64.zz.2.0.0", "0:0:2::/64"},
37 {"80.0.0.0.1.0.0.0.0", "::1:0:0:0/80"},
38 {"80.0.0.0.1.zz", "::1:0:0:0/80"}};
39
40 for (auto& test : tests) {
41 Netmask n = makeNetmaskFromRPZ(DNSName(test[0]));
42 BOOST_CHECK_EQUAL(n.toString(), test[1]);
43 }
44 }
45
46 BOOST_AUTO_TEST_SUITE_END()