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