]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/tests/testACLMaxUserIP.cc
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / tests / testACLMaxUserIP.cc
index 32510878b3b342a8171aa3b5af04283483550ccb..7adcbf8500790359641931a09bd375a68c037c3d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
 
 #if USE_AUTH
 
+#include "acl/Acl.h"
 #include "auth/AclMaxUserIp.h"
+#include "auth/UserRequest.h"
 #include "ConfigParser.h"
-#include "testACLMaxUserIP.h"
+#include "tests/testACLMaxUserIP.h"
+#include "unitTestMain.h"
 
 #include <stdexcept>
 
 CPPUNIT_TEST_SUITE_REGISTRATION( testACLMaxUserIP );
 
+/* globals required to resolve link issues */
+AnyP::PortCfgPointer HttpPortList;
+
 void
 testACLMaxUserIP::testDefaults()
 {
@@ -25,13 +31,17 @@ testACLMaxUserIP::testDefaults()
     /* 0 is not a valid maximum, so we start at 0 */
     CPPUNIT_ASSERT_EQUAL(0,anACL.getMaximum());
     /* and we have no option to turn strict OFF, so start ON. */
-    CPPUNIT_ASSERT_EQUAL(false,anACL.getStrict());
+    CPPUNIT_ASSERT_EQUAL(false, static_cast<bool>(anACL.beStrict));
     /* an unparsed acl must not be valid - there is no sane default */
     CPPUNIT_ASSERT_EQUAL(false,anACL.valid());
 }
 
-ACL::Prototype ACLMaxUserIP::RegistryProtoype(&ACLMaxUserIP::RegistryEntry_, "max_user_ip");
-ACLMaxUserIP ACLMaxUserIP::RegistryEntry_("max_user_ip");
+void
+testACLMaxUserIP::setUp()
+{
+    CPPUNIT_NS::TestFixture::setUp();
+    Acl::RegisterMaker("max_user_ip", [](Acl::TypeName name)->ACL* { return new ACLMaxUserIP(name); });
+}
 
 void
 testACLMaxUserIP::testParseLine()
@@ -48,7 +58,7 @@ testACLMaxUserIP::testParseLine()
     if (maxUserIpACL) {
         /* we want a maximum of one, and strict to be true */
         CPPUNIT_ASSERT_EQUAL(1, maxUserIpACL->getMaximum());
-        CPPUNIT_ASSERT_EQUAL(true, maxUserIpACL->getStrict());
+        CPPUNIT_ASSERT_EQUAL(true, static_cast<bool>(maxUserIpACL->beStrict));
         /* the acl must be vaid */
         CPPUNIT_ASSERT_EQUAL(true, maxUserIpACL->valid());
     }
@@ -57,3 +67,4 @@ testACLMaxUserIP::testParseLine()
 }
 
 #endif /* USE_AUTH */
+