1
0
mirror of https://github.com/TheLocehiliosan/yadm synced 2024-10-27 20:34:27 +00:00
TheLocehiliosan_yadm/test/115_accept_introspect.bats
Tim Byrne ebc90bfc98
Create secured private dirs (#74)
Directories are created prior to merge during clone, and prior to any
Git command run.

This directly addresses CVE-2017-11353.

When cloning a repo which includes data in a .ssh or .gnupg directory,
if those directories do not exist at the time of cloning, yadm will
create the directories with mask 0700 prior to merging the fetched data
into the work-tree.

When running a Git command and .ssh or .gnupg directories do not exist,
create those directories with mask 0700 prior to running the Git
command. However, do not create those directories if
yadm.auto-private-dirs is false.
2017-08-22 21:28:07 -05:00

100 lines
2.2 KiB
Bash

load common
load_fixtures
status=;output=; #; populated by bats run()
function count_introspect() {
local category="$1"
local expected_status="$2"
local expected_words="$3"
local expected_regex="$4"
run "${T_YADM_Y[@]}" introspect "$category"
local output_words
output_words=$(wc -w <<< "$output")
if [ "$status" -ne "$expected_status" ]; then
echo "ERROR: Unexpected exit code (expected $expected_status, got $status)"
return 1;
fi
if [ "$output_words" -ne "$expected_words" ]; then
echo "ERROR: Unexpected number of output words (expected $expected_words, got $output_words)"
return 1;
fi
if [ -n "$expected_regex" ]; then
if [[ ! "$output" =~ $expected_regex ]]; then
echo "OUTPUT:$output"
echo "ERROR: Output does not match regex: $expected_regex"
return 1;
fi
fi
}
@test "Command 'introspect' (no category)" {
echo "
When 'introspect' command is provided,
And no category is provided
Produce no output
Exit with 0
"
count_introspect "" 0 0
}
@test "Command 'introspect' (invalid category)" {
echo "
When 'introspect' command is provided,
And an invalid category is provided
Produce no output
Exit with 0
"
count_introspect "invalid_cat" 0 0
}
@test "Command 'introspect' (commands)" {
echo "
When 'introspect' command is provided,
And category 'commands' is provided
Produce command list
Exit with 0
"
count_introspect "commands" 0 15 'version'
}
@test "Command 'introspect' (configs)" {
echo "
When 'introspect' command is provided,
And category 'configs' is provided
Produce switch list
Exit with 0
"
count_introspect "configs" 0 13 'yadm\.auto-alt'
}
@test "Command 'introspect' (repo)" {
echo "
When 'introspect' command is provided,
And category 'repo' is provided
Output repo
Exit with 0
"
count_introspect "repo" 0 1 "$T_DIR_REPO"
}
@test "Command 'introspect' (switches)" {
echo "
When 'introspect' command is provided,
And category 'switches' is provided
Produce switch list
Exit with 0
"
count_introspect "switches" 0 7 '--yadm-dir'
}