mirror of
https://github.com/systemd/systemd.git
synced 2024-11-23 18:23:32 +08:00
test: add test suite for new credentials logic
This commit is contained in:
parent
b0d29bfdfd
commit
30dd9f7391
1
test/TEST-54-CREDS/Makefile
Symbolic link
1
test/TEST-54-CREDS/Makefile
Symbolic link
@ -0,0 +1 @@
|
||||
../TEST-01-BASIC/Makefile
|
7
test/TEST-54-CREDS/test.sh
Executable file
7
test/TEST-54-CREDS/test.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
TEST_DESCRIPTION="test credentials"
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
do_test "$@" 54
|
7
test/units/testsuite-54.service
Normal file
7
test/units/testsuite-54.service
Normal file
@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=TESTSUITE-54-CREDS
|
||||
|
||||
[Service]
|
||||
ExecStartPre=rm -f /failed /testok
|
||||
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
|
||||
Type=oneshot
|
31
test/units/testsuite-54.sh
Executable file
31
test/units/testsuite-54.sh
Executable file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ex
|
||||
|
||||
systemd-analyze log-level debug
|
||||
|
||||
# Verify that the creds are properly loaded and we can read them from the service's unpriv user
|
||||
systemd-run -p LoadCredential=passwd:/etc/passwd \
|
||||
-p LoadCredential=shadow:/etc/shadow \
|
||||
-p SetCredential=dog:wuff \
|
||||
-p DynamicUser=1 \
|
||||
--wait \
|
||||
--pipe \
|
||||
cat '${CREDENTIALS_DIRECTORY}/passwd' '${CREDENTIALS_DIRECTORY}/shadow' '${CREDENTIALS_DIRECTORY}/dog' > /tmp/ts54-concat
|
||||
( cat /etc/passwd /etc/shadow && echo -n wuff ) | cmp /tmp/ts54-concat
|
||||
rm /tmp/ts54-concat
|
||||
|
||||
# Verify that the creds are immutable
|
||||
! systemd-run -p LoadCredential=passwd:/etc/passwd \
|
||||
-p DynamicUser=1 \
|
||||
--wait \
|
||||
touch '${CREDENTIALS_DIRECTORY}/passwd'
|
||||
! systemd-run -p LoadCredential=passwd:/etc/passwd \
|
||||
-p DynamicUser=1 \
|
||||
--wait \
|
||||
rm '${CREDENTIALS_DIRECTORY}/passwd'
|
||||
|
||||
systemd-analyze log-level info
|
||||
|
||||
echo OK > /testok
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user