mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-06 12:06:49 +00:00
tools.testing: Add way to re-play recorded queries in gatekeeper
to simplify gatekeeper development add support for DEBUG_INPUT which can be used to report content from files gathered in DEBUG run. Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
This commit is contained in:
parent
1a15990ee1
commit
9f8c8ea851
@ -43,6 +43,10 @@ if os.environ.get("DEBUG", "false") == "true":
|
||||
os.makedirs(DEBUG_DIR)
|
||||
else:
|
||||
DEBUG_DIR = None
|
||||
if os.environ.get("DEBUG_INPUT", "") == "":
|
||||
DEBUG_INPUT = None
|
||||
else:
|
||||
DEBUG_INPUT = os.path.abspath(os.environ["DEBUG_INPUT"])
|
||||
|
||||
|
||||
class Checker:
|
||||
@ -153,6 +157,11 @@ class Checker:
|
||||
def fetch_json_from_url(self, url, task, params=None):
|
||||
"""Fetches URL and reports json output"""
|
||||
print(url, file=sys.stderr)
|
||||
if DEBUG_INPUT:
|
||||
with open(f"{os.path.join(DEBUG_INPUT, task)}.json", "r",
|
||||
encoding="utf8") as inp:
|
||||
output = json.load(inp)
|
||||
else:
|
||||
response = requests.get(url, headers=_GH_HEADERS, params=params,
|
||||
timeout=60)
|
||||
response.raise_for_status()
|
||||
|
Loading…
Reference in New Issue
Block a user