Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/WP-418: site search error when user does not have community file listing access. #1005

Merged
Merged
1 change: 1 addition & 0 deletions client/src/components/PublicData/PublicData.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/* FAQ: Public pages, like `PublicData` and `SiteSearch`, have no sidebar */
/* padding-left: 1.5em; /* ~24px (20px * design * 1.2 design-to-app ratio) */
}

12 changes: 10 additions & 2 deletions server/portal/apps/site_search/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,18 @@ def get(self, request, *args, **kwargs):
return JsonResponse(response)

def _handle_tapis_ssh_exception(self, e):
if 'SSH_POOL_MISSING_CREDENTIALS' in str(e) or 'SSH_FX_PERMISSION_DENIED' in str(e):
if (
"SSH_POOL_MISSING_CREDENTIALS" in str(e)
or "SSH_FX_PERMISSION_DENIED" in str(e)
or "FILES_CLIENT_SSH_OP_ERR1" in str(e)
):
# in case of these error types, user is not authenticated
# or does not have access do not fail the entire search
# request, log the issue.
logger.exception("Error retrieving search results due to TAPIS SSH related error: {}".format(str(e)))
logger.exception(
"Error retrieving search results due to TAPIS SSH related error: {}".format(
str(e)
)
)
else:
raise
30 changes: 24 additions & 6 deletions server/portal/apps/site_search/views_unit_test.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
from unittest.mock import patch

from tapipy.errors import BaseTapyException

from portal.apps.site_search.api.views import SiteSearchApiView


def test_search_unauthenticated(client, regular_user):
response = client.get('/search/')
response = client.get("/search/")
assert response.status_code == 200
assert response.context['setup_complete'] is False
assert response.context["setup_complete"] is False


def test_search_authenticated_without_setup_complete(client, authenticated_user):
response = client.get('/search/')
response = client.get("/search/")
assert response.status_code == 200
assert response.context['setup_complete'] is False
assert response.context["setup_complete"] is False


def test_search_authenticated_with_setup_complete(client, authenticated_user):
authenticated_user.profile.setup_complete = True
authenticated_user.profile.save()
response = client.get('/search/')
response = client.get("/search/")
assert response.status_code == 200
assert response.context['setup_complete']
assert response.context["setup_complete"]


@patch("portal.apps.site_search.api.views.logger")
def test_handle_tapis_ssh_exception_files_client_ssh_op_err1(mock_logger):
view = SiteSearchApiView()
message = "FILES_CLIENT_SSH_OP_ERR1"
exception = BaseTapyException(message)
view._handle_tapis_ssh_exception(exception)
mock_logger.exception.assert_called_once_with(
f"Error retrieving search results due to TAPIS SSH related error: message: {message}"
)