Skip to content

Commit

Permalink
Merge pull request #21 from Sebastian-Hojas/master
Browse files Browse the repository at this point in the history
Fix vpn status bug
  • Loading branch information
mrodalgaard authored Dec 29, 2022
2 parents 6a81c5a + 1b4d246 commit e56b7fd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ getVPN() {

# $1 = `scutil --nc list` lines
getVPNInfo() {
if [[ "$1" =~ \*[[:space:]]\((.*)\)[[:space:]].*\"(.*)\".*\[(.*)\] ]]
if [[ "$1" =~ \*[[:space:]]\(([a-zA-Z ]*)\)[[:space:]].*\"(.*)\".*\[(.*)\] ]]
then
STATE=${BASH_REMATCH[1]}
NAME=${BASH_REMATCH[2]}
Expand Down
13 changes: 13 additions & 0 deletions tests/vpnTests.bats
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ load variables
[ "${ARRAY[2]}" == "PPP:L2TP" ]
[ "${ARRAY[3]}" == "$ICON_VPN" ]
}

@test "getVPNInfo: get connected vpn info with paranthesis" {
INPUT="* (Connected) 65F5A799-4C98-4DA1-87D7-9D605D9D666C IPSec (com.vpn.vpn) \"Another: VPN\" [IPSec]"

run getVPNInfo "$INPUT"
IFS='~' read -r -a ARRAY <<< "$output"

[ "$status" -eq 0 ]
[ "${ARRAY[0]}" == "Connected" ]
[ "${ARRAY[1]}" == "Another: VPN" ]
[ "${ARRAY[2]}" == "IPSec" ]
[ "${ARRAY[3]}" == "$ICON_VPN_CONNECTED" ]
}

0 comments on commit e56b7fd

Please sign in to comment.