2018-04-14 12:33:57 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load _test_base
|
|
|
|
|
|
|
|
FILE_TO_HIDE="file_to_hide"
|
|
|
|
FILE_CONTENTS="hidden content юникод"
|
|
|
|
|
|
|
|
FINGERPRINT=""
|
|
|
|
|
|
|
|
|
|
|
|
function setup {
|
|
|
|
FINGERPRINT=$(install_fixture_full_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 "$FILE_TO_HIDE" "$FILE_CONTENTS"
|
|
|
|
set_state_secret_hide
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function teardown {
|
|
|
|
uninstall_fixture_full_key "$TEST_DEFAULT_USER" "$FINGERPRINT"
|
|
|
|
unset_current_state
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "run 'cat' with password argument" {
|
|
|
|
local password=$(test_user_password "$TEST_DEFAULT_USER")
|
|
|
|
run git secret cat -d "$TEST_GPG_HOMEDIR" -p "$password" "$FILE_TO_HIDE"
|
|
|
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
# $output is the output from 'git secret cat' above
|
2018-04-14 19:50:38 +00:00
|
|
|
# note that currently content may differ by a newline
|
2018-04-14 12:33:57 +00:00
|
|
|
[ "$FILE_CONTENTS" == "$output" ]
|
|
|
|
}
|
|
|
|
|
2018-04-14 13:28:05 +00:00
|
|
|
@test "run 'cat' with wrong filename" {
|
2018-04-16 15:05:50 +00:00
|
|
|
run git secret cat -d "$TEST_GPG_HOMEDIR" -p "$password" NO_SUCH_FILE
|
2018-04-14 13:28:05 +00:00
|
|
|
[ "$status" -eq 2 ]
|
|
|
|
}
|
2018-04-14 12:33:57 +00:00
|
|
|
|