Skip to content

Commit

Permalink
Fix trusted_users group schema (home-assistant#92847)
Browse files Browse the repository at this point in the history
* Fix trusted_users group schema

* Add tests for CONFIG_SCHEMA
  • Loading branch information
patrickli authored May 23, 2023
1 parent fa366e5 commit 46103f5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion homeassistant/auth/providers/trusted_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
[
vol.Or(
cv.uuid4_hex,
vol.Schema({vol.Required(CONF_GROUP): cv.uuid4_hex}),
vol.Schema({vol.Required(CONF_GROUP): str}),
)
],
)
Expand Down
26 changes: 26 additions & 0 deletions tests/auth/providers/test_trusted_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 46103f5

Please sign in to comment.