Review fix: owner-account fallback seed for first setup
Review round 4 (Codex gpt-5.6-terra, HIGH): relying on the flow context alone can leave first setup ownerless. seed_setup_admin gains an owner_ids tier: when no persisted copy and no context user exist, every HA owner account is seeded (owners can already do everything in HA — no privilege escalation). __init__ resolves owners via hass.auth.async_get_users on both setup paths; conftest's hass gains the auth surface. Tests: owner fallback seeds only owners, context user still wins over owners, owner_ids argument validation. Suite: 910 passed.
This commit is contained in:
+5
-1
@@ -29,7 +29,7 @@ import tempfile
|
||||
import weakref
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -281,6 +281,10 @@ def make_hass() -> tuple:
|
||||
config=MagicMock(),
|
||||
config_entries=SimpleNamespace(async_reload=None),
|
||||
)
|
||||
# hass.auth mirrors the real surface the integration reads: an
|
||||
# async_get_users list the tests can repoint at will (the setup
|
||||
# path resolves HA owner accounts as the last-resort admin seed).
|
||||
hass.auth = SimpleNamespace(async_get_users=AsyncMock(return_value=[]))
|
||||
|
||||
def _cleanup_config_dir():
|
||||
import shutil
|
||||
|
||||
Reference in New Issue
Block a user