mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
Retry query on 403 after succesful handshake (#785)
If a handshake session becomes invalid the device returns 403 on send and an `AuthenticationError` is raised which prevents a retry, however a retry would be successful. In HA this causes devices to go into reauth flow which is not necessary.
This commit is contained in:
parent
d9d2f1a430
commit
a87fc3b766
@ -57,7 +57,7 @@ from yarl import URL
|
||||
|
||||
from .credentials import Credentials
|
||||
from .deviceconfig import DeviceConfig
|
||||
from .exceptions import AuthenticationError, KasaException
|
||||
from .exceptions import AuthenticationError, KasaException, _RetryableError
|
||||
from .httpclient import HttpClient
|
||||
from .json import loads as json_loads
|
||||
from .protocol import DEFAULT_CREDENTIALS, BaseTransport, get_default_credentials, md5
|
||||
@ -337,7 +337,7 @@ class KlapTransport(BaseTransport):
|
||||
# If we failed with a security error, force a new handshake next time.
|
||||
if response_status == 403:
|
||||
self._handshake_done = False
|
||||
raise AuthenticationError(
|
||||
raise _RetryableError(
|
||||
f"Got a security error from {self._host} after handshake "
|
||||
+ "completed"
|
||||
)
|
||||
|
@ -417,7 +417,7 @@ async def test_query(mocker):
|
||||
pytest.param(
|
||||
(200, 200, 403),
|
||||
True,
|
||||
pytest.raises(AuthenticationError),
|
||||
pytest.raises(_RetryableError),
|
||||
id="request-403-status",
|
||||
),
|
||||
pytest.param(
|
||||
|
Loading…
Reference in New Issue
Block a user