Skip to content

Commit 9b7d8b2

Browse files
committed
Add script to test updating DNS records
1 parent 0763a41 commit 9b7d8b2

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

docker-compose-test.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,16 @@ services:
2121
- ./src/test/resources/bind/named.conf:/etc/bind/named.conf:ro
2222
- ./src/test/resources/bind/example.com.db:/tmp/example.com.db
2323

24+
sut:
25+
build: ./src/test/resources/sut
26+
command: /run-tests.sh
27+
depends_on:
28+
- app
29+
- bind
30+
networks:
31+
- containers
32+
volumes:
33+
- ./run-tests.sh:/run-tests.sh:ro
34+
2435
networks:
2536
containers:

run-tests.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#! /bin/bash
2+
3+
set -e
4+
5+
function test_record()
6+
{
7+
address=$(dig @bind +short $1 myhost.example.com)
8+
9+
if [[ ${address} != $2 ]]; then
10+
echo "Expected $2 but got ${address}"
11+
exit 1
12+
fi
13+
}
14+
15+
curl -s "http://app/?hostname=myhost.example.com&myip=1.2.3.4" -u myuser:mypassword
16+
test_record A "1.2.3.4"
17+
test_record AAAA ""
18+
19+
curl -s "http://app/?hostname=myhost.example.com&myipv6=f410:a02c:a197:2bdf:b9b:e5ac:5c85:f5bd" -u myuser:mypassword
20+
test_record A "1.2.3.4"
21+
test_record AAAA "f410:a02c:a197:2bdf:b9b:e5ac:5c85:f5bd"
22+
23+
curl -s "http://app/?hostname=myhost.example.com&myip=10.20.30.40&myipv6=cbf0:84cb:61a5:139f:ba91:358c:15c5:aca4" -u myuser:mypassword
24+
test_record A "10.20.30.40"
25+
test_record AAAA "cbf0:84cb:61a5:139f:ba91:358c:15c5:aca4"

src/test/resources/sut/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM debian
2+
3+
RUN apt-get update && \
4+
apt-get install -y curl dnsutils

0 commit comments

Comments
 (0)