]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testACLMaxUserIP.cc
Merged from trunk.
[thirdparty/squid.git] / src / tests / testACLMaxUserIP.cc
1 #define SQUID_UNIT_TEST 1
2
3 #include "squid.h"
4 #include <stdexcept>
5
6 #include "testACLMaxUserIP.h"
7 #include "auth/AclMaxUserIp.h"
8
9 CPPUNIT_TEST_SUITE_REGISTRATION( testACLMaxUserIP );
10
11
12 void
13 testACLMaxUserIP::testDefaults()
14 {
15 ACLMaxUserIP anACL("max_user_ip");
16 /* 0 is not a valid maximum, so we start at 0 */
17 CPPUNIT_ASSERT(anACL.getMaximum() == 0);
18 /* and we have no option to turn strict OFF, so start ON. */
19 CPPUNIT_ASSERT(anACL.getStrict() == false);
20 /* an unparsed acl must not be valid - there is no sane default */
21 CPPUNIT_ASSERT(!anACL.valid());
22 }
23
24
25 void
26 testACLMaxUserIP::testParseLine()
27 {
28 /* a config line to pass with a lead-in token to seed the parser. */
29 char * line = xstrdup("token -s 1");
30 /* seed the parser */
31 strtok(line, w_space);
32 ACLMaxUserIP anACL("max_user_ip");
33 anACL.parse();
34 /* we want a maximum of one, and strict to be true */
35 CPPUNIT_ASSERT(anACL.getMaximum() == 1);
36 CPPUNIT_ASSERT(anACL.getStrict() == true);
37 /* the acl must be vaid */
38 CPPUNIT_ASSERT(anACL.valid());
39 xfree(line);
40 }