Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion blinkpy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ async def request_login(
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": DEFAULT_USER_AGENT,
"hardware_id": login_data.get("device_id", "Blinkpy"),
"hardware_id": auth.hardware_id,
"2fa-code": login_data.get("2fa_code") or "",
}

Expand Down
4 changes: 2 additions & 2 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ async def test_query_refresh_token_exists(
headers={
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": const.DEFAULT_USER_AGENT,
"hardware_id": const.DEVICE_ID,
"hardware_id": self.auth.hardware_id,
"2fa-code": "",
},
timeout=10,
Expand Down Expand Up @@ -308,7 +308,7 @@ async def test_query_auth_expired(
headers={
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": const.DEFAULT_USER_AGENT,
"hardware_id": const.DEVICE_ID,
"hardware_id": self.auth.hardware_id,
"2fa-code": "",
},
timeout=10,
Expand Down
15 changes: 15 additions & 0 deletions tests/test_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,21 @@ async def test_complete_2fa_login():
assert not hasattr(auth, "_oauth_code_verifier")


@pytest.mark.asyncio
async def test_request_login_sends_auth_hardware_id_header():
"""Test that request_login sends auth.hardware_id as the hardware_id header."""
auth = Mock()
auth.query = AsyncMock(return_value=Mock(status=200))
auth.refresh_token = "refresh_token"
auth.hardware_id = "726D586E-6A27-49E4-B61B-1BB070908899"

login_data = {"username": "foo", "password": "bar"}
await api.request_login(auth, "https://example.com", login_data, is_refresh=True)

headers = auth.query.call_args.kwargs["headers"]
assert headers["hardware_id"] == auth.hardware_id


@pytest.mark.asyncio
async def test_oauth_refresh_token_failure():
"""Test refresh token request failing with a non-200 status."""
Expand Down
Loading