Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0de6b30eb | ||
|
|
a833665e8b | ||
|
|
f187ac8316 | ||
|
|
726112c48f | ||
|
|
f7a2c60b4e | ||
|
|
04969eb837 | ||
|
|
b2a3cbda1c | ||
|
|
23ddd51e9f | ||
|
|
53a33295dd | ||
|
|
934970d7b4 | ||
|
|
ff753ee980 | ||
|
|
bf163b6c17 | ||
|
|
3917ea6273 |
@@ -2,28 +2,82 @@ name: ABSDEV Framework CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
framework-validation:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
timeout-minutes: 10
|
||||
framework-ci:
|
||||
runs-on: absdev-ci
|
||||
timeout-minutes: 15
|
||||
|
||||
env:
|
||||
PYTHONDONTWRITEBYTECODE: "1"
|
||||
PYTHONUNBUFFERED: "1"
|
||||
ABSDEV_INTEGRATION_TESTS: "0"
|
||||
PYTHONDONTWRITEBYTECODE: "1"
|
||||
|
||||
steps:
|
||||
- name: Checkout framework
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Verify job isolation
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
- name: Verify Python availability
|
||||
run: python3 --version
|
||||
test ! -e /var/run/docker.sock
|
||||
test ! -e /run/docker.sock
|
||||
test ! -e /data/.runner
|
||||
|
||||
- name: Run framework validation
|
||||
test "$(cat /sys/class/net/eth0/mtu)" = "1400"
|
||||
|
||||
grep -E '^NoNewPrivs:[[:space:]]+1$' /proc/self/status
|
||||
|
||||
python3 --version
|
||||
git --version
|
||||
|
||||
python3 -B -c '
|
||||
import sys
|
||||
assert sys.version_info[:2] == (3, 14)
|
||||
print("PASS: Python 3.14")
|
||||
'
|
||||
|
||||
echo "PASS: Job isolation checks"
|
||||
|
||||
- name: Checkout exact revision
|
||||
env:
|
||||
CI_TOKEN: ${{ github.token }}
|
||||
CI_SERVER: ${{ github.server_url }}
|
||||
CI_REPOSITORY: ${{ github.repository }}
|
||||
CI_REVISION: ${{ github.sha }}
|
||||
run: |
|
||||
set -eu
|
||||
umask 077
|
||||
|
||||
test "$CI_SERVER" = "https://git.absdev.net"
|
||||
test "$CI_REPOSITORY" = "mag/absdev-deployment"
|
||||
test -n "$CI_TOKEN"
|
||||
|
||||
printf '%s\n' "$CI_REVISION" |
|
||||
grep -Eq '^[a-f0-9]{40}$'
|
||||
|
||||
git init
|
||||
|
||||
git remote add origin \
|
||||
"$CI_SERVER/$CI_REPOSITORY.git"
|
||||
|
||||
AUTH=$(printf 'x-access-token:%s' "$CI_TOKEN" |
|
||||
base64 -w0)
|
||||
|
||||
GIT_CONFIG_COUNT=1 \
|
||||
GIT_CONFIG_KEY_0=http.extraHeader \
|
||||
GIT_CONFIG_VALUE_0="Authorization: Basic $AUTH" \
|
||||
GIT_TERMINAL_PROMPT=0 \
|
||||
git fetch --no-tags --depth=1 origin "$CI_REVISION"
|
||||
|
||||
unset AUTH CI_TOKEN
|
||||
|
||||
git checkout --detach FETCH_HEAD
|
||||
|
||||
test "$(git rev-parse HEAD)" = "$CI_REVISION"
|
||||
|
||||
echo "PASS: Exact source revision checked out"
|
||||
|
||||
- name: Execute framework CI
|
||||
run: bash scripts/ci-check.sh
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
name: Dedicated Runner Network Acceptance
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
network-acceptance:
|
||||
runs-on: absdev-ci
|
||||
timeout-minutes: 5
|
||||
|
||||
steps:
|
||||
- name: Verify protected network isolation
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
python3 - <<'PY'
|
||||
import socket
|
||||
import concurrent.futures
|
||||
|
||||
targets = [
|
||||
("PEGASUS gateway SSH", "192.168.150.1", 22),
|
||||
("PEGASUS gateway HTTPS", "192.168.150.1", 443),
|
||||
("PEGASUS Cockpit", "192.168.150.1", 9090),
|
||||
("PEGASUS LAN SSH", "192.168.1.2", 22),
|
||||
("PEGASUS MySQL", "192.168.1.2", 3306),
|
||||
("PEGASUS PostgreSQL", "192.168.1.2", 5432),
|
||||
("PEGASUS Redis", "192.168.1.2", 6379),
|
||||
("PEGASUS SFTP", "192.168.1.2", 2222),
|
||||
("PEGASUS rsync", "192.168.1.2", 2225),
|
||||
("Guest SSH via Docker bridge", "172.17.0.1", 22),
|
||||
("Guest SSH via guest IP", "192.168.150.10", 22),
|
||||
("PEGASUS public SSH", "51.194.132.189", 22),
|
||||
("PEGASUS public HTTPS", "51.194.132.189", 443),
|
||||
("ABSDEV public SSH", "217.154.36.101", 22),
|
||||
("ABSDEV public HTTPS", "217.154.36.101", 443),
|
||||
]
|
||||
|
||||
def probe(target):
|
||||
name, host, port = target
|
||||
|
||||
try:
|
||||
with socket.create_connection(
|
||||
(host, port), timeout=3
|
||||
):
|
||||
return name, False
|
||||
except OSError:
|
||||
return name, True
|
||||
|
||||
failures = []
|
||||
|
||||
with concurrent.futures.ThreadPoolExecutor(
|
||||
max_workers=4
|
||||
) as executor:
|
||||
for name, blocked in executor.map(probe, targets):
|
||||
if blocked:
|
||||
print(f"PASS: {name} unavailable")
|
||||
else:
|
||||
print(f"FAIL: {name} reachable")
|
||||
failures.append(name)
|
||||
|
||||
if failures:
|
||||
raise SystemExit(1)
|
||||
|
||||
print(f"PASS: All {len(targets)} protected targets unavailable")
|
||||
PY
|
||||
|
||||
- name: Verify permitted Gitea connectivity
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
curl --fail --silent --show-error \
|
||||
--max-time 15 \
|
||||
https://git.absdev.net/api/v1/version
|
||||
|
||||
echo
|
||||
echo "PASS: Gitea HTTPS connectivity"
|
||||
|
||||
- name: Verify network MTU
|
||||
run: |
|
||||
set -eu
|
||||
test "$(cat /sys/class/net/eth0/mtu)" = "1400"
|
||||
echo "PASS: Network MTU"
|
||||
|
||||
- name: Acceptance result
|
||||
run: |
|
||||
echo "PASS: DEDICATED RUNNER NETWORK ACCEPTANCE"
|
||||
@@ -0,0 +1,101 @@
|
||||
name: Dedicated Runner Security Acceptance
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
security-acceptance:
|
||||
runs-on: absdev-ci
|
||||
timeout-minutes: 5
|
||||
|
||||
steps:
|
||||
- name: Verify runtime
|
||||
run: |
|
||||
set -eu
|
||||
python3 --version
|
||||
node --version
|
||||
git --version
|
||||
echo "PASS: Runtime tools available"
|
||||
|
||||
- name: Verify filesystem isolation
|
||||
run: |
|
||||
set -eu
|
||||
test ! -e /var/run/docker.sock
|
||||
test ! -e /run/docker.sock
|
||||
test ! -e /data/.runner
|
||||
test ! -e /config.yaml
|
||||
echo "PASS: Runner files isolated"
|
||||
|
||||
- name: Verify process security
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
grep -E '^NoNewPrivs:[[:space:]]+1$' \
|
||||
/proc/self/status
|
||||
|
||||
python3 - <<'PY'
|
||||
from pathlib import Path
|
||||
|
||||
status = {}
|
||||
|
||||
for line in Path("/proc/self/status").read_text().splitlines():
|
||||
if ":" in line:
|
||||
key, value = line.split(":", 1)
|
||||
status[key] = value.strip()
|
||||
|
||||
effective = int(status["CapEff"], 16)
|
||||
|
||||
restricted = {
|
||||
"CAP_SYS_MODULE": 16,
|
||||
"CAP_SYS_PTRACE": 19,
|
||||
"CAP_SYS_ADMIN": 21
|
||||
}
|
||||
|
||||
for name, bit in restricted.items():
|
||||
assert not effective & (1 << bit), name
|
||||
print(f"PASS: {name} unavailable")
|
||||
|
||||
assert status["Seccomp"] == "2"
|
||||
print("PASS: Seccomp filtering")
|
||||
PY
|
||||
|
||||
- name: Verify memory limits
|
||||
run: |
|
||||
set -eu
|
||||
cat /sys/fs/cgroup/memory.max
|
||||
test "$(cat /sys/fs/cgroup/memory.max)" = "2147483648"
|
||||
echo "PASS: 2 GiB memory limit"
|
||||
|
||||
- name: Verify CPU limits
|
||||
run: |
|
||||
set -eu
|
||||
cat /sys/fs/cgroup/cpu.max
|
||||
read quota period < /sys/fs/cgroup/cpu.max
|
||||
test "$quota" -eq "$((period * 2))"
|
||||
echo "PASS: Two CPU limit"
|
||||
|
||||
- name: Verify process limits
|
||||
run: |
|
||||
set -eu
|
||||
cat /sys/fs/cgroup/pids.max
|
||||
test "$(cat /sys/fs/cgroup/pids.max)" = "512"
|
||||
echo "PASS: 512 process limit"
|
||||
|
||||
- name: Verify network configuration
|
||||
run: |
|
||||
set -eu
|
||||
test "$(cat /sys/class/net/eth0/mtu)" = "1400"
|
||||
echo "PASS: Network MTU"
|
||||
|
||||
- name: Verify writable workspace
|
||||
run: |
|
||||
set -eu
|
||||
FILE=$(mktemp "$PWD/acceptance-XXXXXX")
|
||||
printf 'acceptance-test\n' > "$FILE"
|
||||
grep -Fx acceptance-test "$FILE"
|
||||
rm "$FILE"
|
||||
echo "PASS: Workspace operational"
|
||||
|
||||
- name: Acceptance result
|
||||
run: |
|
||||
echo "PASS: DEDICATED RUNNER SECURITY ACCEPTANCE"
|
||||
@@ -1,5 +1,43 @@
|
||||
# Changelog
|
||||
|
||||
## [0.1.0-dev.2] - 2026-11-27
|
||||
|
||||
### Added
|
||||
|
||||
- Permanent MySQL 8.4.13 integration qualification.
|
||||
- Permanent PostgreSQL 18.7 integration qualification.
|
||||
- Independent database server and cluster recovery tests.
|
||||
- PostgreSQL transactional restoration rollback tests.
|
||||
- MySQL partial restoration recovery tests.
|
||||
- Database authentication and execution failure tests.
|
||||
- Backup corruption and integrity validation tests.
|
||||
- Dedicated database qualification documentation.
|
||||
|
||||
### Improved
|
||||
|
||||
- Strict backup manifest metadata validation.
|
||||
- Duplicate JSON key rejection.
|
||||
- Timestamp and database identity validation.
|
||||
- Authenticated database readiness checks.
|
||||
- Backup publication safety and failure cleanup.
|
||||
- Dedicated isolated CI runner qualification.
|
||||
|
||||
### Verification
|
||||
|
||||
- 873 permanent framework unit tests passed.
|
||||
- 105 grouped database integration checks passed.
|
||||
- MySQL: 40 grouped checks.
|
||||
- PostgreSQL: 65 grouped checks.
|
||||
- Four original and recovery backups verified.
|
||||
- Independent database server restoration verified.
|
||||
- Complete qualification evidence archived.
|
||||
|
||||
### Safety
|
||||
|
||||
- Production execution remains disabled.
|
||||
- This release is for development and qualification only.
|
||||
- No production deployment readiness claim is made.
|
||||
|
||||
## 0.1.0-dev.1 — 2026-11-26
|
||||
|
||||
Initial development preview.
|
||||
|
||||
@@ -73,3 +73,24 @@ Remote Gitea CI execution remains unverified.
|
||||
|
||||
Private reference files, runtime records and credentials
|
||||
must not be included in distributable packages.
|
||||
|
||||
|
||||
## Database qualification
|
||||
|
||||
The development framework has passed real database
|
||||
backup and restoration qualification using isolated
|
||||
MySQL 8.4.13 and PostgreSQL 18.7 instances.
|
||||
|
||||
- Framework unit tests: 873 passed.
|
||||
- MySQL grouped integration checks: 40 passed.
|
||||
- PostgreSQL grouped integration checks: 65 passed.
|
||||
- Combined grouped integration checks: 105 passed.
|
||||
|
||||
Independent database recovery, backup failure handling
|
||||
and backup integrity have been verified.
|
||||
|
||||
See [Database Qualification](docs/DATABASE-QUALIFICATION.md)
|
||||
for the qualification scope, evidence and remaining limitations.
|
||||
|
||||
This development release is not approved for production
|
||||
deployment execution.
|
||||
|
||||
+64
-3
@@ -28,6 +28,45 @@ def require(condition, message):
|
||||
raise BackupError(message)
|
||||
|
||||
|
||||
def unique_json_object(pairs):
|
||||
|
||||
result = {}
|
||||
|
||||
for key, value in pairs:
|
||||
|
||||
require(
|
||||
key not in result,
|
||||
"Duplicate backup manifest field",
|
||||
)
|
||||
|
||||
result[key] = value
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def validate_timestamp(value):
|
||||
|
||||
require(
|
||||
isinstance(value, str)
|
||||
and bool(value)
|
||||
and "T" in value,
|
||||
"Invalid backup timestamp",
|
||||
)
|
||||
|
||||
try:
|
||||
parsed = datetime.fromisoformat(value)
|
||||
except ValueError as error:
|
||||
raise BackupError(
|
||||
"Invalid backup timestamp"
|
||||
) from error
|
||||
|
||||
require(
|
||||
parsed.tzinfo is not None
|
||||
and parsed.utcoffset() is not None,
|
||||
"Backup timestamp requires timezone",
|
||||
)
|
||||
|
||||
|
||||
def sync_directory(path):
|
||||
|
||||
fd = os.open(
|
||||
@@ -149,8 +188,18 @@ class BackupEngine:
|
||||
|
||||
raw = output.getvalue().decode("utf-8").strip()
|
||||
|
||||
return self.validate_identity(raw)
|
||||
|
||||
def validate_identity(self, raw):
|
||||
|
||||
require(
|
||||
raw and "\n" not in raw,
|
||||
isinstance(raw, str)
|
||||
and bool(raw.strip())
|
||||
and raw == raw.strip()
|
||||
and all(
|
||||
char == chr(9) or char.isprintable()
|
||||
for char in raw
|
||||
),
|
||||
"Invalid database identity output",
|
||||
)
|
||||
|
||||
@@ -187,7 +236,7 @@ class BackupEngine:
|
||||
if driver == "mysql":
|
||||
|
||||
require(
|
||||
bool(parts[2]),
|
||||
bool(parts[2].strip()),
|
||||
"Missing database server identity",
|
||||
)
|
||||
|
||||
@@ -369,7 +418,10 @@ class BackupEngine:
|
||||
|
||||
with os.fdopen(fd, "r", encoding="utf-8") as handle:
|
||||
|
||||
manifest = json.load(handle)
|
||||
manifest = json.load(
|
||||
handle,
|
||||
object_pairs_hook=unique_json_object,
|
||||
)
|
||||
|
||||
fields = {
|
||||
"format_version",
|
||||
@@ -401,6 +453,15 @@ class BackupEngine:
|
||||
"filename": self.filename,
|
||||
}
|
||||
|
||||
require(
|
||||
type(manifest["format_version"]) is int,
|
||||
"Invalid backup format version",
|
||||
)
|
||||
|
||||
validate_timestamp(manifest["created_at"])
|
||||
|
||||
self.validate_identity(manifest["identity"])
|
||||
|
||||
for key, value in expected.items():
|
||||
|
||||
require(
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
# Database Integration Qualification
|
||||
|
||||
## Qualification status
|
||||
|
||||
- Qualification date: 2026-11-27
|
||||
- Development release: 0.1.0-dev.2
|
||||
- Qualified source revision:
|
||||
a833665e8bc54584f4533533bdca1434d437651f
|
||||
- Environment: dedicated isolated ABSDEV-CI virtual machine
|
||||
- Python: 3.14.4
|
||||
|
||||
## Combined results
|
||||
|
||||
| Qualification category | Passed |
|
||||
|---|---:|
|
||||
| Framework unit tests | 873/873 |
|
||||
| MySQL data and schema comparisons | 6/6 |
|
||||
| MySQL failure handling | 13/13 |
|
||||
| MySQL partial restoration recovery | 10/10 |
|
||||
| MySQL independent server recovery | 11/11 |
|
||||
| PostgreSQL successful-path qualification | 26/26 |
|
||||
| PostgreSQL failure handling | 14/14 |
|
||||
| PostgreSQL transactional recovery | 11/11 |
|
||||
| PostgreSQL independent cluster recovery | 14/14 |
|
||||
| Combined grouped database checks | 105/105 |
|
||||
|
||||
The 105 grouped checks are assertions and verification
|
||||
categories executed by two permanent integration test cases.
|
||||
They are not 105 independent unittest test cases.
|
||||
|
||||
## Qualified database engines
|
||||
|
||||
### MySQL
|
||||
|
||||
- Version: 8.4.13
|
||||
- Backup format: SQL
|
||||
- Backup utility: mysqldump
|
||||
- Restore utility: mysql
|
||||
- Independent server restoration: verified
|
||||
|
||||
Pinned image:
|
||||
|
||||
mysql@sha256:8c233bad33d520a7aae1c1e619c3a9775f4a1ba2d463d692fada04ec7f40be00
|
||||
|
||||
### PostgreSQL
|
||||
|
||||
- Version: 18.7
|
||||
- Backup format: PostgreSQL custom archive
|
||||
- Backup utility: pg_dump
|
||||
- Restore utility: pg_restore
|
||||
- Transactional restoration rollback: verified
|
||||
- Independent cluster restoration: verified
|
||||
|
||||
Pinned image:
|
||||
|
||||
postgres@sha256:e742a2668255221388004f3a42b6150a2103f5054ab3a4a93ae9e4f01e551c35
|
||||
|
||||
## Backup engine qualification
|
||||
|
||||
Verified behaviour includes:
|
||||
|
||||
- Strict manifest metadata validation.
|
||||
- Duplicate JSON key rejection.
|
||||
- Timestamp and database identity validation.
|
||||
- SHA-256 backup integrity verification.
|
||||
- Rejection of corrupted backup files.
|
||||
- Failed backup publication prevention.
|
||||
- Partial backup cleanup.
|
||||
- Bounded command execution.
|
||||
- Rejection of unauthorised execution.
|
||||
- Successful backup creation following failures.
|
||||
|
||||
## Disaster recovery
|
||||
|
||||
Both database engines were restored onto independently
|
||||
initialised replacement containers after removal of
|
||||
their original disposable database instances.
|
||||
|
||||
Independent storage and database server identities
|
||||
were verified.
|
||||
|
||||
Data, schema definitions and database constraints were
|
||||
compared with the original database snapshots.
|
||||
|
||||
PostgreSQL identity sequences continued correctly
|
||||
after restoration.
|
||||
|
||||
## Failure recovery
|
||||
|
||||
MySQL qualification demonstrated detection of committed
|
||||
partial restoration changes and recovery through
|
||||
recreation of an isolated restoration target.
|
||||
|
||||
PostgreSQL qualification demonstrated transactional
|
||||
rollback following a genuine pg_restore failure,
|
||||
including preservation of existing target data.
|
||||
|
||||
## Integration execution
|
||||
|
||||
Integration tests require:
|
||||
|
||||
- Dedicated ABSDEV-CI hostname.
|
||||
- Explicit ABSDEV_INTEGRATION_TESTS=1.
|
||||
- Verified immutable database images.
|
||||
- An isolated local Docker engine.
|
||||
- Sufficient available memory.
|
||||
- No conflicting integration containers.
|
||||
|
||||
Database containers use restricted resources,
|
||||
no external network connectivity, private storage
|
||||
and verified ownership labels.
|
||||
|
||||
Integration tests must not be executed against
|
||||
production database instances.
|
||||
|
||||
## Qualification evidence
|
||||
|
||||
The combined qualification completed successfully
|
||||
with exit status zero.
|
||||
|
||||
Evidence includes:
|
||||
|
||||
- Complete qualified framework source snapshot.
|
||||
- Both database integration reports.
|
||||
- Combined qualification report.
|
||||
- Framework regression log.
|
||||
- Integration execution log.
|
||||
- Four verified database backups.
|
||||
- Backup manifests.
|
||||
- Source and archive SHA-256 checksums.
|
||||
|
||||
Archive identifier:
|
||||
|
||||
database-final-20261127-151556
|
||||
|
||||
All 96 archived files passed checksum verification.
|
||||
|
||||
## Remaining limitations
|
||||
|
||||
This qualification does not establish production readiness.
|
||||
|
||||
Outstanding areas include:
|
||||
|
||||
- Least-privilege production database accounts.
|
||||
- Independently enforced database server identity.
|
||||
- Cross-version database restoration.
|
||||
- Large database performance.
|
||||
- Backup authenticity beyond checksum integrity.
|
||||
- Trusted production runtime adapters.
|
||||
- Complete application and release provenance.
|
||||
- Production HTTP and worker containment.
|
||||
- Interrupted deployment reconciliation.
|
||||
- End-to-end application deployment qualification.
|
||||
|
||||
Production deployment, migration, restoration,
|
||||
provisioning and permanent deletion remain disabled.
|
||||
@@ -40,3 +40,20 @@ Production execution must remain disabled until
|
||||
the applicable gates have been satisfied.
|
||||
|
||||
Do not run database integration tests on ABSDEV.
|
||||
|
||||
|
||||
## Database qualification milestone - 2026-11-27
|
||||
|
||||
Real isolated database integration qualification has
|
||||
been completed for MySQL 8.4.13 and PostgreSQL 18.7.
|
||||
|
||||
The combined qualification passed 105 grouped integration
|
||||
checks alongside 873 framework unit tests.
|
||||
|
||||
This closes the development database qualification
|
||||
milestone but does not close the production readiness gates.
|
||||
|
||||
See [Database Qualification](DATABASE-QUALIFICATION.md)
|
||||
for verified capabilities and remaining limitations.
|
||||
|
||||
Production execution remains disabled.
|
||||
|
||||
+866
-61
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,150 @@
|
||||
"""Strict backup manifest validation regression tests."""
|
||||
|
||||
import json
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
|
||||
from core.backup import BackupEngine, BackupError
|
||||
|
||||
|
||||
class BackupManifestValidationTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(temp.cleanup)
|
||||
|
||||
self.root = Path(temp.name)
|
||||
self.root.chmod(0o700)
|
||||
|
||||
self.configure("mysql")
|
||||
|
||||
def configure(self, driver):
|
||||
self.adapter = SimpleNamespace(
|
||||
database={
|
||||
"driver": driver,
|
||||
"name": "example_db",
|
||||
"username": "example_app",
|
||||
"container": "test-database",
|
||||
},
|
||||
identity_command=lambda: ["identity"],
|
||||
backup_command=lambda: ["backup"],
|
||||
)
|
||||
|
||||
identity = (
|
||||
b"example_db\texample_app@localhost\tserver-uuid"
|
||||
if driver == "mysql"
|
||||
else b"example_db|example_app"
|
||||
)
|
||||
|
||||
def runner(command, output):
|
||||
if command == ["identity"]:
|
||||
output.write(identity)
|
||||
elif command == ["backup"]:
|
||||
output.write(b"synthetic backup data")
|
||||
else:
|
||||
raise AssertionError("Unexpected command")
|
||||
|
||||
self.engine = BackupEngine(
|
||||
self.adapter, self.root, runner
|
||||
)
|
||||
|
||||
self.backup = self.engine.create()
|
||||
self.manifest = self.backup / "manifest.json"
|
||||
|
||||
def reject(self, key, value):
|
||||
data = json.loads(self.manifest.read_text())
|
||||
data[key] = value
|
||||
self.manifest.write_text(json.dumps(data))
|
||||
|
||||
with self.assertRaises(BackupError):
|
||||
self.engine.verify(self.backup)
|
||||
|
||||
def test_valid_mysql_manifest(self):
|
||||
self.engine.verify(self.backup)
|
||||
|
||||
def test_valid_postgresql_manifest(self):
|
||||
self.configure("pgsql")
|
||||
self.engine.verify(self.backup)
|
||||
|
||||
def test_null_timestamp(self):
|
||||
self.reject("created_at", None)
|
||||
|
||||
def test_empty_timestamp(self):
|
||||
self.reject("created_at", "")
|
||||
|
||||
def test_numeric_timestamp(self):
|
||||
self.reject("created_at", 123)
|
||||
|
||||
def test_invalid_timestamp(self):
|
||||
self.reject("created_at", "not-a-date")
|
||||
|
||||
def test_date_without_time(self):
|
||||
self.reject("created_at", "2026-11-27")
|
||||
|
||||
def test_timestamp_without_timezone(self):
|
||||
self.reject(
|
||||
"created_at", "2026-11-27T08:49:03"
|
||||
)
|
||||
|
||||
def test_impossible_timestamp(self):
|
||||
self.reject(
|
||||
"created_at", "2026-02-30T08:49:03+00:00"
|
||||
)
|
||||
|
||||
def test_null_identity(self):
|
||||
self.reject("identity", None)
|
||||
|
||||
def test_empty_identity(self):
|
||||
self.reject("identity", "")
|
||||
|
||||
def test_whitespace_identity(self):
|
||||
self.reject("identity", " ")
|
||||
|
||||
def test_numeric_identity(self):
|
||||
self.reject("identity", 123)
|
||||
|
||||
def test_wrong_database_identity(self):
|
||||
self.reject(
|
||||
"identity",
|
||||
"other_db\texample_app@localhost\tserver-uuid"
|
||||
)
|
||||
|
||||
def test_wrong_account_identity(self):
|
||||
self.reject(
|
||||
"identity",
|
||||
"example_db\tother_app@localhost\tserver-uuid"
|
||||
)
|
||||
|
||||
def test_missing_mysql_server_identity(self):
|
||||
self.reject(
|
||||
"identity",
|
||||
"example_db\texample_app@localhost\t"
|
||||
)
|
||||
|
||||
def test_identity_control_character(self):
|
||||
self.reject(
|
||||
"identity",
|
||||
"example_db\texample_app@localhost\tserver\nuuid"
|
||||
)
|
||||
|
||||
def test_invalid_postgresql_identity(self):
|
||||
self.configure("pgsql")
|
||||
self.reject("identity", "example_db|wrong_account")
|
||||
|
||||
def test_boolean_format_version(self):
|
||||
self.reject("format_version", True)
|
||||
|
||||
def test_duplicate_json_key(self):
|
||||
data = self.manifest.read_text().strip()
|
||||
|
||||
# Both values are valid. This tests duplicate-key
|
||||
# rejection rather than invalid field values.
|
||||
data = data[:-1] + ', "format_version": 1}'
|
||||
|
||||
self.manifest.write_text(data)
|
||||
|
||||
with self.assertRaises(BackupError):
|
||||
self.engine.verify(self.backup)
|
||||
Reference in New Issue
Block a user