mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Add more steps
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
import os
|
||||
|
||||
import httpx
|
||||
from behave.runner import Context
|
||||
|
||||
BASE_URL = os.environ.get("INFISICAL_API_URL", "http://localhost:8080")
|
||||
AUTH_TOKEN = os.environ.get("INFISICAL_TOKEN")
|
||||
|
||||
|
||||
def before_all(context: Context):
|
||||
context.vars = {}
|
||||
context.http_client = httpx.Client(
|
||||
base_url=BASE_URL, headers={"Authorization": f"Bearer {AUTH_TOKEN}"}
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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"
|
||||
When I send a HEAD request to "/api/v1/pki/acme/profiles/{pki_project.id}/new-nonce"
|
||||
Then the response status code should be "200"
|
||||
Then the response header "Replay-Nonce" should contains non-empty value
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
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
|
||||
@@ -25,11 +21,21 @@ def step_impl(context: Context, project_var: str):
|
||||
|
||||
@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))
|
||||
context.response = context.http_client.request(method, url.format(**context.vars))
|
||||
|
||||
|
||||
@then('the response status code should be "{expected_status_code}"')
|
||||
def step_impl(context: Context, expected_status_code: int):
|
||||
assert context.response.status_code == expected_status_code, (
|
||||
f"{context.response.status_code} != {expected_status_code}"
|
||||
)
|
||||
|
||||
|
||||
@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
|
||||
print(context.response.headers)
|
||||
assert header_value is not None, f"Header {header} not found in response"
|
||||
assert header_value, (
|
||||
f"Header {header} found in response, but value {header_value:!r} is empty"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user