Escape media_content_id in media player proxy (#77811)
* Escape media_content_id in media player proxy * Change usage in kodi * Change usage in roku * Change usage in sonos * Add test * Add comment * Change path regex instead of double quoting * Use .+ instead of .*
This commit is contained in:
parent
c3b2e03ce8
commit
9b2d17cd00
5 changed files with 43 additions and 10 deletions
|
@ -280,3 +280,34 @@ async def test_enqueue_alert_exclusive(hass):
|
|||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
|
||||
async def test_get_async_get_browse_image_quoting(
|
||||
hass, hass_client_no_auth, hass_ws_client
|
||||
):
|
||||
"""Test get browse image using media_content_id with special characters.
|
||||
|
||||
async_get_browse_image() should get called with the same string that is
|
||||
passed into get_browse_image_url().
|
||||
"""
|
||||
await async_setup_component(
|
||||
hass, "media_player", {"media_player": {"platform": "demo"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
entity_comp = hass.data.get("entity_components", {}).get("media_player")
|
||||
assert entity_comp
|
||||
|
||||
player = entity_comp.get_entity("media_player.bedroom")
|
||||
assert player
|
||||
|
||||
client = await hass_client_no_auth()
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.media_player.MediaPlayerEntity."
|
||||
"async_get_browse_image",
|
||||
) as mock_browse_image:
|
||||
media_content_id = "a/b c/d+e%2Fg{}"
|
||||
url = player.get_browse_image_url("album", media_content_id)
|
||||
await client.get(url)
|
||||
mock_browse_image.assert_called_with("album", media_content_id, None)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue