Skip to content

Commit

Permalink
Add a test case for non authorized set locale:
Browse files Browse the repository at this point in the history
This is prompted by issue #3, but it does not really test that there
is no segmentation fault.
  • Loading branch information
pierre-labastie committed Aug 18, 2020
1 parent dae5256 commit bfc0ac9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ EXTRA_DIST = $(TESTS) \
ref-localed.sh \
unref-localed.sh \
scratch/locale-read-result1 \
scratch/locale-write-result1 \
scratch/keyboard-read-result1 \
scratch/keyboard-read-result2 \
scratch/keyboard-write-result1 \
Expand Down
18 changes: 16 additions & 2 deletions tests/locale-write-no-file
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,23 @@ cmp scratch/locale << EOF
LANG='fr_FR.UTF-8'
LC_TIME='fr_FR.UTF-8'
EOF

RES=$?
rm scratch/locale

if [ $RES = 0 ]; then
echo PASS: write-locale-no-file
rm scratch/locale
gdbus call \
--system \
--dest org.freedesktop.locale1 \
--object-path /org/freedesktop/locale1 \
--method org.freedesktop.locale1.SetLocale \
"['LANG=fr_FR.UTF-8', 'LC_TIME=fr_FR.UTF-8']" \
false |& cmp ${srcdir}/scratch/locale-write-result1
RES=$?
fi

#rm -f scratch/error
. ${srcdir}/unref-localed.sh
. ${srcdir}/unref-polkit.sh
. ${srcdir}/unref-dbus.sh
exit $RES
1 change: 1 addition & 0 deletions tests/scratch/locale-write-result1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Error: GDBus.Error:org.freedesktop.PolicyKit1.Error.NotAuthorized: Authorizing for 'org.freedesktop.locale1.set-locale': not authorized

0 comments on commit bfc0ac9

Please sign in to comment.