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