Add CIDR support to TrustedProxy setting

Fix #1219
This commit is contained in:
Alexey Sokolov
2016-12-25 13:00:02 +00:00
parent bd1a71cb29
commit 6fbab7b44c
7 changed files with 116 additions and 107 deletions
+2 -1
View File
@@ -60,7 +60,8 @@ add_executable(unittest_bin EXCLUDE_FROM_ALL
"${GMOCK_ROOT}/src/gmock-all.cc"
"ThreadTest.cpp" "NickTest.cpp" "ClientTest.cpp" "NetworkTest.cpp"
"MessageTest.cpp" "ModulesTest.cpp" "IRCSockTest.cpp" "QueryTest.cpp"
"StringTest.cpp" "ConfigTest.cpp" "BufferTest.cpp" "UtilsTest.cpp")
"StringTest.cpp" "ConfigTest.cpp" "BufferTest.cpp" "UtilsTest.cpp"
"UserTest.cpp")
target_link_libraries(unittest_bin PRIVATE znclib)
target_include_directories(unittest_bin PRIVATE
"${GTEST_ROOT}" "${GTEST_ROOT}/include"
+5 -3
View File
@@ -27,7 +27,7 @@ class UserTest : public ::testing::Test {
TEST_F(UserTest, IsHostAllowed) {
struct hostTest {
CString sTestHost;
CString sMask;
CString sIP;
bool bExpectedResult;
};
@@ -108,12 +108,14 @@ TEST_F(UserTest, IsHostAllowed) {
{"::2/00000000000", "::1", false},
{"::2/0a", "::1", false},
{"192.168.*", "192.168.0.1", true},
};
for (const hostTest& h : aHostTests) {
CUser user("user");
user.AddAllowedHost(h.sTestHost);
user.AddAllowedHost(h.sMask);
EXPECT_EQ(h.bExpectedResult, user.IsHostAllowed(h.sIP))
<< "Allow-host is " << h.sTestHost;
<< "Allow-host is " << h.sMask;
}
}