diff --git a/p11-kit/test-profiles.sh b/p11-kit/test-profiles.sh index 170676dc..9c3f170d 100755 --- a/p11-kit/test-profiles.sh +++ b/p11-kit/test-profiles.sh @@ -102,6 +102,22 @@ EOF fi } +test_list_profiles_nonexistent_token() { + cat > list.exp < list.out 2> err.out; then + assert_fail "expected to fail: p11-kit list-profiles" + fi + + : ${DIFF=diff} + if ! ${DIFF} list.exp list.out > list.diff; then + sed 's/^/# /' list.diff + assert_fail "output contains wrong results" + fi + assert_contains err.out "no matching token" +} + test_add_profile() { cat > test-profiles.p11-kit < list.exp < list.out 2> err.out; then + assert_fail "expected to fail: p11-kit add-profile" + fi + + : ${DIFF=diff} + if ! ${DIFF} list.exp list.out > list.diff; then + sed 's/^/# /' list.diff + assert_fail "output contains wrong results" + fi + assert_contains err.out "no profile specified" +} + +test_add_profile_duplicate_args() { + cat > list.exp < list.out 2> err.out; then + assert_fail "expected to fail: p11-kit add-profile" + fi + + : ${DIFF=diff} + if ! ${DIFF} list.exp list.out > list.diff; then + sed 's/^/# /' list.diff + assert_fail "output contains wrong results" + fi + assert_contains err.out "multiple profiles specified" +} + test_delete_profile() { cat > test-profiles.p11-kit < test-profiles.p11-kit < list.exp < list.out 2> err.out; then + assert_fail "expected to fail: p11-kit delete-profile" + fi + + : ${DIFF=diff} + if ! ${DIFF} list.exp list.out > list.diff; then + sed 's/^/# /' list.diff + assert_fail "output contains wrong results" + fi + assert_contains err.out "no matching token" +} + +test_delete_profile_no_args() { + cat > list.exp < list.out 2> err.out; then + assert_fail "expected to fail: p11-kit delete-profile" + fi + + : ${DIFF=diff} + if ! ${DIFF} list.exp list.out > list.diff; then + sed 's/^/# /' list.diff + assert_fail "output contains wrong results" + fi + assert_contains err.out "no profile specified" +} + +test_delete_profile_duplicate_args() { + cat > list.exp < list.out 2> err.out; then + assert_fail "expected to fail: p11-kit delete-profile" + fi + + : ${DIFF=diff} + if ! ${DIFF} list.exp list.out > list.diff; then + sed 's/^/# /' list.diff + assert_fail "output contains wrong results" + fi + assert_contains err.out "multiple profiles specified" +} + +run test_list_profiles \ + test_list_profiles_session \ + test_list_profiles_empty \ + test_list_profiles_nonexistent_token \ + test_add_profile \ + test_add_profile_empty \ + test_add_profile_duplicate \ + test_add_profile_session_duplicate \ + test_add_profile_nonexistent_token \ + test_add_profile_no_args \ + test_add_profile_duplicate_args \ + test_delete_profile \ + test_delete_profile_last \ + test_delete_profile_empty \ + test_delete_profile_multiple \ + test_delete_profile_session \ + test_delete_profile_nonexistent_token \ + test_delete_profile_no_args \ + test_delete_profile_duplicate_args