mirror of
https://github.com/python-kasa/python-kasa.git
synced 2026-11-28 08:52:11 +00:00
Add UnsupportedEncryptionError for unsupported encryption schemes (#1866)
Some checks failed
CI / Perform Lint Checks (3.15) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.14 on macos-latest (push) Has been cancelled
CI / Python 3.15 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.14 on ubuntu-latest (push) Has been cancelled
CI / Python 3.15 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
CI / Python 3.14 on windows-latest (push) Has been cancelled
CI / Python 3.15 on windows-latest (push) Has been cancelled
CodeQL Checks / Analyze (python) (push) Has been cancelled
Some checks failed
CI / Perform Lint Checks (3.15) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.14 on macos-latest (push) Has been cancelled
CI / Python 3.15 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.14 on ubuntu-latest (push) Has been cancelled
CI / Python 3.15 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
CI / Python 3.14 on windows-latest (push) Has been cancelled
CI / Python 3.15 on windows-latest (push) Has been cancelled
CodeQL Checks / Analyze (python) (push) Has been cancelled
This commit is contained in:
@@ -209,10 +209,17 @@ async def test_list_update_failed(
|
||||
assert row in res.output.replace("\n", "")
|
||||
|
||||
|
||||
# Unsupported device fixtures failing on their encryption, by fixture id
|
||||
UNSUPPORTED_ENCRYPTION_ROWS = {
|
||||
"unknown_encryption": "ENCRYPTION FOO",
|
||||
"wrong_encryption_smart": "ENCRYPTION IOT",
|
||||
}
|
||||
|
||||
|
||||
async def test_list_unsupported(
|
||||
unsupported_device_info: dict, runner: CliRunner
|
||||
unsupported_device_info: dict, runner: CliRunner, request: pytest.FixtureRequest
|
||||
) -> None:
|
||||
"""Test that device update is called on main."""
|
||||
"""Test that unsupported devices are listed with the reason, if known."""
|
||||
res = await runner.invoke(
|
||||
cli,
|
||||
["--username", "foo", "--password", "bar", "discover", "list"],
|
||||
@@ -223,7 +230,8 @@ async def test_list_unsupported(
|
||||
f"{'HOST':<15} {'MODEL':<9} {'DEVICE FAMILY':<20} {'ENCRYPT':<7} "
|
||||
f"{'HTTPS':<5} {'LV':<3} {'ALIAS'}"
|
||||
)
|
||||
row = f"{'127.0.0.1':<15} UNSUPPORTED DEVICE"
|
||||
reason = UNSUPPORTED_ENCRYPTION_ROWS.get(request.node.callspec.id, "DEVICE")
|
||||
row = f"{'127.0.0.1':<15} UNSUPPORTED {reason}\n"
|
||||
assert header in res.output
|
||||
assert row in res.output
|
||||
|
||||
|
||||
@@ -41,7 +41,11 @@ from kasa.discover import (
|
||||
_DiscoverProtocol,
|
||||
json_dumps,
|
||||
)
|
||||
from kasa.exceptions import AuthenticationError, UnsupportedDeviceError
|
||||
from kasa.exceptions import (
|
||||
AuthenticationError,
|
||||
UnsupportedDeviceError,
|
||||
UnsupportedEncryptionError,
|
||||
)
|
||||
from kasa.iot import IotDevice, IotPlug
|
||||
from kasa.transports.aestransport import AesEncyptionSession
|
||||
from kasa.transports.xortransport import XorEncryption, XorTransport
|
||||
@@ -816,12 +820,10 @@ async def test_connection_parameters_unsupported_encrypt_type():
|
||||
},
|
||||
}
|
||||
with pytest.raises(
|
||||
UnsupportedDeviceError,
|
||||
match=(
|
||||
r"^Device 127\.0\.0\.123 \(SMART\.TAPOROBOVAC\) uses unsupported "
|
||||
r"encryption type TPAP$"
|
||||
),
|
||||
UnsupportedEncryptionError,
|
||||
match=r"encryption type TPAP, enabling third-party compatibility",
|
||||
) as exc_info:
|
||||
Discover._get_connection_parameters(DiscoveryResult.from_dict(result))
|
||||
assert exc_info.value.host == "127.0.0.123"
|
||||
assert exc_info.value.discovery_result
|
||||
assert exc_info.value.encryption_type == "TPAP"
|
||||
|
||||
Reference in New Issue
Block a user