Import ECS deployed relay source and historical patches (2026-10-27)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
"""Opt-in real PostgreSQL verification in an isolated, newly created schema."""
|
||||
import os
|
||||
import uuid
|
||||
import psycopg
|
||||
import pytest
|
||||
from psycopg import sql
|
||||
from relay.store import Store
|
||||
|
||||
|
||||
@pytest.mark.skipif(not os.environ.get("HN_TEST_DATABASE_URL"), reason="real PostgreSQL URL not supplied")
|
||||
def test_postgres_metadata_and_duplicate_claim(tmp_path):
|
||||
url = os.environ["HN_TEST_DATABASE_URL"]
|
||||
schema = "hn_test_" + uuid.uuid4().hex
|
||||
conn = psycopg.connect(url, autocommit=True)
|
||||
conn.execute(sql.SQL("CREATE SCHEMA {}").format(sql.Identifier(schema)))
|
||||
from psycopg.conninfo import make_conninfo
|
||||
isolated = make_conninfo(url, options=f"-c search_path={schema}")
|
||||
store = None
|
||||
try:
|
||||
store = Store(tmp_path / "unused.sqlite", isolated)
|
||||
store.add_device("host", "cert", "fingerprint")
|
||||
store.bind("host", "owner")
|
||||
assert store.by_owner("owner")["host_id"] == "host"
|
||||
assert store.begin_turn("turn", "owner", "host")
|
||||
assert not store.begin_turn("turn", "owner", "host")
|
||||
store.audit("owner", "instruction", "host", "completed")
|
||||
store.revoke("host")
|
||||
assert not store.by_owner("owner")
|
||||
finally:
|
||||
if store:
|
||||
store.close()
|
||||
conn.execute(sql.SQL("DROP SCHEMA {} CASCADE").format(sql.Identifier(schema)))
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user