Files
awoooi/scripts/backup/tests/test_backup_gitea_full_receipt_contract.py

45 lines
1.4 KiB
Python

from __future__ import annotations
from pathlib import Path
ROOT = Path(__file__).resolve().parents[3]
BACKUP_GITEA = ROOT / "scripts" / "backup" / "backup-gitea.sh"
def test_backup_gitea_writes_full_server_component_receipts() -> None:
text = BACKUP_GITEA.read_text(encoding="utf-8")
assert "write_gitea_full_backup_receipt" in text
assert "awoooi_gitea_full_backup_component_receipt" in text
assert "awoooi_gitea_full_backup_secret_value_collected" in text
assert "awoooi_gitea_full_backup_production_restore_performed" in text
assert "gitea dump -c /data/gitea/conf/app.ini" in text
assert "GITEA_FULL_BACKUP_COMPONENTS" in text
for component in [
"database",
"repositories",
"app_settings",
"lfs_objects",
"package_registry",
"attachments",
"hooks_custom_assets",
]:
assert component in text
def test_backup_gitea_receipt_contract_stays_no_secret_no_restore() -> None:
text = BACKUP_GITEA.read_text(encoding="utf-8")
assert "awoooi_gitea_full_backup_secret_value_collected" in text
assert "awoooi_gitea_full_backup_production_restore_performed" in text
assert (
'secret_value_collected{host=\\"${host}\\",service=\\"${service_label}\\"} 0'
in text
)
assert (
'production_restore_performed{host=\\"${host}\\",service=\\"${service_label}\\"} 0'
in text
)