Remove login details before logging stream source (#45398)

* Remove login details before logging stream source

* Convert to str before re

* Use compiled RE

* Add tests and filter log message in worker

* Update import

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* isort

Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
uvjustin
2021-03-23 14:30:45 +08:00
committed by GitHub
parent 55b689b464
commit cd455e296e
4 changed files with 38 additions and 3 deletions

View File

@@ -574,3 +574,18 @@ async def test_update_stream_source(hass):
# Ccleanup
stream.stop()
async def test_worker_log(hass, caplog):
"""Test that the worker logs the url without username and password."""
stream = Stream(hass, "https://abcd:efgh@foo.bar")
stream.add_provider(STREAM_OUTPUT_FORMAT)
with patch("av.open") as av_open:
av_open.side_effect = av.error.InvalidDataError(-2, "error")
segment_buffer = SegmentBuffer(stream.outputs)
stream_worker(
"https://abcd:efgh@foo.bar", {}, segment_buffer, threading.Event()
)
await hass.async_block_till_done()
assert "https://abcd:efgh@foo.bar" not in caplog.text
assert "https://foo.bar" in caplog.text