#!/bin/sh # shellcheck source=testlib.sh . ./testlib.sh echo [STEP] Initialize one node tinc foo init foo test "$(tinc foo get Name)" = "foo" echo [STEP] Test case sensitivity tinc foo set Mode switch test "$(tinc foo get Mode)" = "switch" test "$(tinc foo get mode)" = "switch" tinc foo set mode router test "$(tinc foo get Mode)" = "router" test "$(tinc foo get mode)" = "router" tinc foo set Mode Switch test "$(tinc foo get Mode)" = "Switch" echo [STEP] Test deletion must_fail tinc foo del Mode hub tinc foo del Mode switch test -z "$(tinc foo get Mode)" echo [STEP] There can only be one Mode variable tinc foo add Mode switch tinc foo add Mode hub test "$(tinc foo get Mode)" = "hub" echo [STEP] Test addition/deletion of multivalued variables tinc foo add Subnet 1 tinc foo add Subnet 2 tinc foo add Subnet 2 tinc foo add Subnet 3 test "$(tinc foo get Subnet | rm_cr)" = "1 2 3" tinc foo del Subnet 2 test "$(tinc foo get Subnet | rm_cr)" = "1 3" tinc foo del Subnet test -z "$(tinc foo get Subnet)" echo [STEP] We should not be able to get/set server variables using node.variable syntax test -z "$(tinc foo get foo.Name)" must_fail tinc foo set foo.Name bar echo [STEP] Test getting/setting host variables for other nodes touch "$DIR_FOO/hosts/bar" tinc foo add bar.PMTU 1 tinc foo add bar.PMTU 2 test "$(tinc foo get bar.PMTU)" = "2" tinc foo add bar.Subnet 1 tinc foo add bar.Subnet 2 tinc foo add bar.Subnet 2 tinc foo add bar.Subnet 3 test "$(tinc foo get bar.Subnet | rm_cr)" = "1 2 3" tinc foo del bar.Subnet 2 test "$(tinc foo get bar.Subnet | rm_cr)" = "1 3" tinc foo del bar.Subnet test -z "$(tinc foo get bar.Subnet)" echo [STEP] We should not be able to get/set for nodes with invalid names touch "$DIR_FOO/hosts/qu-ux" must_fail tinc foo set qu-ux.Subnet 1 echo [STEP] We should not be able to set obsolete variables unless forced must_fail tinc foo set PrivateKey 12345 tinc foo --force set PrivateKey 12345 test "$(tinc foo get PrivateKey)" = "12345" tinc foo del PrivateKey test -z "$(tinc foo get PrivateKey)"