]> git.ipfire.org Git - thirdparty/squid.git/blame - src/tests/testACLMaxUserIP.cc
Bug 3610: peername_regex ACL
[thirdparty/squid.git] / src / tests / testACLMaxUserIP.cc
CommitLineData
ec94e362
AJ
1#define SQUID_UNIT_TEST 1
2
f7f3304a 3#include "squid-old.h"
2f1431ea
AJ
4
5#if USE_AUTH
6
d295d770 7#include "testACLMaxUserIP.h"
3ad63615 8#include "auth/AclMaxUserIp.h"
d295d770 9
27e059d4
AJ
10#if HAVE_STDEXCEPT
11#include <stdexcept>
12#endif
13
d295d770 14CPPUNIT_TEST_SUITE_REGISTRATION( testACLMaxUserIP );
15
16
17void
18testACLMaxUserIP::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
30void
31testACLMaxUserIP::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}
2f1431ea
AJ
46
47#endif /* USE_AUTH */