mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Fix diagnostics export for generic camera (#75665)
Fix url redaction and add tests Co-authored-by: Dave T <davet2001@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
"""Test generic (IP camera) diagnostics."""
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.diagnostics import REDACTED
|
||||
from homeassistant.components.generic.diagnostics import redact_url
|
||||
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
|
||||
@@ -22,3 +25,34 @@ async def test_entry_diagnostics(hass, hass_client, setup_entry):
|
||||
"content_type": "image/jpeg",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("url_in", "url_out_expected"),
|
||||
[
|
||||
(
|
||||
"http://www.example.com",
|
||||
"http://www.example.com",
|
||||
),
|
||||
(
|
||||
"http://fred:letmein1@www.example.com/image.php?key=secret2",
|
||||
"http://****:****@www.example.com/****?****=****",
|
||||
),
|
||||
(
|
||||
"http://fred@www.example.com/image.php?key=secret2",
|
||||
"http://****@www.example.com/****?****=****",
|
||||
),
|
||||
(
|
||||
"http://fred@www.example.com/image.php",
|
||||
"http://****@www.example.com/****",
|
||||
),
|
||||
(
|
||||
"http://:letmein1@www.example.com",
|
||||
"http://:****@www.example.com",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_redact_url(url_in, url_out_expected):
|
||||
"""Test url redaction."""
|
||||
url_out = redact_url(url_in)
|
||||
assert url_out == url_out_expected
|
||||
|
||||
Reference in New Issue
Block a user