tests: entry auto-loads after the config flow; traversal assertion checks path segments, not substrings

This commit is contained in:
Matysh
2026-07-06 00:35:36 +03:00
parent 290b107c49
commit a4b3a4a83f
2 changed files with 6 additions and 4 deletions
+1 -2
View File
@@ -46,8 +46,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
) )
result = await hass.config_entries.flow.async_configure(result["flow_id"], user_input={}) result = await hass.config_entries.flow.async_configure(result["flow_id"], user_input={})
entry = hass.config_entries.async_entries(DOMAIN)[0] entry = hass.config_entries.async_entries(DOMAIN)[0]
await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() # entry is auto-set-up after the flow
await hass.async_block_till_done()
result = await hass.config_entries.options.async_init(entry.entry_id) result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] is FlowResultType.FORM assert result["type"] is FlowResultType.FORM
+5 -2
View File
@@ -53,5 +53,8 @@ async def test_upload_traversal_sanitized(hass: HomeAssistant, hass_client: Clie
resp = await client.post("/api/houseplan/upload", data=fd) resp = await client.post("/api/houseplan/upload", data=fd)
assert resp.status == 200 assert resp.status == 200
body = await resp.json() body = await resp.json()
# both the marker dir and the filename must be flattened to safe names # both the marker dir and the filename must be flattened to safe names:
assert ".." not in body["url"] # no path segment may be exactly ".." (dots inside a name are harmless)
path = body["url"].split("?", 1)[0]
assert all(seg != ".." for seg in path.split("/"))
assert path.startswith("/houseplan_files/files/")