Skip to content

Commit f5df09a

Browse files
authored
Added upload (and debug) to whitelisted URLs (#4858)
<!-- Thanks for contributing to Hypha! Please ensure your contributions pass all necessary linting/testing and that the appropriate documentation has been updated. --> <!-- Describe briefly what your pull request changes. If this is resolving an issue, please specify below via "Fixes #<Github Issue ID>" --> Fixes #4857, adds the upload URL prefix to whitelisted URLs to allow for uploading of files to complete a submission without needing to do 2FA. (also added `/__debug__/` as the toolbars were failing to load) ## Test Steps <!-- If step does not require manual testing, skip/remove this section. Give a brief overview of the steps required for a user/dev to test this contribution. Important things to include: - Required user roles for where necessary (ie. "As a Staff Admin...") - Clear & validatable expected results (ie. "Confirm the submit button is now not clickable") - Language that can be understood by non-technical testers if being tested by users --> - [ ] With both `ENFORCE_TWO_FACTOR=True` and `FORCE_LOGIN_FOR_APPLICATION=True`, ensure uploading a file as a user without 2FA enabled works as expected.
1 parent 92dfdcb commit f5df09a

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎hypha/apply/users/middleware.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@
1919
"/logout/",
2020
"/account/",
2121
"/apply/submissions/success/",
22+
"/upload/upload/",
2223
]
2324

25+
if settings.DEBUG:
26+
TWO_FACTOR_EXEMPTED_PATH_PREFIXES.append("/__debug__/")
27+
2428

2529
def get_page_path(wagtail_page):
2630
_, _, page_path = wagtail_page.get_url_parts()

‎hypha/apply/users/tests/test_middleware.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ def test_unverified_user_can_access_allowed_urls(self):
4141
if "success" in path:
4242
submission = ApplicationSubmissionFactory()
4343
path = str(path) + f"{submission.id}/"
44-
if "logout" in path:
44+
response = self.client.get(path, follow=True)
45+
elif "upload" in path:
46+
response = self.client.post(path, HTTP_TUS_RESUMABLE=True)
47+
elif "logout" in path:
4548
response = self.client.post(path, follow=True)
4649
else:
4750
response = self.client.get(path, follow=True)
48-
self.assertEqual(response.status_code, 200)
51+
self.assertIn(response.status_code, [200, 201])

0 commit comments

Comments
 (0)