Parcourir la source

[trac981] Register the creators

Michal 'vorner' Vaner il y a 14 ans
Parent
commit
ea2a4f906d
2 fichiers modifiés avec 35 ajouts et 2 suppressions
  1. 15 2
      src/lib/acl/dns.cc
  2. 20 0
      src/lib/acl/tests/dns_test.cc

+ 15 - 2
src/lib/acl/dns.cc

@@ -13,6 +13,9 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 #include "dns.h"
+#include "logic_check.h"
+
+using boost::shared_ptr;
 
 namespace isc {
 namespace acl {
@@ -22,9 +25,19 @@ Loader&
 getLoader() {
     static Loader* loader(NULL);
     if (loader == NULL) {
+        // TODO:
+        // There's some trick with auto_ptr in the branch when IP check
+        // is added here. That one is better, bring it in on merge.
         loader = new Loader(REJECT);
-        // TODO: This is the place where we register default check creators
-        // like IP check, etc, once we have them.
+        loader->registerCreator(
+            shared_ptr<NotCreator<RequestContext> >(
+                new NotCreator<RequestContext>("NOT")));
+        loader->registerCreator(
+            shared_ptr<LogicCreator<AnyOfSpec, RequestContext> >(
+                new LogicCreator<AnyOfSpec, RequestContext>("ANY")));
+        loader->registerCreator(
+            shared_ptr<LogicCreator<AllOfSpec, RequestContext> >(
+                new LogicCreator<AllOfSpec, RequestContext>("ALL")));
     }
     return (*loader);
 }

+ 20 - 0
src/lib/acl/tests/dns_test.cc

@@ -32,4 +32,24 @@ TEST(DNSACL, getLoader) {
     // check, are loaded.
 }
 
+// The following tests test only the creators are registered, they are tested
+// elsewhere
+
+// TODO: Enable the tests when we merge the IP check branch here (is it called
+// "from" in the branch?)
+TEST(DNSACL, DISABLED_notLoad) {
+    EXPECT_NO_THROW(getLoader().loadCheck(isc::data::Element::fromJSON(
+        "{\"NOT\": {\"from\": \"192.0.2.1\"}}")));
+}
+
+TEST(DNSACL, DISABLED_allLoad) {
+    EXPECT_NO_THROW(getLoader().loadCheck(isc::data::Element::fromJSON(
+        "{\"ALL\": [{\"from\": \"192.0.2.1\"}]}")));
+}
+
+TEST(DNSACL, DISABLED_anyLoad) {
+    EXPECT_NO_THROW(getLoader().loadCheck(isc::data::Element::fromJSON(
+        "{\"ANY\": [{\"from\": \"192.0.2.1\"}]}")));
+}
+
 }