mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-11-04 22:51:54 +00:00
Reduce AuthenticationExceptions raising from transports (#740)
* Reduce AuthenticationExceptions raising from transports * Make auth failed test ids easier to read * Test invalid klap response length
This commit is contained in:
@@ -159,7 +159,7 @@ class KlapTransport(BaseTransport):
|
||||
)
|
||||
|
||||
if response_status != 200:
|
||||
raise AuthenticationException(
|
||||
raise SmartDeviceException(
|
||||
f"Device {self._host} responded with {response_status} to handshake1"
|
||||
)
|
||||
|
||||
@@ -167,6 +167,12 @@ class KlapTransport(BaseTransport):
|
||||
remote_seed: bytes = response_data[0:16]
|
||||
server_hash = response_data[16:]
|
||||
|
||||
if len(server_hash) != 32:
|
||||
raise SmartDeviceException(
|
||||
f"Device {self._host} responded with unexpected klap response "
|
||||
+ f"{response_data!r} to handshake1"
|
||||
)
|
||||
|
||||
if _LOGGER.isEnabledFor(logging.DEBUG):
|
||||
_LOGGER.debug(
|
||||
"Handshake1 success at %s. Host is %s, "
|
||||
@@ -260,7 +266,9 @@ class KlapTransport(BaseTransport):
|
||||
)
|
||||
|
||||
if response_status != 200:
|
||||
raise AuthenticationException(
|
||||
# This shouldn't be caused by incorrect
|
||||
# credentials so don't raise AuthenticationException
|
||||
raise SmartDeviceException(
|
||||
f"Device {self._host} responded with {response_status} to handshake2"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user