Skip to content

Commit

Permalink
APIGEE Auth (#15)
Browse files Browse the repository at this point in the history
Co-authored-by: Rowan Gill <[email protected]>
Co-authored-by: Joel Klinger <[email protected]>
  • Loading branch information
3 people authored Dec 22, 2022
1 parent f65e01b commit c08ddef
Show file tree
Hide file tree
Showing 14 changed files with 1,123 additions and 285 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # This causes all history to be fetched, which is required for calculate-version to function
fetch-depth: 0

- name: Install Python 3.8
uses: actions/setup-python@v1
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ release: clean publish build-proxy

#Command to run end-to-end smoktests post-deployment to verify the environment is working
smoketest:
poetry run pytest -v --junitxml=smoketest-report.xml -s -m smoketest
poetry run pytest -v --junitxml=smoketest-report.xml -s --proxy-name=${PROXY_NAME} --api-name=${API_NAME}
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,21 @@ This file defines 2 dictionaries of fields that are required for the Apigee depl
This template uses poetry for python dependency management, and uses these files: poetry.lock, poetry.toml, pyproject.toml.

Node dependencies of this template project and some npm scripts are listed in: package.json, package-lock.json.

## PLEASE UPDATE ME - how to run the tests

Before you can run any tests you need to setup your Apigee token, this can be done as shown:

- Install and first time setup of [Apigee’s `get_token`](https://docs.apigee.com/api-platform/system-administration/using-gettoken) (make sure to set `export SSO_LOGIN_URL=“https://login.apigee.com”` before setup, and your username and password are the same credentials you use for logging into Apigee).

Then export the following env var:

- export APIGEE_ACCESS_TOKEN=$(get_token)

----

If you want to run the smoke tests against a particular product or app then you can set up the command like this:

Example using `nrl-producer-api-pr-15` as the app:

`pytest tests/api_tests.py::test_smoke --proxy-name="nrl-producer-api-pr-15" --api-name=nrl-producer-api`
3 changes: 3 additions & 0 deletions azure/templates/run-smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ steps:
export APIGEE_ENVIRONMENT="$(ENVIRONMENT)"
export SERVICE_BASE_PATH="$(SERVICE_BASE_PATH)"
export STATUS_ENDPOINT_API_KEY="$(status-endpoint-api-key)"
export PROXY_NAME="$(FULLY_QUALIFIED_SERVICE_NAME)"
export API_NAME="$(SERVICE_NAME)"
export APIGEE_ACCESS_TOKEN=$(secret.AccessToken)
make smoketest
workingDirectory: $(Pipeline.Workspace)/s/$(SERVICE_NAME)/$(SERVICE_ARTIFACT_NAME)
Expand Down
9 changes: 9 additions & 0 deletions manifest_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ DESCRIPTION: example description
APIGEE_ENVIRONMENTS:
- name: internal-dev
display_name: Internal Development
has_mock_auth: true
- name: internal-qa
display_name: Internal QA
has_mock_auth: true
- name: ref
display_name: Reference
has_mock_auth: true
# Enable environments when ready by uncommenting:
# - name: internal-dev-sandbox
# display_name: Internal Development Sandbox
Expand All @@ -20,6 +23,9 @@ APIGEE_ENVIRONMENTS:
# portal_visibility: false
# - name: int
# display_name: Integration Testing
# has_mock_auth: true
# - name: prod
# display_name: Prod
---
meta:
api:
Expand Down Expand Up @@ -64,6 +70,9 @@ apigee:
proxies:
- {{ NAME }}
- identity-service-{{ ENV.name }}
{% if ENV.has_mock_auth | default(false) %}
- identity-service-mock-{{ ENV.name }}
{% endif %}
scopes:
- 'urn:nhsd:apim:app:level3:{{ SERVICE_NAME }}'
- 'urn:nhsd:apim:user-nhs-id:aal3:{{ SERVICE_NAME }}'
Expand Down
Loading

0 comments on commit c08ddef

Please sign in to comment.