mirror of
https://github.com/sobolevn/git-secret
synced 2024-11-08 19:10:31 +00:00
9e8438236c
* show most gpg commands used for 'hide', 'reveal', 'tell' and 'killperson (#554) * fix hang when using ctrl-c during tests (#558)
96 lines
2.1 KiB
Bash
96 lines
2.1 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load _test_base
|
|
|
|
FIRST_FILE="$TEST_DEFAULT_FILENAME"
|
|
SECOND_FILE="$TEST_SECOND_FILENAME"
|
|
|
|
|
|
function setup {
|
|
install_fixture_key "$TEST_DEFAULT_USER"
|
|
|
|
set_state_initial
|
|
set_state_git
|
|
set_state_secret_init
|
|
set_state_secret_tell "$TEST_DEFAULT_USER"
|
|
set_state_secret_add "$FIRST_FILE" "somecontent"
|
|
set_state_secret_add "$SECOND_FILE" "somecontent2"
|
|
set_state_secret_hide
|
|
}
|
|
|
|
|
|
function teardown {
|
|
# This also needs to be cleaned:
|
|
rm "$FIRST_FILE" "$SECOND_FILE"
|
|
|
|
uninstall_fixture_key "$TEST_DEFAULT_USER"
|
|
unset_current_state
|
|
}
|
|
|
|
|
|
function _secret_files_exists {
|
|
local result=$(find . -type f -name "*.$SECRETS_EXTENSION" \
|
|
-print0 2>/dev/null | grep -q .; echo "$?")
|
|
echo "$result"
|
|
}
|
|
|
|
|
|
@test "run 'clean' normally" {
|
|
run_wrapper git secret clean
|
|
[ "$status" -eq 0 ]
|
|
|
|
# There must be no .secret files:
|
|
local exists=$(_secret_files_exists)
|
|
[ "$exists" -ne 0 ]
|
|
}
|
|
|
|
@test "run 'clean' with extra filename" {
|
|
run_wrapper git secret clean extra_filename
|
|
[ "$status" -ne 0 ]
|
|
}
|
|
|
|
@test "run 'clean' with bad arg" {
|
|
run_wrapper git secret clean -Z
|
|
[ "$status" -ne 0 ]
|
|
}
|
|
|
|
|
|
@test "run 'clean' with '-v'" {
|
|
run_wrapper git secret clean -v
|
|
[ "$status" -eq 0 ]
|
|
|
|
# There must be no .secret files:
|
|
local exists=$(_secret_files_exists)
|
|
[ "$exists" -ne 0 ]
|
|
|
|
local first_filename=$(_get_encrypted_filename "$FIRST_FILE")
|
|
local second_filename=$(_get_encrypted_filename "$SECOND_FILE")
|
|
|
|
# Output must be verbose:
|
|
[[ "$output" == *"removing:"* ]]
|
|
[[ "$output" == *"$first_filename"* ]]
|
|
[[ "$output" == *"$second_filename"* ]]
|
|
}
|
|
|
|
# this test is like above, but uses SECRETS_VERBOSE env var
|
|
@test "run 'clean' with 'SECRETS_VERBOSE=1'" {
|
|
export SECRETS_VERBOSE=1
|
|
run_wrapper git secret clean
|
|
[ "$status" -eq 0 ]
|
|
|
|
# Output must be verbose:
|
|
[[ "$output" == *"removing:"* ]]
|
|
}
|
|
|
|
# this test is like above, but sets SECRETS_VERBOSE env var to 0
|
|
# and expected non-verbose output
|
|
@test "run 'clean' with 'SECRETS_VERBOSE=0'" {
|
|
export SECRETS_VERBOSE=0
|
|
run_wrapper git secret clean
|
|
[ "$status" -eq 0 ]
|
|
|
|
# Output must not be verbose:
|
|
[[ "$output" != *"removing:"* ]]
|
|
}
|
|
|