From 0f195846e1e1f738b87f104b088eced6d89a13cb Mon Sep 17 00:00:00 2001 From: Jim Laney Date: Fri, 5 Jan 2024 10:01:41 -0800 Subject: [PATCH 1/4] ubuntu 22.04 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 48b5755..8f5fb20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:20.04 as django-container +FROM ubuntu:22.04 as django-container WORKDIR /app/ ENV PYTHONUNBUFFERED 1 ENV TZ America/Los_Angeles From 4f870ead9ff1a9884d8cf51bbd0bd5635bd8b766 Mon Sep 17 00:00:00 2001 From: Jim Laney Date: Fri, 5 Jan 2024 10:02:25 -0800 Subject: [PATCH 2/4] add CSRF_TRUSTED_ORIGINS to common settings --- project/base_settings/common.py | 2 ++ tests/test_settings/test_common.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/project/base_settings/common.py b/project/base_settings/common.py index 8e2e314..95007bc 100644 --- a/project/base_settings/common.py +++ b/project/base_settings/common.py @@ -12,6 +12,8 @@ os.getenv('HOSTNAME'), # Internal hostname socket.gethostbyname(os.getenv('HOSTNAME')), # IP ] + # Apps that support multiple external hostnames will need to extend this list + CSRF_TRUSTED_ORIGINS = ['https://' + os.getenv('CLUSTER_CNAME')] if os.getenv('ENV', 'localdev') == 'localdev': SECRET_KEY = os.getenv('DJANGO_SECRET', get_random_secret_key()) diff --git a/tests/test_settings/test_common.py b/tests/test_settings/test_common.py index a1115c7..23a594b 100644 --- a/tests/test_settings/test_common.py +++ b/tests/test_settings/test_common.py @@ -26,6 +26,12 @@ def test_notlocaldev_without_django_secret(self): with SettingLoader('project.base_settings', ENV='notlocaldev') as base_settings: self.assertIsNone(base_settings.SECRET_KEY) +class TestAllowedHosts(TestCase): + def test_allowed_hosts(self): + with SettingLoader('project.base_settings', ENV='notlocaldev', CLUSTER_CNAME='test.edu', HOSTNAME='1.2.3.4') as base_settings: + self.assertEqual(base_settings.ALLOWED_HOSTS, ['test.edu', '1.2.3.4', '1.2.3.4']) + self.assertEqual(base_settings.CSRF_TRUSTED_ORIGINS, ['https://test.edu']) + class TestInstalledApps(TestCase): def test_contains_required_apps(self): with SettingLoader('project.base_settings') as base_settings: From 228a08d98c7f011dfb996b1d8913ba1b78aa9c35 Mon Sep 17 00:00:00 2001 From: Jim Laney Date: Fri, 5 Jan 2024 10:02:54 -0800 Subject: [PATCH 3/4] update copyright --- project/mail/backends.py | 2 +- scripts/call_command.py | 2 +- scripts/management_command.py | 2 +- scripts/management_daemon.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/project/mail/backends.py b/project/mail/backends.py index 4f1a446..b6f84bd 100644 --- a/project/mail/backends.py +++ b/project/mail/backends.py @@ -1,4 +1,4 @@ -# Copyright 2023 UW-IT, University of Washington +# Copyright 2024 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 from django.core.mail.backends.smtp import EmailBackend as SMTPBackend diff --git a/scripts/call_command.py b/scripts/call_command.py index 266f7ea..973841c 100644 --- a/scripts/call_command.py +++ b/scripts/call_command.py @@ -1,4 +1,4 @@ -# Copyright 2021 UW-IT, University of Washington +# Copyright 2024 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 import django diff --git a/scripts/management_command.py b/scripts/management_command.py index e44974e..e833157 100644 --- a/scripts/management_command.py +++ b/scripts/management_command.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2021 UW-IT, University of Washington +# Copyright 2024 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 from call_command import CallCommand diff --git a/scripts/management_daemon.py b/scripts/management_daemon.py index 8b92bd2..a13ec28 100644 --- a/scripts/management_daemon.py +++ b/scripts/management_daemon.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2021 UW-IT, University of Washington +# Copyright 2024 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 from call_command import CallCommand From a9b78b65a3843acc178273967d8e25112f933461 Mon Sep 17 00:00:00 2001 From: Jim Laney Date: Fri, 5 Jan 2024 10:09:28 -0800 Subject: [PATCH 4/4] update cicd --- .github/workflows/cicd.yml | 9 ++++----- Dockerfile | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index dfe99ee..a09bb5f 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -13,12 +13,11 @@ on: jobs: test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: matrix: django-version: - - '2.2' - '3.2' - '4.2' @@ -29,7 +28,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: '3.10' - name: Install Test Dependencies run: | @@ -52,7 +51,7 @@ jobs: build: needs: test - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout Repo @@ -61,7 +60,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: '3.10' - name: Set up tags id: tags diff --git a/Dockerfile b/Dockerfile index 8f5fb20..aaca66e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ RUN apt-get update -y && \ openssl \ pkg-config \ python-setuptools \ - python3.8-dev \ + python3.10-dev \ python3-venv \ python3-pip \ sqlite3 \