Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geoipbackend: Add test for city database #5270

Merged
merged 1 commit into from May 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -49,3 +49,4 @@ pdns_recursor.pid
*.gcda
*.gcno
*.gcov
modules/geoipbackend/regression-tests/GeoLiteCity.dat
4 changes: 4 additions & 0 deletions modules/geoipbackend/regression-tests/GeoLiteCity-Blocks.csv
@@ -0,0 +1,4 @@
startIpNum,endIpNum,locId
"2130706433","2130706433","1"
"2130706434","2130706434","2"
"2130706435","2130706435","3"
@@ -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
5 changes: 5 additions & 0 deletions modules/geoipbackend/regression-tests/GeoLiteCity.dat.b64
@@ -0,0 +1,5 @@
AQAAIQAAIQAAAgAAIQAAAwAAIQAABAAAIQAABQAAIQAABgAAIQAABwAAIQAACAAACQAAIQAACgAA
IQAACwAAIQAADAAAIQAADQAAIQAADgAAIQAADwAAIQAAEAAAIQAAEQAAIQAAEgAAIQAAEwAAIQAA
FAAAIQAAFQAAIQAAFgAAIQAAFwAAIQAAGAAAIQAAGQAAIQAAGgAAIQAAGwAAIQAAHAAAIQAAHQAA
IQAAHgAAIQAAHwAAIAAAIQAAIgAAOAAATgAAKvZMMQBDMQAwMDAwMQBAdxtAdxsAAAD2TDIAQzIA
MDAwMDIAQHcbQHcbAAAA9kwzAEMzADAwMDAzAEB3G0B3GwAAAGNzdjJkYXQucHn///8CIQAA
5 changes: 5 additions & 0 deletions modules/geoipbackend/regression-tests/city-resolution/command
@@ -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

@@ -0,0 +1 @@
This test tests that city database support works
@@ -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
11 changes: 10 additions & 1 deletion regression-tests/backends/geoip-master
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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 &
;;
Expand Down