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