/ tests / chutney / test
test
 1  #!/usr/bin/env bash 
 2  
 3  set -xeuo pipefail
 4  
 5  # Hostname must be syncd in `tests/chutney/integration-e2e-shadow`.
 6  TEST_DOMAIN=example.com
 7  
 8  if [ -n "${RUNNING_IN_SHADOW:-}" ]; then
 9      # Resolving DNS through tor in shadow is currently broken:
10      # <https://github.com/shadow/shadow/issues/323>.
11      #
12      # We can still do the "curl" test (using --socks5 instead of
13      # --socks5-hostname to resolve locally).
14      #
15      # TODO: Fix or work around this. e.g. run a local `unbound` resolver inside
16      # the simulation.
17      curl http://"$TEST_DOMAIN" -vs --socks5 127.0.0.1:9150 -o /dev/null
18  else
19      curl http://"$TEST_DOMAIN" -vs --socks5-hostname 127.0.0.1:9150 -o /dev/null
20  
21      DIRECT_LOOKUP="$(dig +short $TEST_DOMAIN A)"
22      TOR_LOOKUP="$(dig @127.0.0.1 -p 35353 +short $TEST_DOMAIN A)"
23      [ "$DIRECT_LOOKUP" == "$TOR_LOOKUP" ]
24  fi
25  
26  ## This test only work on a chutney network with IPv6 support such as ipv6-exit-min,
27  ## sadly such a network can't run in CI because there is no IPv6 in docker (nor in shadow).
28  #[ "$(dig @127.0.0.1 -p 35353 +short example.com AAAA)" == "2606:2800:220:1:248:1893:25c8:1946" ]