diff --git a/.annotation_safe_list.yml b/.annotation_safe_list.yml deleted file mode 100644 index 45c6a18..0000000 --- a/.annotation_safe_list.yml +++ /dev/null @@ -1,37 +0,0 @@ -# This is a Code Annotations automatically-generated Django model safelist file. -# These models must be annotated as follows in order to be counted in the coverage report. -# See https://code-annotations.readthedocs.io/en/latest/safelist.html for more information. -# -# fake_app_1.FakeModelName: -# ".. no_pii:": "This model has no PII" -# fake_app_2.FakeModel2: -# ".. choice_annotation:": foo, bar, baz - -admin.LogEntry: - ".. no_pii:": "This model has no PII" -auth.Group: - ".. no_pii:": "This model has no PII" -auth.Permission: - ".. no_pii:": "This model has no PII" -contenttypes.ContentType: - ".. no_pii:": "This model has no PII" -sessions.Session: - ".. no_pii:": "This model has no PII" -social_django.Association: - ".. no_pii:": "This model has no PII" -social_django.Code: - ".. pii:": "Email address" - ".. pii_types:": other - ".. pii_retirement:": local_api -social_django.Nonce: - ".. no_pii:": "This model has no PII" -social_django.Partial: - ".. no_pii:": "This model has no PII" -social_django.UserSocialAuth: - ".. no_pii:": "This model has no PII" -waffle.Flag: - ".. no_pii:": "This model has no PII" -waffle.Sample: - ".. no_pii:": "This model has no PII" -waffle.Switch: - ".. no_pii:": "This model has no PII" diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index ac656cb..38d4cc7 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,8 +1,9 @@ **Merge checklist:** Check off if complete *or* not applicable: +- [ ] Version bumped +- [ ] Changelog record added - [ ] Documentation updated (not only docstrings) -- [ ] Fixup commits are squashed away - [ ] Unit tests added/updated - [ ] Manual testing instructions provided - [ ] Noted any: Concerns, dependencies, migration issues, deadlines, tickets diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e6645cb..fbb5405 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: matrix: os: [ubuntu-latest] python-version: ["3.12"] - toxenv: ["py311", "quality", "docs", "pii_check"] + toxenv: ["py312", "quality", "docs"] steps: - uses: actions/checkout@v4 - name: setup python diff --git a/.pii_annotations.yml b/.pii_annotations.yml deleted file mode 100644 index 7da8f3c..0000000 --- a/.pii_annotations.yml +++ /dev/null @@ -1,35 +0,0 @@ -source_path: ./ -report_path: pii_report -safelist_path: .annotation_safe_list.yml -coverage_target: 100.0 -annotations: - ".. no_pii:": - "pii_group": - - ".. pii:": - - ".. pii_types:": - choices: - - id # Unique identifier for the user which is shared across systems - - name # Used for any part of the user's name - - username - - password - - location # Used for any part of any type address or country stored - - phone_number # Used for phone or fax numbers - - email_address - - birth_date # Used for any part of a stored birth date - - ip # IP address - - external_service # Used for external service ids or links such as social media links or usernames, website links, etc. - - biography # Any type of free-form biography field - - gender - - sex - - image - - video - - other - - ".. pii_retirement:": - choices: - - retained # Intentionally kept for legal reasons - - local_api # An API exists in this repository for retiring this information - - consumer_api # The data's consumer must implement an API for retiring this information - - third_party # A third party API exists to retire this data -extensions: - python: - - py diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index a792b32..0000000 --- a/Dockerfile +++ /dev/null @@ -1,86 +0,0 @@ -FROM ubuntu:focal as app - -# Packages installed: - -# language-pack-en locales; ubuntu locale support so that system utilities have a consistent -# language and time zone. - -# python; ubuntu doesnt ship with python, so this is the python we will use to run the application - -# python3-pip; install pip to install application requirements.txt files - -# libmysqlclient-dev; to install header files needed to use native C implementation for -# MySQL-python for performance gains. - -# libssl-dev; # mysqlclient wont install without this. - -# python3-dev; to install header files for python extensions; much wheel-building depends on this - -# gcc; for compiling python extensions distributed with python packages like mysql-client - -# If you add a package here please include a comment above describing what it is used for -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qy install --no-install-recommends \ - language-pack-en locales \ - python3.12 python3-dev python3-pip \ - # The mysqlclient Python package has install-time dependencies - libmysqlclient-dev libssl-dev pkg-config \ - gcc - - -RUN pip install --upgrade pip setuptools -# delete apt package lists because we do not need them inflating our image -RUN rm -rf /var/lib/apt/lists/* - -RUN ln -s /usr/bin/python3 /usr/bin/python - -RUN locale-gen en_US.UTF-8 -ENV LANG en_US.UTF-8 -ENV LANGUAGE en_US:en -ENV LC_ALL en_US.UTF-8 - -EXPOSE 18030 -RUN useradd -m --shell /bin/false app - -WORKDIR /edx/app/codejail-service - -FROM app as prod - -ENV DJANGO_SETTINGS_MODULE codejail_service.settings.production - -# Copy the requirements explicitly even though we copy everything below -# this prevents the image cache from busting unless the dependencies have changed. -COPY requirements/production.txt /edx/app/codejail-service/requirements/production.txt - -# Dependencies are installed as root so they cannot be modified by the application user. -RUN pip install -r requirements/production.txt - -RUN mkdir -p /edx/var/log - -# Code is owned by root so it cannot be modified by the application user. -# So we copy it before changing users. -USER app - -# Gunicorn 19 does not log to stdout or stderr by default. Once we are past gunicorn 19, the logging to STDOUT need not be specified. -CMD gunicorn --workers=2 --name codejail-service -c /edx/app/codejail-service/codejail_service/docker_gunicorn_configuration.py --log-file - --max-requests=1000 codejail_service.wsgi:application - -# This line is after the requirements so that changes to the code will not -# bust the image cache -COPY . /edx/app/codejail-service - -FROM app as dev - -ENV DJANGO_SETTINGS_MODULE codejail_service.settings.devstack - -# Copy the requirements explicitly even though we copy everything below -# this prevents the image cache from busting unless the dependencies have changed. -COPY requirements/dev.txt /edx/app/codejail-service/requirements/dev.txt - -RUN pip install -r requirements/dev.txt - -# After the requirements so changes to the code will not bust the image cache -COPY . /edx/app/codejail-service - -# Devstack related step for backwards compatibility -RUN touch codejail_service/codejail_service_env - -CMD while true; do python ./manage.py runserver 0.0.0.0:18030; sleep 2; done \ No newline at end of file diff --git a/Makefile b/Makefile index 2cd0016..3e23d02 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,11 @@ .DEFAULT_GOAL := help .PHONY: help clean clean_tox docs requirements ci_requirements dev_requirements \ - validation_requirements doc_requirements production-requirements static shell \ - test coverage isort_check isort style lint quality pii_check validate \ + validation_requirements doc_requirements static shell \ + test coverage isort_check isort style lint qualityvalidate \ migrate html_coverage upgrade extract_translation dummy_translations \ compile_translations fake_translations pull_translations \ - start-devstack open-devstack pkg-devstack \ - detect_changed_source_translations validate_translations check_keywords \ + detect_changed_source_translations validate_translations \ install_transifex_client # For opening files in a browser. Use like: $(BROWSER)relative/path/to/file.html @@ -21,7 +20,6 @@ clean: ## delete generated byte code and coverage reports find . -name '*.pyc' -delete coverage erase rm -rf assets - rm -rf pii_report clean_tox: ## clear tox requirements cache rm -fr .tox @@ -47,9 +45,6 @@ validation_requirements: piptools ## sync to requirements for testing & code qua doc_requirements: piptools pip-sync -q requirements/doc.txt -production-requirements: piptools ## install requirements for production - pip-sync -q requirements/production.txt - static: ## generate static files python manage.py collectstatic --noinput @@ -79,14 +74,7 @@ lint: ## run Python code linting quality: tox -e quality -pii_check: ## check for PII annotations on all Django models - DJANGO_SETTINGS_MODULE=codejail_service.settings.test \ - code_annotations django_find_annotations --config_file .pii_annotations.yml --lint --report --coverage - -check_keywords: ## Scan the Django models in all installed apps in this project for restricted field names - python manage.py check_reserved_keywords --override_file db_keyword_overrides.yml - -validate: test quality pii_check check_keywords ## run tests, quality, and PII annotation checks +validate: test quality ## run tests, quality migrate: ## apply database migrations python manage.py migrate @@ -112,7 +100,6 @@ upgrade: ## update the requirements/*.txt files with the latest packages satisfy $(PIP_COMPILE) -o requirements/validation.txt requirements/validation.in $(PIP_COMPILE) -o requirements/ci.txt requirements/ci.in $(PIP_COMPILE) -o requirements/dev.txt requirements/dev.in - $(PIP_COMPILE) -o requirements/production.txt requirements/production.in # Let tox control the Django version for tests grep -e "^django==" requirements/base.txt > requirements/django.txt sed '/^[dD]jango==/d' requirements/test.txt > requirements/test.tmp @@ -142,60 +129,11 @@ pull_translations: @echo "Translations have been pulled via Atlas and compiled." endif -start-devstack: ## run a local development copy of the server - docker-compose --x-networking up - -open-devstack: ## open a shell on the server started by start-devstack - docker exec -it codejail-service /edx/app/codejail-service/devstack.sh open - -pkg-devstack: ## build the codejail-service image from the latest configuration and code - docker build -t codejail-service:latest -f docker/build/codejail-service/Dockerfile git://github.com/openedx/configuration - detect_changed_source_translations: ## check if translation files are up-to-date cd codejail_service && i18n_tool changed validate_translations: fake_translations detect_changed_source_translations ## install fake translations and check if translation files are up-to-date -docker_build: - docker build . -f Dockerfile -t openedx/codejail-service - -# devstack-themed shortcuts -dev.up: # Starts all containers - docker-compose up -d - -dev.up.build: - docker-compose up -d --build - -dev.down: # Kills containers and all of their data that isn't in volumes - docker-compose down - -dev.stop: # Stops containers so they can be restarted - docker-compose stop - -app-shell: # Run the app shell as root - docker exec -u 0 -it codejail_service.app bash - -db-shell: # Run the app shell as root, enter the app's database - docker exec -u 0 -it codejail_service.db mysql -u root codejail_service - -%-logs: # View the logs of the specified service container - docker-compose logs -f --tail=500 $* - -%-restart: # Restart the specified service container - docker-compose restart $* - -%-attach: - docker attach codejail_service.$* - -docker_auth: - echo "$$DOCKERHUB_PASSWORD" | docker login -u "$$DOCKERHUB_USERNAME" --password-stdin - -docker_tag_build_push: docker_auth - docker buildx build -t openedx/codejail-service:latest -t openedx/codejail-service:${GITHUB_SHA} --platform linux/amd64,linux/arm64 --target prod --push . - -docker_tag_build_push_dev: docker_auth - docker buildx build -t openedx/codejail-service-dev:latest -t openedx/codejail-service-dev:${GITHUB_SHA} --platform linux/amd64,linux/arm64 --target dev --push . - selfcheck: ## check that the Makefile is well-formed @echo "The Makefile is well-formed." diff --git a/catalog-info.yaml b/catalog-info.yaml index d79b7fb..02c4b0e 100644 --- a/catalog-info.yaml +++ b/catalog-info.yaml @@ -2,7 +2,7 @@ # https://open-edx-proposals.readthedocs.io/en/latest/processes/oep-0055-proc-project-maintainers.html apiVersion: backstage.io/v1alpha1 -kind: "" +kind: Component metadata: name: 'codejail-service' description: "Run codejail (sandboxed Python execution) as a service" @@ -10,29 +10,20 @@ metadata: # The openedx.org/release key is described in OEP-10: # https://open-edx-proposals.readthedocs.io/en/latest/oep-0010-proc-openedx-releases.html # The FAQ might also be helpful: https://openedx.atlassian.net/wiki/spaces/COMM/pages/1331268879/Open+edX+Release+FAQ - # Note: This will only work if the repo is in the `openedx` org in github. Repos in other orgs that have this - # setting will still be treated as if they don't want to be part of the Open edX releases. - openedx.org/release: null - # (Optional) Annotation keys and values can be whatever you want. - # We use it in Open edX repos to have a comma-separated list of GitHub user - # names that might be interested in changes to the architecture of this - # component. - openedx.org/arch-interest-groups: "" + openedx.org/release: "main" spec: # (Required) This can be a group(`group:` or a user(`user:`) owner: "" # (Required) Acceptable Type Values: service, website, library - type: '' + type: service # (Required) Acceptable Lifecycle Values: experimental, production, deprecated lifecycle: 'experimental' # (Optional) The value can be the name of any known component. - subcomponentOf: '' + subcomponentOf: edx-platform # (Optional) An array of different components or resources. - dependsOn: - - '' - - '' + dependsOn: [] diff --git a/codejail_service/apps/api/models.py b/codejail_service/apps/api/models.py deleted file mode 100644 index ff4afbb..0000000 --- a/codejail_service/apps/api/models.py +++ /dev/null @@ -1,4 +0,0 @@ -# Models that can be shared across multiple versions of the API -# should be created here. As the API evolves, models may become more -# specific to a particular version of the API. In this case, the models -# in question should be moved to versioned sub-package. diff --git a/codejail_service/apps/api/serializers.py b/codejail_service/apps/api/serializers.py deleted file mode 100644 index 6906750..0000000 --- a/codejail_service/apps/api/serializers.py +++ /dev/null @@ -1,4 +0,0 @@ -# Serializers that can be shared across multiple versions of the API -# should be created here. As the API evolves, serializers may become more -# specific to a particular version of the API. In this case, the serializers -# in question should be moved to versioned sub-package. diff --git a/codejail_service/apps/core/admin.py b/codejail_service/apps/core/admin.py deleted file mode 100644 index 8122c55..0000000 --- a/codejail_service/apps/core/admin.py +++ /dev/null @@ -1,22 +0,0 @@ -""" Admin configuration for core models. """ - -from django.contrib import admin -from django.contrib.auth.admin import UserAdmin -from django.utils.translation import gettext_lazy as _ - -from codejail_service.apps.core.models import User - - -class CustomUserAdmin(UserAdmin): - """ Admin configuration for the custom User model. """ - list_display = ('username', 'email', 'full_name', 'first_name', 'last_name', 'is_staff') - fieldsets = ( - (None, {'fields': ('username', 'password')}), - (_('Personal info'), {'fields': ('full_name', 'first_name', 'last_name', 'email')}), - (_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser', - 'groups', 'user_permissions')}), - (_('Important dates'), {'fields': ('last_login', 'date_joined')}), - ) - - -admin.site.register(User, CustomUserAdmin) diff --git a/codejail_service/apps/core/constants.py b/codejail_service/apps/core/constants.py deleted file mode 100644 index 8a969c7..0000000 --- a/codejail_service/apps/core/constants.py +++ /dev/null @@ -1,7 +0,0 @@ -""" Constants for the core app. """ - - -class Status: - """Health statuses.""" - OK = "OK" - UNAVAILABLE = "UNAVAILABLE" diff --git a/codejail_service/apps/core/context_processors.py b/codejail_service/apps/core/context_processors.py deleted file mode 100644 index 7d3ba35..0000000 --- a/codejail_service/apps/core/context_processors.py +++ /dev/null @@ -1,9 +0,0 @@ -""" Core context processors. """ -from django.conf import settings - - -def core(_request): - """ Site-wide context processor. """ - return { - 'platform_name': settings.PLATFORM_NAME - } diff --git a/codejail_service/apps/core/migrations/__init__.py b/codejail_service/apps/core/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/codejail_service/apps/core/models.py b/codejail_service/apps/core/models.py deleted file mode 100644 index 0227cd3..0000000 --- a/codejail_service/apps/core/models.py +++ /dev/null @@ -1,37 +0,0 @@ -""" Core models. """ - -from django.contrib.auth.models import AbstractUser -from django.db import models -from django.utils.translation import gettext_lazy as _ - - -class User(AbstractUser): - """ - Custom user model for use with python-social-auth via edx-auth-backends. - - .. pii: Stores full name, username, and email address for a user. - .. pii_types: name, username, email_address - .. pii_retirement: local_api - - """ - full_name = models.CharField(_('Full Name'), max_length=255, blank=True, null=True) - - @property - def access_token(self): - """ - Returns an OAuth2 access token for this user, if one exists; otherwise None. - Assumes user has authenticated at least once with the OAuth2 provider (LMS). - """ - try: - return self.social_auth.first().extra_data['access_token'] # pylint: disable=no-member - except Exception: # pylint: disable=broad-except - return None - - class Meta: - get_latest_by = 'date_joined' - - def get_full_name(self): - return self.full_name or super().get_full_name() - - def __str__(self): - return str(self.get_full_name()) diff --git a/codejail_service/apps/core/tests/test_context_processors.py b/codejail_service/apps/core/tests/test_context_processors.py deleted file mode 100644 index 9de893b..0000000 --- a/codejail_service/apps/core/tests/test_context_processors.py +++ /dev/null @@ -1,16 +0,0 @@ -""" Context processor tests. """ - -from django.test import RequestFactory, TestCase, override_settings - -from codejail_service.apps.core.context_processors import core - -PLATFORM_NAME = 'Test Platform' - - -class CoreContextProcessorTests(TestCase): - """ Tests for core.context_processors.core """ - - @override_settings(PLATFORM_NAME=PLATFORM_NAME) - def test_core(self): - request = RequestFactory().get('/') - self.assertDictEqual(core(request), {'platform_name': PLATFORM_NAME}) diff --git a/codejail_service/apps/core/tests/test_models.py b/codejail_service/apps/core/tests/test_models.py deleted file mode 100644 index 778ea88..0000000 --- a/codejail_service/apps/core/tests/test_models.py +++ /dev/null @@ -1,45 +0,0 @@ -""" Tests for core models. """ - -from django.test import TestCase -from django_dynamic_fixture import G -from social_django.models import UserSocialAuth - -from codejail_service.apps.core.models import User - - -class UserTests(TestCase): - """ User model tests. """ - TEST_CONTEXT = {'foo': 'bar', 'baz': None} - - def test_access_token(self): - user = G(User) - self.assertIsNone(user.access_token) - - social_auth = G(UserSocialAuth, user=user) - self.assertIsNone(user.access_token) - - access_token = 'My voice is my passport. Verify me.' - social_auth.extra_data['access_token'] = access_token - social_auth.save() - self.assertEqual(user.access_token, access_token) - - def test_get_full_name(self): - """ Test that the user model concatenates first and last name if the full name is not set. """ - full_name = 'George Costanza' - user = G(User, full_name=full_name) - self.assertEqual(user.get_full_name(), full_name) - - first_name = 'Jerry' - last_name = 'Seinfeld' - user = G(User, full_name=None, first_name=first_name, last_name=last_name) - expected = '{first_name} {last_name}'.format(first_name=first_name, last_name=last_name) - self.assertEqual(user.get_full_name(), expected) - - user = G(User, full_name=full_name, first_name=first_name, last_name=last_name) - self.assertEqual(user.get_full_name(), full_name) - - def test_string(self): - """Verify that the model's string method returns the user's full name.""" - full_name = 'Bob' - user = G(User, full_name=full_name) - self.assertEqual(str(user), full_name) diff --git a/codejail_service/apps/core/tests/test_views.py b/codejail_service/apps/core/tests/test_views.py index eece556..2515d24 100644 --- a/codejail_service/apps/core/tests/test_views.py +++ b/codejail_service/apps/core/tests/test_views.py @@ -1,76 +1,20 @@ """Test core.views.""" -from unittest import mock - -from django.conf import settings -from django.contrib.auth import get_user_model -from django.db import DatabaseError from django.test import TestCase -from django.test.utils import override_settings from django.urls import reverse -from codejail_service.apps.core.constants import Status - -User = get_user_model() - class HealthTests(TestCase): """Tests of the health endpoint.""" - def test_all_services_available(self): + def test_healthcheck(self): """Test that the endpoint reports when all services are healthy.""" - self._assert_health(200, Status.OK, Status.OK) - - def test_database_outage(self): - """Test that the endpoint reports when the database is unavailable.""" - with mock.patch('django.db.backends.base.base.BaseDatabaseWrapper.cursor', side_effect=DatabaseError): - self._assert_health(503, Status.UNAVAILABLE, Status.UNAVAILABLE) - - def _assert_health(self, status_code, overall_status, database_status): - """Verify that the response matches expectations.""" response = self.client.get(reverse('health')) - self.assertEqual(response.status_code, status_code) + self.assertEqual(response.status_code, 200) self.assertEqual(response['content-type'], 'application/json') expected_data = { - 'overall_status': overall_status, - 'detailed_status': { - 'database_status': database_status - } + 'status': 'OK' } self.assertJSONEqual(response.content, expected_data) - - -class AutoAuthTests(TestCase): - """ Auto Auth view tests. """ - AUTO_AUTH_PATH = reverse('auto_auth') - - @override_settings(ENABLE_AUTO_AUTH=False) - def test_setting_disabled(self): - """When the ENABLE_AUTO_AUTH setting is False, the view should raise a 404.""" - response = self.client.get(self.AUTO_AUTH_PATH) - self.assertEqual(response.status_code, 404) - - @override_settings(ENABLE_AUTO_AUTH=True) - def test_setting_enabled(self): - """ - When ENABLE_AUTO_AUTH is set to True, the view should create and authenticate - a new User with superuser permissions. - """ - original_user_count = User.objects.count() - response = self.client.get(self.AUTO_AUTH_PATH) - - # Verify that a redirect has occured and that a new user has been created - self.assertEqual(response.status_code, 302) - self.assertEqual(User.objects.count(), original_user_count + 1) - - # Get the latest user - user = User.objects.latest() - - # Verify that the user is logged in and that their username has the expected prefix - self.assertEqual(int(self.client.session['_auth_user_id']), user.pk) - self.assertTrue(user.username.startswith(settings.AUTO_AUTH_USERNAME_PREFIX)) - - # Verify that the user has superuser permissions - self.assertTrue(user.is_superuser) diff --git a/codejail_service/apps/core/views.py b/codejail_service/apps/core/views.py index 947978b..25f418b 100644 --- a/codejail_service/apps/core/views.py +++ b/codejail_service/apps/core/views.py @@ -1,22 +1,12 @@ """ Core views. """ import logging -import uuid -from django.conf import settings -from django.contrib.auth import authenticate, get_user_model, login -from django.db import DatabaseError, connection, transaction -from django.http import Http404, JsonResponse -from django.shortcuts import redirect -from django.views.generic import View +from django.http import JsonResponse from edx_django_utils.monitoring import ignore_transaction -from codejail_service.apps.core.constants import Status - logger = logging.getLogger(__name__) -User = get_user_model() -@transaction.non_atomic_requests def health(_): """Allows a load balancer to verify this service is up. @@ -37,53 +27,5 @@ def health(_): # Ignores health check in performance monitoring so as to not artifically inflate our response time metrics ignore_transaction() - try: - cursor = connection.cursor() - cursor.execute("SELECT 1") - cursor.fetchone() - cursor.close() - database_status = Status.OK - except DatabaseError: - database_status = Status.UNAVAILABLE - - overall_status = Status.OK if (database_status == Status.OK) else Status.UNAVAILABLE - - data = { - 'overall_status': overall_status, - 'detailed_status': { - 'database_status': database_status, - }, - } - - if overall_status == Status.OK: - return JsonResponse(data) - else: - return JsonResponse(data, status=503) - - -class AutoAuth(View): - """Creates and authenticates a new User with superuser permissions. - - If the ENABLE_AUTO_AUTH setting is not True, returns a 404. - """ - - def get(self, request): - """ - Create a new User. - - Raises Http404 if auto auth is not enabled. - """ - if not getattr(settings, 'ENABLE_AUTO_AUTH', None): - raise Http404 - - username_prefix = getattr(settings, 'AUTO_AUTH_USERNAME_PREFIX', 'auto_auth_') - - # Create a new user with staff permissions - username = password = username_prefix + uuid.uuid4().hex[0:20] - User.objects.create_superuser(username, email=None, password=password) - - # Log in the new user - user = authenticate(username=username, password=password) - login(request, user) - - return redirect('/') + # Always "healthy", for now -- no state to look at. Revisit later. + return JsonResponse({'status': 'OK'}) diff --git a/codejail_service/docker_gunicorn_configuration.py b/codejail_service/docker_gunicorn_configuration.py index 0dde6eb..6437ef6 100644 --- a/codejail_service/docker_gunicorn_configuration.py +++ b/codejail_service/docker_gunicorn_configuration.py @@ -5,7 +5,6 @@ preload_app = True timeout = 300 -bind = "0.0.0.0:18030" workers = 2 diff --git a/codejail_service/settings/base.py b/codejail_service/settings/base.py index a2fe213..58a50dd 100644 --- a/codejail_service/settings/base.py +++ b/codejail_service/settings/base.py @@ -3,8 +3,6 @@ import os from os.path import abspath, dirname, join -from corsheaders.defaults import default_headers as corsheaders_default_headers - from codejail_service.settings.utils import get_logger_config # PATH vars @@ -26,218 +24,40 @@ def root(*path_fragments): # Application definition INSTALLED_APPS = ( - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'release_util', -) - -THIRD_PARTY_APPS = ( - 'corsheaders', - 'csrf.apps.CsrfAppConfig', # Enables frontend apps to retrieve CSRF tokens - 'rest_framework', - 'rest_framework_swagger', - 'social_django', - 'waffle', -) - -PROJECT_APPS = ( 'codejail_service.apps.core', 'codejail_service.apps.api', ) -INSTALLED_APPS += THIRD_PARTY_APPS -INSTALLED_APPS += PROJECT_APPS - MIDDLEWARE = ( - # Resets RequestCache utility for added safety. - 'edx_django_utils.cache.middleware.RequestCacheMiddleware', - # Monitoring middleware should be immediately after RequestCacheMiddleware - 'edx_django_utils.monitoring.DeploymentMonitoringMiddleware', # python and django version - 'edx_django_utils.monitoring.CookieMonitoringMiddleware', # cookie names (compliance) and sizes - 'edx_django_utils.monitoring.CachedCustomMonitoringMiddleware', # support accumulate & increment - 'edx_django_utils.monitoring.MonitoringMemoryMiddleware', # memory usage + # TODO: re-enable once we have waffle available + # 'edx_django_utils.monitoring.DeploymentMonitoringMiddleware', # python and django version + # 'edx_django_utils.monitoring.CookieMonitoringMiddleware', # cookie names (compliance) and sizes + # 'edx_django_utils.monitoring.CachedCustomMonitoringMiddleware', # support accumulate & increment + # 'edx_django_utils.monitoring.MonitoringMemoryMiddleware', # memory usage - 'corsheaders.middleware.CorsMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', - 'edx_rest_framework_extensions.auth.jwt.middleware.JwtAuthCookieMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'social_django.middleware.SocialAuthExceptionMiddleware', - 'waffle.middleware.WaffleMiddleware', - # Enables force_django_cache_miss functionality for TieredCache. - 'edx_django_utils.cache.middleware.TieredCacheMiddleware', - # Outputs monitoring metrics for a request. - 'edx_rest_framework_extensions.middleware.RequestCustomAttributesMiddleware', - # Ensures proper DRF permissions in support of JWTs - 'edx_rest_framework_extensions.auth.jwt.middleware.EnsureJWTAuthSettingsMiddleware', ) -# Enable CORS -CORS_ALLOW_CREDENTIALS = True -CORS_ALLOW_HEADERS = corsheaders_default_headers + ( - 'use-jwt-cookie', -) -CORS_ORIGIN_WHITELIST = [] - ROOT_URLCONF = 'codejail_service.urls' # Python dotted path to the WSGI application used by Django's runserver. WSGI_APPLICATION = 'codejail_service.wsgi.application' -# Database -# https://docs.djangoproject.com/en/3.2/ref/settings/#databases -# Set this value in the environment-specific files (e.g. local.py, production.py, test.py) -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.', - 'NAME': '', - 'USER': '', - 'PASSWORD': '', - 'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. - 'PORT': '', # Set to empty string for default. - } -} - -# New DB primary keys default to an IntegerField. -DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' +# No database for codejail +DATABASES = {} # Internationalization # https://docs.djangoproject.com/en/dev/topics/i18n/ - LANGUAGE_CODE = 'en-us' - TIME_ZONE = 'UTC' - USE_I18N = True - USE_L10N = True - USE_TZ = True - LOCALE_PATHS = ( root('conf', 'locale'), ) - -# MEDIA CONFIGURATION -# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root -MEDIA_ROOT = root('media') - -# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url -MEDIA_URL = '/media/' -# END MEDIA CONFIGURATION - - -# STATIC FILE CONFIGURATION -# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root -STATIC_ROOT = root('assets') - -# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url -STATIC_URL = '/static/' - -# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS -STATICFILES_DIRS = ( - root('static'), -) - -# TEMPLATE CONFIGURATION -# See: https://docs.djangoproject.com/en/3.2/ref/settings/#templates -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'APP_DIRS': True, - 'DIRS': ( - root('templates'), - ), - 'OPTIONS': { - 'context_processors': ( - 'django.contrib.auth.context_processors.auth', - 'django.template.context_processors.debug', - 'django.template.context_processors.i18n', - 'django.template.context_processors.media', - 'django.template.context_processors.request', - 'django.template.context_processors.static', - 'django.template.context_processors.tz', - 'django.contrib.messages.context_processors.messages', - 'codejail_service.apps.core.context_processors.core', - ), - 'debug': True, # Django will only display debug pages if the global DEBUG setting is set to True. - } - }, -] -# END TEMPLATE CONFIGURATION - - -# COOKIE CONFIGURATION -# The purpose of customizing the cookie names is to avoid conflicts when -# multiple Django services are running behind the same hostname. -# Detailed information at: https://docs.djangoproject.com/en/dev/ref/settings/ -SESSION_COOKIE_NAME = 'codejail_service_sessionid' -CSRF_COOKIE_NAME = 'codejail_service_csrftoken' -LANGUAGE_COOKIE_NAME = 'codejail_service_language' -# END COOKIE CONFIGURATION - -CSRF_COOKIE_SECURE = False -CSRF_TRUSTED_ORIGINS = [] - -# AUTHENTICATION CONFIGURATION -LOGIN_URL = '/login/' -LOGOUT_URL = '/logout/' - -AUTH_USER_MODEL = 'core.User' - -AUTHENTICATION_BACKENDS = ( - 'auth_backends.backends.EdXOAuth2', - 'django.contrib.auth.backends.ModelBackend', -) - -ENABLE_AUTO_AUTH = False -AUTO_AUTH_USERNAME_PREFIX = 'auto_auth_' - -SOCIAL_AUTH_STRATEGY = 'auth_backends.strategies.EdxDjangoStrategy' - -# Set these to the correct values for your OAuth2 provider (e.g., LMS) -SOCIAL_AUTH_EDX_OAUTH2_KEY = 'replace-me' -SOCIAL_AUTH_EDX_OAUTH2_SECRET = 'replace-me' -SOCIAL_AUTH_EDX_OAUTH2_URL_ROOT = 'replace-me' -SOCIAL_AUTH_EDX_OAUTH2_LOGOUT_URL = 'replace-me' -BACKEND_SERVICE_EDX_OAUTH2_KEY = 'replace-me' -BACKEND_SERVICE_EDX_OAUTH2_SECRET = 'replace-me' - -JWT_AUTH = { - 'JWT_AUTH_HEADER_PREFIX': 'JWT', - 'JWT_ISSUER': 'http://127.0.0.1:8000/oauth2', - 'JWT_ALGORITHM': 'HS256', - 'JWT_VERIFY_EXPIRATION': True, - 'JWT_PAYLOAD_GET_USERNAME_HANDLER': lambda d: d.get('preferred_username'), - 'JWT_LEEWAY': 1, - 'JWT_DECODE_HANDLER': 'edx_rest_framework_extensions.auth.jwt.decoder.jwt_decode_handler', - 'JWT_PUBLIC_SIGNING_JWK_SET': None, - 'JWT_AUTH_COOKIE': 'edx-jwt-cookie', - 'JWT_AUTH_COOKIE_HEADER_PAYLOAD': 'edx-jwt-cookie-header-payload', - 'JWT_AUTH_COOKIE_SIGNATURE': 'edx-jwt-cookie-signature', -} - -# Request the user's permissions in the ID token -EXTRA_SCOPE = ['permissions'] - -# TODO Set this to another (non-staff, ideally) path. -LOGIN_REDIRECT_URL = '/admin/' -# END AUTHENTICATION CONFIGURATION - - -# OPENEDX-SPECIFIC CONFIGURATION -PLATFORM_NAME = 'Your Platform Name Here' -# END OPENEDX-SPECIFIC CONFIGURATION - # Set up logging for development use (logging to stdout) LOGGING = get_logger_config(debug=DEBUG) diff --git a/codejail_service/settings/devstack.py b/codejail_service/settings/devstack.py deleted file mode 100644 index 223734c..0000000 --- a/codejail_service/settings/devstack.py +++ /dev/null @@ -1,60 +0,0 @@ -"""Settings for devstack use.""" - -from codejail_service.settings.local import * # pylint: disable=wildcard-import - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': os.environ.get('DB_NAME', 'codejail_service'), - 'USER': os.environ.get('DB_USER', 'root'), - 'PASSWORD': os.environ.get('DB_PASSWORD', ''), - 'HOST': os.environ.get('DB_HOST', 'codejail_service.db'), - 'PORT': os.environ.get('DB_PORT', 3306), - 'ATOMIC_REQUESTS': False, - 'CONN_MAX_AGE': 60, - } -} - -# Generic OAuth2 variables irrespective of SSO/backend service key types. -OAUTH2_PROVIDER_URL = 'http://edx.devstack.lms:18000/oauth2' - -# OAuth2 variables specific to social-auth/SSO login use case. -SOCIAL_AUTH_EDX_OAUTH2_KEY = os.environ.get('SOCIAL_AUTH_EDX_OAUTH2_KEY', 'codejail_service-sso-key') -SOCIAL_AUTH_EDX_OAUTH2_SECRET = os.environ.get('SOCIAL_AUTH_EDX_OAUTH2_SECRET', 'codejail_service-sso-secret') -SOCIAL_AUTH_EDX_OAUTH2_ISSUER = os.environ.get('SOCIAL_AUTH_EDX_OAUTH2_ISSUER', 'http://localhost:18000') -SOCIAL_AUTH_EDX_OAUTH2_URL_ROOT = os.environ.get('SOCIAL_AUTH_EDX_OAUTH2_URL_ROOT', 'http://edx.devstack.lms:18000') -SOCIAL_AUTH_EDX_OAUTH2_LOGOUT_URL = os.environ.get('SOCIAL_AUTH_EDX_OAUTH2_LOGOUT_URL', 'http://localhost:18000/logout') -SOCIAL_AUTH_EDX_OAUTH2_PUBLIC_URL_ROOT = os.environ.get( - 'SOCIAL_AUTH_EDX_OAUTH2_PUBLIC_URL_ROOT', 'http://localhost:18000', -) - -# OAuth2 variables specific to backend service API calls. -BACKEND_SERVICE_EDX_OAUTH2_KEY = os.environ.get('BACKEND_SERVICE_EDX_OAUTH2_KEY', 'codejail_service-backend-service-key') -BACKEND_SERVICE_EDX_OAUTH2_SECRET = os.environ.get( - 'BACKEND_SERVICE_EDX_OAUTH2_SECRET', - 'codejail_service-backend-service-secret' -) - -JWT_AUTH.update({ - 'JWT_SECRET_KEY': 'lms-secret', - 'JWT_ISSUER': 'http://localhost:18000/oauth2', - 'JWT_AUDIENCE': None, - 'JWT_VERIFY_AUDIENCE': False, - 'JWT_PUBLIC_SIGNING_JWK_SET': """ - { - "keys": [ - { - "kty": "RSA", - "kid": "devstack_key", - "n": "smKFSYowG6nNUAdeqH1jQQnH1PmIHphzBmwJ5vRf1vu48BUI5VcVtUWIPqzRK_LDSlZYh9D0YFL0ZTxIrlb6Tn3Xz7pYvpIAeYuQv3_H5p8tbz7Fb8r63c1828wXPITVTv8f7oxx5W3lFFgpFAyYMmROC4Ee9qG5T38LFe8_oAuFCEntimWxN9F3P-FJQy43TL7wG54WodgiM0EgzkeLr5K6cDnyckWjTuZbWI-4ffcTgTZsL_Kq1owa_J2ngEfxMCObnzGy5ZLcTUomo4rZLjghVpq6KZxfS6I1Vz79ZsMVUWEdXOYePCKKsrQG20ogQEkmTf9FT_SouC6jPcHLXw", - "e": "AQAB" - } - ] - } - """, # noqa: E501 - 'JWT_ISSUERS': [{ - 'AUDIENCE': 'lms-key', - 'ISSUER': 'http://localhost:18000/oauth2', - 'SECRET_KEY': 'lms-secret', - }], -}) diff --git a/codejail_service/settings/local.py b/codejail_service/settings/local.py index 816cdc2..05978eb 100644 --- a/codejail_service/settings/local.py +++ b/codejail_service/settings/local.py @@ -4,68 +4,6 @@ DEBUG = True -# CACHE CONFIGURATION -# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches -CACHES = { - 'default': { - 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', - } -} -# END CACHE CONFIGURATION - -# DATABASE CONFIGURATION -# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': root('default.db'), - 'USER': '', - 'PASSWORD': '', - 'HOST': '', - 'PORT': '', - } -} -# END DATABASE CONFIGURATION - -# EMAIL CONFIGURATION -# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend -EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' -# END EMAIL CONFIGURATION - -# TOOLBAR CONFIGURATION -# See: https://django-debug-toolbar.readthedocs.org/en/latest/installation.html -if os.environ.get('ENABLE_DJANGO_TOOLBAR', False): - INSTALLED_APPS += ( - 'debug_toolbar', - ) - - MIDDLEWARE += ( - 'debug_toolbar.middleware.DebugToolbarMiddleware', - ) - - DEBUG_TOOLBAR_PATCH_SETTINGS = False - -INTERNAL_IPS = ('127.0.0.1',) -# END TOOLBAR CONFIGURATION - -# AUTHENTICATION -# Use a non-SSL URL for authorization redirects -SOCIAL_AUTH_REDIRECT_IS_HTTPS = False - -# Generic OAuth2 variables irrespective of SSO/backend service key types. -OAUTH2_PROVIDER_URL = 'http://localhost:18000/oauth2' - -JWT_AUTH.update({ - 'JWT_ALGORITHM': 'HS256', - 'JWT_SECRET_KEY': SOCIAL_AUTH_EDX_OAUTH2_SECRET, - 'JWT_ISSUER': OAUTH2_PROVIDER_URL, - 'JWT_AUDIENCE': SOCIAL_AUTH_EDX_OAUTH2_KEY, -}) - -ENABLE_AUTO_AUTH = True - -LOGGING = get_logger_config(debug=DEBUG) - ##################################################################### # Lastly, see if the developer has any local overrides. if os.path.isfile(join(dirname(abspath(__file__)), 'private.py')): diff --git a/codejail_service/settings/private.py.example b/codejail_service/settings/private.py.example deleted file mode 100644 index 8aece8a..0000000 --- a/codejail_service/settings/private.py.example +++ /dev/null @@ -1,5 +0,0 @@ -SOCIAL_AUTH_EDX_OAUTH2_KEY = 'replace-me' -SOCIAL_AUTH_EDX_OAUTH2_SECRET = 'replace-me' -SOCIAL_AUTH_EDX_OAUTH2_URL_ROOT = 'http://127.0.0.1:8000/oauth' -BACKEND_SERVICE_EDX_OAUTH2_KEY = 'codejail-service-backend-service-key' -BACKEND_SERVICE_EDX_OAUTH2_SECRET = 'codejail-service-backend-service-secret' diff --git a/codejail_service/settings/production.py b/codejail_service/settings/production.py index d2d4896..3e8e9b6 100644 --- a/codejail_service/settings/production.py +++ b/codejail_service/settings/production.py @@ -10,18 +10,11 @@ DEBUG = False TEMPLATE_DEBUG = DEBUG -ALLOWED_HOSTS = ['*'] - LOGGING = get_logger_config() # Keep track of the names of settings that represent dicts. Instead of overriding the values in base.py, # the values read from disk should UPDATE the pre-configured dicts. -DICT_UPDATE_KEYS = ('JWT_AUTH',) - -# This may be overridden by the YAML in codejail_service_CFG, -# but it should be here as a default. -MEDIA_STORAGE_BACKEND = {} -FILE_STORAGE_BACKEND = {} +DICT_UPDATE_KEYS = () if 'CODEJAIL_SERVICE_CFG' in environ: CONFIG_FILE = get_env_setting('CODEJAIL_SERVICE_CFG') @@ -37,21 +30,3 @@ vars()[key].update(value) vars().update(config_from_yaml) - - # Unpack the media and files storage backend settings for django storages. - # These dicts are not Django settings themselves, but they contain a mapping - # of Django settings. - vars().update(FILE_STORAGE_BACKEND) - vars().update(MEDIA_STORAGE_BACKEND) - -DB_OVERRIDES = { - "PASSWORD": environ.get('DB_MIGRATION_PASS', DATABASES['default']['PASSWORD']), - "ENGINE": environ.get('DB_MIGRATION_ENGINE', DATABASES['default']['ENGINE']), - "USER": environ.get('DB_MIGRATION_USER', DATABASES['default']['USER']), - "NAME": environ.get('DB_MIGRATION_NAME', DATABASES['default']['NAME']), - "HOST": environ.get('DB_MIGRATION_HOST', DATABASES['default']['HOST']), - "PORT": environ.get('DB_MIGRATION_PORT', DATABASES['default']['PORT']), -} - -for override, value in DB_OVERRIDES.items(): - DATABASES['default'][override] = value diff --git a/codejail_service/settings/test.py b/codejail_service/settings/test.py index 84e25f0..849c249 100644 --- a/codejail_service/settings/test.py +++ b/codejail_service/settings/test.py @@ -2,15 +2,10 @@ from codejail_service.settings.base import * # pylint: disable=wildcard-import -# IN-MEMORY TEST DATABASE +# Django *really* wants a database. So we give it a blank in-memory one. DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:', - 'USER': '', - 'PASSWORD': '', - 'HOST': '', - 'PORT': '', - }, + } } -# END IN-MEMORY TEST DATABASE diff --git a/codejail_service/urls.py b/codejail_service/urls.py index c3b2274..d119957 100644 --- a/codejail_service/urls.py +++ b/codejail_service/urls.py @@ -19,30 +19,12 @@ 2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) """ -import os - -from auth_backends.urls import oauth2_urlpatterns -from django.conf import settings -from django.contrib import admin from django.urls import include, re_path -from rest_framework_swagger.views import get_swagger_view from codejail_service.apps.api import urls as api_urls from codejail_service.apps.core import views as core_views -admin.autodiscover() - -urlpatterns = oauth2_urlpatterns + [ - re_path(r'^admin/', admin.site.urls), +urlpatterns = [ re_path(r'^api/', include(api_urls)), - re_path(r'^api-docs/', get_swagger_view(title='codejail-service API')), - re_path(r'^auto_auth/$', core_views.AutoAuth.as_view(), name='auto_auth'), - re_path(r'', include('csrf.urls')), # Include csrf urls from edx-drf-extensions re_path(r'^health/$', core_views.health, name='health'), ] - -if settings.DEBUG and os.environ.get('ENABLE_DJANGO_TOOLBAR', False): # pragma: no cover - # Disable pylint import error because we don't install django-debug-toolbar - # for CI build - import debug_toolbar # pylint: disable=import-error - urlpatterns.append(re_path(r'^__debug__/', include(debug_toolbar.urls))) diff --git a/codejail_service/wsgi.py b/codejail_service/wsgi.py index 9df1f42..b52e02e 100644 --- a/codejail_service/wsgi.py +++ b/codejail_service/wsgi.py @@ -11,17 +11,9 @@ from sys import path from django.conf import settings -from django.contrib.staticfiles.handlers import StaticFilesHandler from django.core.wsgi import get_wsgi_application SITE_ROOT = dirname(dirname(abspath(__file__))) path.append(SITE_ROOT) application = get_wsgi_application() # pylint: disable=invalid-name - -# Allows the gunicorn app to serve static files in development environment. -# Without this, css in django admin will not be served locally. -if settings.DEBUG: - application = StaticFilesHandler(get_wsgi_application()) -else: - application = get_wsgi_application() diff --git a/db_keyword_overrides.yml b/db_keyword_overrides.yml deleted file mode 100644 index 24d9846..0000000 --- a/db_keyword_overrides.yml +++ /dev/null @@ -1,13 +0,0 @@ -# This file is used by the 'check_reserved_keywords' management command to allow specific field names to be overridden -# when checking for conflicts with lists of restricted keywords used in various database/data warehouse tools. -# For more information, see: -# https://openedx.atlassian.net/wiki/spaces/DE/pages/1411809288/Reserved+Keyword+Linter -# and -# https://github.com/openedx/edx-django-release-util/release_util/management/commands/check_reserved_keywords.py -# -# overrides should be added in the following format: -# - ModelName.field_name ---- -MYSQL: -SNOWFLAKE: -STITCH: diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 5996547..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,41 +0,0 @@ -version: "2.1" -services: - db: - image: mysql:8.0 - container_name: codejail_service.db - environment: - # See how these environment variables being used at https://github.com/mysql/mysql-docker/blob/mysql-server/8.0/docker-entrypoint.sh - MYSQL_ROOT_PASSWORD: "" - MYSQL_ALLOW_EMPTY_PASSWORD: "yes" - networks: - - devstack_default - volumes: - - codejail_service_mysql:/var/lib/mysql - - memcache: - image: memcached:1.4.24 - container_name: codejail_service.memcache - - app: - # Uncomment this line to use the official codejail_service base image - image: openedx/codejail_service - - container_name: codejail_service.app - volumes: - - .:/edx/app/codejail_service/ - command: bash -c 'while true; do python /edx/app/codejail_service/manage.py runserver 0.0.0.0:18030; sleep 2; done' - environment: - DJANGO_SETTINGS_MODULE: codejail_service.settings.devstack - ports: - - "18030:18030" # TODO: change this to your port - networks: - - devstack_default - stdin_open: true - tty: true - -networks: - devstack_default: - external: true - -volumes: - codejail_service_mysql: diff --git a/provision-codejail-service.sh b/provision-codejail-service.sh deleted file mode 100644 index 5c40b58..0000000 --- a/provision-codejail-service.sh +++ /dev/null @@ -1,38 +0,0 @@ -name="codejail_service" -port="18030" - -docker-compose up -d --build - -# Install requirements -# Can be skipped right now because we're using the --build flag on docker-compose. This will need to be changed once we move to devstack. - -# Wait for MySQL -echo "Waiting for MySQL" -until docker exec -i codejail_service.db mysql -u root -se "SELECT EXISTS(SELECT 1 FROM mysql.user WHERE user = 'root')" &> /dev/null -do - printf "." - sleep 1 -done -sleep 5 - -# Create the database -docker exec -i codejail_service.db mysql -u root -se "CREATE DATABASE codejail_service;" - -# Run migrations -echo -e "${GREEN}Running migrations for ${name}...${NC}" -docker exec -t codejail_service.app bash -c "cd /edx/app/${name}/ && make migrate" - -# Create superuser -echo -e "${GREEN}Creating super-user for ${name}...${NC}" -docker exec -t codejail_service.app bash -c "echo 'from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser(\"edx\", \"edx@example.com\", \"edx\") if not User.objects.filter(username=\"edx\").exists() else None' | python /edx/app/${name}/manage.py shell" - -# Provision IDA User in LMS -echo -e "${GREEN}Provisioning ${name}_worker in LMS...${NC}" -docker exec -t edx.devstack.lms bash -c "source /edx/app/edxapp/edxapp_env && python /edx/app/edxapp/edx-platform/manage.py lms --settings=devstack_docker manage_user ${name}_worker ${name}_worker@example.com --staff --superuser" - -# Create the DOT applications - one for single sign-on and one for backend service IDA-to-IDA authentication. -docker exec -t edx.devstack.lms bash -c "source /edx/app/edxapp/edxapp_env && python /edx/app/edxapp/edx-platform/manage.py lms --settings=devstack_docker create_dot_application --grant-type authorization-code --skip-authorization --redirect-uris 'http://localhost:${port}/complete/edx-oauth2/' --client-id '${name}-sso-key' --client-secret '${name}-sso-secret' --scopes 'user_id' ${name}-sso ${name}_worker" -docker exec -t edx.devstack.lms bash -c "source /edx/app/edxapp/edxapp_env && python /edx/app/edxapp/edx-platform/manage.py lms --settings=devstack_docker create_dot_application --grant-type client-credentials --client-id '${name}-backend-service-key' --client-secret '${name}-backend-service-secret' ${name}-backend-service ${name}_worker" - -# Restart enterprise.catalog app and worker containers -docker-compose restart app diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index d119713..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -# This file is here because many Platforms as a Service look for -# requirements.txt in the root directory of a project. --r requirements/production.txt diff --git a/requirements/base.in b/requirements/base.in index 45af4ba..d4c7584 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -2,17 +2,9 @@ -c constraints.txt Django # Web application framework -django-cors-headers -django-extensions -django-rest-swagger -django-waffle -djangorestframework -edx-auth-backends +gunicorn # HTTP server framework + edx-django-utils -edx-django-release-util -edx-drf-extensions edx-i18n-tools -edx-rest-api-client -mysqlclient openedx-atlas pytz diff --git a/requirements/base.txt b/requirements/base.txt new file mode 100644 index 0000000..16bc63c --- /dev/null +++ b/requirements/base.txt @@ -0,0 +1,62 @@ +# +# This file is autogenerated by pip-compile with Python 3.12 +# by the following command: +# +# make upgrade +# +asgiref==3.8.1 + # via django +cffi==1.17.1 + # via pynacl +click==8.1.8 + # via edx-django-utils +django==4.2.18 + # via + # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt + # -r requirements/base.in + # django-crum + # django-waffle + # edx-django-utils + # edx-i18n-tools +django-crum==0.7.9 + # via edx-django-utils +django-waffle==4.2.0 + # via edx-django-utils +edx-django-utils==7.1.0 + # via -r requirements/base.in +edx-i18n-tools==1.6.3 + # via -r requirements/base.in +gunicorn==23.0.0 + # via -r requirements/base.in +lxml[html-clean,html_clean]==5.3.0 + # via + # edx-i18n-tools + # lxml-html-clean +lxml-html-clean==0.4.1 + # via lxml +newrelic==10.4.0 + # via edx-django-utils +openedx-atlas==0.6.2 + # via -r requirements/base.in +packaging==24.2 + # via gunicorn +path==16.16.0 + # via edx-i18n-tools +pbr==6.1.0 + # via stevedore +polib==1.2.0 + # via edx-i18n-tools +psutil==6.1.1 + # via edx-django-utils +pycparser==2.22 + # via cffi +pynacl==1.5.0 + # via edx-django-utils +pytz==2024.2 + # via -r requirements/base.in +pyyaml==6.0.2 + # via edx-i18n-tools +sqlparse==0.5.3 + # via django +stevedore==5.4.0 + # via edx-django-utils diff --git a/requirements/ci.txt b/requirements/ci.txt new file mode 100644 index 0000000..b1afc54 --- /dev/null +++ b/requirements/ci.txt @@ -0,0 +1,34 @@ +# +# This file is autogenerated by pip-compile with Python 3.12 +# by the following command: +# +# make upgrade +# +cachetools==5.5.1 + # via tox +chardet==5.2.0 + # via tox +colorama==0.4.6 + # via tox +distlib==0.3.9 + # via virtualenv +filelock==3.17.0 + # via + # tox + # virtualenv +packaging==24.2 + # via + # pyproject-api + # tox +platformdirs==4.3.6 + # via + # tox + # virtualenv +pluggy==1.5.0 + # via tox +pyproject-api==1.9.0 + # via tox +tox==4.24.1 + # via -r requirements/ci.in +virtualenv==20.29.1 + # via tox diff --git a/requirements/dev.in b/requirements/dev.in index d55e4a5..730d30a 100644 --- a/requirements/dev.in +++ b/requirements/dev.in @@ -4,4 +4,3 @@ -r validation.txt # Core, testing, and quality check dependencies diff-cover # Changeset diff test coverage -django-debug-toolbar # For debugging Django diff --git a/requirements/dev.txt b/requirements/dev.txt new file mode 100644 index 0000000..18d6efa --- /dev/null +++ b/requirements/dev.txt @@ -0,0 +1,373 @@ +# +# This file is autogenerated by pip-compile with Python 3.12 +# by the following command: +# +# make upgrade +# +asgiref==3.8.1 + # via + # -r requirements/validation.txt + # django +astroid==3.3.8 + # via + # -r requirements/validation.txt + # pylint + # pylint-celery +build==1.2.2.post1 + # via + # -r requirements/pip-tools.txt + # pip-tools +cachetools==5.5.1 + # via + # -r requirements/validation.txt + # tox +certifi==2024.12.14 + # via + # -r requirements/validation.txt + # requests +cffi==1.17.1 + # via + # -r requirements/validation.txt + # cryptography + # pynacl +chardet==5.2.0 + # via + # -r requirements/validation.txt + # diff-cover + # tox +charset-normalizer==3.4.1 + # via + # -r requirements/validation.txt + # requests +click==8.1.8 + # via + # -r requirements/pip-tools.txt + # -r requirements/validation.txt + # click-log + # code-annotations + # edx-django-utils + # edx-lint + # pip-tools +click-log==0.4.0 + # via + # -r requirements/validation.txt + # edx-lint +code-annotations==2.2.0 + # via + # -r requirements/validation.txt + # edx-lint +colorama==0.4.6 + # via + # -r requirements/validation.txt + # tox +coverage[toml]==7.6.10 + # via + # -r requirements/validation.txt + # pytest-cov +cryptography==44.0.0 + # via + # -r requirements/validation.txt + # secretstorage +diff-cover==9.2.1 + # via -r requirements/dev.in +dill==0.3.9 + # via + # -r requirements/validation.txt + # pylint +distlib==0.3.9 + # via + # -r requirements/validation.txt + # virtualenv +django==4.2.18 + # via + # -r requirements/validation.txt + # django-crum + # django-waffle + # edx-django-utils + # edx-i18n-tools +django-crum==0.7.9 + # via + # -r requirements/validation.txt + # edx-django-utils +django-waffle==4.2.0 + # via + # -r requirements/validation.txt + # edx-django-utils +docutils==0.21.2 + # via + # -r requirements/validation.txt + # readme-renderer +edx-django-utils==7.1.0 + # via -r requirements/validation.txt +edx-i18n-tools==1.6.3 + # via -r requirements/validation.txt +edx-lint==5.5.0 + # via -r requirements/validation.txt +filelock==3.17.0 + # via + # -r requirements/validation.txt + # tox + # virtualenv +gunicorn==23.0.0 + # via -r requirements/validation.txt +id==1.5.0 + # via + # -r requirements/validation.txt + # twine +idna==3.10 + # via + # -r requirements/validation.txt + # requests +iniconfig==2.0.0 + # via + # -r requirements/validation.txt + # pytest +isort==5.13.2 + # via + # -r requirements/validation.txt + # pylint +jaraco-classes==3.4.0 + # via + # -r requirements/validation.txt + # keyring +jaraco-context==6.0.1 + # via + # -r requirements/validation.txt + # keyring +jaraco-functools==4.1.0 + # via + # -r requirements/validation.txt + # keyring +jeepney==0.8.0 + # via + # -r requirements/validation.txt + # keyring + # secretstorage +jinja2==3.1.5 + # via + # -r requirements/validation.txt + # code-annotations + # diff-cover +keyring==25.6.0 + # via + # -r requirements/validation.txt + # twine +lxml[html-clean]==5.3.0 + # via + # -r requirements/validation.txt + # edx-i18n-tools + # lxml-html-clean +lxml-html-clean==0.4.1 + # via + # -r requirements/validation.txt + # lxml +markdown-it-py==3.0.0 + # via + # -r requirements/validation.txt + # rich +markupsafe==3.0.2 + # via + # -r requirements/validation.txt + # jinja2 +mccabe==0.7.0 + # via + # -r requirements/validation.txt + # pylint +mdurl==0.1.2 + # via + # -r requirements/validation.txt + # markdown-it-py +more-itertools==10.6.0 + # via + # -r requirements/validation.txt + # jaraco-classes + # jaraco-functools +newrelic==10.4.0 + # via + # -r requirements/validation.txt + # edx-django-utils +nh3==0.2.20 + # via + # -r requirements/validation.txt + # readme-renderer +openedx-atlas==0.6.2 + # via -r requirements/validation.txt +packaging==24.2 + # via + # -r requirements/pip-tools.txt + # -r requirements/validation.txt + # build + # gunicorn + # pyproject-api + # pytest + # tox + # twine +path==16.16.0 + # via + # -r requirements/validation.txt + # edx-i18n-tools +pbr==6.1.0 + # via + # -r requirements/validation.txt + # stevedore +pip-tools==7.4.1 + # via -r requirements/pip-tools.txt +platformdirs==4.3.6 + # via + # -r requirements/validation.txt + # pylint + # tox + # virtualenv +pluggy==1.5.0 + # via + # -r requirements/validation.txt + # diff-cover + # pytest + # tox +polib==1.2.0 + # via + # -r requirements/validation.txt + # edx-i18n-tools +psutil==6.1.1 + # via + # -r requirements/validation.txt + # edx-django-utils +pycodestyle==2.12.1 + # via -r requirements/validation.txt +pycparser==2.22 + # via + # -r requirements/validation.txt + # cffi +pydocstyle==6.3.0 + # via -r requirements/validation.txt +pygments==2.19.1 + # via + # -r requirements/validation.txt + # diff-cover + # readme-renderer + # rich +pylint==3.3.3 + # via + # -r requirements/validation.txt + # edx-lint + # pylint-celery + # pylint-django + # pylint-plugin-utils +pylint-celery==0.3 + # via + # -r requirements/validation.txt + # edx-lint +pylint-django==2.6.1 + # via + # -r requirements/validation.txt + # edx-lint +pylint-plugin-utils==0.8.2 + # via + # -r requirements/validation.txt + # pylint-celery + # pylint-django +pynacl==1.5.0 + # via + # -r requirements/validation.txt + # edx-django-utils +pyproject-api==1.9.0 + # via + # -r requirements/validation.txt + # tox +pyproject-hooks==1.2.0 + # via + # -r requirements/pip-tools.txt + # build + # pip-tools +pytest==8.3.4 + # via + # -r requirements/validation.txt + # pytest-cov + # pytest-django +pytest-cov==6.0.0 + # via -r requirements/validation.txt +pytest-django==4.9.0 + # via -r requirements/validation.txt +python-slugify==8.0.4 + # via + # -r requirements/validation.txt + # code-annotations +pytz==2024.2 + # via -r requirements/validation.txt +pyyaml==6.0.2 + # via + # -r requirements/validation.txt + # code-annotations + # edx-i18n-tools +readme-renderer==44.0 + # via + # -r requirements/validation.txt + # twine +requests==2.32.3 + # via + # -r requirements/validation.txt + # id + # requests-toolbelt + # twine +requests-toolbelt==1.0.0 + # via + # -r requirements/validation.txt + # twine +rfc3986==2.0.0 + # via + # -r requirements/validation.txt + # twine +rich==13.9.4 + # via + # -r requirements/validation.txt + # twine +secretstorage==3.3.3 + # via + # -r requirements/validation.txt + # keyring +six==1.17.0 + # via + # -r requirements/validation.txt + # edx-lint +snowballstemmer==2.2.0 + # via + # -r requirements/validation.txt + # pydocstyle +sqlparse==0.5.3 + # via + # -r requirements/validation.txt + # django +stevedore==5.4.0 + # via + # -r requirements/validation.txt + # code-annotations + # edx-django-utils +text-unidecode==1.3 + # via + # -r requirements/validation.txt + # python-slugify +tomlkit==0.13.2 + # via + # -r requirements/validation.txt + # pylint +tox==4.24.1 + # via -r requirements/validation.txt +twine==6.1.0 + # via -r requirements/validation.txt +urllib3==2.2.3 + # via + # -r requirements/validation.txt + # requests + # twine +virtualenv==20.29.1 + # via + # -r requirements/validation.txt + # tox +wheel==0.45.1 + # via + # -r requirements/pip-tools.txt + # pip-tools + +# The following packages are considered to be unsafe in a requirements file: +# pip +# setuptools diff --git a/requirements/django.txt b/requirements/django.txt new file mode 100644 index 0000000..697db5b --- /dev/null +++ b/requirements/django.txt @@ -0,0 +1 @@ +django==4.2.18 diff --git a/requirements/doc.txt b/requirements/doc.txt new file mode 100644 index 0000000..b56d79e --- /dev/null +++ b/requirements/doc.txt @@ -0,0 +1,358 @@ +# +# This file is autogenerated by pip-compile with Python 3.12 +# by the following command: +# +# make upgrade +# +accessible-pygments==0.0.5 + # via pydata-sphinx-theme +alabaster==1.0.0 + # via sphinx +asgiref==3.8.1 + # via + # -r requirements/test.txt + # django +astroid==3.3.8 + # via + # -r requirements/test.txt + # pylint + # pylint-celery +babel==2.16.0 + # via + # pydata-sphinx-theme + # sphinx +beautifulsoup4==4.12.3 + # via pydata-sphinx-theme +build==1.2.2.post1 + # via -r requirements/doc.in +cachetools==5.5.1 + # via + # -r requirements/test.txt + # tox +certifi==2024.12.14 + # via requests +cffi==1.17.1 + # via + # -r requirements/test.txt + # cryptography + # pynacl +chardet==5.2.0 + # via + # -r requirements/test.txt + # tox +charset-normalizer==3.4.1 + # via requests +click==8.1.8 + # via + # -r requirements/test.txt + # click-log + # code-annotations + # edx-django-utils + # edx-lint +click-log==0.4.0 + # via + # -r requirements/test.txt + # edx-lint +code-annotations==2.2.0 + # via + # -r requirements/test.txt + # edx-lint +colorama==0.4.6 + # via + # -r requirements/test.txt + # tox +coverage[toml]==7.6.10 + # via + # -r requirements/test.txt + # pytest-cov +cryptography==44.0.0 + # via secretstorage +dill==0.3.9 + # via + # -r requirements/test.txt + # pylint +distlib==0.3.9 + # via + # -r requirements/test.txt + # virtualenv +django==4.2.18 + # via + # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt + # -r requirements/test.txt + # django-crum + # django-waffle + # edx-django-utils + # edx-i18n-tools +django-crum==0.7.9 + # via + # -r requirements/test.txt + # edx-django-utils +django-waffle==4.2.0 + # via + # -r requirements/test.txt + # edx-django-utils +doc8==1.1.2 + # via -r requirements/doc.in +docutils==0.21.2 + # via + # doc8 + # pydata-sphinx-theme + # readme-renderer + # restructuredtext-lint + # sphinx +edx-django-utils==7.1.0 + # via -r requirements/test.txt +edx-i18n-tools==1.6.3 + # via -r requirements/test.txt +edx-lint==5.5.0 + # via -r requirements/test.txt +filelock==3.17.0 + # via + # -r requirements/test.txt + # tox + # virtualenv +gunicorn==23.0.0 + # via -r requirements/test.txt +id==1.5.0 + # via twine +idna==3.10 + # via requests +imagesize==1.4.1 + # via sphinx +iniconfig==2.0.0 + # via + # -r requirements/test.txt + # pytest +isort==5.13.2 + # via + # -r requirements/test.txt + # pylint +jaraco-classes==3.4.0 + # via keyring +jaraco-context==6.0.1 + # via keyring +jaraco-functools==4.1.0 + # via keyring +jeepney==0.8.0 + # via + # keyring + # secretstorage +jinja2==3.1.5 + # via + # -r requirements/test.txt + # code-annotations + # sphinx +keyring==25.6.0 + # via twine +lxml[html-clean]==5.3.0 + # via + # -r requirements/test.txt + # edx-i18n-tools + # lxml-html-clean +lxml-html-clean==0.4.1 + # via + # -r requirements/test.txt + # lxml +markdown-it-py==3.0.0 + # via rich +markupsafe==3.0.2 + # via + # -r requirements/test.txt + # jinja2 +mccabe==0.7.0 + # via + # -r requirements/test.txt + # pylint +mdurl==0.1.2 + # via markdown-it-py +more-itertools==10.6.0 + # via + # jaraco-classes + # jaraco-functools +newrelic==10.4.0 + # via + # -r requirements/test.txt + # edx-django-utils +nh3==0.2.20 + # via readme-renderer +openedx-atlas==0.6.2 + # via -r requirements/test.txt +packaging==24.2 + # via + # -r requirements/test.txt + # build + # gunicorn + # pyproject-api + # pytest + # sphinx + # tox + # twine +path==16.16.0 + # via + # -r requirements/test.txt + # edx-i18n-tools +pbr==6.1.0 + # via + # -r requirements/test.txt + # stevedore +platformdirs==4.3.6 + # via + # -r requirements/test.txt + # pylint + # tox + # virtualenv +pluggy==1.5.0 + # via + # -r requirements/test.txt + # pytest + # tox +polib==1.2.0 + # via + # -r requirements/test.txt + # edx-i18n-tools +psutil==6.1.1 + # via + # -r requirements/test.txt + # edx-django-utils +pycparser==2.22 + # via + # -r requirements/test.txt + # cffi +pydata-sphinx-theme==0.16.1 + # via sphinx-book-theme +pygments==2.19.1 + # via + # accessible-pygments + # doc8 + # pydata-sphinx-theme + # readme-renderer + # rich + # sphinx +pylint==3.3.3 + # via + # -r requirements/test.txt + # edx-lint + # pylint-celery + # pylint-django + # pylint-plugin-utils +pylint-celery==0.3 + # via + # -r requirements/test.txt + # edx-lint +pylint-django==2.6.1 + # via + # -r requirements/test.txt + # edx-lint +pylint-plugin-utils==0.8.2 + # via + # -r requirements/test.txt + # pylint-celery + # pylint-django +pynacl==1.5.0 + # via + # -r requirements/test.txt + # edx-django-utils +pyproject-api==1.9.0 + # via + # -r requirements/test.txt + # tox +pyproject-hooks==1.2.0 + # via build +pytest==8.3.4 + # via + # -r requirements/test.txt + # pytest-cov + # pytest-django +pytest-cov==6.0.0 + # via -r requirements/test.txt +pytest-django==4.9.0 + # via -r requirements/test.txt +python-slugify==8.0.4 + # via + # -r requirements/test.txt + # code-annotations +pytz==2024.2 + # via -r requirements/test.txt +pyyaml==6.0.2 + # via + # -r requirements/test.txt + # code-annotations + # edx-i18n-tools +readme-renderer==44.0 + # via twine +requests==2.32.3 + # via + # id + # requests-toolbelt + # sphinx + # twine +requests-toolbelt==1.0.0 + # via twine +restructuredtext-lint==1.4.0 + # via doc8 +rfc3986==2.0.0 + # via twine +rich==13.9.4 + # via twine +secretstorage==3.3.3 + # via keyring +six==1.17.0 + # via + # -r requirements/test.txt + # edx-lint +snowballstemmer==2.2.0 + # via sphinx +soupsieve==2.6 + # via beautifulsoup4 +sphinx==8.1.3 + # via + # -r requirements/doc.in + # pydata-sphinx-theme + # sphinx-book-theme +sphinx-book-theme==1.1.3 + # via -r requirements/doc.in +sphinxcontrib-applehelp==2.0.0 + # via sphinx +sphinxcontrib-devhelp==2.0.0 + # via sphinx +sphinxcontrib-htmlhelp==2.1.0 + # via sphinx +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-qthelp==2.0.0 + # via sphinx +sphinxcontrib-serializinghtml==2.0.0 + # via sphinx +sqlparse==0.5.3 + # via + # -r requirements/test.txt + # django +stevedore==5.4.0 + # via + # -r requirements/test.txt + # code-annotations + # doc8 + # edx-django-utils +text-unidecode==1.3 + # via + # -r requirements/test.txt + # python-slugify +tomlkit==0.13.2 + # via + # -r requirements/test.txt + # pylint +tox==4.24.1 + # via -r requirements/test.txt +twine==6.1.0 + # via -r requirements/doc.in +typing-extensions==4.12.2 + # via pydata-sphinx-theme +urllib3==2.2.3 + # via + # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt + # requests + # twine +virtualenv==20.29.1 + # via + # -r requirements/test.txt + # tox diff --git a/requirements/monitoring/requirements.txt b/requirements/monitoring/requirements.txt deleted file mode 100644 index 22f1248..0000000 --- a/requirements/monitoring/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -# This requirements.txt file is meant to pull in other requirements.txt files so that -# dependency monitoring tools like gemnasium.com can easily process them. - -# It can not be used to do the full installation because it is not in the correct -# order. - --r ../dev.txt # Includes validation requirements --r ../optional.txt --r ../production.txt diff --git a/requirements/pip-tools.txt b/requirements/pip-tools.txt index 173c2a2..31d211c 100644 --- a/requirements/pip-tools.txt +++ b/requirements/pip-tools.txt @@ -11,7 +11,7 @@ click==8.1.8 packaging==24.2 # via build pip-tools==7.4.1 - # via -r python-template/placeholder_repo_name_0/requirements/pip-tools.in + # via -r requirements/pip-tools.in pyproject-hooks==1.2.0 # via # build diff --git a/requirements/pip.txt b/requirements/pip.txt index f429e1f..50f7b5d 100644 --- a/requirements/pip.txt +++ b/requirements/pip.txt @@ -5,10 +5,12 @@ # make upgrade # wheel==0.45.1 - # via -r python-template/placeholder_repo_name_0/requirements/pip.in + # via -r requirements/pip.in # The following packages are considered to be unsafe in a requirements file: -pip==24.3.1 - # via -r python-template/placeholder_repo_name_0/requirements/pip.in -setuptools==75.7.0 - # via -r python-template/placeholder_repo_name_0/requirements/pip.in +pip==24.2 + # via + # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt + # -r requirements/pip.in +setuptools==75.8.0 + # via -r requirements/pip.in diff --git a/requirements/production.in b/requirements/production.in deleted file mode 100644 index 292fe18..0000000 --- a/requirements/production.in +++ /dev/null @@ -1,8 +0,0 @@ -# Packages required in a production environment --r base.txt - -gevent -gunicorn -mysqlclient -python-memcached -PyYAML>=5.1 diff --git a/requirements/quality.txt b/requirements/quality.txt new file mode 100644 index 0000000..d69d1ba --- /dev/null +++ b/requirements/quality.txt @@ -0,0 +1,306 @@ +# +# This file is autogenerated by pip-compile with Python 3.12 +# by the following command: +# +# make upgrade +# +asgiref==3.8.1 + # via + # -r requirements/test.txt + # django +astroid==3.3.8 + # via + # -r requirements/test.txt + # pylint + # pylint-celery +cachetools==5.5.1 + # via + # -r requirements/test.txt + # tox +certifi==2024.12.14 + # via requests +cffi==1.17.1 + # via + # -r requirements/test.txt + # cryptography + # pynacl +chardet==5.2.0 + # via + # -r requirements/test.txt + # tox +charset-normalizer==3.4.1 + # via requests +click==8.1.8 + # via + # -r requirements/test.txt + # click-log + # code-annotations + # edx-django-utils + # edx-lint +click-log==0.4.0 + # via + # -r requirements/test.txt + # edx-lint +code-annotations==2.2.0 + # via + # -r requirements/test.txt + # edx-lint +colorama==0.4.6 + # via + # -r requirements/test.txt + # tox +coverage[toml]==7.6.10 + # via + # -r requirements/test.txt + # pytest-cov +cryptography==44.0.0 + # via secretstorage +dill==0.3.9 + # via + # -r requirements/test.txt + # pylint +distlib==0.3.9 + # via + # -r requirements/test.txt + # virtualenv +django==4.2.18 + # via + # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt + # -r requirements/test.txt + # django-crum + # django-waffle + # edx-django-utils + # edx-i18n-tools +django-crum==0.7.9 + # via + # -r requirements/test.txt + # edx-django-utils +django-waffle==4.2.0 + # via + # -r requirements/test.txt + # edx-django-utils +docutils==0.21.2 + # via readme-renderer +edx-django-utils==7.1.0 + # via -r requirements/test.txt +edx-i18n-tools==1.6.3 + # via -r requirements/test.txt +edx-lint==5.5.0 + # via + # -r requirements/quality.in + # -r requirements/test.txt +filelock==3.17.0 + # via + # -r requirements/test.txt + # tox + # virtualenv +gunicorn==23.0.0 + # via -r requirements/test.txt +id==1.5.0 + # via twine +idna==3.10 + # via requests +iniconfig==2.0.0 + # via + # -r requirements/test.txt + # pytest +isort==5.13.2 + # via + # -r requirements/quality.in + # -r requirements/test.txt + # pylint +jaraco-classes==3.4.0 + # via keyring +jaraco-context==6.0.1 + # via keyring +jaraco-functools==4.1.0 + # via keyring +jeepney==0.8.0 + # via + # keyring + # secretstorage +jinja2==3.1.5 + # via + # -r requirements/test.txt + # code-annotations +keyring==25.6.0 + # via twine +lxml[html-clean]==5.3.0 + # via + # -r requirements/test.txt + # edx-i18n-tools + # lxml-html-clean +lxml-html-clean==0.4.1 + # via + # -r requirements/test.txt + # lxml +markdown-it-py==3.0.0 + # via rich +markupsafe==3.0.2 + # via + # -r requirements/test.txt + # jinja2 +mccabe==0.7.0 + # via + # -r requirements/test.txt + # pylint +mdurl==0.1.2 + # via markdown-it-py +more-itertools==10.6.0 + # via + # jaraco-classes + # jaraco-functools +newrelic==10.4.0 + # via + # -r requirements/test.txt + # edx-django-utils +nh3==0.2.20 + # via readme-renderer +openedx-atlas==0.6.2 + # via -r requirements/test.txt +packaging==24.2 + # via + # -r requirements/test.txt + # gunicorn + # pyproject-api + # pytest + # tox + # twine +path==16.16.0 + # via + # -r requirements/test.txt + # edx-i18n-tools +pbr==6.1.0 + # via + # -r requirements/test.txt + # stevedore +platformdirs==4.3.6 + # via + # -r requirements/test.txt + # pylint + # tox + # virtualenv +pluggy==1.5.0 + # via + # -r requirements/test.txt + # pytest + # tox +polib==1.2.0 + # via + # -r requirements/test.txt + # edx-i18n-tools +psutil==6.1.1 + # via + # -r requirements/test.txt + # edx-django-utils +pycodestyle==2.12.1 + # via -r requirements/quality.in +pycparser==2.22 + # via + # -r requirements/test.txt + # cffi +pydocstyle==6.3.0 + # via -r requirements/quality.in +pygments==2.19.1 + # via + # readme-renderer + # rich +pylint==3.3.3 + # via + # -r requirements/test.txt + # edx-lint + # pylint-celery + # pylint-django + # pylint-plugin-utils +pylint-celery==0.3 + # via + # -r requirements/test.txt + # edx-lint +pylint-django==2.6.1 + # via + # -r requirements/test.txt + # edx-lint +pylint-plugin-utils==0.8.2 + # via + # -r requirements/test.txt + # pylint-celery + # pylint-django +pynacl==1.5.0 + # via + # -r requirements/test.txt + # edx-django-utils +pyproject-api==1.9.0 + # via + # -r requirements/test.txt + # tox +pytest==8.3.4 + # via + # -r requirements/test.txt + # pytest-cov + # pytest-django +pytest-cov==6.0.0 + # via -r requirements/test.txt +pytest-django==4.9.0 + # via -r requirements/test.txt +python-slugify==8.0.4 + # via + # -r requirements/test.txt + # code-annotations +pytz==2024.2 + # via -r requirements/test.txt +pyyaml==6.0.2 + # via + # -r requirements/test.txt + # code-annotations + # edx-i18n-tools +readme-renderer==44.0 + # via twine +requests==2.32.3 + # via + # id + # requests-toolbelt + # twine +requests-toolbelt==1.0.0 + # via twine +rfc3986==2.0.0 + # via twine +rich==13.9.4 + # via twine +secretstorage==3.3.3 + # via keyring +six==1.17.0 + # via + # -r requirements/test.txt + # edx-lint +snowballstemmer==2.2.0 + # via pydocstyle +sqlparse==0.5.3 + # via + # -r requirements/test.txt + # django +stevedore==5.4.0 + # via + # -r requirements/test.txt + # code-annotations + # edx-django-utils +text-unidecode==1.3 + # via + # -r requirements/test.txt + # python-slugify +tomlkit==0.13.2 + # via + # -r requirements/test.txt + # pylint +tox==4.24.1 + # via -r requirements/test.txt +twine==6.1.0 + # via -r requirements/quality.in +urllib3==2.2.3 + # via + # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt + # requests + # twine +virtualenv==20.29.1 + # via + # -r requirements/test.txt + # tox diff --git a/requirements/test.in b/requirements/test.in index 091f47c..6a3f791 100644 --- a/requirements/test.in +++ b/requirements/test.in @@ -5,7 +5,6 @@ code-annotations coverage -django-dynamic-fixture # library to create dynamic model instances for testing purposes edx-lint pytest-cov pytest-django diff --git a/requirements/test.txt b/requirements/test.txt new file mode 100644 index 0000000..f688b13 --- /dev/null +++ b/requirements/test.txt @@ -0,0 +1,189 @@ +# +# This file is autogenerated by pip-compile with Python 3.12 +# by the following command: +# +# make upgrade +# +asgiref==3.8.1 + # via + # -r requirements/base.txt + # django +astroid==3.3.8 + # via + # pylint + # pylint-celery +cachetools==5.5.1 + # via tox +cffi==1.17.1 + # via + # -r requirements/base.txt + # pynacl +chardet==5.2.0 + # via tox +click==8.1.8 + # via + # -r requirements/base.txt + # click-log + # code-annotations + # edx-django-utils + # edx-lint +click-log==0.4.0 + # via edx-lint +code-annotations==2.2.0 + # via + # -r requirements/test.in + # edx-lint +colorama==0.4.6 + # via tox +coverage[toml]==7.6.10 + # via + # -r requirements/test.in + # pytest-cov +dill==0.3.9 + # via pylint +distlib==0.3.9 + # via virtualenv + # via + # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt + # -r requirements/base.txt + # django-crum + # django-waffle + # edx-django-utils + # edx-i18n-tools +django-crum==0.7.9 + # via + # -r requirements/base.txt + # edx-django-utils +django-waffle==4.2.0 + # via + # -r requirements/base.txt + # edx-django-utils +edx-django-utils==7.1.0 + # via -r requirements/base.txt +edx-i18n-tools==1.6.3 + # via -r requirements/base.txt +edx-lint==5.5.0 + # via -r requirements/test.in +filelock==3.17.0 + # via + # tox + # virtualenv +gunicorn==23.0.0 + # via -r requirements/base.txt +iniconfig==2.0.0 + # via pytest +isort==5.13.2 + # via pylint +jinja2==3.1.5 + # via code-annotations +lxml[html-clean]==5.3.0 + # via + # -r requirements/base.txt + # edx-i18n-tools + # lxml-html-clean +lxml-html-clean==0.4.1 + # via + # -r requirements/base.txt + # lxml +markupsafe==3.0.2 + # via jinja2 +mccabe==0.7.0 + # via pylint +newrelic==10.4.0 + # via + # -r requirements/base.txt + # edx-django-utils +openedx-atlas==0.6.2 + # via -r requirements/base.txt +packaging==24.2 + # via + # -r requirements/base.txt + # gunicorn + # pyproject-api + # pytest + # tox +path==16.16.0 + # via + # -r requirements/base.txt + # edx-i18n-tools +pbr==6.1.0 + # via + # -r requirements/base.txt + # stevedore +platformdirs==4.3.6 + # via + # pylint + # tox + # virtualenv +pluggy==1.5.0 + # via + # pytest + # tox +polib==1.2.0 + # via + # -r requirements/base.txt + # edx-i18n-tools +psutil==6.1.1 + # via + # -r requirements/base.txt + # edx-django-utils +pycparser==2.22 + # via + # -r requirements/base.txt + # cffi +pylint==3.3.3 + # via + # edx-lint + # pylint-celery + # pylint-django + # pylint-plugin-utils +pylint-celery==0.3 + # via edx-lint +pylint-django==2.6.1 + # via edx-lint +pylint-plugin-utils==0.8.2 + # via + # pylint-celery + # pylint-django +pynacl==1.5.0 + # via + # -r requirements/base.txt + # edx-django-utils +pyproject-api==1.9.0 + # via tox +pytest==8.3.4 + # via + # pytest-cov + # pytest-django +pytest-cov==6.0.0 + # via -r requirements/test.in +pytest-django==4.9.0 + # via -r requirements/test.in +python-slugify==8.0.4 + # via code-annotations +pytz==2024.2 + # via -r requirements/base.txt +pyyaml==6.0.2 + # via + # -r requirements/base.txt + # code-annotations + # edx-i18n-tools +six==1.17.0 + # via edx-lint +sqlparse==0.5.3 + # via + # -r requirements/base.txt + # django +stevedore==5.4.0 + # via + # -r requirements/base.txt + # code-annotations + # edx-django-utils +text-unidecode==1.3 + # via python-slugify +tomlkit==0.13.2 + # via pylint +tox==4.24.1 + # via -r requirements/test.in +virtualenv==20.29.1 + # via tox diff --git a/requirements/validation.txt b/requirements/validation.txt new file mode 100644 index 0000000..dce29da --- /dev/null +++ b/requirements/validation.txt @@ -0,0 +1,409 @@ +# +# This file is autogenerated by pip-compile with Python 3.12 +# by the following command: +# +# make upgrade +# +asgiref==3.8.1 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # django +astroid==3.3.8 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # pylint + # pylint-celery +cachetools==5.5.1 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # tox +certifi==2024.12.14 + # via + # -r requirements/quality.txt + # requests +cffi==1.17.1 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # cryptography + # pynacl +chardet==5.2.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # tox +charset-normalizer==3.4.1 + # via + # -r requirements/quality.txt + # requests +click==8.1.8 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # click-log + # code-annotations + # edx-django-utils + # edx-lint +click-log==0.4.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # edx-lint +code-annotations==2.2.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # edx-lint +colorama==0.4.6 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # tox +coverage[toml]==7.6.10 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # pytest-cov +cryptography==44.0.0 + # via + # -r requirements/quality.txt + # secretstorage +dill==0.3.9 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # pylint +distlib==0.3.9 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # virtualenv +django==4.2.18 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # django-crum + # django-waffle + # edx-django-utils + # edx-i18n-tools +django-crum==0.7.9 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # edx-django-utils +django-waffle==4.2.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # edx-django-utils +docutils==0.21.2 + # via + # -r requirements/quality.txt + # readme-renderer +edx-django-utils==7.1.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt +edx-i18n-tools==1.6.3 + # via + # -r requirements/quality.txt + # -r requirements/test.txt +edx-lint==5.5.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt +filelock==3.17.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # tox + # virtualenv +gunicorn==23.0.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt +id==1.5.0 + # via + # -r requirements/quality.txt + # twine +idna==3.10 + # via + # -r requirements/quality.txt + # requests +iniconfig==2.0.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # pytest +isort==5.13.2 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # pylint +jaraco-classes==3.4.0 + # via + # -r requirements/quality.txt + # keyring +jaraco-context==6.0.1 + # via + # -r requirements/quality.txt + # keyring +jaraco-functools==4.1.0 + # via + # -r requirements/quality.txt + # keyring +jeepney==0.8.0 + # via + # -r requirements/quality.txt + # keyring + # secretstorage +jinja2==3.1.5 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # code-annotations +keyring==25.6.0 + # via + # -r requirements/quality.txt + # twine +lxml[html-clean]==5.3.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # edx-i18n-tools + # lxml-html-clean +lxml-html-clean==0.4.1 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # lxml +markdown-it-py==3.0.0 + # via + # -r requirements/quality.txt + # rich +markupsafe==3.0.2 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # jinja2 +mccabe==0.7.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # pylint +mdurl==0.1.2 + # via + # -r requirements/quality.txt + # markdown-it-py +more-itertools==10.6.0 + # via + # -r requirements/quality.txt + # jaraco-classes + # jaraco-functools +newrelic==10.4.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # edx-django-utils +nh3==0.2.20 + # via + # -r requirements/quality.txt + # readme-renderer +openedx-atlas==0.6.2 + # via + # -r requirements/quality.txt + # -r requirements/test.txt +packaging==24.2 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # gunicorn + # pyproject-api + # pytest + # tox + # twine +path==16.16.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # edx-i18n-tools +pbr==6.1.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # stevedore +platformdirs==4.3.6 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # pylint + # tox + # virtualenv +pluggy==1.5.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # pytest + # tox +polib==1.2.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # edx-i18n-tools +psutil==6.1.1 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # edx-django-utils +pycodestyle==2.12.1 + # via -r requirements/quality.txt +pycparser==2.22 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # cffi +pydocstyle==6.3.0 + # via -r requirements/quality.txt +pygments==2.19.1 + # via + # -r requirements/quality.txt + # readme-renderer + # rich +pylint==3.3.3 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # edx-lint + # pylint-celery + # pylint-django + # pylint-plugin-utils +pylint-celery==0.3 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # edx-lint +pylint-django==2.6.1 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # edx-lint +pylint-plugin-utils==0.8.2 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # pylint-celery + # pylint-django +pynacl==1.5.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # edx-django-utils +pyproject-api==1.9.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # tox +pytest==8.3.4 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # pytest-cov + # pytest-django +pytest-cov==6.0.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt +pytest-django==4.9.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt +python-slugify==8.0.4 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # code-annotations +pytz==2024.2 + # via + # -r requirements/quality.txt + # -r requirements/test.txt +pyyaml==6.0.2 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # code-annotations + # edx-i18n-tools +readme-renderer==44.0 + # via + # -r requirements/quality.txt + # twine +requests==2.32.3 + # via + # -r requirements/quality.txt + # id + # requests-toolbelt + # twine +requests-toolbelt==1.0.0 + # via + # -r requirements/quality.txt + # twine +rfc3986==2.0.0 + # via + # -r requirements/quality.txt + # twine +rich==13.9.4 + # via + # -r requirements/quality.txt + # twine +secretstorage==3.3.3 + # via + # -r requirements/quality.txt + # keyring +six==1.17.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # edx-lint +snowballstemmer==2.2.0 + # via + # -r requirements/quality.txt + # pydocstyle +sqlparse==0.5.3 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # django +stevedore==5.4.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # code-annotations + # edx-django-utils +text-unidecode==1.3 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # python-slugify +tomlkit==0.13.2 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # pylint +tox==4.24.1 + # via + # -r requirements/quality.txt + # -r requirements/test.txt +twine==6.1.0 + # via -r requirements/quality.txt +urllib3==2.2.3 + # via + # -r requirements/quality.txt + # requests + # twine +virtualenv==20.29.1 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # tox diff --git a/tox.ini b/tox.ini index 65f1740..d15b146 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py312-django{42}, quality, docs, pii_check +envlist = py312-django{42}, quality, docs skipsdist = true [doc8] @@ -85,12 +85,3 @@ commands = pydocstyle codejail_service manage.py isort --check-only --diff test_utils codejail_service manage.py make selfcheck - -[testenv:pii_check] -setenv = - DJANGO_SETTINGS_MODULE = codejail_service.settings.test -deps = - -r{toxinidir}/requirements/test.txt -commands = - code_annotations django_find_annotations --config_file .pii_annotations.yml --lint --report --coverage -