Skip to content

Read allowlist templates from correct path#2597

Merged
cptanalatriste merged 1 commit intoalan-turing-institute:developfrom
llewelld:2533-allowlist-template
Apr 30, 2026
Merged

Read allowlist templates from correct path#2597
cptanalatriste merged 1 commit intoalan-turing-institute:developfrom
llewelld:2533-allowlist-template

Conversation

@llewelld
Copy link
Copy Markdown
Contributor

✅ Checklist

  • You have given your pull request a meaningful title (e.g. Enable foobar integration rather than 515 foobar).
  • You are targeting the appropriate branch. If you're not certain which one this is, it should be develop.
  • Your branch is up-to-date with the target branch (it probably was when you started, but it may have changed since then).

🚦 Depends on

N/A.

⤴️ Summary

The allowlist templates were being read from a path relative to the CWD. This meant that they would be correctly output, but only if the command was run from inside the root of the data-save-haven working directory. This updates the code to read the files correctly from the resource directory irrespective of the CWD.

🌂 Related issues

Closes #2533

🔬 Tests

Tested by running the following commands:

cd data-safe-haven
dsh allowlist template pypi
pushd ..
dsh allowlist template pypi
popd

Previously the second call to dsh would generate an error, but after this change it no longer does. I've also added a new unit test to perform roughly the same check (changes directory, requests template, restores directory). The test fails with previous versions of the code but passes after the changes here.

I specifically chose this issue while I'm awaiting access to the dev SRE, because it only relies on code running locally (and it was an easy fix while I get familiar with the code and processes).

The allowlist templates were being read from a path relative to the CWD.
This meant that they would be correctly output, but only if the command
was run from inside the root of the data-save-haven working directory.
This updates the code to read the files correctly from the resource
directory irrespective of the CWD.

Fixes alan-turing-institute#2533
@llewelld llewelld requested a review from a team as a code owner April 29, 2026 12:38
@github-actions
Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  data_safe_haven/commands
  allowlist.py 133-134
  data_safe_haven/utility
  file_reader.py
Project Total  

This report was generated by python-coverage-comment-action

Copy link
Copy Markdown
Contributor

@cptanalatriste cptanalatriste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@llewelld
Copy link
Copy Markdown
Contributor Author

Thanks for looking at this @cptanalatriste. Is one review enough to have this merged? If so, I'm not authorised to merge myself, would you mind please merging it for me?

@cptanalatriste cptanalatriste merged commit 13d97bf into alan-turing-institute:develop Apr 30, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calling dsh allowlist template generates an error

2 participants