Remove supports_encryption check from mobile_app (#113490)

helpers already ports nacl at top level so this check can never
be False

```
>>> import sys
>>> from nacl.secret import SecretBox
>>> assert nacl in sys.modules
>>>
```
This commit is contained in:
J. Nick Koston 2024-03-15 00:13:44 -10:00 committed by GitHub
parent 4df2398b9f
commit c69495b64f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 1 additions and 21 deletions

View File

@ -143,16 +143,6 @@ def error_response(
)
def supports_encryption() -> bool:
"""Test if we support encryption."""
try:
import nacl # noqa: F401 pylint: disable=import-outside-toplevel
return True
except OSError:
return False
def safe_registration(registration: dict) -> dict:
"""Return a registration without sensitive values."""
# Sensitive values: webhook_id, secret, cloudhook_url

View File

@ -35,7 +35,6 @@ from .const import (
DOMAIN,
SCHEMA_APP_DATA,
)
from .helpers import supports_encryption
from .util import async_create_cloud_hook
@ -77,7 +76,7 @@ class RegistrationsView(HomeAssistantView):
data[CONF_WEBHOOK_ID] = webhook_id
if data[ATTR_SUPPORTS_ENCRYPTION] and supports_encryption():
if data[ATTR_SUPPORTS_ENCRYPTION]:
data[CONF_SECRET] = secrets.token_hex(SecretBox.KEY_SIZE)
data[CONF_USER_ID] = request["hass_user"].id

View File

@ -100,7 +100,6 @@ from .const import (
DATA_DEVICES,
DOMAIN,
ERR_ENCRYPTION_ALREADY_ENABLED,
ERR_ENCRYPTION_NOT_AVAILABLE,
ERR_ENCRYPTION_REQUIRED,
ERR_INVALID_FORMAT,
ERR_SENSOR_NOT_REGISTERED,
@ -115,7 +114,6 @@ from .helpers import (
error_response,
registration_context,
safe_registration,
supports_encryption,
webhook_response,
)
@ -484,13 +482,6 @@ async def webhook_enable_encryption(
ERR_ENCRYPTION_ALREADY_ENABLED, "Encryption already enabled"
)
if not supports_encryption():
_LOGGER.warning(
"Unable to enable encryption for %s because libsodium is unavailable!",
config_entry.data[ATTR_DEVICE_NAME],
)
return error_response(ERR_ENCRYPTION_NOT_AVAILABLE, "Encryption is unavailable")
secret = secrets.token_hex(SecretBox.KEY_SIZE)
update_data = {