summaryrefslogtreecommitdiff
path: root/tests/keyctl/id/valid/runtest.sh
blob: 56c2d956ac25ac9f61fade62cebc8caab2a0e9a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash

. ../../../prepare.inc.sh
. ../../../toolbox.inc.sh


# ---- do the actual testing ----

result=PASS
echo "++++ BEGINNING TEST" >$OUTPUTFILE

# check standard IDs
marker "CHECK STD IDS"
id_key --fail @t
expect_error ENOKEY
id_key --fail @p
expect_error ENOKEY
id_key @s
id_key @u
id_key @us
id_key --fail @g
expect_error EINVAL
id_key --fail @a
expect_error ENOKEY

# create a keyring
marker "CREATE KEYRING"
create_keyring lizard @s
expect_keyid keyid

# check that a non-keyring ID works
marker "CHECK NON-KEYRING KEY"
id_key $keyid
id_key %:lizard
id_key --fail %:lizardx

# dispose of the key we were using
marker "UNLINK KEYRING"
unlink_key --wait $keyid @s

# check that a non-existent key ID fails correctly
marker "CHECK NON-EXISTENT KEYRING ID"
id_key --fail $keyid
expect_error ENOKEY

# create a non-keyring
marker "CREATE KEY"
create_key user lizard gizzard @s
expect_keyid keyid

# check that a non-keyring ID works
marker "CHECK NON-KEYRING KEY"
id_key $keyid
id_key %user:lizard

# dispose of the key we were using
marker "UNLINK KEY"
unlink_key --wait $keyid @s

# check that a non-existent key ID fails correctly
marker "CHECK NON-EXISTENT KEY ID"
id_key --fail $keyid
expect_error ENOKEY

echo "++++ FINISHED TEST: $result" >>$OUTPUTFILE

# --- then report the results in the database ---
toolbox_report_result $TEST $result