]> git.ipfire.org Git - thirdparty/squid.git/blame - src/tests/testACLMaxUserIP.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / tests / testACLMaxUserIP.cc
CommitLineData
ec94e362
AJ
1#define SQUID_UNIT_TEST 1
2
582c2af2 3#include "squid.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
d295d770 16void
17testACLMaxUserIP::testDefaults()
18{
19 ACLMaxUserIP anACL("max_user_ip");
20 /* 0 is not a valid maximum, so we start at 0 */
21 CPPUNIT_ASSERT(anACL.getMaximum() == 0);
22 /* and we have no option to turn strict OFF, so start ON. */
23 CPPUNIT_ASSERT(anACL.getStrict() == false);
24 /* an unparsed acl must not be valid - there is no sane default */
25 CPPUNIT_ASSERT(!anACL.valid());
26}
27
d295d770 28void
29testACLMaxUserIP::testParseLine()
30{
31 /* a config line to pass with a lead-in token to seed the parser. */
32 char * line = xstrdup("token -s 1");
33 /* seed the parser */
34 strtok(line, w_space);
35 ACLMaxUserIP anACL("max_user_ip");
36 anACL.parse();
37 /* we want a maximum of one, and strict to be true */
38 CPPUNIT_ASSERT(anACL.getMaximum() == 1);
39 CPPUNIT_ASSERT(anACL.getStrict() == true);
40 /* the acl must be vaid */
41 CPPUNIT_ASSERT(anACL.valid());
42 xfree(line);
43}
2f1431ea
AJ
44
45#endif /* USE_AUTH */