mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 14:28:20 +00:00
Add bdd stuff
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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
|
||||
Reference in New Issue
Block a user