mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 12:27:28 +00:00
Add bdd stuff
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
from behave.runner import Context
|
||||
|
||||
|
||||
def before_all(context: Context):
|
||||
context.vars = {}
|
||||
@@ -0,0 +1,5 @@
|
||||
Feature: Nonce
|
||||
Scenario: Generate a new nonce
|
||||
Given I have a PKI project as "pki_project"
|
||||
When I send a HEAD request to "/v1/pki/acme/profiles/{pki_project.id}/new-nonce"
|
||||
Then the response header "Replay-Nonce" should contains non-empty value
|
||||
@@ -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