X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=test%2Fvariables.test;h=fffbd8ced0da877e6122b042da16a87f1fd74564;hb=df716df33af8e9a5b93d573a023ecd7fc24d9a03;hp=bcec9fb2427b74b7155308e0a67593950c79429f;hpb=cfe507c299935bd231be698b8a426cc730f52936;p=tinc diff --git a/test/variables.test b/test/variables.test index bcec9fb2..fffbd8ce 100755 --- a/test/variables.test +++ b/test/variables.test @@ -1,6 +1,7 @@ #!/bin/sh -. ./testlib.sh +# shellcheck disable=SC1090 +. "$TESTLIB_PATH" echo [STEP] Initialize one node @@ -22,7 +23,7 @@ test "$(tinc foo get Mode)" = "Switch" echo [STEP] Test deletion -must_fail tinc foo del Mode hub +expect_code "$EXIT_FAILURE" tinc foo del Mode hub tinc foo del Mode switch test -z "$(tinc foo get Mode)" @@ -34,17 +35,17 @@ 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 add Subnet 1.1.1.1 +tinc foo add Subnet 2.2.2.2 +tinc foo add Subnet 2.2.2.2 +tinc foo add Subnet 3.3.3.3 +test "$(tinc foo get Subnet | rm_cr)" = "1.1.1.1 +2.2.2.2 +3.3.3.3" -tinc foo del Subnet 2 -test "$(tinc foo get Subnet | rm_cr)" = "1 -3" +tinc foo del Subnet 2.2.2.2 +test "$(tinc foo get Subnet | rm_cr)" = "1.1.1.1 +3.3.3.3" tinc foo del Subnet test -z "$(tinc foo get Subnet)" @@ -52,7 +53,7 @@ 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 +expect_code "$EXIT_FAILURE" tinc foo set foo.Name bar echo [STEP] Test getting/setting host variables for other nodes @@ -62,17 +63,17 @@ 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 add bar.Subnet 1.1.1.1 +tinc foo add bar.Subnet 2.2.2.2 +tinc foo add bar.Subnet 2.2.2.2 +tinc foo add bar.Subnet 3.3.3.3 +test "$(tinc foo get bar.Subnet | rm_cr)" = "1.1.1.1 +2.2.2.2 +3.3.3.3" -tinc foo del bar.Subnet 2 -test "$(tinc foo get bar.Subnet | rm_cr)" = "1 -3" +tinc foo del bar.Subnet 2.2.2.2 +test "$(tinc foo get bar.Subnet | rm_cr)" = "1.1.1.1 +3.3.3.3" tinc foo del bar.Subnet test -z "$(tinc foo get bar.Subnet)" @@ -80,13 +81,32 @@ 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 +expect_code "$EXIT_FAILURE" tinc foo set qu-ux.Subnet 1.1.1.1 echo [STEP] We should not be able to set obsolete variables unless forced -must_fail tinc foo set PrivateKey 12345 +expect_code "$EXIT_FAILURE" 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)" + +echo [STEP] We should not be able to set/add malformed Subnets + +expect_code "$EXIT_FAILURE" tinc foo add Subnet 1.1.1 +expect_code "$EXIT_FAILURE" tinc foo add Subnet 1:2:3:4:5: +expect_code "$EXIT_FAILURE" tinc foo add Subnet 1:2:3:4:5:::6 +expect_code "$EXIT_FAILURE" tinc foo add Subnet 1:2:3:4:5:6:7:8:9 +expect_code "$EXIT_FAILURE" tinc foo add Subnet 256.256.256.256 +expect_code "$EXIT_FAILURE" tinc foo add Subnet 1:2:3:4:5:6:7:8.123 +expect_code "$EXIT_FAILURE" tinc foo add Subnet 1:2:3:4:5:6:7:1.2.3.4 +expect_code "$EXIT_FAILURE" tinc foo add Subnet a:b:c:d:e:f:g:h +expect_code "$EXIT_FAILURE" tinc foo add Subnet 1.1.1.1/0 +expect_code "$EXIT_FAILURE" tinc foo add Subnet 1.1.1.1/-1 +expect_code "$EXIT_FAILURE" tinc foo add Subnet 1.1.1.1/33 +expect_code "$EXIT_FAILURE" tinc foo add Subnet 1::/0 +expect_code "$EXIT_FAILURE" tinc foo add Subnet 1::/-1 +expect_code "$EXIT_FAILURE" tinc foo add Subnet 1::/129 +expect_code "$EXIT_FAILURE" tinc foo add Subnet :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +test -z "$(tinc foo get Subnet)"