Skip to content

Commit

Permalink
Running single test
Browse files Browse the repository at this point in the history
  • Loading branch information
helen-brown committed Sep 28, 2023
1 parent 2999ca2 commit e7e1027
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
15 changes: 15 additions & 0 deletions tests/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def test_check_immunization_is_secured(service_url):
assert resp.status_code == 401


@pytest.mark.skip(reason="running cut down version while sorting out tests")
@pytest.mark.e2e
@pytest.mark.parametrize(
"immunisation_history_app",
Expand Down Expand Up @@ -110,6 +111,7 @@ def test_client_credentials_happy_path(immunisation_history_app, service_url):
assert len(body["entry"]) == 3, body


@pytest.mark.skip(reason="running cut down version while sorting out tests")
@pytest.mark.e2e
@pytest.mark.asyncio
@pytest.mark.parametrize(
Expand Down Expand Up @@ -144,6 +146,7 @@ async def test_immunization_no_auth_bearer_token_provided(
], body


@pytest.mark.skip(reason="running cut down version while sorting out tests")
@pytest.mark.e2e
@pytest.mark.asyncio
@pytest.mark.parametrize(
Expand Down Expand Up @@ -208,6 +211,7 @@ def test_correlation_id_mirrored_in_resp_when_error(service_url):
assert resp.headers["x-correlation-id"] == correlation_id, resp.headers


@pytest.mark.skip(reason="running cut down version while sorting out tests")
# TODO Fix
@pytest.mark.e2e
@pytest.mark.parametrize(
Expand Down Expand Up @@ -271,6 +275,7 @@ def test_token_exchange_happy_path(immunisation_history_app, service_url):
assert len(body["entry"]) == 3, body


@pytest.mark.skip(reason="running cut down version while sorting out tests")
# TODO Fix
@pytest.mark.e2e
@pytest.mark.parametrize(
Expand Down Expand Up @@ -305,6 +310,7 @@ def test_token_exchange_sad_path(immunisation_history_app):
)


@pytest.mark.skip(reason="running cut down version while sorting out tests")
# TODO Fix
@pytest.mark.e2e
@pytest.mark.asyncio
Expand Down Expand Up @@ -355,6 +361,7 @@ async def test_user_restricted_access_not_permitted(test_product_and_app, servic
assert body["issue"][0]["code"] == "forbidden"


@pytest.mark.skip(reason="running cut down version while sorting out tests")
# TODO Fix
@pytest.mark.e2e
@pytest.mark.parametrize(
Expand Down Expand Up @@ -434,6 +441,7 @@ def test_pass_when_auth_targets_is_null(immunisation_history_app, service_url):
assert resp.status_code == 200, body


@pytest.mark.skip(reason="running cut down version while sorting out tests")
@pytest.mark.e2e
@pytest.mark.parametrize(
"immunisation_history_app",
Expand Down Expand Up @@ -470,6 +478,7 @@ def test_fail_when_auth_targets_is_null_in_strict_mode(
}


@pytest.mark.skip(reason="running cut down version while sorting out tests")
@pytest.mark.e2e
@pytest.mark.parametrize(
"immunisation_history_app",
Expand Down Expand Up @@ -509,6 +518,7 @@ def test_fail_when_auth_targets_is_blank_or_invalid(
assert resp.status_code == 401, body


@pytest.mark.skip(reason="running cut down version while sorting out tests")
@pytest.mark.e2e
@pytest.mark.parametrize(
"immunisation_history_app",
Expand Down Expand Up @@ -537,6 +547,7 @@ def test_pass_when_auth_targets_is_star_in_non_strict_mode(
assert resp.status_code == 200, body


@pytest.mark.skip(reason="running cut down version while sorting out tests")
@pytest.mark.e2e
@pytest.mark.parametrize(
"immunisation_history_app",
Expand Down Expand Up @@ -566,6 +577,7 @@ def test_fail_when_auth_targets_is_star_in_strict_mode(
assert resp.status_code == 403, body


@pytest.mark.skip(reason="running cut down version while sorting out tests")
@pytest.mark.e2e
@pytest.mark.parametrize(
"immunisation_history_app",
Expand Down Expand Up @@ -601,6 +613,7 @@ def test_fail_when_authorised_targets_header_upper_set_in_good_request(
}


@pytest.mark.skip(reason="running cut down version while sorting out tests")
@pytest.mark.e2e
@pytest.mark.parametrize(
"immunisation_history_app",
Expand Down Expand Up @@ -631,6 +644,7 @@ def test_immunization_target_happy_path(immunisation_history_app, immunization_t
assert resp.status_code == 200, body


@pytest.mark.skip(reason="running cut down version while sorting out tests")
@pytest.mark.e2e
@pytest.mark.parametrize(
"immunisation_history_app",
Expand Down Expand Up @@ -662,6 +676,7 @@ def test_immunization_target_unhappy_path(immunisation_history_app, immunization
assert resp.status_code == 400, body


@pytest.mark.skip(reason="running cut down version while sorting out tests")
@pytest.mark.e2e
@pytest.mark.parametrize(
"immunisation_history_app",
Expand Down
14 changes: 7 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ def nhs_login_id_token(
def get_token(
app, id_token: str = None
):
credentials = app["credentials"]
credentials = app["credentials"][0]
return get_access_token_via_signed_jwt_flow(
identity_service_base_url=f'{get_env("OAUTH_BASE_URI")}/oauth2',
client_id=credentials["consumerKey"],
jwt_private_key=credentials["app_jwt_private_key"],
jwt_private_key=app["app_jwt_private_key"],
jwt_kid="kid-1",
id_token=id_token
)
Expand All @@ -117,13 +117,13 @@ def get_authorised_headers(client_app):

def check_for_unauthorised_headers(client_app):
# do I need the jwt?
credentials = client_app["credentials"]
credentials = client_app["credentials"][0]

with pytest.raises(RuntimeError) as exc_info:
get_access_token_via_signed_jwt_flow(
identity_service_base_url=f'{get_env("OAUTH_BASE_URI")}/oauth2',
client_id=credentials["consumerKey"],
jwt_private_key=credentials["app_jwt_private_key"],
jwt_private_key=client_app["app_jwt_private_key"],
jwt_kid="kid-1",
id_token=None
)
Expand Down Expand Up @@ -155,7 +155,7 @@ def get_token_nhs_login_token_exchange(
environment=environment,
identity_service_base_url=f'{get_env("OAUTH_BASE_URI")}/oauth2',
client_id=credentials["consumerKey"],
jwt_private_key=credentials["app_jwt_private_key"],
jwt_private_key=test_app["app_jwt_private_key"],
jwt_kid="kid-1",
id_token=id_token_jwt,
)
Expand Down Expand Up @@ -188,7 +188,7 @@ def check_for_unauthorised_token_exchange(
environment=environment,
identity_service_base_url=f'{get_env("OAUTH_BASE_URI")}/oauth2',
client_id=credentials["consumerKey"],
jwt_private_key=credentials["app_jwt_private_key"],
jwt_private_key=test_app["app_jwt_private_key"],
jwt_kid="kid-1",
id_token=id_token_jwt,
)
Expand Down Expand Up @@ -225,7 +225,7 @@ def _create_app(dev_apps_api: DeveloperAppsAPI, app_name: str, api_products: Lis
"keyExpiresIn": 60000
}
resp = dev_apps_api.create_app(email=APP_EMAIL, body=body)
resp["credentials"]["app_jwt_private_key"] = jwt_key_pair["private_key_pem"]
resp["app_jwt_private_key"] = jwt_key_pair["private_key_pem"]

return resp

Expand Down

0 comments on commit e7e1027

Please sign in to comment.