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

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;
}
}