Attempt to make the test suite work with Windows executables.
[tinc] / test / invite-tinc-up.test
1 #!/bin/sh
2
3 . "${0%/*}/testlib.sh"
4
5 # Initialize one node
6
7 $tinc $c1 <<EOF
8 init foo
9 set DeviceType dummy
10 set Address localhost
11 set Port 32756
12 start $r1
13 EOF
14
15 # Generate an invitation and let another node join the VPN
16
17 sleep 1
18
19 cat >$d1/invitation-created <<EOF
20 #!/bin/sh
21 echo Name = \$NODE >\$INVITATION_FILE
22 echo Ifconfig = 93.184.216.34/24 >>\$INVITATION_FILE
23 echo Route = 2606:2800:220:1::/64 2606:2800:220:1:248:1893:25c8:1946 >>\$INVITATION_FILE
24 echo Route = 1.2.3.4 1234:: >>\$INVITATION_FILE
25 $tinc $c1 export >>\$INVITATION_FILE
26 EOF
27
28 cat >$d1/invitation-created.cmd <<EOF
29 echo Name = %NODE% >%INVITATION_FILE%
30 echo Ifconfig = 93.184.216.34/24 >>%INVITATION_FILE%
31 echo Route = 2606:2800:220:1::/64 2606:2800:220:1:248:1893:25c8:1946 >>%INVITATION_FILE%
32 echo Route = 1.2.3.4 1234:: >>%INVITATION_FILE%
33 $tinc $c1 export >>%INVITATION_FILE%
34 EOF
35
36 chmod u+x $d1/invitation-created
37
38 $tinc $c1 invite bar | tail -1 | $tinc $c2 --batch join
39
40 # Test equivalence of host config files
41
42 cmp $d1/hosts/foo $d2/hosts/foo
43 test "`grep ^Ed25519PublicKey $d1/hosts/bar`" = "`grep ^Ed25519PublicKey $d2/hosts/bar`"
44
45 # Check if the tinc-up.invitation file is created and contains the right commands
46
47 test -f $d2/tinc-up.invitation
48
49 fgrep -q "93.184.216.34/24" $d2/tinc-up.invitation
50 fgrep -q "2606:2800:220:1::/64" $d2/tinc-up.invitation
51 fgrep -q "2606:2800:220:1:248:1893:25c8:1946" $d2/tinc-up.invitation
52 fgrep -q "1234::" $d2/tinc-up.invitation && exit 1
53
54 # Check that no tinc-up is created and that tinc-up.invitation is not executable
55
56 test -x $d2/tinc-up.invitation && exit 1
57 test -f $d2/tinc-up && exit 1
58
59 $tinc $c1 stop