async def test_app(): """Programatically create and destroy test app for each test""" apigee_product = ApigeeApiProducts() await apigee_product.create_new_product() await apigee_product.update_proxies([config.SERVICE_NAME]) apigee_app = ApigeeApiDeveloperApps() await apigee_product.update_ratelimits( quota=60000, quota_interval="1", quota_time_unit="minute", rate_limit="1000ps", ) await apigee_app.setup_app( api_products=[apigee_product.name], custom_attributes={ "jwks-resource-url": "https://internal-dev.api.service.nhs.uk/mock-nhsid-jwks/identity-service/nhs-cis2-jwks" }) apigee_app.oauth = OauthHelper(apigee_app.client_id, apigee_app.client_secret, apigee_app.callback_url) api_service_name = get_env("SERVICE_NAME") await apigee_product.update_scopes( ["urn:nhsd:apim:user-nhs-id:aal3:personal-demographics-service"]) yield apigee_app await apigee_app.destroy_app()
def test_product_and_app(): """Setup & Teardown an product and app for this api""" product = ApigeeApiProducts() app = ApigeeApiDeveloperApps() loop = asyncio.new_event_loop() loop.run_until_complete(product.create_new_product()) loop.run_until_complete(app.setup_app()) app.oauth = OauthHelper(app.client_id, app.client_secret, app.callback_url) yield product, app loop.run_until_complete(app.destroy_app()) loop.run_until_complete(product.destroy_product())
def base_test_app(): """Setup & Teardown an app-restricted app for this api""" app = ApigeeApiDeveloperApps() loop = asyncio.new_event_loop() loop.run_until_complete( app.setup_app( api_products=[get_env("APIGEE_PRODUCT")], custom_attributes=_BASE_CUSTOM_ATTRIBUTES, )) app.oauth = OauthHelper(app.client_id, app.client_secret, app.callback_url) yield app loop.run_until_complete(app.destroy_app())
def test_app(): """Setup & Teardown an app-restricted app for this api""" app = ApigeeApiDeveloperApps() loop = asyncio.new_event_loop() loop.run_until_complete( app.setup_app( api_products=[get_env("APIGEE_PRODUCT")], custom_attributes={ "jwks-resource-url": "https://raw.githubusercontent.com/NHSDigital/identity-service-jwks/main/jwks/internal-dev/9baed6f4-1361-4a8e-8531-1f8426e3aba8.json" # noqa }, ) ) app.oauth = OauthHelper(app.client_id, app.client_secret, app.callback_url) yield app loop.run_until_complete(app.destroy_app())
def test_product_and_app(): """Setup & Teardown an product and app for this api""" product = ApigeeApiProducts() app = ApigeeApiDeveloperApps() loop = asyncio.new_event_loop() loop.run_until_complete(product.create_new_product()) loop.run_until_complete( product.update_scopes([ "urn:nhsd:apim:app:level3:immunisation-history", "urn:nhsd:apim:user-nhs-login:P9:immunisation-history", "urn:nhsd:apim:user-nhs-login:P5:immunisation-history" ])) loop.run_until_complete( app.setup_app( api_products=[product.name], custom_attributes=_BASE_CUSTOM_ATTRIBUTES, )) app.oauth = OauthHelper(app.client_id, app.client_secret, app.callback_url) yield product, app loop.run_until_complete(app.destroy_app()) loop.run_until_complete(product.destroy_product())
def test_product_and_app(request): """Setup & Teardown an product and app for this api""" request_params = request.param product = ApigeeApiProducts() app = ApigeeApiDeveloperApps() loop = asyncio.new_event_loop() loop.run_until_complete(product.create_new_product()) loop.run_until_complete(product.update_scopes( request_params['scopes'] )) loop.run_until_complete( app.setup_app( api_products=[product.name], custom_attributes= { "jwks-resource-url": "https://raw.githubusercontent.com/NHSDigital/identity-service-jwks/main/jwks/internal-dev/9baed6f4-1361-4a8e-8531-1f8426e3aba8.json", "nhs-login-allowed-proofing-level": request_params.get('requested_proofing_level') }, ) ) app.oauth = OauthHelper(app.client_id, app.client_secret, app.callback_url) app.request_params = request_params yield product, app loop.run_until_complete(app.destroy_app()) loop.run_until_complete(product.destroy_product())