ap-test/common/webfinger.py

33 lines
931 B
Python

# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
from urllib.parse import urlparse, urlunparse
import requests
from .logger import logger
def get_webfinger():
from .env import TARGET_HOST, FTEST_USER
parsed_target_host = urlparse(TARGET_HOST)
webfinger = urlunparse(
(
parsed_target_host.scheme,
parsed_target_host.netloc,
"/.well-known/webfinger",
"",
f"resource=acct:{FTEST_USER}",
"",
)
)
logger.info(f"Query webfinger: {webfinger}")
res = requests.get(webfinger)
logger.debug(
f"webfinger response:\n\nSTATUS: {res.status_code}\n\nHEADERS:\n {res.headers}\n\nRESPONSE PAYLOAD:\n{res.json()}"
)
assert res.status_code == 200
logger.info("[SUCCESS] webfinger query response is HTTP 200")
return res.json()