From bdb2a02756f2e97519259af51d4c03018fc09e58 Mon Sep 17 00:00:00 2001 From: shayanaijaz Date: Thu, 9 Nov 2023 10:25:53 -0600 Subject: [PATCH] linting, added CSRF setting to settings_default --- server/portal/apps/onboarding/api/views_unit_test.py | 2 +- server/portal/apps/projects/views.py | 4 ++-- server/portal/apps/webhooks/models.py | 1 - server/portal/asgi.py | 4 ++-- server/portal/settings/settings.py | 4 ++-- server/portal/settings/settings_default.py | 1 + 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/server/portal/apps/onboarding/api/views_unit_test.py b/server/portal/apps/onboarding/api/views_unit_test.py index 5beebe5a5..dd3ebab7c 100644 --- a/server/portal/apps/onboarding/api/views_unit_test.py +++ b/server/portal/apps/onboarding/api/views_unit_test.py @@ -199,7 +199,7 @@ def test_admin_route(client, authenticated_staff): # If the user is authenticated and is_staff, then the route should # return a JsonResponse response = client.get("/api/onboarding/admin/") - assert type(response) == JsonResponse + assert isinstance(response, JsonResponse) def test_admin_route_is_protected(authenticated_user, client): diff --git a/server/portal/apps/projects/views.py b/server/portal/apps/projects/views.py index ca03a8479..5fa35be9a 100644 --- a/server/portal/apps/projects/views.py +++ b/server/portal/apps/projects/views.py @@ -14,8 +14,8 @@ from portal.views.base import BaseApiView from portal.apps.projects.managers.base import ProjectsManager from portal.apps.projects.workspace_operations.shared_workspace_operations import \ - list_projects, get_project, create_shared_workspace,\ - update_project, get_workspace_role, change_user_role, add_user_to_workspace,\ + list_projects, get_project, create_shared_workspace, \ + update_project, get_workspace_role, change_user_role, add_user_to_workspace, \ remove_user, transfer_ownership from portal.apps.search.tasks import tapis_project_listing_indexer from portal.libs.elasticsearch.indexes import IndexedProject diff --git a/server/portal/apps/webhooks/models.py b/server/portal/apps/webhooks/models.py index 5ac622760..cbd42d3d7 100644 --- a/server/portal/apps/webhooks/models.py +++ b/server/portal/apps/webhooks/models.py @@ -1,6 +1,5 @@ from django.db import models from django.conf import settings -from datetime import datetime from django.utils import timezone diff --git a/server/portal/asgi.py b/server/portal/asgi.py index 74d5d5e21..ebf8cdd9a 100644 --- a/server/portal/asgi.py +++ b/server/portal/asgi.py @@ -5,7 +5,7 @@ import os import django -from channels.routing import get_default_application, ProtocolTypeRouter +from channels.routing import ProtocolTypeRouter from django.core.asgi import get_asgi_application @@ -13,4 +13,4 @@ django.setup() application = ProtocolTypeRouter({ "http": get_asgi_application(), -}) \ No newline at end of file +}) diff --git a/server/portal/settings/settings.py b/server/portal/settings/settings.py index ddbc0265d..619d12960 100644 --- a/server/portal/settings/settings.py +++ b/server/portal/settings/settings.py @@ -44,8 +44,8 @@ # whether the session cookie should be secure (https:// only) SESSION_COOKIE_SECURE = True CSRF_COOKIE_SAMESITE = 'Strict' -# for local testing -CSRF_TRUSTED_ORIGINS = ['https://cep.test'] +# for local testing +CSRF_TRUSTED_ORIGINS = settings_custom._CSRF_TRUSTED_ORIGINS SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') ALLOWED_HOSTS = ['*'] diff --git a/server/portal/settings/settings_default.py b/server/portal/settings/settings_default.py index 443520033..9ce91759a 100644 --- a/server/portal/settings/settings_default.py +++ b/server/portal/settings/settings_default.py @@ -28,6 +28,7 @@ _RT_QUEUE = 'Web & Mobile Apps' _RT_TAG = 'core_portal' +_CSRF_TRUSTED_ORIGINS = ['https://cep.test'] ######################## # TAPIS SETTINGS