Skip to content

Commit f5c373f

Browse files
authored
Bug/WP-418: site search error when user does not have community file listing access. (#1005)
* file fix starting point * ssh_op_err1 exception addition and test * comment fix * linting
1 parent 84d30e5 commit f5c373f

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

client/src/components/PublicData/PublicData.module.css

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
/* FAQ: Public pages, like `PublicData` and `SiteSearch`, have no sidebar */
88
/* padding-left: 1.5em; /* ~24px (20px * design * 1.2 design-to-app ratio) */
99
}
10+

server/portal/apps/site_search/api/views.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,18 @@ def get(self, request, *args, **kwargs):
102102
return JsonResponse(response)
103103

104104
def _handle_tapis_ssh_exception(self, e):
105-
if 'SSH_POOL_MISSING_CREDENTIALS' in str(e) or 'SSH_FX_PERMISSION_DENIED' in str(e):
105+
if (
106+
"SSH_POOL_MISSING_CREDENTIALS" in str(e)
107+
or "SSH_FX_PERMISSION_DENIED" in str(e)
108+
or "FILES_CLIENT_SSH_OP_ERR1" in str(e)
109+
):
106110
# in case of these error types, user is not authenticated
107111
# or does not have access do not fail the entire search
108112
# request, log the issue.
109-
logger.exception("Error retrieving search results due to TAPIS SSH related error: {}".format(str(e)))
113+
logger.exception(
114+
"Error retrieving search results due to TAPIS SSH related error: {}".format(
115+
str(e)
116+
)
117+
)
110118
else:
111119
raise
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
1+
from unittest.mock import patch
2+
3+
from tapipy.errors import BaseTapyException
4+
5+
from portal.apps.site_search.api.views import SiteSearchApiView
6+
7+
18
def test_search_unauthenticated(client, regular_user):
2-
response = client.get('/search/')
9+
response = client.get("/search/")
310
assert response.status_code == 200
4-
assert response.context['setup_complete'] is False
11+
assert response.context["setup_complete"] is False
512

613

714
def test_search_authenticated_without_setup_complete(client, authenticated_user):
8-
response = client.get('/search/')
15+
response = client.get("/search/")
916
assert response.status_code == 200
10-
assert response.context['setup_complete'] is False
17+
assert response.context["setup_complete"] is False
1118

1219

1320
def test_search_authenticated_with_setup_complete(client, authenticated_user):
1421
authenticated_user.profile.setup_complete = True
1522
authenticated_user.profile.save()
16-
response = client.get('/search/')
23+
response = client.get("/search/")
1724
assert response.status_code == 200
18-
assert response.context['setup_complete']
25+
assert response.context["setup_complete"]
26+
27+
28+
@patch("portal.apps.site_search.api.views.logger")
29+
def test_handle_tapis_ssh_exception_files_client_ssh_op_err1(mock_logger):
30+
view = SiteSearchApiView()
31+
message = "FILES_CLIENT_SSH_OP_ERR1"
32+
exception = BaseTapyException(message)
33+
view._handle_tapis_ssh_exception(exception)
34+
mock_logger.exception.assert_called_once_with(
35+
f"Error retrieving search results due to TAPIS SSH related error: message: {message}"
36+
)

0 commit comments

Comments
 (0)