You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -36,6 +37,11 @@ This file outlines the configuration of pytest, and ultimately how Playwright al
36
37
37
38
Any configuration you want to apply to all of your test executions should be placed in this file where possible, to ensure easy maintenance.
38
39
40
+
### `users.json`
41
+
42
+
This file outlines the users you may want to use as part of your testing, and is utilised by the User Tools utility. Further information on how this file is used
43
+
can be found in the [User Tools Utility Guide](../utility-guides/UserTools.md).
44
+
39
45
### `tests/`
40
46
41
47
This directory is designed to house all of your tests intended for execution.
@@ -66,3 +72,4 @@ The following directories and files are specific for this repository, and may re
66
72
-`scripts/`: This directory houses the scripts used by this repository, primarily as part of the CI/CD checks.
67
73
-`tests_utils/`: This directory houses the unit tests for the utilities provided by this repository. You may want to copy these over if you want to ensure utilities are behaving as expected.
68
74
-`.editorconfig`, `.gitattributes`, `.gitignore`, `.gitleaks.toml`, `.gitleaksignore`: These files are configuration for git, and quality and security checks provided via the CI/CD checks.
75
+
-`Makefile`: This file is used to import some of the scripts for CI/CD checks, but can be customised per project if needed. The template this project is based from provides a more comprehensive example [here](https://github.com/nhs-england-tools/repository-template/blob/main/Makefile).
| nhs_number |`str` or `int`| The NHS number to format. |
36
+
37
+
### Returns
38
+
39
+
A `str` with the provided NHS number in `nnn nnn nnnn` format. For example, `NHSNumberTools.spaced_nhs_number(1234567890)` would return `123 456 7890`.
Copy file name to clipboardExpand all lines: docs/utility-guides/UserTools.md
+55Lines changed: 55 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,11 @@ at the base of the repository.
9
9
-[Table of Contents](#table-of-contents)
10
10
-[Using the User Tools class](#using-the-user-tools-class)
11
11
-[Managing Users](#managing-users)
12
+
-[Considering Security](#considering-security)
13
+
-[`retrieve_user()`: Retrieve User Details](#retrieve_user-retrieve-user-details)
14
+
-[Required Arguments](#required-arguments)
15
+
-[Returns](#returns)
16
+
-[Example Usage](#example-usage)
12
17
13
18
## Using the User Tools class
14
19
@@ -32,3 +37,53 @@ For example, adding a record like so (this example shows the entire `users.json`
32
37
"unique_id": 42
33
38
}
34
39
}
40
+
41
+
The data you require for these users can be completely customised for what information you need, so whilst the example shows `username`, `roles`
42
+
and `unique_id` as possible values we may want to use, this is not an exhaustive list. The key that is used (so in this example, `"Documentation User"`)
43
+
is also customisable and should be how you want to easily reference retrieving this user in your tests.
44
+
45
+
### Considering Security
46
+
47
+
An important note on managing users in this way is that passwords or security credentials should **never** be stored in the `users.json` file. These
48
+
are considered secrets, and whilst it may be convenient to store them in this file, it goes against the
49
+
[security principles outlined in the Software Engineering Quality Framework](https://github.com/NHSDigital/software-engineering-quality-framework/blob/main/practices/security.md#application-level-security).
50
+
51
+
With this in mind, it's recommended to do the following when it comes to managing these types of credentials:
52
+
53
+
- When running locally, store any secret values in a local configuration file and set this file in `.gitignore` so it is not committed to the codebase.
54
+
- When running via a CI/CD process, store any secret values in an appropriate secret store and pass the values into pytest at runtime.
55
+
56
+
## `retrieve_user()`: Retrieve User Details
57
+
58
+
The `retrieve_user()` method is designed to easily retrieve the data for a specific user entry from the `users.json` file. This is a static method,
59
+
so can be called using the following logic:
60
+
61
+
# Retrieving documentation user details from example
0 commit comments