11import base64
22import hashlib
3-
43import pytest # type: ignore
54from livekit .api import AccessToken , TokenVerifier , WebhookReceiver
65
7- TEST_API_KEY = ' myapikey'
8- TEST_API_SECRET = ' thiskeyistotallyunsafe'
6+ TEST_API_KEY = " myapikey"
7+ TEST_API_SECRET = " thiskeyistotallyunsafe"
98TEST_EVENT = """
109{
1110 "event": "room_started",
@@ -61,7 +60,7 @@ def test_bad_hash():
6160 receiver = WebhookReceiver (token_verifier )
6261
6362 token = AccessToken (TEST_API_KEY , TEST_API_SECRET )
64- hash64 = base64 .b64encode (hashlib .sha256 (' wrong_hash' .encode ()).digest ()).decode ()
63+ hash64 = base64 .b64encode (hashlib .sha256 (" wrong_hash" .encode ()).digest ()).decode ()
6564 token .claims .sha256 = hash64
6665 jwt = token .to_jwt ()
6766 with pytest .raises (Exception ): # Using a broad Exception for existing test
@@ -73,7 +72,7 @@ def test_invalid_body():
7372 receiver = WebhookReceiver (token_verifier )
7473
7574 token = AccessToken (TEST_API_KEY , TEST_API_SECRET )
76- body = ' invalid body'
75+ body = " invalid body"
7776 hash64 = base64 .b64encode (hashlib .sha256 (body .encode ()).digest ()).decode ()
7877 token .claims .sha256 = hash64
7978 jwt = token .to_jwt ()
@@ -88,7 +87,7 @@ def test_malformed_jwt():
8887 token_verifier = TokenVerifier (TEST_API_KEY , TEST_API_SECRET )
8988 receiver = WebhookReceiver (token_verifier )
9089
91- malformed_jwt = ' this.is.not.a.valid.jwt' # A clearly malformed string
90+ malformed_jwt = " this.is.not.a.valid.jwt" # A clearly malformed string
9291
9392 with pytest .raises (Exception ):
94- receiver .receive (TEST_EVENT , malformed_jwt )
93+ receiver .receive (TEST_EVENT , malformed_jwt )
0 commit comments