diff options
Diffstat (limited to 'keyutils-1.5.6/tests/keyctl/unlink')
-rw-r--r-- | keyutils-1.5.6/tests/keyctl/unlink/all/runtest.sh | 103 | ||||
-rw-r--r-- | keyutils-1.5.6/tests/keyctl/unlink/bad-args/runtest.sh | 47 | ||||
-rw-r--r-- | keyutils-1.5.6/tests/keyctl/unlink/noargs/runtest.sh | 30 | ||||
-rw-r--r-- | keyutils-1.5.6/tests/keyctl/unlink/valid/runtest.sh | 99 |
4 files changed, 279 insertions, 0 deletions
diff --git a/keyutils-1.5.6/tests/keyctl/unlink/all/runtest.sh b/keyutils-1.5.6/tests/keyctl/unlink/all/runtest.sh new file mode 100644 index 0000000..2014470 --- /dev/null +++ b/keyutils-1.5.6/tests/keyctl/unlink/all/runtest.sh @@ -0,0 +1,103 @@ +#!/bin/sh + +. ../../../prepare.inc.sh +. ../../../toolbox.inc.sh + + +# ---- do the actual testing ---- + +result=PASS + +if keyutils_at_or_later_than 1.5 +then + echo "++++ BEGINNING TEST" >$OUTPUTFILE + + # create a keyring and attach it to the session keyring + marker "ADD KEYRING" + create_keyring wibble @s + expect_keyid keyringid + + # stick a key in the keyring + marker "ADD KEY" + create_key user lizard gizzard $keyringid + expect_keyid keyid + + # check that we can list it + marker "LIST KEYRING WITH ONE" + list_keyring $keyringid + expect_keyring_rlist rlist $keyid + + # dispose of the key and make sure it gets destroyed + marker "UNLINK KEY FROM KEYRING" + unlink_key --wait $keyid $keyringid + + # trying a tree-wide unlink should succeed with no links removed + marker "CHECK NO UNLINK KEY FROM TREE" + unlink_key $keyid + expect_unlink_count n_unlinked 0 + + # check that the keyring is now empty + marker "LIST KEYRING" + list_keyring $keyringid + expect_keyring_rlist rlist empty + + # create a key to be massively linked + marker "ADD MULTI KEY" + create_key user lizard gizzard $keyringid + expect_keyid keyid + + # stick twenty keyrings in the keyring with twenty links + marker "ADD TWENTY KEYRINGS WITH LINKS" + subrings= + for ((i=0; i<20; i++)) + do + create_keyring ring$i $keyringid + expect_keyid x + keys="$keys $x" + subrings="$subrings $x" + list_keyring $keyringid + expect_keyring_rlist rlist $x + + link_key $keyid $x + list_keyring $x + expect_keyring_rlist rlist $keyid + done + + marker "SHOW" + if ! keyctl show >>$OUTPUTFILE 2>&1 + then + failed + fi + + # delete all the keys from the keyring tree + marker "REMOVE ALL LINKS TO KEY" + unlink_key $keyid + expect_unlink_count n_unlinked 21 + + # there should not now be any left + unlink_key $keyid + expect_unlink_count n_unlinked 0 + + # check that the key is no longer in the main keyring + marker "CHECK GONE" + list_keyring $keyringid + expect_keyring_rlist rlist $keyid --absent + + for i in $subrings + do + list_keyring $i + expect_keyring_rlist rlist $keyid --absent + done + + # remove the keyring we added + marker "UNLINK KEY" + unlink_key $keyringid @s + + echo "++++ FINISHED TEST: $result" >>$OUTPUTFILE +else + echo "++++ SKIPPING TEST" >>$OUTPUTFILE + marker SKIP on version +fi + +# --- then report the results in the database --- +toolbox_report_result $TEST $result diff --git a/keyutils-1.5.6/tests/keyctl/unlink/bad-args/runtest.sh b/keyutils-1.5.6/tests/keyctl/unlink/bad-args/runtest.sh new file mode 100644 index 0000000..82f4371 --- /dev/null +++ b/keyutils-1.5.6/tests/keyctl/unlink/bad-args/runtest.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +. ../../../prepare.inc.sh +. ../../../toolbox.inc.sh + + +# ---- do the actual testing ---- + +result=PASS +echo "++++ BEGINNING TEST" >$OUTPUTFILE + +# check that a bad key ID fails correctly +marker "CHECK UNLINK BAD KEY ID" +unlink_key --fail 0 @s +expect_error EINVAL + +marker "CHECK UNLINK FROM BAD KEY ID" +unlink_key --fail @s 0 +expect_error EINVAL + +# create a non-keyring +marker "CREATE KEY" +create_key user lizard gizzard @s +expect_keyid keyid + +# check that unlinking from a non-keyring ID fails correctly +marker "CHECK UNLINK FROM NON-KEYRING KEY" +unlink_key --fail @s $keyid +expect_error ENOTDIR + +# 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 UNLINK FROM NON-EXISTENT KEY ID" +unlink_key --fail @s $keyid +expect_error ENOKEY + +marker "CHECK UNLINK NON-EXISTENT KEY ID" +unlink_key --fail $keyid @s +expect_error ENOKEY + +echo "++++ FINISHED TEST: $result" >>$OUTPUTFILE + +# --- then report the results in the database --- +toolbox_report_result $TEST $result diff --git a/keyutils-1.5.6/tests/keyctl/unlink/noargs/runtest.sh b/keyutils-1.5.6/tests/keyctl/unlink/noargs/runtest.sh new file mode 100644 index 0000000..1ed9f26 --- /dev/null +++ b/keyutils-1.5.6/tests/keyctl/unlink/noargs/runtest.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +. ../../../prepare.inc.sh +. ../../../toolbox.inc.sh + + +# ---- do the actual testing ---- + +result=PASS +echo "++++ BEGINNING TEST" >$OUTPUTFILE + +# check that no arguments fails correctly +marker "NO ARGS" +expect_args_error keyctl unlink + +if keyutils_older_than 1.5 +then + # check that one argument fails correctly + marker "ONE ARGS" + expect_args_error keyctl unlink 0 +fi + +# check that three arguments fails correctly +marker "THREE ARGS" +expect_args_error keyctl unlink 0 0 0 + +echo "++++ FINISHED TEST: $result" >>$OUTPUTFILE + +# --- then report the results in the database --- +toolbox_report_result $TEST $result diff --git a/keyutils-1.5.6/tests/keyctl/unlink/valid/runtest.sh b/keyutils-1.5.6/tests/keyctl/unlink/valid/runtest.sh new file mode 100644 index 0000000..cedf8a4 --- /dev/null +++ b/keyutils-1.5.6/tests/keyctl/unlink/valid/runtest.sh @@ -0,0 +1,99 @@ +#!/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 + +# stick a key in the keyring +marker "ADD KEY" +create_key user lizard gizzard $keyringid +expect_keyid keyid + +# check that we can list it +marker "LIST KEYRING WITH ONE" +list_keyring $keyringid +expect_keyring_rlist rlist $keyid + +# dispose of the key and make sure it gets destroyed +marker "UNLINK KEY FROM KEYRING" +unlink_key --wait $keyid $keyringid + +# trying again should fail +marker "CHECK NO UNLINK KEY FROM KEYRING" +unlink_key --fail $keyid $keyringid +expect_error ENOKEY + +# check that the keyring is now empty +marker "LIST KEYRING" +list_keyring $keyringid +expect_keyring_rlist rlist empty + +# stick twenty keys and twenty keyrings in the keyring +marker "ADD TWENTY KEYS" +keys="" +for ((i=0; i<20; i++)) + do + create_key user lizard$i gizzard$i $keyringid + expect_keyid x + keys="$keys $x" + list_keyring $keyringid + expect_keyring_rlist rlist $x +done + +marker "ADD TWENTY KEYRINGS" +for ((i=0; i<20; i++)) + do + create_keyring ring$i $keyringid + expect_keyid x + keys="$keys $x" + list_keyring $keyringid + expect_keyring_rlist rlist $x +done + +marker "CHECK KEYRING CONTENTS" +list_keyring $keyringid +for i in $keys +do + expect_keyring_rlist rlist $i +done + +marker "SHOW" +if ! keyctl show >>$OUTPUTFILE 2>&1 +then + failed +fi + +# delete all the keys from the keyring +marker "DELETE CONTENTS OF KEYRING" +for i in $keys + do + unlink_key --wait $i $keyringid + unlink_key --fail $i $keyringid + expect_error ENOKEY +done + +keyctl show + +# check that it's now empty +marker "LIST KEYRING" +list_keyring $keyringid +expect_keyring_rlist rlist empty + +# remove the keyring we added +marker "UNLINK KEY" +unlink_key $keyringid @s + +echo "++++ FINISHED TEST: $result" >>$OUTPUTFILE + +# --- then report the results in the database --- +toolbox_report_result $TEST $result |