2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
13 #include "auth/AclMaxUserIp.h"
14 #include "ConfigParser.h"
15 #include "testACLMaxUserIP.h"
16 #include "unitTestMain.h"
20 CPPUNIT_TEST_SUITE_REGISTRATION( testACLMaxUserIP
);
23 testACLMaxUserIP::testDefaults()
25 ACLMaxUserIP
anACL("max_user_ip");
26 /* 0 is not a valid maximum, so we start at 0 */
27 CPPUNIT_ASSERT_EQUAL(0,anACL
.getMaximum());
28 /* and we have no option to turn strict OFF, so start ON. */
29 CPPUNIT_ASSERT_EQUAL(false,anACL
.getStrict());
30 /* an unparsed acl must not be valid - there is no sane default */
31 CPPUNIT_ASSERT_EQUAL(false,anACL
.valid());
34 ACL::Prototype
ACLMaxUserIP::RegistryProtoype(&ACLMaxUserIP::RegistryEntry_
, "max_user_ip");
35 ACLMaxUserIP
ACLMaxUserIP::RegistryEntry_("max_user_ip");
38 testACLMaxUserIP::testParseLine()
40 /* a config line to pass with a lead-in token to seed the parser. */
41 char * line
= xstrdup("test max_user_ip -s 1");
43 ConfigParser::SetCfgLine(line
);
45 ConfigParser LegacyParser
;
46 ACL::ParseAclLine(LegacyParser
, &anACL
);
47 ACLMaxUserIP
*maxUserIpACL
= dynamic_cast<ACLMaxUserIP
*>(anACL
);
48 CPPUNIT_ASSERT(maxUserIpACL
);
50 /* we want a maximum of one, and strict to be true */
51 CPPUNIT_ASSERT_EQUAL(1, maxUserIpACL
->getMaximum());
52 CPPUNIT_ASSERT_EQUAL(true, maxUserIpACL
->getStrict());
53 /* the acl must be vaid */
54 CPPUNIT_ASSERT_EQUAL(true, maxUserIpACL
->valid());