Skip to content

Commit

Permalink
Print product request body
Browse files Browse the repository at this point in the history
  • Loading branch information
helen-brown committed Sep 29, 2023
1 parent f4c6427 commit 1119aef
Showing 1 changed file with 4 additions and 35 deletions.
39 changes: 4 additions & 35 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,27 +117,6 @@ def get_authorised_headers(client_app: Dict, environment: str, _jwt_keys):
return {"Authorization": f'Bearer {token["access_token"]}'}


def check_for_unauthorised_headers(client_app: Dict, environment: str, _jwt_keys):
with pytest.raises(RuntimeError) as exc_info:
client_credentials_config = ClientCredentialsConfig(
environment=environment,
identity_service_base_url=get_oath_url(environment),
client_id=client_app["credentials"][0]["consumerKey"],
jwt_private_key=_jwt_keys["private_key_pem"],
jwt_kid="test-1",
)
client_credentials_authenticator = ClientCredentialsAuthenticator(config=client_credentials_config)
client_credentials_authenticator.get_token()

message = json.loads(str(exc_info.value))
assert message.keys()[0] == 401 # response status_code
assert message["0"]["error"] == "unauthorized_client"
assert (
message["0"]["error_description"]
== "you have tried to request authorization but your application is not configured to use this authorization grant type"
)


def get_token_nhs_login_token_exchange(
test_app,
environment: str,
Expand Down Expand Up @@ -210,10 +189,6 @@ def _create_product(product_name: str, products_api: ApiProductsAPI, proxies: Li
"quotaTimeUnit": "minute",
"scopes": scopes
}

product = json.dumps(body)
print(product)

product = products_api.post_products(body=body)
return product

Expand Down Expand Up @@ -282,7 +257,7 @@ def immunisation_history_app(client: ApigeeClient, jwt_public_key_url: str, requ


@pytest.fixture()
def test_product_and_app(client: ApigeeClient, jwt_public_key_url: str, request):
def test_product_and_app(client: ApigeeClient, service_name: str, environment: str, jwt_public_key_url: str, request):
"""Setup & Teardown an product and app for this api"""
request_params = request.param

Expand All @@ -294,21 +269,15 @@ def test_product_and_app(client: ApigeeClient, jwt_public_key_url: str, request)
if service_name is not None:
proxies.append(service_name)

scopes = request_params["scopes"]

app_name = f"apim-auto-{uuid4()}"
product_name = f"apim-auto-{uuid4()}"

try:
product = _create_product(product_name=product_name, products_api=products_api, proxies=proxies,
scopes=scopes)
except Exception as e:
print(e)
raise RuntimeError("Problem creating product")
product = _create_product(product_name=product_name, products_api=products_api, proxies=proxies,
scopes=request_params.get("scopes", []))

custom_attributes = {
"nhs-login-allowed-proofing-level": request_params[
"requested_proofing_level", ""
"requested_proofing_level"
]
}

Expand Down

0 comments on commit 1119aef

Please sign in to comment.