test: coverage for store protections self-heal (hook on push/rekey, no-op, gitignore content)
This commit is contained in:
parent
53350853d9
commit
5865c40d77
1 changed files with 45 additions and 0 deletions
|
|
@ -1552,3 +1552,48 @@ gradle_project() {
|
|||
[ "$(cat .env)" = "SECRET_KEY=abc123" ]
|
||||
[ "$(cat .env.staging)" = "DB_HOST=staging.db.example.com" ]
|
||||
}
|
||||
|
||||
@test "push reinstalls missing pre-commit hook" {
|
||||
init_with_remote
|
||||
rm "$SECRETS_DIR/.git/hooks/pre-commit"
|
||||
create_project_dir
|
||||
|
||||
run "$SECRETS_BIN" push
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "$SECRETS_DIR/.git/hooks/pre-commit" ]
|
||||
}
|
||||
|
||||
@test "rekey reinstalls missing pre-commit hook" {
|
||||
init_with_remote
|
||||
create_project_dir
|
||||
"$SECRETS_BIN" push >/dev/null 2>&1
|
||||
rm "$SECRETS_DIR/.git/hooks/pre-commit"
|
||||
|
||||
run "$SECRETS_BIN" rekey
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "$SECRETS_DIR/.git/hooks/pre-commit" ]
|
||||
}
|
||||
|
||||
@test "store protections heal is a silent no-op when nothing is missing" {
|
||||
init_with_remote
|
||||
create_project_dir
|
||||
|
||||
run "$SECRETS_BIN" push
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" != *"Restored store .gitignore"* ]]
|
||||
[[ "$output" != *"Reinstalled pre-commit hook"* ]]
|
||||
}
|
||||
|
||||
@test "restored store .gitignore carries the full block/allow globs" {
|
||||
init_with_remote
|
||||
rm "$SECRETS_DIR/.gitignore"
|
||||
create_project_dir
|
||||
"$SECRETS_BIN" push >/dev/null 2>&1
|
||||
|
||||
grep -q "^key.txt$" "$SECRETS_DIR/.gitignore"
|
||||
grep -qF '**/.env' "$SECRETS_DIR/.gitignore"
|
||||
grep -qF '**/.dev.vars' "$SECRETS_DIR/.gitignore"
|
||||
grep -qF '!**/.env.age' "$SECRETS_DIR/.gitignore"
|
||||
grep -qF '!**/.env.*.age' "$SECRETS_DIR/.gitignore"
|
||||
grep -qF '!**/.dev.vars.age' "$SECRETS_DIR/.gitignore"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue