Increase test coverage for template sandbox (#39750)
This commit is contained in:
parent
ae5d8f4d64
commit
5e83feeabf
1 changed files with 15 additions and 0 deletions
|
@ -2306,3 +2306,18 @@ def test_is_template_string():
|
|||
assert template.is_template_string("{# a comment #} Hey") is True
|
||||
assert template.is_template_string("1") is False
|
||||
assert template.is_template_string("Some Text") is False
|
||||
|
||||
|
||||
async def test_protected_blocked(hass):
|
||||
"""Test accessing __getattr__ produces a template error."""
|
||||
tmp = template.Template('{{ states.__getattr__("any") }}', hass)
|
||||
with pytest.raises(TemplateError):
|
||||
tmp.async_render()
|
||||
|
||||
tmp = template.Template('{{ states.sensor.__getattr__("any") }}', hass)
|
||||
with pytest.raises(TemplateError):
|
||||
tmp.async_render()
|
||||
|
||||
tmp = template.Template('{{ states.sensor.any.__getattr__("any") }}', hass)
|
||||
with pytest.raises(TemplateError):
|
||||
tmp.async_render()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue