mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Fix trusted_users group schema (#92847)
* Fix trusted_users group schema * Add tests for CONFIG_SCHEMA
This commit is contained in:
parent
fa366e59e0
commit
46103f56c4
@ -46,7 +46,7 @@ CONFIG_SCHEMA = AUTH_PROVIDER_SCHEMA.extend(
|
||||
[
|
||||
vol.Or(
|
||||
cv.uuid4_hex,
|
||||
vol.Schema({vol.Required(CONF_GROUP): cv.uuid4_hex}),
|
||||
vol.Schema({vol.Required(CONF_GROUP): str}),
|
||||
)
|
||||
],
|
||||
)
|
||||
|
@ -116,6 +116,32 @@ def manager_bypass_login(hass, store, provider_bypass_login):
|
||||
)
|
||||
|
||||
|
||||
async def test_config_schema():
|
||||
"""Test CONFIG_SCHEMA."""
|
||||
# Valid configuration
|
||||
tn_auth.CONFIG_SCHEMA(
|
||||
{
|
||||
"type": "trusted_networks",
|
||||
"trusted_networks": ["192.168.0.1"],
|
||||
"trusted_users": {
|
||||
"192.168.0.1": [
|
||||
"a1ab982744b64757bf80515589258924",
|
||||
{"group": "system-group"},
|
||||
]
|
||||
},
|
||||
}
|
||||
)
|
||||
# Wrong user id format
|
||||
with pytest.raises(vol.Invalid):
|
||||
tn_auth.CONFIG_SCHEMA(
|
||||
{
|
||||
"type": "trusted_networks",
|
||||
"trusted_networks": ["192.168.0.1"],
|
||||
"trusted_users": {"192.168.0.1": ["abcde"]},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
async def test_trusted_networks_credentials(manager, provider) -> None:
|
||||
"""Test trusted_networks credentials related functions."""
|
||||
owner = await manager.async_create_user("test-owner")
|
||||
|
Loading…
x
Reference in New Issue
Block a user