fix: migrate as durable database owner
All checks were successful
Build and Publish Container Image / build-and-push (push) Successful in 37s
All checks were successful
Build and Publish Container Image / build-and-push (push) Successful in 37s
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a028f0-a42f-7582-89a8-ebaad7343834
This commit is contained in:
parent
7a57d9a30f
commit
4143f7c004
5 changed files with 52 additions and 6 deletions
|
|
@ -4,7 +4,7 @@ from pathlib import Path
|
|||
|
||||
import pytest
|
||||
|
||||
from sbom_nexus.config import database_target
|
||||
from sbom_nexus.config import database_target, migration_role
|
||||
|
||||
|
||||
def test_database_target_prefers_secret_file(monkeypatch, tmp_path: Path) -> None:
|
||||
|
|
@ -23,3 +23,17 @@ def test_database_target_rejects_empty_secret_file(monkeypatch, tmp_path: Path)
|
|||
|
||||
with pytest.raises(RuntimeError, match="is empty"):
|
||||
database_target()
|
||||
|
||||
|
||||
def test_migration_role_accepts_a_postgres_identifier(monkeypatch) -> None:
|
||||
monkeypatch.setenv("SBOM_NEXUS_MIGRATION_ROLE", "sbom_nexus_owner")
|
||||
|
||||
assert migration_role() == "sbom_nexus_owner"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("role", ["owner; DROP DATABASE postgres", "UpperCase", 'bad"role'])
|
||||
def test_migration_role_rejects_unsafe_identifiers(monkeypatch, role: str) -> None:
|
||||
monkeypatch.setenv("SBOM_NEXUS_MIGRATION_ROLE", role)
|
||||
|
||||
with pytest.raises(RuntimeError, match="PostgreSQL identifier"):
|
||||
migration_role()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue