Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Send the opentracing span information also to appservices #16227

Merged
14 changes: 8 additions & 6 deletions tests/appservice/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ async def get_json(
headers: Mapping[Union[str, bytes], Sequence[Union[str, bytes]]],
clokep marked this conversation as resolved.
Show resolved Hide resolved
) -> List[JsonDict]:
# Ensure the access token is passed as a header.
if not headers or not headers.get("Authorization"):
clokep marked this conversation as resolved.
Show resolved Hide resolved
if not headers or not headers.get(b"Authorization"):
raise RuntimeError("Access token not provided")
# ... and not as a query param
if b"access_token" in args:
raise RuntimeError(
"Access token should not be passed as a query param."
)

self.assertEqual(headers.get("Authorization"), [f"Bearer {TOKEN}"])
self.assertEqual(headers.get(b"Authorization"), [f"Bearer {TOKEN}".encode()])
self.request_url = url
if url == URL_USER:
return SUCCESS_RESULT_USER
Expand Down Expand Up @@ -152,11 +152,12 @@ async def get_json(
# Ensure the access token is passed as a both a query param and in the headers.
if not args.get(b"access_token"):
raise RuntimeError("Access token should be provided in query params.")
if not headers or not headers.get("Authorization"):
if not headers or not headers.get(b"Authorization"):
raise RuntimeError("Access token should be provided in auth headers.")

self.assertEqual(args.get(b"access_token"), TOKEN)
self.assertEqual(headers.get("Authorization"), [f"Bearer {TOKEN}"])
self.assertEqual(headers.get(b"Authorization"),
[f"Bearer {TOKEN}".encode()])
self.request_url = url
if url == URL_USER:
return SUCCESS_RESULT_USER
Expand Down Expand Up @@ -208,10 +209,11 @@ async def post_json_get_json(
headers: Mapping[Union[str, bytes], Sequence[Union[str, bytes]]],
) -> JsonDict:
# Ensure the access token is passed as both a header and query arg.
if not headers.get("Authorization"):
if not headers.get(b"Authorization"):
raise RuntimeError("Access token not provided")

self.assertEqual(headers.get("Authorization"), [f"Bearer {TOKEN}"])
self.assertEqual(headers.get(b"Authorization"),
[f"Bearer {TOKEN}".encode()])
return RESPONSE

# We assign to a method, which mypy doesn't like.
Expand Down
Loading