mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Serve challenge server
This commit is contained in:
@@ -17,4 +17,5 @@ Feature: Challenge
|
||||
Then I sign the certificate signing request csr with private key cert_key and output it as csr_pem in PEM format
|
||||
Then I submit the certificate signing request PEM csr_pem certificate order to the ACME server as order
|
||||
Then I select challenge with type http-01 for domain localhost from order at order as challenge
|
||||
Then I serve challenge response for challenge at localhost
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import requests
|
||||
import glom
|
||||
from acme import client
|
||||
from acme import messages
|
||||
from acme import standalone
|
||||
from behave.runner import Context
|
||||
from behave import given
|
||||
from behave import when
|
||||
@@ -340,4 +341,21 @@ def step_impl(
|
||||
raise ValueError(
|
||||
f"More than one authorization for type {challenge_type!r} found in {var_path!r}"
|
||||
)
|
||||
context.vars[challenge_var] = auths[0]
|
||||
context.vars[challenge_var] = challenges[0]
|
||||
|
||||
|
||||
@then("I serve challenge response for {var_path} at {hostname}")
|
||||
def step_impl(context: Context, var_path: str, hostname: str):
|
||||
if hostname != "localhost":
|
||||
raise ValueError("Currently only localhost is supported")
|
||||
challenge = eval_var(context, var_path, as_json=False)
|
||||
acme_challenge = challenge.chall
|
||||
response, validation = acme_challenge.response_and_validation(
|
||||
context.acme_client.net.key
|
||||
)
|
||||
resource = standalone.HTTP01RequestHandler.HTTP01Resource(
|
||||
chall=acme_challenge, response=response, validation=validation
|
||||
)
|
||||
servers = standalone.HTTP01DualNetworkedServers(("", 8087), resource)
|
||||
# Start client standalone web server.
|
||||
servers.serve_forever()
|
||||
|
||||
Reference in New Issue
Block a user