]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/units/testsuite-46.sh
808270f33d917dbe99b1a24d1a307f0d107269ce
[thirdparty/systemd.git] / test / units / testsuite-46.sh
1 #!/usr/bin/env bash
2 set -eux
3 set -o pipefail
4
5 # Check if homectl is installed, and if it isn't bail out early instead of failing
6 if ! test -x /usr/bin/homectl ; then
7 echo OK >/testok
8 exit 0
9 fi
10
11 inspect() {
12 # As updating disk-size-related attributes can take some time on some
13 # filesystems, let's drop these fields before comparing the outputs to
14 # avoid unexpected fails. To see the full outputs of both homectl &
15 # userdbctl (for debugging purposes) drop the fields just before the
16 # comparison.
17 local USERNAME="${1:?missing argument}"
18 homectl inspect "$USERNAME" | tee /tmp/a
19 userdbctl user "$USERNAME" | tee /tmp/b
20
21 diff -I '/^\s*Disk (Size|Free|Floor|Ceiling):/' /tmp/{a,b}
22 rm /tmp/{a,b}
23 }
24
25 systemd-analyze log-level debug
26 systemd-analyze log-target console
27
28 NEWPASSWORD=xEhErW0ndafV4s homectl create test-user --disk-size=20M
29 inspect test-user
30
31 PASSWORD=xEhErW0ndafV4s homectl authenticate test-user
32
33 PASSWORD=xEhErW0ndafV4s homectl activate test-user
34 inspect test-user
35
36 PASSWORD=xEhErW0ndafV4s homectl update test-user --real-name="Inline test"
37 inspect test-user
38
39 homectl deactivate test-user
40 inspect test-user
41
42 PASSWORD=xEhErW0ndafV4s NEWPASSWORD=yPN4N0fYNKUkOq homectl passwd test-user
43 inspect test-user
44
45 PASSWORD=yPN4N0fYNKUkOq homectl activate test-user
46 inspect test-user
47
48 SYSTEMD_LOG_LEVEL=debug PASSWORD=yPN4N0fYNKUkOq NEWPASSWORD=xEhErW0ndafV4s homectl passwd test-user
49 inspect test-user
50
51 homectl deactivate test-user
52 inspect test-user
53
54 PASSWORD=xEhErW0ndafV4s homectl activate test-user
55 inspect test-user
56
57 PASSWORD=xEhErW0ndafV4s homectl deactivate test-user
58 inspect test-user
59
60 PASSWORD=xEhErW0ndafV4s homectl update test-user --real-name="Offline test"
61 inspect test-user
62
63 PASSWORD=xEhErW0ndafV4s homectl activate test-user
64 inspect test-user
65
66 PASSWORD=xEhErW0ndafV4s homectl deactivate test-user
67 inspect test-user
68
69 PASSWORD=xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz
70 PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz \
71 && { echo 'unexpected success'; exit 1; }
72 PASSWORD=xEhErW0ndafV4s homectl with test-user -- touch /home/test-user/xyz
73 PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz
74 PASSWORD=xEhErW0ndafV4s homectl with test-user -- rm /home/test-user/xyz
75 PASSWORD=xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz
76 PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz \
77 && { echo 'unexpected success'; exit 1; }
78
79 homectl remove test-user
80
81 systemd-analyze log-level info
82
83 echo OK >/testok
84
85 exit 0