]> granicus.if.org Git - pdns/commitdiff
geoipbackend: Add test for city database
authorAki Tuomi <cmouse@cmouse.fi>
Mon, 24 Apr 2017 12:23:04 +0000 (15:23 +0300)
committerAki Tuomi <cmouse@cmouse.fi>
Tue, 25 Apr 2017 16:54:27 +0000 (19:54 +0300)
.gitignore
modules/geoipbackend/regression-tests/GeoLiteCity-Blocks.csv [new file with mode: 0644]
modules/geoipbackend/regression-tests/GeoLiteCity-Location.csv [new file with mode: 0644]
modules/geoipbackend/regression-tests/GeoLiteCity.dat.b64 [new file with mode: 0644]
modules/geoipbackend/regression-tests/city-resolution/command [new file with mode: 0755]
modules/geoipbackend/regression-tests/city-resolution/description [new file with mode: 0644]
modules/geoipbackend/regression-tests/city-resolution/expected_result [new file with mode: 0644]
regression-tests/backends/geoip-master

index 0d91436f7ec6e148898d3c5d559272827ab9a383..b96b924d40dc62c2c3c903d13d950c4e57ac5d97 100644 (file)
@@ -49,3 +49,4 @@ pdns_recursor.pid
 *.gcda
 *.gcno
 *.gcov
+modules/geoipbackend/regression-tests/GeoLiteCity.dat
diff --git a/modules/geoipbackend/regression-tests/GeoLiteCity-Blocks.csv b/modules/geoipbackend/regression-tests/GeoLiteCity-Blocks.csv
new file mode 100644 (file)
index 0000000..3e0866a
--- /dev/null
@@ -0,0 +1,4 @@
+startIpNum,endIpNum,locId
+"2130706433","2130706433","1"
+"2130706434","2130706434","2"
+"2130706435","2130706435","3"
diff --git a/modules/geoipbackend/regression-tests/GeoLiteCity-Location.csv b/modules/geoipbackend/regression-tests/GeoLiteCity-Location.csv
new file mode 100644 (file)
index 0000000..a0786c2
--- /dev/null
@@ -0,0 +1,4 @@
+locId,country,region,city,postalCode,latitude,longitude,metroCode,areaCode
+1,"O1","L1","C1","00001",0,0,1,1
+2,"O1","L2","C2","00002",0,0,2,2
+3,"O1","L3","C3","00003",0,0,3,3
diff --git a/modules/geoipbackend/regression-tests/GeoLiteCity.dat.b64 b/modules/geoipbackend/regression-tests/GeoLiteCity.dat.b64
new file mode 100644 (file)
index 0000000..da06c58
--- /dev/null
@@ -0,0 +1,5 @@
+AQAAIQAAIQAAAgAAIQAAAwAAIQAABAAAIQAABQAAIQAABgAAIQAABwAAIQAACAAACQAAIQAACgAA
+IQAACwAAIQAADAAAIQAADQAAIQAADgAAIQAADwAAIQAAEAAAIQAAEQAAIQAAEgAAIQAAEwAAIQAA
+FAAAIQAAFQAAIQAAFgAAIQAAFwAAIQAAGAAAIQAAGQAAIQAAGgAAIQAAGwAAIQAAHAAAIQAAHQAA
+IQAAHgAAIQAAHwAAIAAAIQAAIgAAOAAATgAAKvZMMQBDMQAwMDAwMQBAdxtAdxsAAAD2TDIAQzIA
+MDAwMDIAQHcbQHcbAAAA9kwzAEMzADAwMDAzAEB3G0B3GwAAAGNzdjJkYXQucHn///8CIQAA
diff --git a/modules/geoipbackend/regression-tests/city-resolution/command b/modules/geoipbackend/regression-tests/city-resolution/command
new file mode 100755 (executable)
index 0000000..d1b4f78
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+cleandig city.geo.example.com A ednssubnet 127.0.0.1
+cleandig city.geo.example.com A ednssubnet 127.0.0.2
+cleandig city.geo.example.com A ednssubnet 127.0.0.3
+
diff --git a/modules/geoipbackend/regression-tests/city-resolution/description b/modules/geoipbackend/regression-tests/city-resolution/description
new file mode 100644 (file)
index 0000000..e08b4cc
--- /dev/null
@@ -0,0 +1 @@
+This test tests that city database support works
diff --git a/modules/geoipbackend/regression-tests/city-resolution/expected_result b/modules/geoipbackend/regression-tests/city-resolution/expected_result
new file mode 100644 (file)
index 0000000..a6990b5
--- /dev/null
@@ -0,0 +1,12 @@
+0      city.geo.example.com.   IN      A       30      127.0.1.1
+2      .       IN      OPT     0       AAgACAABICB/AAAB
+Rcode: 0 (No Error), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
+Reply to question for qname='city.geo.example.com.', qtype=A
+0      city.geo.example.com.   IN      A       30      127.0.2.1
+2      .       IN      OPT     0       AAgACAABICB/AAAC
+Rcode: 0 (No Error), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
+Reply to question for qname='city.geo.example.com.', qtype=A
+0      city.geo.example.com.   IN      A       30      127.0.3.1
+2      .       IN      OPT     0       AAgACAABICB/AAAD
+Rcode: 0 (No Error), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
+Reply to question for qname='city.geo.example.com.', qtype=A
index 8a3039b35333c49d51df9e056eee10c74cc497d9..0397e138cf51767644353ba2e9034323775d7a40 100644 (file)
@@ -32,6 +32,12 @@ domains:
       - ns: ns1.example.com
       - ns: ns2.example.com
       - mx: 10 mx.example.com
+    c1.l1.o1.city.geo.example.com:
+      - a: 127.0.1.1
+    c2.l2.o1.city.geo.example.com:
+      - a: 127.0.2.1
+    c3.l3.o1.city.geo.example.com:
+      - a: 127.0.3.1
     continent.geo.example.com:
       - txt: Your continent is %cn
     $geoipregion.service.geo.example.com:
@@ -41,6 +47,7 @@ domains:
   services:
     www.geo.example.com: '%cn.service.geo.example.com'
     indirect.geo.example.com: '%cn.elsewhere.example.com'
+    city.geo.example.com: '%ci.%re.%cc.city.geo.example.com'
 EOF
                cat > $testsdir/region-a-resolution/expected_result <<EOF
 0      www.geo.example.com.    IN      A       30      62.236.200.4
@@ -75,11 +82,13 @@ EOF
                        geoipkeydir="--geoip-dnssec-keydir=$testsdir/geosec"
                fi
 
+               base64 -d < $testsdir/GeoLiteCity.dat.b64 > $testsdir/GeoLiteCity.dat
+
                $RUNWRAPPER $PDNS --daemon=no --local-port=$port --socket-dir=./ \
                        --no-shuffle --launch=geoip \
                        --cache-ttl=$cachettl --dname-processing --no-config \
                        --distributor-threads=1 \
-                        --geoip-zones-file=$testsdir/geo.yaml --geoip-database-files=/usr/share/GeoIP/GeoIP.dat \
+                        --geoip-zones-file=$testsdir/geo.yaml --geoip-database-files="/usr/share/GeoIP/GeoIP.dat $testsdir/GeoLiteCity.dat" \
                         --module-dir=./modules --edns-subnet-processing=yes \
                        $geoipkeydir &
                ;;