chiark / gitweb /
autopkgtests: wip, a test for non-root to non-root
[userv.git] / tests / t-config
diff --git a/tests/t-config b/tests/t-config
new file mode 100755 (executable)
index 0000000..64e2b83
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/bash
+set -ex
+
+. tests/lib
+
+(
+    cat >/etc/userv/services.d/userv-t-config <<END
+if ( glob calling-user bin
+   & glob service-user games
+   )
+       execute printenv
+fi
+END
+)
+
+tmp="${AUTOPKGTEST_ARTIFACTS}"
+if [ "x$tmp" = x ]; then
+    rm -rf tmp
+    mkdir tmp
+    tmp=tmp
+fi
+
+bin_uid=$(id -u bin)
+bin_gid=$(id -g bin)
+
+really -u bin \
+userv games userv-t-config >"$tmp"/env
+
+for expect in                                  \
+    'USERV_SERVICE=userv-t-config'             \
+    'USERV_USER=bin'                           \
+    'USERV_GROUP=bin bin'                      \
+    "USERV_UID=$bin_uid"                       \
+    "USERV_GID=$bin_gid $bin_gid"              \
+; do
+    egrep "^$expect\$" "$tmp"/env
+done
+
+expect_output 255 '' \
+really -u daemon \
+userv games userv-t-config
+
+echo ok.