pytest-nhsd-apim 3.4.1__tar.gz → 3.4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pytest-nhsd-apim might be problematic. Click here for more details.

Files changed (25) hide show
  1. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/PKG-INFO +1 -1
  2. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/pyproject.toml +1 -1
  3. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/src/pytest_nhsd_apim/nhsd_apim_authorization.py +1 -1
  4. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/src/pytest_nhsd_apim.egg-info/PKG-INFO +1 -1
  5. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/tests/test_examples.py +41 -32
  6. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/README.md +0 -0
  7. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/setup.cfg +0 -0
  8. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/setup.py +0 -0
  9. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/src/pytest_nhsd_apim/__init__.py +0 -0
  10. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/src/pytest_nhsd_apim/apigee_apis.py +0 -0
  11. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/src/pytest_nhsd_apim/apigee_edge.py +0 -0
  12. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/src/pytest_nhsd_apim/auth_journey.py +0 -0
  13. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/src/pytest_nhsd_apim/config.py +0 -0
  14. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/src/pytest_nhsd_apim/identity_service.py +0 -0
  15. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/src/pytest_nhsd_apim/log.py +0 -0
  16. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/src/pytest_nhsd_apim/pytest_nhsd_apim.py +0 -0
  17. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/src/pytest_nhsd_apim/secrets.py +0 -0
  18. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/src/pytest_nhsd_apim/token_cache.py +0 -0
  19. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/src/pytest_nhsd_apim.egg-info/SOURCES.txt +0 -0
  20. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/src/pytest_nhsd_apim.egg-info/dependency_links.txt +0 -0
  21. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/src/pytest_nhsd_apim.egg-info/entry_points.txt +0 -0
  22. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/src/pytest_nhsd_apim.egg-info/requires.txt +0 -0
  23. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/src/pytest_nhsd_apim.egg-info/top_level.txt +0 -0
  24. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/tests/test_apigee_apis.py +0 -0
  25. {pytest_nhsd_apim-3.4.1 → pytest_nhsd_apim-3.4.3}/tests/test_nhsd_apim.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pytest-nhsd-apim
3
- Version: 3.4.1
3
+ Version: 3.4.3
4
4
  Summary: Pytest plugin accessing NHSDigital's APIM proxies
5
5
  Home-page: https://github.com/NHSDigital/pytest-nhsd-apim
6
6
  Author: Adrian Ciobanita
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pytest-nhsd-apim"
3
- version = "3.4.1"
3
+ version = "3.4.3"
4
4
  description = "Pytest plugin accessing NHSDigital's APIM proxies"
5
5
  authors = ["Adrian Ciobanita <adrian.ciobanita1@nhs.net>", "Alex Carrie <alexander.carrie1@nhs.net>", "Lucas Fantini <lucas.fantini@nhs.net>"]
6
6
  maintainers = ["Alex Carrie <alexander.carrie1@nhs.net>", "Alex Hawdon <alex.hawdon1@nhs.net"]
