{"id":23421236,"url":"https://github.com/nhsdigital/pytest-nhsd-apim","last_synced_at":"2025-07-18T22:10:15.446Z","repository":{"id":43175791,"uuid":"462250901","full_name":"NHSDigital/pytest-nhsd-apim","owner":"NHSDigital","description":"A pytest extension to run tests against NHSDigital API Management Platform hosted APIs","archived":false,"fork":false,"pushed_at":"2025-06-10T11:36:39.000Z","size":482,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":36,"default_branch":"main","last_synced_at":"2025-07-01T04:08:02.039Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NHSDigital.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-02-22T10:39:59.000Z","updated_at":"2025-04-01T14:16:00.000Z","dependencies_parsed_at":"2024-01-10T16:14:39.938Z","dependency_job_id":"b1df23b9-f5eb-4a45-b5b0-7e123060266c","html_url":"https://github.com/NHSDigital/pytest-nhsd-apim","commit_stats":{"total_commits":111,"total_committers":9,"mean_commits":"12.333333333333334","dds":0.7297297297297297,"last_synced_commit":"042dac754b4e21ee23efa04be4f638ccb8bd8862"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NHSDigital/pytest-nhsd-apim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fpytest-nhsd-apim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fpytest-nhsd-apim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fpytest-nhsd-apim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fpytest-nhsd-apim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NHSDigital","download_url":"https://codeload.github.com/NHSDigital/pytest-nhsd-apim/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fpytest-nhsd-apim/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265845217,"owners_count":23837755,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-23T02:14:31.621Z","updated_at":"2025-07-18T22:10:15.367Z","avatar_url":"https://github.com/NHSDigital.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pytest-nhsd-apim\n\nA pytest extension for NHSDigital's API Mangement suite.\n\n## Installation\nIn your project's virtual environment\n```code()\npoetry add pytest-nhsd-apim\n```\nor if using pip directly\n```code()\npython -m pip install pytest-nhsd-apim\n```\n\n## Usage\n- create a python test file\n- write a test using our custom authentication markers!\n- enjoy!?\n      \n\n\n## Testing\n- run `make test` to run test examples, located in this repo\n- after creating your file you can use the plugin as:\n```code()\npython -m pytest -p pytest_nhsd_apim test_nhsd_apim.py -s --apigee-proxy-name=\u003cyour-proxy-name\u003e\n```\n\n## Available tools\nWhen installing this library in your project you can access some very handy tools, including our platform authenticators and our apigee api wrapper library.\n### Autheticators\nWe present a variety of authenticators including AuthorizationCodeAuthenticator, ClientCredentialsAuthenticator and TokenExchangeAuthenticator. The way of using them is simple. First you create the configuration object which will validate that your coniguration is correct on creation using pydantic, then pass the config to the authenticator and call get_token() on it.\n```python\n    from pytest_nhsd_apim.identity_service import ClientCredentialsConfig, ClientCredentialsAuthenticator\n\n    config = ClientCredentialsConfig(\n        environment={APIGEE_ENVIRONMENT},\n        identity_service_base_url={BASE_URL},\n        client_id={CLIENT_ID},\n        jwt_private_key={PRIVATE_KEY_PEM},\n        jwt_kid={KEY_ID},\n    )\n\n    authenticator=ClientCredentialsAuthenticator(config=config)\n    token=authenticator.get_token()\n```\nFor a more detailed implementation on the rest of the authenticators please refer to the examples [here](/tests/test_examples.py#L308).\n### Apigee APIs\nWe also present a variety off Apigee APIs with the benefit of a fully authenticated Apigee client ready to use. Just remember to export the following variables\n```bash\n# If you want the client to authenticate you...\nexport APIGEE_NHSD_NONPROD_USERNAME={my_username}\nexport APIGEE_NHSD_NONPROD_PASSWORD={my_password}\nexport APIGEE_NHSD_NONPROD_OTP_KEY={my_otp}\n# Or alternatively, if you already have a token you can pass it and the client will use it.\nexport APIGEE_ACCESS_TOKEN={access_token}\n\n#NOTE: in case both sets of credentials are defined, the username and password take presedence, this is so the Apigee client can keep itself authenticated all the time.\n```\n```python\nfrom pytest_nhsd_apim.apigee_apis import ApigeeNonProdCredentials, DeveloperAppsAPI\n\nconfig = ApigeeNonProdCredentials()\nclient =  ApigeeClient(config=config)\napps = DeveloperAppsAPI(client=client)\n\nprint(apps.list_aps('lucas.fantini@nhs.net'))\n```\nThe APIs we offer at the moment are:\n| API  | Methods | Documentation| \n| ------------- | ------------- |-------------|\n| DeveloperAppsAPI  | [here](/src/pytest_nhsd_apim/apigee_apis.py#L292)  |[Overview](https://apidocs.apigee.com/docs/developer-apps/1/overview)|\n| ApiProductsAPI  | [here](/src/pytest_nhsd_apim/apigee_apis.py#L575)  |[Overview](https://apidocs.apigee.com/docs/api-products/1/overview)|\n| DebugSessionsAPI  | [here](/src/pytest_nhsd_apim/apigee_apis.py#L844)  |[Overview](https://apidocs.apigee.com/docs/debug-sessions/1/overview)|\n| AccessTokensAPI  | [here](/src/pytest_nhsd_apim/apigee_apis.py#L983)  |[Overview](https://apidocs.apigee.com/docs/oauth-20-access-tokens/1/overview)|\n| AppKeysAPI  | [here](/src/pytest_nhsd_apim/apigee_apis.py#L1243)  |[Overview](https://apidocs.apigee.com/docs/developer-app-keys/1/overview)|\n\nFor a more detailed implementation of the available APIs please refer to the tests [here](/tests/test_apigee_apis.py).\nWe will keep adding APIs with time, if you are looking for a particular APIs not listed above please feel free to open a pull request and send it to us.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhsdigital%2Fpytest-nhsd-apim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnhsdigital%2Fpytest-nhsd-apim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhsdigital%2Fpytest-nhsd-apim/lists"}