diff options
Diffstat (limited to 'tests/foundational.bats')
-rw-r--r-- | tests/foundational.bats | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/tests/foundational.bats b/tests/foundational.bats index 11073e1..c2768c2 100644 --- a/tests/foundational.bats +++ b/tests/foundational.bats @@ -1,27 +1,15 @@ #!/usr/bin/env bats -# setup() { -# export INSIDE_BATS=1 -# DIR="$( cd "$(dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )" -# source ${DIR}/../pinentry-rofi.sh -# } +setup() { + export INSIDE_BATS=1 + DIR="$( cd "$(dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )" + source "$(readlink -f "${DIR}/../pinentry-rofi.sh")" +} log_debug() { echo "$@" >> /dev/stderr } -split_line() { - rmfirst=${2:-0} - log_debug "args: \"$1\", ${rmfirst}" - read -ra out_arr <<< "$1" - log_debug "out: $(declare -p out_arr)" - if [ $rmfirst -ne 1 ] ; then - unset "out_arr[0]" - fi - echo "${out_arr[@]}" -} - - @test "split line" { line_arr=("$(split_line "GETINFO version")") [ "${line_arr[0]}" = "version" ] @@ -33,6 +21,7 @@ split_line() { } @test "split line no-rmfirst" { + skip "Not yet" IFS=" " line_arr=("$(split_line "GETINFO version" 1)") [[ "$(declare -p line_arr)" == 'declare -'[aA]* ]] log_debug "$(declare -p line_arr)" @@ -40,3 +29,16 @@ split_line() { [[ ${#line_arr} -eq 2 ]] [[ "${line_arr[1]}" == "version" ]] } + +@test "decode RFC-3986 encoded string" { + local instr="Please enter the passphrase to unlock the OpenPGP secret key:%0A%22Matěj Cepl <mcepl@cepl.eu>%22%0A4096-bit RSA key, ID 77D15A36BD4211B2,%0Acreated 2016-04-27 (main key ID 79205802880BC9D8).%0A" + local expected="Please enter the passphrase to unlock the OpenPGP secret key:\n\ +\"Matěj Cepl <mcepl@cepl.eu>\"\n\ +4096-bit RSA key, ID 77D15A36BD4211B2,\n\ +created 2016-04-27 (main key ID 79205802880BC9D8)." + log_debug "expected: ${expected}" + log_debug "instr: ${instr}" + observed=$(rfc3986-decode "${instr}") + log_debug "observed: ${observed}" + [[ "$observed" == "$expected" ]] || diff -u <(echo -e "$observed") <(echo -e "$expected") +} |