Support running tests on NetBSD 8.2.
[tinc] / test / invite-tinc-up.test
1 #!/bin/sh
2
3 . ./testlib.sh
4
5 echo [STEP] Initialize one node
6
7 tinc foo <<EOF
8 init foo
9 set DeviceType dummy
10 set Address localhost
11 set Port 30030
12 EOF
13
14 create_script foo tinc-up
15 start_tinc foo
16 wait_script foo tinc-up
17
18 echo [STEP] Generate an invitation and let another node join the VPN
19
20 # shellcheck disable=SC2016
21 create_script foo invitation-created '
22 cat >"$INVITATION_FILE" <<INVITE
23 Name = $NODE
24 Ifconfig = 93.184.216.34/24
25 Route = 2606:2800:220:1::/64 2606:2800:220:1:248:1893:25c8:1946
26 Route = 1.2.3.4 1234::
27
28 $(tinc foo export)
29 INVITE
30 '
31
32 tinc foo invite bar | tail -1 | tinc bar --batch join
33
34 echo [STEP] Test equivalence of host config files
35
36 diff -w "$DIR_FOO/hosts/foo" "$DIR_BAR/hosts/foo"
37 test "$(grep ^Ed25519PublicKey "$DIR_FOO/hosts/bar")" = "$(grep ^Ed25519PublicKey "$DIR_BAR/hosts/bar")"
38
39 echo [STEP] Check if the tinc-up.invitation file is created and contains the right commands
40
41 bar_tinc_up="$DIR_BAR/tinc-up.invitation"
42 test -f "$bar_tinc_up"
43
44 grep -F -q "93.184.216.34/24" "$bar_tinc_up"
45 grep -F -q "2606:2800:220:1::/64" "$bar_tinc_up"
46 grep -F -q "2606:2800:220:1:248:1893:25c8:1946" "$bar_tinc_up"
47 must_fail grep -F -q "1234::" "$bar_tinc_up"
48
49 echo [STEP] Check that no tinc-up is created and that tinc-up.invitation is not executable
50
51 must_fail test -x "$bar_tinc_up"
52 must_fail test -f "$DIR_BAR/tinc-up"