diff options
author | David Mládek <david.mladek.cz@gmail.com> | 2024-02-28 22:49:18 +0100 |
---|---|---|
committer | David Mládek <david.mladek.cz@gmail.com> | 2024-03-04 17:41:25 +0100 |
commit | 99d3d6292aab52786bef664862ea78ad45b9d898 (patch) | |
tree | 5806dccf55f644027a341fdd9210060fe4af9154 /test | |
parent | a256241c0cc048df8cfd615ed2fef43bc5129cfb (diff) |
tests: check queried domain name in reverse lookup tests
Signed-off-by: David Mládek <david.mladek.cz@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/500-reverse-lookups.bats | 33 | ||||
-rw-r--r-- | test/helpers.bash | 3 |
2 files changed, 20 insertions, 16 deletions
diff --git a/test/500-reverse-lookups.bats b/test/500-reverse-lookups.bats index b513a9c..d82641c 100644 --- a/test/500-reverse-lookups.bats +++ b/test/500-reverse-lookups.bats @@ -22,18 +22,22 @@ load helpers create_container "$a2_config" a2_pid="$CONTAINER_NS_PID" - echo "$a1_config" - echo "$a2_config" + echo "a1 config:\n${a1_config}\n" + echo "a2 config:\n${a2_config}\n" # Resolve IPs to container names dig_reverse "$a1_pid" "$a2_ip" "$gw" - assert "$output" =~ "atwo" - assert "$output" =~ "a2" - assert "$output" =~ "2a" + echo -e "Output:\n${output}\n" + a2_expected_name=$(echo $a2_ip | awk -F. '{printf "%d.%d.%d.%d.in-addr.arpa.", $4, $3, $2, $1}') + assert "$output" =~ "$a2_expected_name[ ].*[ ]atwo\." + assert "$output" =~ "$a2_expected_name[ ].*[ ]a2\." + assert "$output" =~ "$a2_expected_name[ ].*[ ]2a\." dig_reverse "$a2_pid" "$a1_ip" "$gw" - assert "$output" =~ "aone" - assert "$output" =~ "a1" - assert "$output" =~ "1a" + echo -e "Output:\n${output}\n" + a1_expected_name=$(echo $a1_ip | awk -F. '{printf "%d.%d.%d.%d.in-addr.arpa.", $4, $3, $2, $1}') + assert "$output" =~ "$a1_expected_name[ ].*[ ]aone\." + assert "$output" =~ "$a1_expected_name[ ].*[ ]a1\." + assert "$output" =~ "$a1_expected_name[ ].*[ ]1a\." } @test "check reverse lookups on ipaddress v6" { @@ -57,12 +61,13 @@ load helpers echo "$a2_config" # Resolve IPs to container names + # It is much harder to construct the arpa address in ipv6 so we just check that we are in the fd::/8 range dig_reverse "$a1_pid" "$a2_ip" "$gw" - assert "$output" =~ "atwo" - assert "$output" =~ "a2" - assert "$output" =~ "2a" + assert "$output" =~ '([0-9a-f]\.){30}d\.f\.ip6\.arpa\.[ ].*[ ]atwo\.' + assert "$output" =~ '([0-9a-f]\.){30}d\.f\.ip6\.arpa\.[ ].*[ ]a2\.' + assert "$output" =~ '([0-9a-f]\.){30}d\.f\.ip6\.arpa\.[ ].*[ ]2a\.' dig_reverse "$a2_pid" "$a1_ip" "$gw" - assert "$output" =~ "aone" - assert "$output" =~ "a1" - assert "$output" =~ "1a" + assert "$output" =~ '([0-9a-f]\.){30}d\.f\.ip6\.arpa\.[ ].*[ ]aone\.' + assert "$output" =~ '([0-9a-f]\.){30}d\.f\.ip6\.arpa\.[ ].*[ ]a1\.' + assert "$output" =~ '([0-9a-f]\.){30}d\.f\.ip6\.arpa\.[ ].*[ ]1a\.' } diff --git a/test/helpers.bash b/test/helpers.bash index fe2907b..8f61af9 100644 --- a/test/helpers.bash +++ b/test/helpers.bash @@ -597,8 +597,7 @@ function dig_reverse() { # first arg is container_netns_pid # second arg is the IP address # third arg is server addr - #run_in_container_netns "$1" "dig" "-x" "$2" "+short" "@$3" - run_in_container_netns "$1" "nslookup" "$2" "$3" + run_in_container_netns "$1" "dig" "-x" "$2" "@$3" } function setup() { |