mirror of
https://github.com/Matysh/houseplan-card
synced 2026-07-31 08:28:31 +00:00
tests: entry auto-loads after the config flow; traversal assertion checks path segments, not substrings
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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/")
|
||||||
|
|||||||
Reference in New Issue
Block a user