1 #define SQUID_UNIT_TEST 1
6 #include "auth/AclMaxUserIp.h"
7 #include "ConfigParser.h"
8 #include "testACLMaxUserIP.h"
12 CPPUNIT_TEST_SUITE_REGISTRATION( testACLMaxUserIP
);
15 testACLMaxUserIP::testDefaults()
17 ACLMaxUserIP
anACL("max_user_ip");
18 /* 0 is not a valid maximum, so we start at 0 */
19 CPPUNIT_ASSERT_EQUAL(0,anACL
.getMaximum());
20 /* and we have no option to turn strict OFF, so start ON. */
21 CPPUNIT_ASSERT_EQUAL(false,anACL
.getStrict());
22 /* an unparsed acl must not be valid - there is no sane default */
23 CPPUNIT_ASSERT_EQUAL(false,anACL
.valid());
26 ACL::Prototype
ACLMaxUserIP::RegistryProtoype(&ACLMaxUserIP::RegistryEntry_
, "max_user_ip");
27 ACLMaxUserIP
ACLMaxUserIP::RegistryEntry_("max_user_ip");
30 testACLMaxUserIP::testParseLine()
32 /* a config line to pass with a lead-in token to seed the parser. */
33 char * line
= xstrdup("test max_user_ip -s 1");
35 ConfigParser::SetCfgLine(line
);
37 ConfigParser LegacyParser
;
38 ACL::ParseAclLine(LegacyParser
, &anACL
);
39 ACLMaxUserIP
*maxUserIpACL
= dynamic_cast<ACLMaxUserIP
*>(anACL
);
40 CPPUNIT_ASSERT(maxUserIpACL
);
42 /* we want a maximum of one, and strict to be true */
43 CPPUNIT_ASSERT_EQUAL(1, maxUserIpACL
->getMaximum());
44 CPPUNIT_ASSERT_EQUAL(true, maxUserIpACL
->getStrict());
45 /* the acl must be vaid */
46 CPPUNIT_ASSERT_EQUAL(true, maxUserIpACL
->valid());