fixes for git secret changes (#160)

* fixes for git secret changes

check that we can find filenames passed on command line, and that
we can find the unencrypted versions of hidden files.

* new test

* add tests
pull/167/head
Josh Rabinowitz 7 years ago committed by Nikita Sobolev
parent 7884a51f18
commit c2081514d6

@ -37,14 +37,23 @@ function changes {
local path # absolute path
local normalized_path # relative to the .git dir
local encrypted_filename
normalized_path=$(_git_normalize_filename "$filename")
encrypted_filename=$(_get_encrypted_filename "$filename")
if [[ ! -f "$encrypted_filename" ]]; then
_abort "cannot find encrypted version of file: $filename"
fi
if [[ ! -z "$normalized_path" ]]; then
path=$(_append_root_path "$normalized_path")
else
# Path was already normalized
path=$(_append_root_path "$filename")
fi
if [[ ! -f "$path" ]]; then
_abort "file not found. Consider using 'git secret reveal': $filename"
fi
# Now we have all the data required:
decrypted=$(_decrypt "$path" "0" "0" "$homedir" "$passphrase")

@ -44,6 +44,23 @@ function teardown {
[[ "$output" == *"+$new_content"* ]]
}
@test "run 'changes' with source file missing" {
local password=$(test_user_password "$TEST_DEFAULT_USER")
rm "$FILE_TO_HIDE"
run git secret changes -d "$TEST_GPG_HOMEDIR" -p "$password" "$FILE_TO_HIDE"
[ "$status" -ne 0 ]
}
@test "run 'changes' with hidden file missing" {
local password=$(test_user_password "$TEST_DEFAULT_USER")
local encrypted_file=$(_get_encrypted_filename $FILE_TO_HIDE)
rm "$encrypted_file"
run git secret changes -d "$TEST_GPG_HOMEDIR" -p "$password" "$FILE_TO_HIDE"
[ "$status" -ne 0 ]
}
@test "run 'changes' with one file changed (with deletions)" {
local password=$(test_user_password "$TEST_DEFAULT_USER")

Loading…
Cancel
Save