mirror of
https://github.com/znc/znc.git
synced 2026-08-02 15:03:16 +02:00
+2
-1
@@ -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
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user