Rewrite the test suite for better compat and stability
[tinc] / test / invite-offline.test
1 #!/bin/sh
2
3 # shellcheck source=testlib.sh
4 . "${0%/*}/testlib.sh"
5
6 echo [STEP] Initialize one node
7
8 tinc foo <<EOF
9 init foo
10 set DeviceType dummy
11 set Mode switch
12 set Broadcast no
13 set Address localhost
14 set Port 30020
15 EOF
16
17 echo [STEP] Generate an invitation offline and let another node join the VPN
18
19 invitation=$(tinc foo invite bar)
20
21 start_tinc foo
22 tinc bar join "$invitation"
23
24 echo [STEP] Test equivalence of host config files
25
26 diff -w "$DIR_FOO/hosts/foo" "$DIR_BAR/hosts/foo"
27 test "$(grep ^Ed25519PublicKey "$DIR_FOO/hosts/bar")" = "$(grep ^Ed25519PublicKey "$DIR_BAR/hosts/bar")"
28
29 echo [STEP] Test Mode, Broadcast and ConnectTo statements
30
31 test "$(tinc bar get Mode)" = switch
32 test "$(tinc bar get Broadcast)" = no
33 test "$(tinc bar get ConnectTo)" = foo
34
35 echo [STEP] Check whether the new node can join the VPN
36
37 tinc bar <<EOF
38 set DeviceType dummy
39 set Port 0
40 EOF
41
42 create_script foo hosts/bar-up
43 create_script bar hosts/foo-up
44
45 start_tinc bar
46
47 wait_script foo hosts/bar-up
48 wait_script bar hosts/foo-up
49
50 require_nodes foo 2
51 require_nodes bar 2