Use snapshot assertion for nextdns diagnostics test (#99157)
parent
15de221c3e
commit
fb42042402
|
@ -119,6 +119,7 @@ async def init_integration(hass: HomeAssistant) -> MockConfigEntry:
|
|||
title="Fake Profile",
|
||||
unique_id="xyz12",
|
||||
data={CONF_API_KEY: "fake_api_key", CONF_PROFILE_ID: "xyz12"},
|
||||
entry_id="d9aa37407ddac7b964a99e86312288d6",
|
||||
)
|
||||
|
||||
with patch(
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
{
|
||||
"block_page": false,
|
||||
"cache_boost": true,
|
||||
"cname_flattening": true,
|
||||
"anonymized_ecs": true,
|
||||
"logs": true,
|
||||
"logs_location": "ch",
|
||||
"logs_retention": 720,
|
||||
"web3": true,
|
||||
"allow_affiliate": true,
|
||||
"block_disguised_trackers": true,
|
||||
"ai_threat_detection": true,
|
||||
"block_csam": true,
|
||||
"block_ddns": true,
|
||||
"block_nrd": true,
|
||||
"block_parked_domains": true,
|
||||
"cryptojacking_protection": true,
|
||||
"dga_protection": true,
|
||||
"dns_rebinding_protection": true,
|
||||
"google_safe_browsing": false,
|
||||
"idn_homograph_attacks_protection": true,
|
||||
"threat_intelligence_feeds": true,
|
||||
"typosquatting_protection": true,
|
||||
"block_bypass_methods": true,
|
||||
"safesearch": false,
|
||||
"youtube_restricted_mode": false,
|
||||
"block_9gag": true,
|
||||
"block_amazon": true,
|
||||
"block_bereal": true,
|
||||
"block_blizzard": true,
|
||||
"block_chatgpt": true,
|
||||
"block_dailymotion": true,
|
||||
"block_discord": true,
|
||||
"block_disneyplus": true,
|
||||
"block_ebay": true,
|
||||
"block_facebook": true,
|
||||
"block_fortnite": true,
|
||||
"block_google_chat": true,
|
||||
"block_hbomax": true,
|
||||
"block_hulu": true,
|
||||
"block_imgur": true,
|
||||
"block_instagram": true,
|
||||
"block_leagueoflegends": true,
|
||||
"block_mastodon": true,
|
||||
"block_messenger": true,
|
||||
"block_minecraft": true,
|
||||
"block_netflix": true,
|
||||
"block_pinterest": true,
|
||||
"block_playstation_network": true,
|
||||
"block_primevideo": true,
|
||||
"block_reddit": true,
|
||||
"block_roblox": true,
|
||||
"block_signal": true,
|
||||
"block_skype": true,
|
||||
"block_snapchat": true,
|
||||
"block_spotify": true,
|
||||
"block_steam": true,
|
||||
"block_telegram": true,
|
||||
"block_tiktok": true,
|
||||
"block_tinder": true,
|
||||
"block_tumblr": true,
|
||||
"block_twitch": true,
|
||||
"block_twitter": true,
|
||||
"block_vimeo": true,
|
||||
"block_vk": true,
|
||||
"block_whatsapp": true,
|
||||
"block_xboxlive": true,
|
||||
"block_youtube": true,
|
||||
"block_zoom": true,
|
||||
"block_dating": true,
|
||||
"block_gambling": true,
|
||||
"block_online_gaming": true,
|
||||
"block_piracy": true,
|
||||
"block_porn": true,
|
||||
"block_social_networks": true,
|
||||
"block_video_streaming": true
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
# serializer version: 1
|
||||
# name: test_entry_diagnostics
|
||||
dict({
|
||||
'config_entry': dict({
|
||||
'data': dict({
|
||||
'api_key': '**REDACTED**',
|
||||
'profile_id': '**REDACTED**',
|
||||
}),
|
||||
'disabled_by': None,
|
||||
'domain': 'nextdns',
|
||||
'entry_id': 'd9aa37407ddac7b964a99e86312288d6',
|
||||
'options': dict({
|
||||
}),
|
||||
'pref_disable_new_entities': False,
|
||||
'pref_disable_polling': False,
|
||||
'source': 'user',
|
||||
'title': 'Fake Profile',
|
||||
'unique_id': '**REDACTED**',
|
||||
'version': 1,
|
||||
}),
|
||||
'dnssec_coordinator_data': dict({
|
||||
'not_validated_queries': 25,
|
||||
'validated_queries': 75,
|
||||
'validated_queries_ratio': 75.0,
|
||||
}),
|
||||
'encryption_coordinator_data': dict({
|
||||
'encrypted_queries': 60,
|
||||
'encrypted_queries_ratio': 60.0,
|
||||
'unencrypted_queries': 40,
|
||||
}),
|
||||
'ip_versions_coordinator_data': dict({
|
||||
'ipv4_queries': 90,
|
||||
'ipv6_queries': 10,
|
||||
'ipv6_queries_ratio': 10.0,
|
||||
}),
|
||||
'protocols_coordinator_data': dict({
|
||||
'doh3_queries': 15,
|
||||
'doh3_queries_ratio': 13.0,
|
||||
'doh_queries': 20,
|
||||
'doh_queries_ratio': 17.4,
|
||||
'doq_queries': 10,
|
||||
'doq_queries_ratio': 8.7,
|
||||
'dot_queries': 30,
|
||||
'dot_queries_ratio': 26.1,
|
||||
'tcp_queries': 0,
|
||||
'tcp_queries_ratio': 0.0,
|
||||
'udp_queries': 40,
|
||||
'udp_queries_ratio': 34.8,
|
||||
}),
|
||||
'settings_coordinator_data': dict({
|
||||
'ai_threat_detection': True,
|
||||
'allow_affiliate': True,
|
||||
'anonymized_ecs': True,
|
||||
'block_9gag': True,
|
||||
'block_amazon': True,
|
||||
'block_bereal': True,
|
||||
'block_blizzard': True,
|
||||
'block_bypass_methods': True,
|
||||
'block_chatgpt': True,
|
||||
'block_csam': True,
|
||||
'block_dailymotion': True,
|
||||
'block_dating': True,
|
||||
'block_ddns': True,
|
||||
'block_discord': True,
|
||||
'block_disguised_trackers': True,
|
||||
'block_disneyplus': True,
|
||||
'block_ebay': True,
|
||||
'block_facebook': True,
|
||||
'block_fortnite': True,
|
||||
'block_gambling': True,
|
||||
'block_google_chat': True,
|
||||
'block_hbomax': True,
|
||||
'block_hulu': True,
|
||||
'block_imgur': True,
|
||||
'block_instagram': True,
|
||||
'block_leagueoflegends': True,
|
||||
'block_mastodon': True,
|
||||
'block_messenger': True,
|
||||
'block_minecraft': True,
|
||||
'block_netflix': True,
|
||||
'block_nrd': True,
|
||||
'block_online_gaming': True,
|
||||
'block_page': False,
|
||||
'block_parked_domains': True,
|
||||
'block_pinterest': True,
|
||||
'block_piracy': True,
|
||||
'block_playstation_network': True,
|
||||
'block_porn': True,
|
||||
'block_primevideo': True,
|
||||
'block_reddit': True,
|
||||
'block_roblox': True,
|
||||
'block_signal': True,
|
||||
'block_skype': True,
|
||||
'block_snapchat': True,
|
||||
'block_social_networks': True,
|
||||
'block_spotify': True,
|
||||
'block_steam': True,
|
||||
'block_telegram': True,
|
||||
'block_tiktok': True,
|
||||
'block_tinder': True,
|
||||
'block_tumblr': True,
|
||||
'block_twitch': True,
|
||||
'block_twitter': True,
|
||||
'block_video_streaming': True,
|
||||
'block_vimeo': True,
|
||||
'block_vk': True,
|
||||
'block_whatsapp': True,
|
||||
'block_xboxlive': True,
|
||||
'block_youtube': True,
|
||||
'block_zoom': True,
|
||||
'cache_boost': True,
|
||||
'cname_flattening': True,
|
||||
'cryptojacking_protection': True,
|
||||
'dga_protection': True,
|
||||
'dns_rebinding_protection': True,
|
||||
'google_safe_browsing': False,
|
||||
'idn_homograph_attacks_protection': True,
|
||||
'logs': True,
|
||||
'logs_location': 'ch',
|
||||
'logs_retention': 720,
|
||||
'safesearch': False,
|
||||
'threat_intelligence_feeds': True,
|
||||
'typosquatting_protection': True,
|
||||
'web3': True,
|
||||
'youtube_restricted_mode': False,
|
||||
}),
|
||||
'status_coordinator_data': dict({
|
||||
'all_queries': 100,
|
||||
'allowed_queries': 30,
|
||||
'blocked_queries': 20,
|
||||
'blocked_queries_ratio': 20.0,
|
||||
'default_queries': 40,
|
||||
'relayed_queries': 10,
|
||||
}),
|
||||
})
|
||||
# ---
|
|
@ -1,74 +1,21 @@
|
|||
"""Test NextDNS diagnostics."""
|
||||
import json
|
||||
|
||||
from homeassistant.components.diagnostics import REDACTED
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import init_integration
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
async def test_entry_diagnostics(
|
||||
hass: HomeAssistant, hass_client: ClientSessionGenerator
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test config entry diagnostics."""
|
||||
settings = json.loads(load_fixture("settings.json", "nextdns"))
|
||||
|
||||
entry = await init_integration(hass)
|
||||
|
||||
result = await get_diagnostics_for_config_entry(hass, hass_client, entry)
|
||||
|
||||
assert result["config_entry"] == {
|
||||
"entry_id": entry.entry_id,
|
||||
"version": 1,
|
||||
"domain": "nextdns",
|
||||
"title": "Fake Profile",
|
||||
"data": {"profile_id": REDACTED, "api_key": REDACTED},
|
||||
"options": {},
|
||||
"pref_disable_new_entities": False,
|
||||
"pref_disable_polling": False,
|
||||
"source": "user",
|
||||
"unique_id": REDACTED,
|
||||
"disabled_by": None,
|
||||
}
|
||||
assert result["dnssec_coordinator_data"] == {
|
||||
"not_validated_queries": 25,
|
||||
"validated_queries": 75,
|
||||
"validated_queries_ratio": 75.0,
|
||||
}
|
||||
assert result["encryption_coordinator_data"] == {
|
||||
"encrypted_queries": 60,
|
||||
"unencrypted_queries": 40,
|
||||
"encrypted_queries_ratio": 60.0,
|
||||
}
|
||||
assert result["ip_versions_coordinator_data"] == {
|
||||
"ipv6_queries": 10,
|
||||
"ipv4_queries": 90,
|
||||
"ipv6_queries_ratio": 10.0,
|
||||
}
|
||||
assert result["protocols_coordinator_data"] == {
|
||||
"doh_queries": 20,
|
||||
"doh3_queries": 15,
|
||||
"doq_queries": 10,
|
||||
"dot_queries": 30,
|
||||
"tcp_queries": 0,
|
||||
"udp_queries": 40,
|
||||
"doh_queries_ratio": 17.4,
|
||||
"doh3_queries_ratio": 13.0,
|
||||
"doq_queries_ratio": 8.7,
|
||||
"dot_queries_ratio": 26.1,
|
||||
"tcp_queries_ratio": 0.0,
|
||||
"udp_queries_ratio": 34.8,
|
||||
}
|
||||
assert result["settings_coordinator_data"] == settings
|
||||
assert result["status_coordinator_data"] == {
|
||||
"all_queries": 100,
|
||||
"allowed_queries": 30,
|
||||
"blocked_queries": 20,
|
||||
"default_queries": 40,
|
||||
"relayed_queries": 10,
|
||||
"blocked_queries_ratio": 20.0,
|
||||
}
|
||||
assert await get_diagnostics_for_config_entry(hass, hass_client, entry) == snapshot
|
||||
|
|
Loading…
Reference in New Issue