diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-11-23 01:17:25 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-11-23 11:09:12 +0100 |
commit | 3b352a9748e9c209ef562b8a196bc7b4ecb7b9d9 (patch) | |
tree | 5cc01e33908a1dbf8bd0cd9cfd7880cea6d169ea /src/tests/netns.sh | |
parent | 71db96bcb99cc8e8e06885d7fa8819c6a02c963a (diff) |
tools: fix removing preshared keys
Also clean up related logic quite a bit and add unit tests.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/tests/netns.sh')
-rwxr-xr-x | src/tests/netns.sh | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/tests/netns.sh b/src/tests/netns.sh index 2ad8d88..8118b02 100755 --- a/src/tests/netns.sh +++ b/src/tests/netns.sh @@ -427,6 +427,24 @@ ip0 link del wg0 ! n0 wg show doesnotexist || false +n0 ip link add wg0 type wireguard +n0 wg set wg0 private-key <(echo "$key1") peer "$pub2" preshared-key <(echo "$psk") +[[ $(n0 wg show wg0 private-key) == "$key1" ]] +[[ $(n0 wg show wg0 preshared-keys) == "$pub2 $psk" ]] +n0 wg set wg0 private-key /dev/null peer "$pub2" preshared-key /dev/null +[[ $(n0 wg show wg0 private-key) == "(none)" ]] +[[ $(n0 wg show wg0 preshared-keys) == "$pub2 (none)" ]] +n0 wg set wg0 peer "$pub2" +n0 wg set wg0 private-key <(echo "$key2") +[[ $(n0 wg show wg0 public-key) == "$pub2" ]] +[[ -z $(n0 wg show wg0 peers) ]] +n0 wg set wg0 peer "$pub2" +[[ -z $(n0 wg show wg0 peers) ]] +n0 wg set wg0 private-key <(echo "$key1") +n0 wg set wg0 peer "$pub2" +[[ $(n0 wg show wg0 peers) == "$pub2" ]] +n0 ip link del wg0 + declare -A objects while read -t 0.1 -r line 2>/dev/null || [[ $? -ne 142 ]]; do [[ $line =~ .*(wg[0-9]+:\ [A-Z][a-z]+\ [0-9]+)\ .*(created|destroyed).* ]] || continue |