Debian Codegraph @

cli-tests/t_status.sh

raw
1 #!/bin/bash
2
3 # Test getting global, filesystem, and unencrypted directory status
4 # when the filesystem is or isn't set up for fscrypt.
5
6 cd "$(dirname "$0")"
7 . common.sh
8
9 dir="$MNT/dir"
10 mkdir "$dir"
11
12 filter_mnt_status()
13 {
14 awk '$1 == "'"$MNT"'" { print $3, $4, $5 }'
15 }
16
17 # Initially, $MNT has encryption enabled and fscrypt setup.
18
19 enabled_count1=$(_get_enabled_fs_count)
20 setup_count1=$(_get_setup_fs_count)
21
22
23 _print_header "Get status of setup mountpoint via global status"
24 fscrypt status | filter_mnt_status
25 _user_do "fscrypt status" | filter_mnt_status
26
27 _print_header "Get status of setup mountpoint"
28 fscrypt status "$MNT"
29 _user_do "fscrypt status '$MNT'"
30
31 _print_header "Get status of unencrypted directory on setup mountpoint"
32 _expect_failure "fscrypt status '$dir'"
33 _user_do_and_expect_failure "fscrypt status '$dir'"
34
35 _print_header "Remove fscrypt metadata from $MNT"
36 _rm_metadata "$MNT"
37
38 # Now, $MNT has encryption enabled but fscrypt *not* setup.
39
40 _print_header "Check enabled / setup count again"
41 enabled_count2=$(_get_enabled_fs_count)
42 setup_count2=$(_get_setup_fs_count)
43 (( enabled_count2 == enabled_count1 )) || _fail "wrong enabled count"
44 (( setup_count2 == setup_count1 - 1 )) || _fail "wrong setup count"
45
46 _print_header "Get status of not-setup mounntpoint via global status"
47 fscrypt status | filter_mnt_status
48 _user_do "fscrypt status" | filter_mnt_status
49
50 _print_header "Get status of not-setup mountpoint"
51 _expect_failure "fscrypt status '$MNT'"
52 _user_do_and_expect_failure "fscrypt status '$MNT'"
53
54 _print_header "Get status of unencrypted directory on not-setup mountpoint"
55 _expect_failure "fscrypt status '$dir'"
56 _user_do_and_expect_failure "fscrypt status '$dir'"