Rewrite the test suite for better compat and stability
[tinc] / test / invite-join.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 30010
15 EOF
16
17 start_tinc foo
18
19 echo [STEP] Generate an invitation and let another node join the VPN
20
21 tinc foo invite bar | tinc bar join
22
23 echo [STEP] Test equivalence of host config files
24
25 diff -w "$DIR_FOO/hosts/foo" "$DIR_BAR/hosts/foo"
26 test "$(grep ^Ed25519PublicKey "$DIR_FOO/hosts/bar")" = "$(grep ^Ed25519PublicKey "$DIR_BAR/hosts/bar")"
27
28 echo [STEP] Test Mode, Broadcast and ConnectTo statements
29
30 test "$(tinc bar get Mode)" = switch
31 test "$(tinc bar get Broadcast)" = no
32 test "$(tinc bar get ConnectTo)" = foo
33
34 echo [STEP] Check whether the new node can join the VPN
35
36 tinc bar <<EOF
37 set DeviceType dummy
38 set Port 0
39 EOF
40
41 create_script foo hosts/bar-up
42 create_script bar hosts/foo-up
43
44 start_tinc bar
45
46 wait_script foo hosts/bar-up
47 wait_script bar hosts/foo-up
48
49 require_nodes foo 2
50 require_nodes bar 2