mirror of
https://github.com/Infisical/infisical.git
synced 2026-01-09 15:38:03 -05:00
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
from behave.runner import Context
|
|
|
|
import httpx
|
|
from behave import given
|
|
from behave import when
|
|
from behave import then
|
|
|
|
|
|
BASE_URL = "http://localhost:8080"
|
|
|
|
|
|
class PkiProject:
|
|
def __init__(self, id: str):
|
|
self.id = id
|
|
|
|
|
|
@given('I have a PKI project as "{project_var}"')
|
|
def step_impl(context: Context, project_var: str):
|
|
# TODO: Fixed value for now, just to make test much easier,
|
|
# we should call infisical API to create such project instead
|
|
# in the future
|
|
project_id = "c051e74c-48a7-4724-832c-d5b496698546"
|
|
context.vars[project_var] = PkiProject(project_id)
|
|
|
|
|
|
@when('I send a {method} request to "{url}"')
|
|
def step_impl(context: Context, method: str, url: str):
|
|
with httpx.Client(base_url=BASE_URL) as client:
|
|
context.response = client.request(method, url.format(**context.vars))
|
|
|
|
|
|
@then('the response header "{header}" should contains non-empty value')
|
|
def step_impl(context: Context, header: str):
|
|
header_value = context.response.headers.get(header)
|
|
assert header_value
|