@@ -48,7 +48,7 @@ class HealthcareWorkerAuthorization(UserRestrictedAuthorization):
48
48
  """
49
49
 
50
50
  access: Literal["healthcare_worker"]
51
- level: Literal["aal1", "aal3"]
51
+ level: Literal["aal1", "aal2", "aal3"]
52
52
 
53
53
 
54
54
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pytest-nhsd-apim
3
- Version: 3.4.1
3
+ Version: 3.4.3
4
4
  Summary: Pytest plugin accessing NHSDigital's APIM proxies
5
5
  Home-page: https://github.com/NHSDigital/pytest-nhsd-apim
6
6
  Author: Adrian Ciobanita
@@ -208,37 +208,36 @@ def test_patient_access_level_with_parametrization(
208
208
  # We are on our second generation of mock identity provider for
209
209
  # healthcare_worker access (CIS2). This allows you to log-in using a
210
210
  # username.
211
- MOCK_CIS2_USERNAMES = ["656005750104", "656005750105", "656005750106", "656005750107"]
211
+ MOCK_CIS2_USERNAMES = {
212
+ "aal1": ["656005750110"],
213
+ "aal2": ["656005750109", "656005750111", "656005750112"],
214
+ "aal3": ["656005750104", "656005750105", "656005750106"],
215
+ }
212
216
 
213
217
 
214
- # You can make the parametrization less verbose by using a function to
215
- # construct each pytest.param!
216
- def cis2_aal3_mark(username: str):
217
- return pytest.param(
218
+ # Create a list of pytest.param for each combination of username and level for combined auth
219
+ combined_auth_params = [
220
+ pytest.param(
221
+ username, level,
218
222
  marks=pytest.mark.nhsd_apim_authorization(
219
223
  access="healthcare_worker",
220
- level="aal3",
224
+ level=level,
221
225
  login_form={"username": username},
222
226
  ),
223
227
  )
228
+ for level, usernames in MOCK_CIS2_USERNAMES.items()
229
+ for username in usernames
230
+ ]
224
231
 
225
232
 
226
- # It's getting pretty abstract now, but we're accessing the same
227
- # endpoint using access tokens granted to four different mock
228
- # users. Each is a valid mock user with aal3 credentials and so is
229
- # granted a token we can use.
230
- @pytest.mark.parametrize(
231
- (),
232
- [cis2_aal3_mark(username) for username in MOCK_CIS2_USERNAMES],
233
- )
233
+ @pytest.mark.parametrize("username, level", combined_auth_params)
234
234
  def test_healthcare_worker_user_restricted_combined_auth(
235
- nhsd_apim_proxy_url, nhsd_apim_auth_headers
235
+ nhsd_apim_proxy_url, nhsd_apim_auth_headers, username, level
236
236
  ):
237
- resp0 = requests.get(nhsd_apim_proxy_url + "/test-auth/nhs-cis2/aal3")
237
+ url = f"{nhsd_apim_proxy_url}/test-auth/nhs-cis2/{level}"
238
+ resp0 = requests.get(url)
238
239
  assert resp0.status_code == 401
239
- resp1 = requests.get(
240
- nhsd_apim_proxy_url + "/test-auth/nhs-cis2/aal3", headers=nhsd_apim_auth_headers
241
- )
240
+ resp1 = requests.get(url, headers=nhsd_apim_auth_headers)
242
241
  assert resp1.status_code == 200
243
242
 
244
243
 
@@ -249,21 +248,31 @@ def test_healthcare_worker_user_restricted_combined_auth(
249
248
  # doesn't look too different. "combined" authentication is the default for this
250
249
  # library. To use separate authentication instead, add authentication="separate"
251
250
  # to the nhsd_apim_authorization mark.
252
- @pytest.mark.nhsd_apim_authorization(
253
- {
254
- "access": "healthcare_worker",
255
- "level": "aal3",
256
- "login_form": {"username": "aal3"},
257
- "authentication": "separate",
258
- }
259
- )
251
+
252
+ # Create a combined list for separate authentication testing
253
+ separate_auth_params = [
254
+ pytest.param(
255
+ username, level,
256
+ marks=pytest.mark.nhsd_apim_authorization(
257
+ access="healthcare_worker",
258
+ level=level,
259
+ login_form={"username": username},
260
+ authentication="separate",
261
+ ),
262
+ )
263
+ for level, usernames in MOCK_CIS2_USERNAMES.items()
264
+ for username in usernames
265
+ ]
266
+
267
+
268
+ @pytest.mark.parametrize("username, level", separate_auth_params)
260
269
  def test_healthcare_work_user_restricted_separate_auth(
261
- nhsd_apim_proxy_url, nhsd_apim_auth_headers
270
+ nhsd_apim_proxy_url, nhsd_apim_auth_headers, username, level
262
271
  ):
263
- aal3_url = f"{nhsd_apim_proxy_url}/test-auth/nhs-cis2/aal3"
264
- resp0 = requests.get(aal3_url)
272
+ aal_url = f"{nhsd_apim_proxy_url}/test-auth/nhs-cis2/{level}"
273
+ resp0 = requests.get(aal_url)
265
274
  assert resp0.status_code == 401
266
- resp1 = requests.get(aal3_url, headers=nhsd_apim_auth_headers)
275
+ resp1 = requests.get(aal_url, headers=nhsd_apim_auth_headers)
267
276
  assert resp1.status_code == 200
268
277
 
269
278
 
@@ -439,4 +448,4 @@ def test_trace(nhsd_apim_proxy_url, nhsd_apim_auth_headers, trace):
439
448
 
440
449
  trace.delete_debugsession_by_name(session_name)
441
450
 
442
- assert status_code_from_trace == "200"
451
+ assert status_code_from_trace == "200"