-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapi_key_test.py
More file actions
47 lines (32 loc) · 1.34 KB
/
api_key_test.py
File metadata and controls
47 lines (32 loc) · 1.34 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
import pytest
from seam import Seam
from seam.auth import SeamInvalidTokenError
def test_seam_client_from_api_key_returns_instance_authorized_with_api_key(
server,
):
endpoint, seed = server
seam = Seam.from_api_key(seed["seam_apikey1_token"], endpoint=endpoint)
devices = seam.devices.list()
assert len(devices) > 0
def test_seam_client_constructor_returns_instance_authorized_with_api_key(
server,
):
endpoint, seed = server
seam = Seam(api_key=seed["seam_apikey1_token"], endpoint=endpoint)
devices = seam.devices.list()
assert len(devices) > 0
def test_seam_client_constructor_interprets_single_string_argument_as_api_key(server):
_, seed = server
seam = Seam(seed["seam_apikey1_token"])
assert seam is not None
with pytest.raises(SeamInvalidTokenError, match=r"api_key"):
Seam("some-invalid-key-format")
def test_seam_client_checks_api_key_format():
with pytest.raises(SeamInvalidTokenError, match=r"Unknown"):
Seam.from_api_key("some-invalid-key-format")
with pytest.raises(SeamInvalidTokenError, match=r"JWT"):
Seam.from_api_key("ey")
with pytest.raises(SeamInvalidTokenError, match=r"Client Session Token"):
Seam.from_api_key("seam_cst_token")
with pytest.raises(SeamInvalidTokenError, match=r"Access Token"):
Seam.from_api_key("seam_at")