More strict failure code checks in integration tests.
[tinc] / test / variables.test
1 #!/bin/sh
2
3 . ./testlib.sh
4
5 echo [STEP] Initialize one node
6
7 tinc foo init foo
8 test "$(tinc foo get Name)" = "foo"
9
10 echo [STEP] Test case sensitivity
11
12 tinc foo set Mode switch
13 test "$(tinc foo get Mode)" = "switch"
14 test "$(tinc foo get mode)" = "switch"
15
16 tinc foo set mode router
17 test "$(tinc foo get Mode)" = "router"
18 test "$(tinc foo get mode)" = "router"
19
20 tinc foo set Mode Switch
21 test "$(tinc foo get Mode)" = "Switch"
22
23 echo [STEP] Test deletion
24
25 expect_code "$EXIT_FAILURE" tinc foo del Mode hub
26 tinc foo del Mode switch
27 test -z "$(tinc foo get Mode)"
28
29 echo [STEP] There can only be one Mode variable
30
31 tinc foo add Mode switch
32 tinc foo add Mode hub
33 test "$(tinc foo get Mode)" = "hub"
34
35 echo [STEP] Test addition/deletion of multivalued variables
36
37 tinc foo add Subnet 1
38 tinc foo add Subnet 2
39 tinc foo add Subnet 2
40 tinc foo add Subnet 3
41 test "$(tinc foo get Subnet | rm_cr)" = "1
42 2
43 3"
44
45 tinc foo del Subnet 2
46 test "$(tinc foo get Subnet | rm_cr)" = "1
47 3"
48
49 tinc foo del Subnet
50 test -z "$(tinc foo get Subnet)"
51
52 echo [STEP] We should not be able to get/set server variables using node.variable syntax
53
54 test -z "$(tinc foo get foo.Name)"
55 expect_code "$EXIT_FAILURE" tinc foo set foo.Name bar
56
57 echo [STEP] Test getting/setting host variables for other nodes
58
59 touch "$DIR_FOO/hosts/bar"
60
61 tinc foo add bar.PMTU 1
62 tinc foo add bar.PMTU 2
63 test "$(tinc foo get bar.PMTU)" = "2"
64
65 tinc foo add bar.Subnet 1
66 tinc foo add bar.Subnet 2
67 tinc foo add bar.Subnet 2
68 tinc foo add bar.Subnet 3
69 test "$(tinc foo get bar.Subnet | rm_cr)" = "1
70 2
71 3"
72
73 tinc foo del bar.Subnet 2
74 test "$(tinc foo get bar.Subnet | rm_cr)" = "1
75 3"
76
77 tinc foo del bar.Subnet
78 test -z "$(tinc foo get bar.Subnet)"
79
80 echo [STEP] We should not be able to get/set for nodes with invalid names
81
82 touch "$DIR_FOO/hosts/qu-ux"
83 expect_code "$EXIT_FAILURE" tinc foo set qu-ux.Subnet 1
84
85 echo [STEP] We should not be able to set obsolete variables unless forced
86
87 expect_code "$EXIT_FAILURE" tinc foo set PrivateKey 12345
88 tinc foo --force set PrivateKey 12345
89 test "$(tinc foo get PrivateKey)" = "12345"
90
91 tinc foo del PrivateKey
92 test -z "$(tinc foo get PrivateKey)"