]> granicus.if.org Git - pdns/commitdiff
Add RPZ lua tests
authorPieter Lexis <pieter.lexis@powerdns.com>
Tue, 26 Jul 2016 13:54:38 +0000 (15:54 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 25 Aug 2016 08:44:33 +0000 (10:44 +0200)
regression-tests.recursor/RPZ-Lua/command [new file with mode: 0755]
regression-tests.recursor/RPZ-Lua/description [new file with mode: 0644]
regression-tests.recursor/RPZ-Lua/expected_result [new file with mode: 0644]
regression-tests.recursor/config.sh

diff --git a/regression-tests.recursor/RPZ-Lua/command b/regression-tests.recursor/RPZ-Lua/command
new file mode 100755 (executable)
index 0000000..006830e
--- /dev/null
@@ -0,0 +1 @@
+$SDIG $nameserver 5301 www3.example.net a recurse 2>&1
diff --git a/regression-tests.recursor/RPZ-Lua/description b/regression-tests.recursor/RPZ-Lua/description
new file mode 100644 (file)
index 0000000..b223c89
--- /dev/null
@@ -0,0 +1 @@
+Test if we can indeed change the action for a policy in Lua
diff --git a/regression-tests.recursor/RPZ-Lua/expected_result b/regression-tests.recursor/RPZ-Lua/expected_result
new file mode 100644 (file)
index 0000000..b3c2cf6
--- /dev/null
@@ -0,0 +1,3 @@
+Reply to question for qname='www3.example.net.', qtype=A
+Rcode: 0 (No Error), RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
+0      www3.example.net.       IN      CNAME   0       www2.example.net.
index 1fd7bf342345c11b54676c9d9f14ef0559c10234..60fb2b1bcf20f63d83775d86945ee9b365741a6e 100755 (executable)
@@ -544,6 +544,7 @@ cat > recursor-service3/recursor.conf << EOF
 local-port=5301
 socket-dir=$(pwd)/recursor-service3S
 lua-config-file=$(pwd)/recursor-service3/config.lua
+lua-dns-script=$(pwd)/recursor-service3/script.lua
 
 EOF
 
@@ -561,6 +562,18 @@ arthur.example.net     CNAME .                   ; NXDOMAIN on apex
 *.arthur.example.net   CNAME *.                  ; NODATA for everything below the apex
 srv.arthur.example.net CNAME rpz-passthru.       ; Allow this name though
 www.example.net        CNAME www2.example.net.   ; Local-Data Action
+www3.example.net       CNAME www4.example.net.   ; Local-Data Action (to be changed in preresolve)
 
 32.4.2.0.192.rpz-ip    CNAME rpz-drop.           ; www4.example.net resolves to 192.0.2.4, drop A responses with that IP
 EOF
+
+cat > recursor-service3/script.lua <<EOF
+function preresolve(dq)
+  if dq.appliedPolicy.policyKind == pdns.policykinds.Custom then
+    if dq.qname:equal("www3.example.net") then
+      dq.appliedPolicy.policyCustom = "www2.example.net"
+    end
+  end
+  return false
+end
+EOF