Skip to content

Commit

Permalink
Renamed fixture to avoid clash
Browse files Browse the repository at this point in the history
  • Loading branch information
helen-brown committed Sep 25, 2023
1 parent 2279dfe commit 065368e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 38 deletions.
75 changes: 38 additions & 37 deletions tests/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ def test_check_immunization_is_secured(service_url):
def test_check_proxy_name():
proxy_name = conftest.get_env("PROXY_NAME")
print(f"PROXY {proxy_name}")
print(f'RODUCT_NAME {conftest.get_env("APIGEE_PRODUCT")}')
print(f'PRODUCT_NAME {conftest.get_env("APIGEE_PRODUCT")}')


@pytest.mark.e2e
@pytest.mark.parametrize(
"test_app",
"immunisation_history_app",
_add_authorised_targets_to_request_params(
[
{"suffixes": ["-application-restricted"]},
Expand All @@ -97,8 +97,8 @@ def test_check_proxy_name():
),
indirect=True,
)
def test_client_credentials_happy_path(test_app, service_url, environment, _jwt_keys):
authorised_headers = conftest.get_authorised_headers(test_app, environment, _jwt_keys)
def test_client_credentials_happy_path(immunisation_history_app, service_url, environment, _jwt_keys):
authorised_headers = conftest.get_authorised_headers(immunisation_history_app, environment, _jwt_keys)

correlation_id = _generate_correlation_id('test_client_credentials_happy_path')
authorised_headers["X-Correlation-ID"] = correlation_id
Expand All @@ -118,7 +118,7 @@ def test_client_credentials_happy_path(test_app, service_url, environment, _jwt_
@pytest.mark.e2e
@pytest.mark.asyncio
@pytest.mark.parametrize(
"test_app",
"immunisation_history_app",
_add_authorised_targets_to_request_params(
[
{"suffixes": ["-user-restricted"]},
Expand All @@ -128,7 +128,7 @@ def test_client_credentials_happy_path(test_app, service_url, environment, _jwt_
indirect=True,
)
async def test_immunization_no_auth_bearer_token_provided(
test_app, service_url
immunisation_history_app, service_url
):
await asyncio.sleep(1) # Add delay to tests to avoid 429 on service callout
correlation_id = _generate_correlation_id('test_immunization_no_auth_bearer_token_provided')
Expand Down Expand Up @@ -199,7 +199,7 @@ def test_correlation_id_mirrored_in_resp_when_error(service_url):

@pytest.mark.e2e
@pytest.mark.parametrize(
"test_app",
"immunisation_history_app",
_add_authorised_targets_to_request_params(
[
{
Expand Down Expand Up @@ -236,10 +236,11 @@ def test_correlation_id_mirrored_in_resp_when_error(service_url):
),
indirect=True,
)
def test_token_exchange_happy_path(test_app, service_url, environment, _keycloak_client_credentials, _jwt_keys):
def test_token_exchange_happy_path(immunisation_history_app, service_url, environment, _keycloak_client_credentials,
_jwt_keys):
nhs_login_id = "9912003071"
token_response = conftest.get_token_nhs_login_token_exchange(
test_app, environment=environment, _keycloak_client_credentials=_keycloak_client_credentials,
immunisation_history_app, environment=environment, _keycloak_client_credentials=_keycloak_client_credentials,
_jwt_keys=_jwt_keys, nhs_login_id=nhs_login_id
)
token = token_response["access_token"]
Expand Down Expand Up @@ -346,7 +347,7 @@ def test_token_exchange_invalid_identity_proofing_level_scope(test_product_and_a
test_product, test_app = test_product_and_app

token_response = conftest.get_token_nhs_login_token_exchange(
test_app, environment=environment, _keycloak_client_credentials=_keycloak_client_credentials,
app=test_app, environment=environment, _keycloak_client_credentials=_keycloak_client_credentials,
_jwt_keys=_jwt_keys, nhs_login_id=nhs_login_id
)
token = token_response["access_token"]
Expand Down Expand Up @@ -376,7 +377,7 @@ def test_token_exchange_invalid_identity_proofing_level_scope(test_product_and_a

@pytest.mark.e2e
@pytest.mark.parametrize(
"test_app",
"immunisation_history_app",
[
{
"suffixes": ["-application-restricted"],
Expand All @@ -386,8 +387,8 @@ def test_token_exchange_invalid_identity_proofing_level_scope(test_product_and_a
],
indirect=True,
)
def test_pass_when_auth_targets_is_null(test_app, service_url, environment, _jwt_keys):
authorised_headers = conftest.get_authorised_headers(test_app, environment, _jwt_keys)
def test_pass_when_auth_targets_is_null(immunisation_history_app, service_url, environment, _jwt_keys):
authorised_headers = conftest.get_authorised_headers(immunisation_history_app, environment, _jwt_keys)

correlation_id = _generate_correlation_id('test_pass_when_auth_targets_is_null')
authorised_headers["X-Correlation-ID"] = correlation_id
Expand All @@ -402,7 +403,7 @@ def test_pass_when_auth_targets_is_null(test_app, service_url, environment, _jwt

@pytest.mark.e2e
@pytest.mark.parametrize(
"test_app",
"immunisation_history_app",
[
{
"suffixes": ["-application-restricted"],
Expand All @@ -413,9 +414,9 @@ def test_pass_when_auth_targets_is_null(test_app, service_url, environment, _jwt
indirect=True,
)
def test_fail_when_auth_targets_is_null_in_strict_mode(
test_app, service_url, environment, _jwt_keys
immunisation_history_app, service_url, environment, _jwt_keys
):
authorised_headers = conftest.get_authorised_headers(app=test_app, environment=environment,
authorised_headers = conftest.get_authorised_headers(app=immunisation_history_app, environment=environment,
_jwt_keys=_jwt_keys)

correlation_id = _generate_correlation_id('test_fail_when_auth_targets_is_null_in_strict_mode')
Expand All @@ -439,7 +440,7 @@ def test_fail_when_auth_targets_is_null_in_strict_mode(

@pytest.mark.e2e
@pytest.mark.parametrize(
"test_app",
"immunisation_history_app",
[
{
"suffixes": ["-application-restricted"],
Expand All @@ -460,9 +461,9 @@ def test_fail_when_auth_targets_is_null_in_strict_mode(
indirect=True,
)
def test_fail_when_auth_targets_is_blank_or_invalid(
test_app, service_url, environment, _jwt_keys
immunisation_history_app, service_url, environment, _jwt_keys
):
authorised_headers = conftest.get_authorised_headers(app=test_app, environment=environment,
authorised_headers = conftest.get_authorised_headers(app=immunisation_history_app, environment=environment,
_jwt_keys=_jwt_keys)

correlation_id = _generate_correlation_id('test_fail_when_auth_targets_is_blank_or_invalid')
Expand All @@ -479,7 +480,7 @@ def test_fail_when_auth_targets_is_blank_or_invalid(

@pytest.mark.e2e
@pytest.mark.parametrize(
"test_app",
"immunisation_history_app",
[
{
"suffixes": ["-application-restricted"],
Expand All @@ -490,9 +491,9 @@ def test_fail_when_auth_targets_is_blank_or_invalid(
indirect=True,
)
def test_pass_when_auth_targets_is_star_in_non_strict_mode(
test_app, service_url: str, environment: str, _jwt_keys
immunisation_history_app, service_url: str, environment: str, _jwt_keys
):
authorised_headers = conftest.get_authorised_headers(app=test_app, environment=environment,
authorised_headers = conftest.get_authorised_headers(app=immunisation_history_app, environment=environment,
_jwt_keys=_jwt_keys)

correlation_id = _generate_correlation_id('test_pass_when_auth_targets_is_star_in_non_strict_mode')
Expand All @@ -508,7 +509,7 @@ def test_pass_when_auth_targets_is_star_in_non_strict_mode(

@pytest.mark.e2e
@pytest.mark.parametrize(
"test_app",
"immunisation_history_app",
[
{
"suffixes": ["-application-restricted"],
Expand All @@ -519,9 +520,9 @@ def test_pass_when_auth_targets_is_star_in_non_strict_mode(
indirect=True,
)
def test_fail_when_auth_targets_is_star_in_strict_mode(
test_app, service_url, environment, _jwt_keys
immunisation_history_app, service_url, environment, _jwt_keys
):
authorised_headers = conftest.get_authorised_headers(app=test_app, environment=environment,
authorised_headers = conftest.get_authorised_headers(app=immunisation_history_app, environment=environment,
_jwt_keys=_jwt_keys)

correlation_id = _generate_correlation_id('test_fail_when_auth_targets_is_star_in_strict_mode')
Expand All @@ -538,7 +539,7 @@ def test_fail_when_auth_targets_is_star_in_strict_mode(

@pytest.mark.e2e
@pytest.mark.parametrize(
"test_app",
"immunisation_history_app",
_add_authorised_targets_to_request_params(
[
{"suffixes": ["-application-restricted"]},
Expand All @@ -550,9 +551,9 @@ def test_fail_when_auth_targets_is_star_in_strict_mode(
"extra_header", ["AUTHORISED_TARGETS", "authorised_targets", "autHORised_TArgets"]
)
def test_fail_when_authorised_targets_header_upper_set_in_good_request(
test_app, extra_header, service_url, environment, _jwt_keys
immunisation_history_app, extra_header, service_url, environment, _jwt_keys
):
authorised_headers = conftest.get_authorised_headers(app=test_app, environment=environment,
authorised_headers = conftest.get_authorised_headers(app=immunisation_history_app, environment=environment,
_jwt_keys=_jwt_keys)

correlation_id = _generate_correlation_id('test_fail_when_authorised_targets_header_upper_set_in_good_request')
Expand All @@ -574,7 +575,7 @@ def test_fail_when_authorised_targets_header_upper_set_in_good_request(

@pytest.mark.e2e
@pytest.mark.parametrize(
"test_app",
"immunisation_history_app",
[
{
"suffixes": ["-application-restricted"],
Expand All @@ -587,9 +588,9 @@ def test_fail_when_authorised_targets_header_upper_set_in_good_request(
@pytest.mark.parametrize(
"immunization_target", ["COVID19", "HPV"]
)
def test_immunization_target_happy_path(test_app, immunization_target, service_url, environment,
def test_immunization_target_happy_path(immunisation_history_app, immunization_target, service_url, environment,
_jwt_keys):
authorised_headers = conftest.get_authorised_headers(app=test_app, environment=environment,
authorised_headers = conftest.get_authorised_headers(app=immunisation_history_app, environment=environment,
_jwt_keys=_jwt_keys)

correlation_id = _generate_correlation_id('test_immunization_target_happy_path')
Expand All @@ -606,7 +607,7 @@ def test_immunization_target_happy_path(test_app, immunization_target, service_u

@pytest.mark.e2e
@pytest.mark.parametrize(
"test_app",
"immunisation_history_app",
[
{
"suffixes": ["-application-restricted"],
Expand All @@ -619,9 +620,9 @@ def test_immunization_target_happy_path(test_app, immunization_target, service_u
@pytest.mark.parametrize(
"immunization_target", ["COvID19", "hPV", "RANDOM"]
)
def test_immunization_target_unhappy_path(test_app, immunization_target,
def test_immunization_target_unhappy_path(immunisation_history_app, immunization_target,
service_url, environment, _jwt_keys):
authorised_headers = conftest.get_authorised_headers(app=test_app, environment=environment,
authorised_headers = conftest.get_authorised_headers(app=immunisation_history_app, environment=environment,
_jwt_keys=_jwt_keys)

correlation_id = _generate_correlation_id('test_immunization_target_unhappy_path')
Expand All @@ -638,7 +639,7 @@ def test_immunization_target_unhappy_path(test_app, immunization_target,

@pytest.mark.e2e
@pytest.mark.parametrize(
"test_app",
"immunisation_history_app",
[
{
"suffixes": ["-application-restricted"],
Expand All @@ -654,9 +655,9 @@ def test_immunization_target_unhappy_path(test_app, immunization_target,
@pytest.mark.parametrize(
"x_request_url_name", ["X-Request-Url", "X-REQUEST-URL", "x-request-url"]
)
def test_fails_if_request_url_set_in_header(test_app, immunization_target, x_request_url_name,
def test_fails_if_request_url_set_in_header(immunisation_history_app, immunization_target, x_request_url_name,
service_url, environment, _jwt_keys):
authorised_headers = conftest.get_authorised_headers(app=test_app, environment=environment,
authorised_headers = conftest.get_authorised_headers(app=immunisation_history_app, environment=environment,
_jwt_keys=_jwt_keys)

correlation_id = _generate_correlation_id('test_fails_if_request_url_set_in_header')
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def service_url(environment):


@pytest.fixture()
def test_app(client: ApigeeClient, request):
def immunisation_history_app(client: ApigeeClient, request):
"""Setup & Teardown an app-restricted app for this api"""
request_params = request.param

Expand Down

0 comments on commit 065368e

Please sign in to comment.