File: test_async_auth.py

package info (click to toggle)
python-homematicip 1.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,796 kB
  • sloc: python: 15,164; makefile: 17; sh: 4
file content (35 lines) | stat: -rw-r--r-- 1,118 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import hashlib

import pytest


@pytest.mark.asyncio
async def test_async_auth_challenge_no_pin(
    no_ssl_fake_async_auth, no_ssl_fake_async_home
):

    auth = no_ssl_fake_async_auth

    sgtin = "3014F711A000000BAD0C0DED"
    devicename = "auth_test"

    await auth.init(sgtin, lookup_url=no_ssl_fake_async_home._connection._lookup_url)
    result = await auth.connectionRequest(devicename)

    # The response to the request should be a json data type (as indicated in the header of
    # the response). But it is actually not. So the return value is none. If there were to be any error
    # an exception would be thrown.
    assert result is None

    assert (await auth.isRequestAcknowledged()) is False
    assert (await auth.isRequestAcknowledged()) is False

    await no_ssl_fake_async_home._connection.api_call("auth/simulateBlueButton")

    assert await auth.isRequestAcknowledged() is True

    token = await auth.requestAuthToken()
    assert token == hashlib.sha512(auth.uuid.encode("utf-8")).hexdigest().upper()

    result_id = await auth.confirmAuthToken(token)
    assert result_id == auth.uuid