summaryrefslogtreecommitdiff
path: root/keyutils-1.5.6/tests/keyctl/newring/valid/runtest.sh
blob: bcb94384bfc316fc210d6480fc3cc82c88ab75e9 (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
#!/bin/sh

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


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

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

# create a keyring and attach it to the session keyring
marker "ADD KEYRING"
create_keyring wibble @s
expect_keyid keyringid

# check that we now have an empty keyring
marker "LIST KEYRING"
list_keyring $keyringid
expect_keyring_rlist rlist empty

# check that creating a second keyring of the same name displaces the first
marker "ADD KEYRING AGAIN"
create_keyring wibble @s
expect_keyid keyringid2

# should be different keyrings
if [ "x$keyringid" == "x$keyringid2" ]
then
    failed
fi

# the first should no longer exist in the session keyring
marker "LIST SESSION KEYRING"
list_keyring @s
expect_keyring_rlist sessionrlist $keyringid --absent

# and should no longer be accessible
marker "VALIDATE NEW KEYRING"
pause_till_key_destroyed $keyringid
describe_key --fail $keyringid
expect_error ENOKEY

# list the session keyring
marker "LIST SESSION KEYRING2"
list_keyring @s
expect_keyring_rlist sessionrlist $keyringid2

# validate the new keyring's name and type
marker "VALIDATE NEW KEYRING2"
describe_key $keyringid2
expect_key_rdesc rdesc 'keyring@.*@wibble'

# remove the keyring we added
marker "UNLINK KEY"
unlink_key $keyringid2 @s

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

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