From c0dda22c9cc169df1e69131ea7350c109466322b Mon Sep 17 00:00:00 2001 From: "tlimoncelli@stackexchange.com" Date: Sat, 20 Jun 2015 15:39:32 +0000 Subject: [PATCH] Bug: blackbox_deregister_file deletes blackbox-files.txt * Clarified symantics of blackbox_deregister_file in comments. * Added confidence test --- bin/blackbox_deregister_file | 11 ++++++----- tools/confidence_test.sh | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/bin/blackbox_deregister_file b/bin/blackbox_deregister_file index a092bc1..f47be19 100755 --- a/bin/blackbox_deregister_file +++ b/bin/blackbox_deregister_file @@ -3,8 +3,9 @@ # # blackbox_deregister_file -- Remove a file from the blackbox system. # -# Takes an encrypted file and removes it from the blackbox system. The -# encrypted file will also be removed from the filesystem. +# Takes an encrypted file and removes it from the blackbox system. +# The encrypted file will also be removed from the filesystem. +# The unencrypted file, if it exists, will be left alone. set -e source "${0%/*}/_blackbox_common.sh" @@ -25,10 +26,10 @@ fail_if_not_exists "$encrypted_file" "Please specify an existing file." prepare_keychain remove_filename_from_cryptlist "$unencrypted_file" -vcs_notice "$unencrypted_file" -vcs_remove "$BB_FILES" +vcs_remove "$encrypted_file" +vcs_add "$BB_FILES" -vcs_commit "Removing from blackbox: ${unencrypted_file}" +vcs_commit "Removing from blackbox: ${unencrypted_file}" "$BB_FILES" "$encrypted_file" echo "========== UPDATING VCS: DONE" echo "Local repo updated. Please push when ready." echo " $(which_vcs) push" diff --git a/tools/confidence_test.sh b/tools/confidence_test.sh index 6e83365..6183ac4 100755 --- a/tools/confidence_test.sh +++ b/tools/confidence_test.sh @@ -307,7 +307,7 @@ assert_file_group secret.txt "$TEST_GID_NAME" PHASE 'Bob cleans up the secret.' rm secret.txt -PHASE 'Bob removes alice.' +PHASE 'Bob removes Alice.' blackbox_removeadmin alice@example.com assert_line_not_exists 'alice@example.com' keyrings/live/blackbox-admins.txt @@ -439,7 +439,17 @@ assert_file_exists 'secret.txt.gpg' assert_file_exists 'space space.txt.gpg' assert_file_exists 'stars*bars?.txt.gpg' +PHASE 'Bob DEregisters mistake.txt' +touch 'mistake.txt' +blackbox_deregister_file 'mistake.txt.gpg' +assert_file_exists 'keyrings/live/blackbox-admins.txt' +assert_file_exists 'keyrings/live/blackbox-files.txt' +assert_line_not_exists 'mistake.txt' 'keyrings/live/blackbox-files.txt' +assert_file_missing 'mistake.txt.gpg' +assert_file_exists 'mistake.txt' + PHASE 'Alice returns. She should be locked out' +assert_file_missing 'secret.txt' become_alice PHASE 'Alice tries to decrypt secret.txt. Is blocked.' if blackbox_edit_start secret.txt ; then @@ -455,11 +465,15 @@ fi # ASSERTIONS # +echo '========== Verifying .gnupg was not accidentally created.' + if [[ -e $HOME/.gnupg ]]; then echo "ASSERT FAILED: $HOME/.gnupg should not exist." exit 1 fi +echo '========== DONE with tests. Outputing some diagnostics:' + find .git?* * -type f -ls echo cd "$test_repository" echo rm -rf "$test_repository"