3 # shellcheck disable=SC1090
6 echo [STEP] Initialize one node
9 test "$(tinc foo get Name)" = "foo"
11 echo [STEP] Test case sensitivity
13 tinc foo set Mode switch
14 test "$(tinc foo get Mode)" = "switch"
15 test "$(tinc foo get mode)" = "switch"
17 tinc foo set mode router
18 test "$(tinc foo get Mode)" = "router"
19 test "$(tinc foo get mode)" = "router"
21 tinc foo set Mode Switch
22 test "$(tinc foo get Mode)" = "Switch"
24 echo [STEP] Test deletion
26 expect_code "$EXIT_FAILURE" tinc foo del Mode hub
27 tinc foo del Mode switch
28 test -z "$(tinc foo get Mode)"
30 echo [STEP] There can only be one Mode variable
32 tinc foo add Mode switch
34 test "$(tinc foo get Mode)" = "hub"
36 echo [STEP] Test addition/deletion of multivalued variables
38 tinc foo add Subnet 1.1.1.1
39 tinc foo add Subnet 2.2.2.2
40 tinc foo add Subnet 2.2.2.2
41 tinc foo add Subnet 3.3.3.3
42 test "$(tinc foo get Subnet | rm_cr)" = "1.1.1.1
46 tinc foo del Subnet 2.2.2.2
47 test "$(tinc foo get Subnet | rm_cr)" = "1.1.1.1
51 test -z "$(tinc foo get Subnet)"
53 echo [STEP] We should not be able to get/set server variables using node.variable syntax
55 test -z "$(tinc foo get foo.Name)"
56 expect_code "$EXIT_FAILURE" tinc foo set foo.Name bar
58 echo [STEP] Test getting/setting host variables for other nodes
60 touch "$DIR_FOO/hosts/bar"
62 tinc foo add bar.PMTU 1
63 tinc foo add bar.PMTU 2
64 test "$(tinc foo get bar.PMTU)" = "2"
66 tinc foo add bar.Subnet 1.1.1.1
67 tinc foo add bar.Subnet 2.2.2.2
68 tinc foo add bar.Subnet 2.2.2.2
69 tinc foo add bar.Subnet 3.3.3.3
70 test "$(tinc foo get bar.Subnet | rm_cr)" = "1.1.1.1
74 tinc foo del bar.Subnet 2.2.2.2
75 test "$(tinc foo get bar.Subnet | rm_cr)" = "1.1.1.1
78 tinc foo del bar.Subnet
79 test -z "$(tinc foo get bar.Subnet)"
81 echo [STEP] We should not be able to get/set for nodes with invalid names
83 touch "$DIR_FOO/hosts/qu-ux"
84 expect_code "$EXIT_FAILURE" tinc foo set qu-ux.Subnet 1.1.1.1
86 echo [STEP] We should not be able to set obsolete variables unless forced
88 expect_code "$EXIT_FAILURE" tinc foo set PrivateKey 12345
89 tinc foo --force set PrivateKey 12345
90 test "$(tinc foo get PrivateKey)" = "12345"
92 tinc foo del PrivateKey
93 test -z "$(tinc foo get PrivateKey)"
95 echo [STEP] We should not be able to set/add malformed Subnets
97 expect_code "$EXIT_FAILURE" tinc foo add Subnet 1.1.1
98 expect_code "$EXIT_FAILURE" tinc foo add Subnet 1:2:3:4:5:
99 expect_code "$EXIT_FAILURE" tinc foo add Subnet 1:2:3:4:5:::6
100 expect_code "$EXIT_FAILURE" tinc foo add Subnet 1:2:3:4:5:6:7:8:9
101 expect_code "$EXIT_FAILURE" tinc foo add Subnet 256.256.256.256
102 expect_code "$EXIT_FAILURE" tinc foo add Subnet 1:2:3:4:5:6:7:8.123
103 expect_code "$EXIT_FAILURE" tinc foo add Subnet 1:2:3:4:5:6:7:1.2.3.4
104 expect_code "$EXIT_FAILURE" tinc foo add Subnet a:b:c:d:e:f:g:h
105 expect_code "$EXIT_FAILURE" tinc foo add Subnet 1.1.1.1/0
106 expect_code "$EXIT_FAILURE" tinc foo add Subnet 1.1.1.1/-1
107 expect_code "$EXIT_FAILURE" tinc foo add Subnet 1.1.1.1/33
108 expect_code "$EXIT_FAILURE" tinc foo add Subnet 1::/0
109 expect_code "$EXIT_FAILURE" tinc foo add Subnet 1::/-1
110 expect_code "$EXIT_FAILURE" tinc foo add Subnet 1::/129
111 expect_code "$EXIT_FAILURE" tinc foo add Subnet ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
112 test -z "$(tinc foo get Subnet)"