Skip to content

Commit

Permalink
fix: bump pycryptodomex
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernst79 committed Jan 9, 2024
1 parent 1d403f0 commit 213c3c1
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
fail-fast: false
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
os:
- ubuntu-latest
runs-on: ${{ matrix.os }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
labels:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12
- name: Install labels
run: pip install labels
- name: Sync config with Github
Expand Down
27 changes: 13 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: debug-statements
- id: check-builtin-literals
Expand All @@ -28,39 +28,38 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: debug-statements
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
args: ["--tab-width", "2"]
# - repo: https://github.com/pre-commit/mirrors-prettier
# rev: v3.1.0
# hooks:
# - id: prettier
- repo: https://github.com/asottile/pyupgrade
rev: v3.4.0
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.3.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.12.1
hooks:
- id: black
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
rev: v2.2.6
hooks:
- id: codespell
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.0.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies: []
- repo: https://github.com/PyCQA/bandit
rev: 1.7.4
rev: 1.7.6
hooks:
- id: bandit
args: [-x, tests]
22 changes: 21 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bleak-retry-connector = ">=2.13.0"
bluetooth-data-tools = ">=0.3.1"
bleak = ">=0.19.5"
cryptography = ">=40.0.0"
pycryptodomex = ">=3.18.0"
pycryptodomex = ">=3.19.1"

[tool.poetry.extras]
docs = [
Expand All @@ -48,11 +48,11 @@ docs = [
[tool.poetry.dev-dependencies]
pytest = "^7.0"
pytest-cov = "^3.0"
black = "^23.3.0"
isort = "^5.12.0"
flake8 = "^6.0.0"
mypy = "^1.3.0"
pyupgrade = "^3.4.0"
black = "^23.12.1"
isort = "^5.13.2"
flake8 = "^7.0.0"
mypy = "^1.8.0"
pyupgrade = "^3.15.0"

[tool.semantic_release]
branch = "main"
Expand Down
57 changes: 54 additions & 3 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ def test_blank_advertisements_then_encrypted():
device.update(advertisement)

assert device.encryption_scheme == EncryptionScheme.MIBEACON_4_5
assert device.pending is False
assert device.pending is False # type: ignore


def test_blank_advertisements_then_unencrypted():
"""Test that we can reject empty payloads."""

# NOTE: THIS IS SYNTHETIC TEST DATA - i took a known unecrypted device and flipped
# NOTE: THIS IS SYNTHETIC TEST DATA - i took a known unencrypted device and flipped
# frctrl_object_include, then truncated it to not include the data payload

device = XiaomiBluetoothDeviceData()
Expand Down Expand Up @@ -150,7 +150,7 @@ def test_blank_advertisements_then_encrypted_last_service_info():
def test_blank_advertisements_then_unencrypted_last_service_info():
"""Test that we can capture valid service info records."""

# NOTE: THIS IS SYNTHETIC TEST DATA - i took a known unecrypted device and flipped
# NOTE: THIS IS SYNTHETIC TEST DATA - i took a known unencrypted device and flipped
# frctrl_object_include, then truncated it to not include the data payload

device = XiaomiBluetoothDeviceData()
Expand Down Expand Up @@ -1391,6 +1391,57 @@ def test_Xiaomi_WX08ZM():

def test_Xiaomi_MCCGQ02HL():
"""Test Xiaomi parser for MCCGQ02HL."""
data_string = b"XX\x8b\t\xa3\xae!\x81\xec\xaa\xe4\x0e,U<\x04\x00\x00\xd2\x8aP\x0c"
advertisement = bytes_to_service_info(data_string, address="E4:AA:EC:81:21:AE")
bindkey = "017e52d2684779298709b117c0a75a7b"

device = XiaomiBluetoothDeviceData(bindkey=bytes.fromhex(bindkey))
assert device.supported(advertisement)
assert device.bindkey_verified
assert device.update(advertisement) == SensorUpdate(
title="Door/Window Sensor 21AE (MCCGQ02HL)",
devices={
None: SensorDeviceInfo(
name="Door/Window Sensor 21AE",
manufacturer="Xiaomi",
model="MCCGQ02HL",
hw_version=None,
sw_version="Xiaomi (MiBeacon V5 encrypted)",
)
},
entity_descriptions={
KEY_SIGNAL_STRENGTH: SensorDescription(
device_key=KEY_SIGNAL_STRENGTH,
device_class=DeviceClass.SIGNAL_STRENGTH,
native_unit_of_measurement="dBm",
),
},
entity_values={
KEY_SIGNAL_STRENGTH: SensorValue(
name="Signal Strength", device_key=KEY_SIGNAL_STRENGTH, native_value=-60
),
},
binary_entity_descriptions={
KEY_BINARY_OPENING: BinarySensorDescription(
device_key=KEY_BINARY_OPENING,
device_class=BinarySensorDeviceClass.OPENING,
),
KEY_BINARY_DOOR_LEFT_OPEN: BinarySensorDescription(
device_key=KEY_BINARY_DOOR_LEFT_OPEN,
device_class=ExtendedBinarySensorDeviceClass.DOOR_LEFT_OPEN,
),
},
binary_entity_values={
KEY_BINARY_OPENING: BinarySensorValue(
device_key=KEY_BINARY_OPENING, name="Opening", native_value=True
),
KEY_BINARY_DOOR_LEFT_OPEN: BinarySensorValue(
device_key=KEY_BINARY_DOOR_LEFT_OPEN,
name="Door left open",
native_value=True,
),
},
)


def test_Xiaomi_CGH1():
Expand Down

0 comments on commit 213c3c1

Please sign in to comment.