From d94826762760d3edb4a6976e623c6368c0eb7773 Mon Sep 17 00:00:00 2001 From: Kaustav Banerjee Date: Tue, 26 Sep 2023 16:15:53 +0530 Subject: [PATCH 001/170] fix: clarify grade range numerical values --- cms/static/js/views/settings/grading.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cms/static/js/views/settings/grading.js b/cms/static/js/views/settings/grading.js index ac4d170352a2..dcb2ce9b3e96 100644 --- a/cms/static/js/views/settings/grading.js +++ b/cms/static/js/views/settings/grading.js @@ -268,7 +268,7 @@ function(ValidatingView, _, $, ui, GraderView, StringUtils, HtmlUtils) { var cutoffs = this.descendingCutoffs; this.$el.find('.range').each(function(i) { var min = (i < cutoffs.length ? cutoffs[i].cutoff : 0); - var max = (i > 0 ? cutoffs[i - 1].cutoff : 100); + var max = (i > 0 ? cutoffs[i - 1].cutoff - 1 : 100); $(this).text(min + '-' + max); }); }, From 42ca0ddec46c19ccd5ecfaed939de6512e960916 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Wed, 27 Sep 2023 10:58:37 +0500 Subject: [PATCH 002/170] chore: remove bok choy settings --- .github/workflows/js-tests.yml | 14 +- .github/workflows/static-assets-check.yml | 5 - .gitignore | 1 - cms/envs/bok_choy.auth.json | 116 ----- cms/envs/bok_choy.env.json | 127 ----- cms/envs/bok_choy.py | 184 ------- cms/envs/bok_choy.yml | 150 ------ cms/envs/bok_choy_docker.auth.json | 116 ----- cms/envs/bok_choy_docker.env.json | 126 ----- cms/envs/bok_choy_docker.py | 26 - cms/envs/bok_choy_docker.yml | 147 ------ common/djangoapps/terrain/stubs/lti.py | 4 +- .../static/common/js/jasmine.common.conf.js | 12 - .../static/common/js/jasmine_stack_trace.js | 29 -- common/static/common/js/karma.common.conf.js | 467 ------------------ .../0004-managing-django-settings.rst | 2 - lms/envs/bok_choy.py | 154 ------ lms/envs/bok_choy.yml | 274 ---------- lms/envs/bok_choy_docker.py | 27 - lms/envs/bok_choy_docker.yml | 183 ------- .../management/commands/update_fixtures.py | 30 -- .../util/tests/test_update_fixtures.py | 42 -- .../content_type_gating/tests/test_access.py | 3 +- .../pytest_plugin.py | 25 +- pavelib/utils/envs.py | 93 +--- requirements/edx/development.txt | 8 - requirements/edx/testing.in | 2 - requirements/edx/testing.txt | 8 - scripts/reset-test-db.sh | 140 ------ tox.ini | 4 - xmodule/modulestore/tests/mongo_connection.py | 3 +- xmodule/tests/test_mongo_utils.py | 3 +- xmodule/tests/test_video.py | 3 +- 33 files changed, 28 insertions(+), 2500 deletions(-) delete mode 100644 cms/envs/bok_choy.auth.json delete mode 100644 cms/envs/bok_choy.env.json delete mode 100644 cms/envs/bok_choy.py delete mode 100644 cms/envs/bok_choy.yml delete mode 100644 cms/envs/bok_choy_docker.auth.json delete mode 100644 cms/envs/bok_choy_docker.env.json delete mode 100644 cms/envs/bok_choy_docker.py delete mode 100644 cms/envs/bok_choy_docker.yml delete mode 100644 common/static/common/js/jasmine.common.conf.js delete mode 100644 common/static/common/js/jasmine_stack_trace.js delete mode 100644 common/static/common/js/karma.common.conf.js delete mode 100644 lms/envs/bok_choy.py delete mode 100644 lms/envs/bok_choy.yml delete mode 100644 lms/envs/bok_choy_docker.py delete mode 100644 lms/envs/bok_choy_docker.yml delete mode 100644 openedx/core/djangoapps/util/management/commands/update_fixtures.py delete mode 100644 openedx/core/djangoapps/util/tests/test_update_fixtures.py delete mode 100755 scripts/reset-test-db.sh diff --git a/.github/workflows/js-tests.yml b/.github/workflows/js-tests.yml index c26e4e79fc77..092e6e38e2f1 100644 --- a/.github/workflows/js-tests.yml +++ b/.github/workflows/js-tests.yml @@ -30,13 +30,13 @@ jobs: - name: Setup npm run: npm i -g npm@8.5.x - - name: Install Firefox 61.0 - run: | - sudo apt-get purge firefox - wget "https://ftp.mozilla.org/pub/firefox/releases/61.0/linux-x86_64/en-US/firefox-61.0.tar.bz2" - tar -xjf firefox-61.0.tar.bz2 - sudo mv firefox /opt/firefox - sudo ln -s /opt/firefox/firefox /usr/bin/firefox + # - name: Install Firefox 61.0 + # run: | + # sudo apt-get purge firefox + # wget "https://ftp.mozilla.org/pub/firefox/releases/61.0/linux-x86_64/en-US/firefox-61.0.tar.bz2" + # tar -xjf firefox-61.0.tar.bz2 + # sudo mv firefox /opt/firefox + # sudo ln -s /opt/firefox/firefox /usr/bin/firefox - name: Install Required System Packages run: sudo apt-get update && sudo apt-get install libxmlsec1-dev ubuntu-restricted-extras xvfb diff --git a/.github/workflows/static-assets-check.yml b/.github/workflows/static-assets-check.yml index c4da37f2d1fe..7aa7dce78330 100644 --- a/.github/workflows/static-assets-check.yml +++ b/.github/workflows/static-assets-check.yml @@ -62,11 +62,6 @@ jobs: - name: Add node_modules bin to $Path run: echo $GITHUB_WORKSPACE/node_modules/.bin >> $GITHUB_PATH - - name: Run Static Assets Check - env: - LMS_CFG: lms/envs/bok_choy.yml - CMS_CFG: cms/envs/bok_choy.yml - run: | paver update_assets lms paver update_assets cms diff --git a/.gitignore b/.gitignore index d6f1202bf4ce..e7f12787f598 100644 --- a/.gitignore +++ b/.gitignore @@ -86,7 +86,6 @@ test_root/paver_logs/ test_root/uploads/ django-pyfs .tox/ -common/test/db_cache/bok_choy_*.yaml common/test/data/badges/*.png ### Installation artifacts diff --git a/cms/envs/bok_choy.auth.json b/cms/envs/bok_choy.auth.json deleted file mode 100644 index db92b5ba924e..000000000000 --- a/cms/envs/bok_choy.auth.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "AWS_ACCESS_KEY_ID": "", - "AWS_SECRET_ACCESS_KEY": "", - "CELERY_BROKER_PASSWORD": "celery", - "CELERY_BROKER_USER": "celery", - "CONTENTSTORE": { - "DOC_STORE_CONFIG": { - "collection": "modulestore", - "db": "test", - "host": [ - "localhost" - ], - "port": 27017 - }, - "ENGINE": "xmodule.contentstore.mongo.MongoContentStore", - "OPTIONS": { - "db": "test", - "host": [ - "localhost" - ], - "port": 27017 - } - }, - "DATABASES": { - "default": { - "ENGINE": "django.db.backends.mysql", - "HOST": "localhost", - "NAME": "edxtest", - "PASSWORD": "", - "PORT": "3306", - "USER": "root" - }, - "student_module_history": { - "ENGINE": "django.db.backends.mysql", - "HOST": "localhost", - "NAME": "student_module_history_test", - "PASSWORD": "", - "PORT": "3306", - "USER": "root" - } - }, - "DOC_STORE_CONFIG": { - "collection": "modulestore", - "db": "test", - "host": [ - "localhost" - ], - "port": 27017 - }, - "JWT_AUTH": { - "JWT_SECRET_KEY": "super-secret-key", - "JWT_PUBLIC_SIGNING_JWK_SET": "{\"keys\": [{\"kid\": \"BTZ9HA6K\", \"e\": \"AQAB\", \"kty\": \"RSA\", \"n\": \"o5cn3ljSRi6FaDEKTn0PS-oL9EFyv1pI7dRgffQLD1qf5D6sprmYfWWokSsrWig8u2y0HChSygR6Jn5KXBqQn6FpM0dDJLnWQDRXHLl3Ey1iPYgDSmOIsIGrV9ZyNCQwk03wAgWbfdBTig3QSDYD-sTNOs3pc4UD_PqAvU2nz_1SS2ZiOwOn5F6gulE1L0iE3KEUEvOIagfHNVhz0oxa_VRZILkzV-zr6R_TW1m97h4H8jXl_VJyQGyhMGGypuDrQ9_vaY_RLEulLCyY0INglHWQ7pckxBtI5q55-Vio2wgewe2_qYcGsnBGaDNbySAsvYcWRrqDiFyzrJYivodqTQ\"}]}" - }, - "MODULESTORE": { - "default": { - "ENGINE": "xmodule.modulestore.mixed.MixedModuleStore", - "OPTIONS": { - "mappings": {}, - "stores": [ - { - "NAME": "draft", - "DOC_STORE_CONFIG": { - "collection": "modulestore", - "db": "test", - "host": [ - "localhost" - ], - "port": 27017 - }, - "ENGINE": "xmodule.modulestore.mongo.DraftMongoModuleStore", - "OPTIONS": { - "collection": "modulestore", - "db": "test", - "default_class": "xmodule.hidden_block.HiddenBlock", - "fs_root": "** OVERRIDDEN **", - "host": [ - "localhost" - ], - "port": 27017, - "render_template": "common.djangoapps.edxmako.shortcuts.render_to_string" - } - }, - { - "NAME": "xml", - "ENGINE": "xmodule.modulestore.xml.XMLModuleStore", - "OPTIONS": { - "data_dir": "** OVERRIDDEN **", - "default_class": "xmodule.hidden_block.HiddenBlock" - } - } - ] - } - } - }, - "DJFS": { - "type": "s3fs", - "bucket": "test", - "prefix": "test", - "aws_access_key_id": "test", - "aws_secret_access_key": "test" - }, - "SECRET_KEY": "", - "XQUEUE_INTERFACE": { - "basic_auth": [ - "edx", - "edx" - ], - "django_auth": { - "password": "password", - "username": "lms" - }, - "url": "http://localhost:18040" - }, - "ZENDESK_API_KEY": "", - "ZENDESK_USER": "" -} diff --git a/cms/envs/bok_choy.env.json b/cms/envs/bok_choy.env.json deleted file mode 100644 index 6343dc048c69..000000000000 --- a/cms/envs/bok_choy.env.json +++ /dev/null @@ -1,127 +0,0 @@ -{ - "BUGS_EMAIL": "bugs@example.com", - "BULK_EMAIL_DEFAULT_FROM_EMAIL": "no-reply@example.com", - "CACHES": { - "celery": { - "BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache", - "OPTIONS": { - "no_delay": true, - "ignore_exc": true, - "use_pooling": true - }, - "KEY_FUNCTION": "common.djangoapps.util.memcache.safe_key", - "KEY_PREFIX": "integration_celery", - "LOCATION": [ - "localhost:11211" - ] - }, - "default": { - "BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache", - "OPTIONS": { - "no_delay": true, - "ignore_exc": true, - "use_pooling": true - }, - "KEY_FUNCTION": "common.djangoapps.util.memcache.safe_key", - "KEY_PREFIX": "sandbox_default", - "LOCATION": [ - "localhost:11211" - ] - }, - "general": { - "BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache", - "OPTIONS": { - "no_delay": true, - "ignore_exc": true, - "use_pooling": true - }, - "KEY_FUNCTION": "common.djangoapps.util.memcache.safe_key", - "KEY_PREFIX": "sandbox_general", - "LOCATION": [ - "localhost:11211" - ] - }, - "mongo_metadata_inheritance": { - "BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache", - "OPTIONS": { - "no_delay": true, - "ignore_exc": true, - "use_pooling": true - }, - "KEY_FUNCTION": "common.djangoapps.util.memcache.safe_key", - "KEY_PREFIX": "integration_mongo_metadata_inheritance", - "LOCATION": [ - "localhost:11211" - ] - }, - "staticfiles": { - "BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache", - "OPTIONS": { - "no_delay": true, - "ignore_exc": true, - "use_pooling": true - }, - "KEY_FUNCTION": "common.djangoapps.util.memcache.safe_key", - "KEY_PREFIX": "integration_static_files", - "LOCATION": [ - "localhost:11211" - ] - } - }, - "CELERY_ALWAYS_EAGER": true, - "CELERY_BROKER_HOSTNAME": "localhost", - "CELERY_BROKER_TRANSPORT": "amqp", - "CERT_QUEUE": "certificates", - "CLEAR_REQUEST_CACHE_ON_TASK_COMPLETION": false, - "CMS_BASE": "localhost:8031", - "CODE_JAIL": { - "limits": { - "REALTIME": 3, - "VMEM": 0 - } - }, - "COMMENTS_SERVICE_KEY": "password", - "COMMENTS_SERVICE_URL": "http://localhost:4567", - "CONTACT_EMAIL": "info@example.com", - "DEFAULT_FEEDBACK_EMAIL": "feedback@example.com", - "DEFAULT_FROM_EMAIL": "registration@example.com", - "EMAIL_BACKEND": "django.core.mail.backends.smtp.EmailBackend", - "SOCIAL_SHARING_SETTINGS": { - "CUSTOM_COURSE_URLS": true - }, - "FEATURES": { - "CERTIFICATES_HTML_VIEW": true, - "ENABLE_DISCUSSION_SERVICE": true, - "ENABLE_GRADE_DOWNLOADS": true, - "ENTRANCE_EXAMS": true, - "MILESTONES_APP": true, - "PREVIEW_LMS_BASE": "preview.localhost:8003", - "ENABLE_CONTENT_LIBRARIES": true, - "ENABLE_SPECIAL_EXAMS": true, - "SHOW_HEADER_LANGUAGE_SELECTOR": true, - "ENABLE_EXTENDED_COURSE_DETAILS": true, - "CUSTOM_COURSES_EDX": true - }, - "FEEDBACK_SUBMISSION_EMAIL": "", - "GITHUB_REPO_ROOT": "** OVERRIDDEN **", - "GRADES_DOWNLOAD": { - "BUCKET": "edx-grades", - "ROOT_PATH": "/tmp/edx-s3/grades", - "STORAGE_TYPE": "localfs" - }, - "LMS_BASE": "localhost:8003", - "LMS_ROOT_URL": "http://localhost:8003", - "LOCAL_LOGLEVEL": "INFO", - "LOGGING_ENV": "sandbox", - "LOG_DIR": "** OVERRIDDEN **", - "MEDIA_URL": "/media/", - "MKTG_URL_LINK_MAP": {}, - "SERVER_EMAIL": "devops@example.com", - "SESSION_COOKIE_DOMAIN": null, - "SITE_NAME": "localhost", - "STATIC_URL_BASE": "/static/", - "SYSLOG_SERVER": "", - "TECH_SUPPORT_EMAIL": "technical@example.com", - "TIME_ZONE": "America/New_York", - "WIKI_ENABLED": true, -} diff --git a/cms/envs/bok_choy.py b/cms/envs/bok_choy.py deleted file mode 100644 index f96183840c71..000000000000 --- a/cms/envs/bok_choy.py +++ /dev/null @@ -1,184 +0,0 @@ -""" -Settings for Bok Choy tests that are used when running Studio. - -Bok Choy uses two different settings files: -1. test_static_optimized is used when invoking collectstatic -2. bok_choy is used when running the tests - -Note: it isn't possible to have a single settings file, because Django doesn't -support both generating static assets to a directory and also serving static -from the same directory. -""" - - -# Silence noisy logs -import logging -import os - -from django.utils.translation import gettext_lazy -from path import Path as path - -from openedx.core.release import RELEASE_LINE -from xmodule.modulestore.modulestore_settings import update_module_store_settings # lint-amnesty, pylint: disable=wrong-import-order - -########################## Prod-like settings ################################### -# These should be as close as possible to the settings we use in production. -# As in prod, we read in environment and auth variables from JSON files. -# Unlike in prod, we use the JSON files stored in this repo. -# This is a convenience for ensuring (a) that we can consistently find the files -# and (b) that the files are the same in Jenkins as in local dev. -os.environ['SERVICE_VARIANT'] = 'bok_choy_docker' if 'BOK_CHOY_HOSTNAME' in os.environ else 'bok_choy' -CONFIG_ROOT = path(__file__).abspath().dirname() -os.environ['STUDIO_CFG'] = str.format("{config_root}/{service_variant}.yml", - config_root=CONFIG_ROOT, - service_variant=os.environ['SERVICE_VARIANT']) -os.environ['REVISION_CFG'] = f"{CONFIG_ROOT}/revisions.yml" - -from .production import * # pylint: disable=wildcard-import, unused-wildcard-import, wrong-import-position - - -######################### Testing overrides #################################### - -# Redirect to the test_root folder within the repo -TEST_ROOT = REPO_ROOT / "test_root" -GITHUB_REPO_ROOT = (TEST_ROOT / "data").abspath() -LOG_DIR = (TEST_ROOT / "log").abspath() -DATA_DIR = TEST_ROOT / "data" - -# Configure modulestore to use the test folder within the repo -update_module_store_settings( - MODULESTORE, - module_store_options={ - 'fs_root': (TEST_ROOT / "data").abspath(), - }, - xml_store_options={ - 'data_dir': (TEST_ROOT / "data").abspath(), - }, - default_store=os.environ.get('DEFAULT_STORE', 'draft'), -) - -# Needed to enable licensing on video blocks -XBLOCK_SETTINGS.update({'VideoBlock': {'licensing_enabled': True}}) - -# Capture the console log via template includes, until webdriver supports log capture again -CAPTURE_CONSOLE_LOG = True - -PLATFORM_NAME = gettext_lazy("édX") -PLATFORM_DESCRIPTION = gettext_lazy("Open édX Platform") -STUDIO_NAME = gettext_lazy("Your Platform 𝓢𝓽𝓾𝓭𝓲𝓸") -STUDIO_SHORT_NAME = gettext_lazy("𝓢𝓽𝓾𝓭𝓲𝓸") - -############################ STATIC FILES ############################# - -# Enable debug so that static assets are served by Django -DEBUG = True - -# Serve static files at /static directly from the staticfiles directory under test root -# Note: optimized files for testing are generated with settings from test_static_optimized -STATIC_URL = "/static/" -STATICFILES_FINDERS = [ - 'django.contrib.staticfiles.finders.FileSystemFinder', -] -STATICFILES_DIRS = [ - (TEST_ROOT / "staticfiles" / "cms").abspath(), -] - -DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage' -MEDIA_ROOT = TEST_ROOT / "uploads" - -WEBPACK_LOADER['DEFAULT']['STATS_FILE'] = TEST_ROOT / "staticfiles" / "cms" / "webpack-stats.json" - -LOG_OVERRIDES = [ - ('common.djangoapps.track.middleware', logging.CRITICAL), - ('edx.discussion', logging.CRITICAL), -] -for log_name, log_level in LOG_OVERRIDES: - logging.getLogger(log_name).setLevel(log_level) - -# Use the auto_auth workflow for creating users and logging them in -FEATURES['AUTOMATIC_AUTH_FOR_TESTING'] = True -FEATURES['RESTRICT_AUTOMATIC_AUTH'] = False - -# Enable milestones app -FEATURES['MILESTONES_APP'] = True - -# Enable pre-requisite course -FEATURES['ENABLE_PREREQUISITE_COURSES'] = True - -# Enable student notes -FEATURES['ENABLE_EDXNOTES'] = True - -# Enable teams feature -FEATURES['ENABLE_TEAMS'] = True - -# Enable custom content licensing -FEATURES['LICENSING'] = True - -FEATURES['ENABLE_MOBILE_REST_API'] = True # Enable video bumper in Studio -FEATURES['ENABLE_VIDEO_BUMPER'] = True # Enable video bumper in Studio settings - -FEATURES['ENABLE_ENROLLMENT_TRACK_USER_PARTITION'] = True - -# Whether archived courses (courses with end dates in the past) should be -# shown in Studio in a separate list. -FEATURES['ENABLE_SEPARATE_ARCHIVED_COURSES'] = True - -# Enable support for OpenBadges accomplishments -FEATURES['ENABLE_OPENBADGES'] = True - -# Enable partner support link in Studio footer -PARTNER_SUPPORT_EMAIL = 'partner-support@example.com' - -########################### Entrance Exams ################################# -FEATURES['ENTRANCE_EXAMS'] = True - -FEATURES['ENABLE_SPECIAL_EXAMS'] = True - -# Point the URL used to test YouTube availability to our stub YouTube server -YOUTUBE_PORT = 9080 -YOUTUBE['TEST_TIMEOUT'] = 5000 -YOUTUBE_HOSTNAME = os.environ.get('BOK_CHOY_HOSTNAME', '127.0.0.1') -YOUTUBE['API'] = f"http://{YOUTUBE_HOSTNAME}:{YOUTUBE_PORT}/get_youtube_api/" -YOUTUBE['METADATA_URL'] = f"http://{YOUTUBE_HOSTNAME}:{YOUTUBE_PORT}/test_youtube/" - -FEATURES['ENABLE_COURSEWARE_INDEX'] = True -FEATURES['ENABLE_LIBRARY_INDEX'] = True -FEATURES['ENABLE_CONTENT_LIBRARY_INDEX'] = False - -ORGANIZATIONS_AUTOCREATE = False - -SEARCH_ENGINE = "search.tests.mock_search_engine.MockSearchEngine" -# Path at which to store the mock index -MOCK_SEARCH_BACKING_FILE = ( - TEST_ROOT / "index_file.dat" -).abspath() - -# this secret key should be the same as lms/envs/bok_choy.py's -SECRET_KEY = "very_secret_bok_choy_key" - -LMS_ROOT_URL = "http://localhost:8003" -if RELEASE_LINE == "master": - # On master, acceptance tests use edX books, not the default Open edX books. - HELP_TOKENS_BOOKS = { - 'learner': 'https://edx.readthedocs.io/projects/edx-guide-for-students', - 'course_author': 'https://edx.readthedocs.io/projects/edx-partner-course-staff', - } - -########################## VIDEO TRANSCRIPTS STORAGE ############################ -VIDEO_TRANSCRIPTS_SETTINGS = dict( - VIDEO_TRANSCRIPTS_MAX_BYTES=3 * 1024 * 1024, # 3 MB - STORAGE_KWARGS=dict( - location=MEDIA_ROOT, - base_url=MEDIA_URL, - ), - DIRECTORY_PREFIX='video-transcripts/', -) - -INSTALLED_APPS.append('openedx.testing.coverage_context_listener') - -##################################################################### -# Lastly, see if the developer has any local overrides. -try: - from .private import * # pylint: disable=wildcard-import -except ImportError: - pass diff --git a/cms/envs/bok_choy.yml b/cms/envs/bok_choy.yml deleted file mode 100644 index 03bd022414b4..000000000000 --- a/cms/envs/bok_choy.yml +++ /dev/null @@ -1,150 +0,0 @@ -# ingested bok_choy.env.json -# ingested bok_choy.auth.json -AWS_ACCESS_KEY_ID: '' -AWS_SECRET_ACCESS_KEY: '' -BUGS_EMAIL: bugs@example.com -BULK_EMAIL_DEFAULT_FROM_EMAIL: no-reply@example.com -CACHES: - celery: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - OPTIONS: - ignore_exc: true - no_delay: true - use_pooling: true - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: integration_celery - LOCATION: ['localhost:11211'] - default: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - OPTIONS: - ignore_exc: true - no_delay: true - use_pooling: true - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: sandbox_default - LOCATION: ['localhost:11211'] - general: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - OPTIONS: - ignore_exc: true - no_delay: true - use_pooling: true - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: sandbox_general - LOCATION: ['localhost:11211'] - mongo_metadata_inheritance: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - OPTIONS: - ignore_exc: true - no_delay: true - use_pooling: true - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: integration_mongo_metadata_inheritance - LOCATION: ['localhost:11211'] - staticfiles: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - OPTIONS: - ignore_exc: true - no_delay: true - use_pooling: true - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: integration_static_files - LOCATION: ['localhost:11211'] -CELERY_ALWAYS_EAGER: true -CELERY_BROKER_HOSTNAME: localhost -CELERY_BROKER_PASSWORD: celery -CELERY_BROKER_TRANSPORT: amqp -CELERY_BROKER_USER: celery -CLEAR_REQUEST_CACHE_ON_TASK_COMPLETION: false -CERT_QUEUE: certificates -CMS_BASE: localhost:8031 -CODE_JAIL: - limits: {REALTIME: 3, VMEM: 0} -COMMENTS_SERVICE_KEY: password -COMMENTS_SERVICE_URL: http://localhost:4567 -CONTACT_EMAIL: info@example.com -CONTENTSTORE: - DOC_STORE_CONFIG: - collection: modulestore - db: test - host: [localhost] - port: 27017 - ENGINE: xmodule.contentstore.mongo.MongoContentStore - OPTIONS: - db: test - host: [localhost] - port: 27017 -DATABASES: - default: {ENGINE: django.db.backends.mysql, HOST: localhost, NAME: edxtest, PASSWORD: '', - PORT: '3306', USER: root} - student_module_history: {ENGINE: django.db.backends.mysql, HOST: localhost, NAME: student_module_history_test, - PASSWORD: '', PORT: '3306', USER: root} -DEFAULT_FEEDBACK_EMAIL: feedback@example.com -DEFAULT_FROM_EMAIL: registration@example.com -DJFS: {aws_access_key_id: test, aws_secret_access_key: test, bucket: test, prefix: test, - type: s3fs} -DOC_STORE_CONFIG: - collection: modulestore - db: test - host: [localhost] - port: 27017 -EMAIL_BACKEND: django.core.mail.backends.smtp.EmailBackend -FEATURES: {CERTIFICATES_HTML_VIEW: true, CUSTOM_COURSES_EDX: true, - ENABLE_CONTENT_LIBRARIES: true, ENABLE_DISCUSSION_SERVICE: true, ENABLE_EXTENDED_COURSE_DETAILS: true, - ENABLE_GRADE_DOWNLOADS: true, ENABLE_SPECIAL_EXAMS: true, ENTRANCE_EXAMS: true, - MILESTONES_APP: true, PREVIEW_LMS_BASE: 'preview.localhost:8003', SHOW_HEADER_LANGUAGE_SELECTOR: true} -GITHUB_REPO_ROOT: '** OVERRIDDEN **' -GRADES_DOWNLOAD: {BUCKET: edx-grades, ROOT_PATH: /tmp/edx-s3/grades, STORAGE_TYPE: localfs} -JWT_AUTH: {JWT_PUBLIC_SIGNING_JWK_SET: '{"keys": [{"kid": - "BTZ9HA6K", "e": "AQAB", "kty": "RSA", "n": "o5cn3ljSRi6FaDEKTn0PS-oL9EFyv1pI7dRgffQLD1qf5D6sprmYfWWokSsrWig8u2y0HChSygR6Jn5KXBqQn6FpM0dDJLnWQDRXHLl3Ey1iPYgDSmOIsIGrV9ZyNCQwk03wAgWbfdBTig3QSDYD-sTNOs3pc4UD_PqAvU2nz_1SS2ZiOwOn5F6gulE1L0iE3KEUEvOIagfHNVhz0oxa_VRZILkzV-zr6R_TW1m97h4H8jXl_VJyQGyhMGGypuDrQ9_vaY_RLEulLCyY0INglHWQ7pckxBtI5q55-Vio2wgewe2_qYcGsnBGaDNbySAsvYcWRrqDiFyzrJYivodqTQ"}]}', - JWT_SECRET_KEY: super-secret-key} -LMS_BASE: localhost:8003 -LMS_ROOT_URL: http://localhost:8003 -LOCAL_LOGLEVEL: INFO -LOGGING_ENV: sandbox -LOG_DIR: '** OVERRIDDEN **' -MEDIA_URL: /media/ -MKTG_URL_LINK_MAP: {} -MODULESTORE: - default: - ENGINE: xmodule.modulestore.mixed.MixedModuleStore - OPTIONS: - mappings: {} - stores: - - DOC_STORE_CONFIG: - collection: modulestore - db: test - host: [localhost] - port: 27017 - ENGINE: xmodule.modulestore.mongo.DraftMongoModuleStore - NAME: draft - OPTIONS: - collection: modulestore - db: test - default_class: xmodule.hidden_block.HiddenBlock - fs_root: '** OVERRIDDEN **' - host: [localhost] - port: 27017 - render_template: common.djangoapps.edxmako.shortcuts.render_to_string - - ENGINE: xmodule.modulestore.xml.XMLModuleStore - NAME: xml - OPTIONS: {data_dir: '** OVERRIDDEN **', default_class: xmodule.hidden_block.HiddenBlock} -# We need to test different scenarios, following setting effectively disbale rate limiting -PASSWORD_RESET_IP_RATE: '1/s' -PASSWORD_RESET_EMAIL_RATE: '1/s' -SECRET_KEY: '' -SERVER_EMAIL: devops@example.com -SESSION_COOKIE_DOMAIN: null -SITE_NAME: localhost -SOCIAL_SHARING_SETTINGS: {CUSTOM_COURSE_URLS: true} -STATIC_URL_BASE: /static/ -SYSLOG_SERVER: '' -TECH_SUPPORT_EMAIL: technical@example.com -TIME_ZONE: America/New_York -WIKI_ENABLED: true -XQUEUE_INTERFACE: - basic_auth: [edx, edx] - django_auth: {password: password, username: lms} - url: http://localhost:18040 -ZENDESK_API_KEY: '' -ZENDESK_USER: '' diff --git a/cms/envs/bok_choy_docker.auth.json b/cms/envs/bok_choy_docker.auth.json deleted file mode 100644 index fce8a970fef8..000000000000 --- a/cms/envs/bok_choy_docker.auth.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "AWS_ACCESS_KEY_ID": "", - "AWS_SECRET_ACCESS_KEY": "", - "CELERY_BROKER_PASSWORD": "celery", - "CELERY_BROKER_USER": "celery", - "CONTENTSTORE": { - "DOC_STORE_CONFIG": { - "collection": "modulestore", - "db": "test", - "host": [ - "edx.devstack.mongo" - ], - "port": 27017 - }, - "ENGINE": "xmodule.contentstore.mongo.MongoContentStore", - "OPTIONS": { - "db": "test", - "host": [ - "edx.devstack.mongo" - ], - "port": 27017 - } - }, - "DATABASES": { - "default": { - "ENGINE": "django.db.backends.mysql", - "HOST": "edx.devstack.mysql57", - "NAME": "edxtest", - "PASSWORD": "", - "PORT": "3306", - "USER": "root" - }, - "student_module_history": { - "ENGINE": "django.db.backends.mysql", - "HOST": "edx.devstack.mysql57", - "NAME": "student_module_history_test", - "PASSWORD": "", - "PORT": "3306", - "USER": "root" - } - }, - "DOC_STORE_CONFIG": { - "collection": "modulestore", - "db": "test", - "host": [ - "edx.devstack.mongo" - ], - "port": 27017 - }, - "JWT_AUTH": { - "JWT_SECRET_KEY": "super-secret-key", - "JWT_PUBLIC_SIGNING_JWK_SET": "{\"keys\": [{\"kid\": \"BTZ9HA6K\", \"e\": \"AQAB\", \"kty\": \"RSA\", \"n\": \"o5cn3ljSRi6FaDEKTn0PS-oL9EFyv1pI7dRgffQLD1qf5D6sprmYfWWokSsrWig8u2y0HChSygR6Jn5KXBqQn6FpM0dDJLnWQDRXHLl3Ey1iPYgDSmOIsIGrV9ZyNCQwk03wAgWbfdBTig3QSDYD-sTNOs3pc4UD_PqAvU2nz_1SS2ZiOwOn5F6gulE1L0iE3KEUEvOIagfHNVhz0oxa_VRZILkzV-zr6R_TW1m97h4H8jXl_VJyQGyhMGGypuDrQ9_vaY_RLEulLCyY0INglHWQ7pckxBtI5q55-Vio2wgewe2_qYcGsnBGaDNbySAsvYcWRrqDiFyzrJYivodqTQ\"}]}" - }, - "MODULESTORE": { - "default": { - "ENGINE": "xmodule.modulestore.mixed.MixedModuleStore", - "OPTIONS": { - "mappings": {}, - "stores": [ - { - "NAME": "draft", - "DOC_STORE_CONFIG": { - "collection": "modulestore", - "db": "test", - "host": [ - "edx.devstack.mongo" - ], - "port": 27017 - }, - "ENGINE": "xmodule.modulestore.mongo.DraftMongoModuleStore", - "OPTIONS": { - "collection": "modulestore", - "db": "test", - "default_class": "xmodule.hidden_block.HiddenBlock", - "fs_root": "** OVERRIDDEN **", - "host": [ - "edx.devstack.mongo" - ], - "port": 27017, - "render_template": "common.djangoapps.edxmako.shortcuts.render_to_string" - } - }, - { - "NAME": "xml", - "ENGINE": "xmodule.modulestore.xml.XMLModuleStore", - "OPTIONS": { - "data_dir": "** OVERRIDDEN **", - "default_class": "xmodule.hidden_block.HiddenBlock" - } - } - ] - } - } - }, - "DJFS": { - "type": "s3fs", - "bucket": "test", - "prefix": "test", - "aws_access_key_id": "test", - "aws_secret_access_key": "test" - }, - "SECRET_KEY": "", - "XQUEUE_INTERFACE": { - "basic_auth": [ - "edx", - "edx" - ], - "django_auth": { - "password": "password", - "username": "lms" - }, - "url": "http://localhost:18040" - }, - "ZENDESK_API_KEY": "", - "ZENDESK_USER": "" -} diff --git a/cms/envs/bok_choy_docker.env.json b/cms/envs/bok_choy_docker.env.json deleted file mode 100644 index 47fed49f1a38..000000000000 --- a/cms/envs/bok_choy_docker.env.json +++ /dev/null @@ -1,126 +0,0 @@ -{ - "BUGS_EMAIL": "bugs@example.com", - "BULK_EMAIL_DEFAULT_FROM_EMAIL": "no-reply@example.com", - "CACHES": { - "celery": { - "BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache", - "OPTIONS": { - "no_delay": true, - "ignore_exc": true, - "use_pooling": true - }, - "KEY_FUNCTION": "common.djangoapps.util.memcache.safe_key", - "KEY_PREFIX": "integration_celery", - "LOCATION": [ - "edx.devstack.memcached:11211" - ] - }, - "default": { - "BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache", - "OPTIONS": { - "no_delay": true, - "ignore_exc": true, - "use_pooling": true - }, - "KEY_FUNCTION": "common.djangoapps.util.memcache.safe_key", - "KEY_PREFIX": "sandbox_default", - "LOCATION": [ - "edx.devstack.memcached:11211" - ] - }, - "general": { - "BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache", - "OPTIONS": { - "no_delay": true, - "ignore_exc": true, - "use_pooling": true - }, - "KEY_FUNCTION": "common.djangoapps.util.memcache.safe_key", - "KEY_PREFIX": "sandbox_general", - "LOCATION": [ - "edx.devstack.memcached:11211" - ] - }, - "mongo_metadata_inheritance": { - "BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache", - "OPTIONS": { - "no_delay": true, - "ignore_exc": true, - "use_pooling": true - }, - "KEY_FUNCTION": "common.djangoapps.util.memcache.safe_key", - "KEY_PREFIX": "integration_mongo_metadata_inheritance", - "LOCATION": [ - "edx.devstack.memcached:11211" - ] - }, - "staticfiles": { - "BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache", - "OPTIONS": { - "no_delay": true, - "ignore_exc": true, - "use_pooling": true - }, - "KEY_FUNCTION": "common.djangoapps.util.memcache.safe_key", - "KEY_PREFIX": "integration_static_files", - "LOCATION": [ - "edx.devstack.memcached:11211" - ] - } - }, - "CELERY_ALWAYS_EAGER": true, - "CLEAR_REQUEST_CACHE_ON_TASK_COMPLETION": false, - "CELERY_BROKER_HOSTNAME": "localhost", - "CELERY_BROKER_TRANSPORT": "amqp", - "CERT_QUEUE": "certificates", - "CMS_BASE": "** OVERRIDDEN **", - "CODE_JAIL": { - "limits": { - "REALTIME": 3, - "VMEM": 0 - } - }, - "COMMENTS_SERVICE_KEY": "password", - "COMMENTS_SERVICE_URL": "http://edx.devstack.studio:4567", - "CONTACT_EMAIL": "info@example.com", - "DEFAULT_FEEDBACK_EMAIL": "feedback@example.com", - "DEFAULT_FROM_EMAIL": "registration@example.com", - "EMAIL_BACKEND": "django.core.mail.backends.smtp.EmailBackend", - "SOCIAL_SHARING_SETTINGS": { - "CUSTOM_COURSE_URLS": true - }, - "FEATURES": { - "CERTIFICATES_HTML_VIEW": true, - "ENABLE_DISCUSSION_SERVICE": true, - "ENABLE_GRADE_DOWNLOADS": true, - "ENTRANCE_EXAMS": true, - "MILESTONES_APP": true, - "PREVIEW_LMS_BASE": "preview.localhost:8003", - "ENABLE_CONTENT_LIBRARIES": true, - "ENABLE_SPECIAL_EXAMS": true, - "SHOW_HEADER_LANGUAGE_SELECTOR": true, - "ENABLE_EXTENDED_COURSE_DETAILS": true, - "CUSTOM_COURSES_EDX": true - }, - "GITHUB_REPO_ROOT": "** OVERRIDDEN **", - "GRADES_DOWNLOAD": { - "BUCKET": "edx-grades", - "ROOT_PATH": "/tmp/edx-s3/grades", - "STORAGE_TYPE": "localfs" - }, - "LMS_BASE": "** OVERRIDDEN **", - "LMS_ROOT_URL": "** OVERRIDDEN **", - "LOCAL_LOGLEVEL": "INFO", - "LOGGING_ENV": "sandbox", - "LOG_DIR": "** OVERRIDDEN **", - "MEDIA_URL": "/media/", - "MKTG_URL_LINK_MAP": {}, - "SERVER_EMAIL": "devops@example.com", - "SESSION_COOKIE_DOMAIN": null, - "SITE_NAME": "localhost", - "STATIC_URL_BASE": "/static/", - "SYSLOG_SERVER": "", - "TECH_SUPPORT_EMAIL": "technical@example.com", - "TIME_ZONE": "America/New_York", - "WIKI_ENABLED": true, -} diff --git a/cms/envs/bok_choy_docker.py b/cms/envs/bok_choy_docker.py deleted file mode 100644 index 878537de008d..000000000000 --- a/cms/envs/bok_choy_docker.py +++ /dev/null @@ -1,26 +0,0 @@ -""" -Settings for Bok Choy tests that are used when running Studio in Docker-based devstack. -""" - -# noinspection PyUnresolvedReferences -from .bok_choy import * # pylint: disable=wildcard-import - -CMS_BASE = '{}:{}'.format(os.environ['BOK_CHOY_HOSTNAME'], os.environ.get('BOK_CHOY_CMS_PORT', 8031)) -LMS_BASE = '{}:{}'.format(os.environ['BOK_CHOY_HOSTNAME'], os.environ.get('BOK_CHOY_LMS_PORT', 8003)) -LMS_ROOT_URL = f'http://{LMS_BASE}' -LOGIN_REDIRECT_WHITELIST = [CMS_BASE] - -COMMENTS_SERVICE_URL = 'http://{}:4567'.format(os.environ['BOK_CHOY_HOSTNAME']) -EDXNOTES_PUBLIC_API = 'http://{}:8042/api/v1'.format(os.environ['BOK_CHOY_HOSTNAME']) - -# Docker does not support the syslog socket at /dev/log. Rely on the console. -LOGGING['handlers']['local'] = LOGGING['handlers']['tracking'] = { - 'class': 'logging.NullHandler', -} - -LOGGING['loggers']['tracking']['handlers'] = ['console'] - -# Point the URL used to test YouTube availability to our stub YouTube server -BOK_CHOY_HOST = os.environ['BOK_CHOY_HOSTNAME'] -YOUTUBE['API'] = f"http://{BOK_CHOY_HOST}:{YOUTUBE_PORT}/get_youtube_api/" -YOUTUBE['METADATA_URL'] = f"http://{BOK_CHOY_HOST}:{YOUTUBE_PORT}/test_youtube/" diff --git a/cms/envs/bok_choy_docker.yml b/cms/envs/bok_choy_docker.yml deleted file mode 100644 index bc9727d7cdf9..000000000000 --- a/cms/envs/bok_choy_docker.yml +++ /dev/null @@ -1,147 +0,0 @@ -# ingested bok_choy_docker.env.json -# ingested bok_choy_docker.auth.json -AWS_ACCESS_KEY_ID: '' -AWS_SECRET_ACCESS_KEY: '' -BUGS_EMAIL: bugs@example.com -BULK_EMAIL_DEFAULT_FROM_EMAIL: no-reply@example.com -CACHES: - celery: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: integration_celery - LOCATION: ['edx.devstack.memcached:11211'] - default: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: sandbox_default - LOCATION: ['edx.devstack.memcached:11211'] - general: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: sandbox_general - LOCATION: ['edx.devstack.memcached:11211'] - mongo_metadata_inheritance: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: integration_mongo_metadata_inheritance - LOCATION: ['edx.devstack.memcached:11211'] - staticfiles: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: integration_static_files - LOCATION: ['edx.devstack.memcached:11211'] -CELERY_ALWAYS_EAGER: true -CELERY_BROKER_HOSTNAME: localhost -CELERY_BROKER_PASSWORD: celery -CELERY_BROKER_TRANSPORT: amqp -CELERY_BROKER_USER: celery -CERT_QUEUE: certificates -CLEAR_REQUEST_CACHE_ON_TASK_COMPLETION: false -CMS_BASE: '** OVERRIDDEN **' -CODE_JAIL: - limits: {REALTIME: 3, VMEM: 0} -COMMENTS_SERVICE_KEY: password -COMMENTS_SERVICE_URL: http://edx.devstack.studio:4567 -CONTACT_EMAIL: info@example.com -CONTENTSTORE: - DOC_STORE_CONFIG: - collection: modulestore - db: test - host: [edx.devstack.mongo] - port: 27017 - ENGINE: xmodule.contentstore.mongo.MongoContentStore - OPTIONS: - db: test - host: [edx.devstack.mongo] - port: 27017 -DATABASES: - default: {ENGINE: django.db.backends.mysql, HOST: edx.devstack.mysql57, NAME: edxtest, - PASSWORD: '', PORT: '3306', USER: root} - student_module_history: {ENGINE: django.db.backends.mysql, HOST: edx.devstack.mysql57, - NAME: student_module_history_test, PASSWORD: '', PORT: '3306', USER: root} -DEFAULT_FEEDBACK_EMAIL: feedback@example.com -DEFAULT_FROM_EMAIL: registration@example.com -DJFS: {aws_access_key_id: test, aws_secret_access_key: test, bucket: test, prefix: test, - type: s3fs} -DOC_STORE_CONFIG: - collection: modulestore - db: test - host: [edx.devstack.mongo] - port: 27017 -EMAIL_BACKEND: django.core.mail.backends.smtp.EmailBackend -FEATURES: {CERTIFICATES_HTML_VIEW: true, CUSTOM_COURSES_EDX: true, - ENABLE_CONTENT_LIBRARIES: true, ENABLE_DISCUSSION_SERVICE: true, ENABLE_EXTENDED_COURSE_DETAILS: true, - ENABLE_GRADE_DOWNLOADS: true, ENABLE_SPECIAL_EXAMS: true, ENTRANCE_EXAMS: true, - MILESTONES_APP: true, PREVIEW_LMS_BASE: 'preview.localhost:8003', SHOW_HEADER_LANGUAGE_SELECTOR: true} -GITHUB_REPO_ROOT: '** OVERRIDDEN **' -GRADES_DOWNLOAD: {BUCKET: edx-grades, ROOT_PATH: /tmp/edx-s3/grades, STORAGE_TYPE: localfs} -JWT_AUTH: {JWT_PUBLIC_SIGNING_JWK_SET: '{"keys": [{"kid": - "BTZ9HA6K", "e": "AQAB", "kty": "RSA", "n": "o5cn3ljSRi6FaDEKTn0PS-oL9EFyv1pI7dRgffQLD1qf5D6sprmYfWWokSsrWig8u2y0HChSygR6Jn5KXBqQn6FpM0dDJLnWQDRXHLl3Ey1iPYgDSmOIsIGrV9ZyNCQwk03wAgWbfdBTig3QSDYD-sTNOs3pc4UD_PqAvU2nz_1SS2ZiOwOn5F6gulE1L0iE3KEUEvOIagfHNVhz0oxa_VRZILkzV-zr6R_TW1m97h4H8jXl_VJyQGyhMGGypuDrQ9_vaY_RLEulLCyY0INglHWQ7pckxBtI5q55-Vio2wgewe2_qYcGsnBGaDNbySAsvYcWRrqDiFyzrJYivodqTQ"}]}', - JWT_SECRET_KEY: super-secret-key} -LMS_BASE: '** OVERRIDDEN **' -LMS_ROOT_URL: '** OVERRIDDEN **' -LOCAL_LOGLEVEL: INFO -LOGGING_ENV: sandbox -LOG_DIR: '** OVERRIDDEN **' -MEDIA_URL: /media/ -MKTG_URL_LINK_MAP: {} -MODULESTORE: - default: - ENGINE: xmodule.modulestore.mixed.MixedModuleStore - OPTIONS: - mappings: {} - stores: - - DOC_STORE_CONFIG: - collection: modulestore - db: test - host: [edx.devstack.mongo] - port: 27017 - ENGINE: xmodule.modulestore.mongo.DraftMongoModuleStore - NAME: draft - OPTIONS: - collection: modulestore - db: test - default_class: xmodule.hidden_block.HiddenBlock - fs_root: '** OVERRIDDEN **' - host: [edx.devstack.mongo] - port: 27017 - render_template: common.djangoapps.edxmako.shortcuts.render_to_string - - ENGINE: xmodule.modulestore.xml.XMLModuleStore - NAME: xml - OPTIONS: {data_dir: '** OVERRIDDEN **', default_class: xmodule.hidden_block.HiddenBlock} -SECRET_KEY: '' -SERVER_EMAIL: devops@example.com -SESSION_COOKIE_DOMAIN: null -SITE_NAME: localhost -SOCIAL_SHARING_SETTINGS: {CUSTOM_COURSE_URLS: true} -STATIC_URL_BASE: /static/ -SYSLOG_SERVER: '' -TECH_SUPPORT_EMAIL: technical@example.com -TIME_ZONE: America/New_York -WIKI_ENABLED: true -XQUEUE_INTERFACE: - basic_auth: [edx, edx] - django_auth: {password: password, username: lms} - url: http://localhost:18040 -ZENDESK_API_KEY: '' -ZENDESK_USER: '' diff --git a/common/djangoapps/terrain/stubs/lti.py b/common/djangoapps/terrain/stubs/lti.py index c406da5e6ed3..b3518f22cf25 100644 --- a/common/djangoapps/terrain/stubs/lti.py +++ b/common/djangoapps/terrain/stubs/lti.py @@ -78,7 +78,7 @@ def do_POST(self): 'callback_url': self.post_dict.get('lis_outcome_service_url').replace('https', 'http'), 'sourcedId': self.post_dict.get('lis_result_sourcedid') } - host = os.environ.get('BOK_CHOY_HOSTNAME', self.server.server_address[0]) + host = os.environ.get(self.server.server_address[0]) submit_url = f'//{host}:{self.server.server_address[1]}' content = self._create_content(status_message, submit_url) self.send_response(200, content) @@ -296,7 +296,7 @@ def _check_oauth_signature(self, params, client_signature): """ client_secret = str(self.server.config.get('client_secret', self.DEFAULT_CLIENT_SECRET)) - host = os.environ.get('BOK_CHOY_HOSTNAME', '127.0.0.1') + host = os.environ.get('127.0.0.1') port = self.server.server_address[1] lti_base = self.DEFAULT_LTI_ADDRESS.format(host=host, port=port) lti_endpoint = self.server.config.get('lti_endpoint', self.DEFAULT_LTI_ENDPOINT) diff --git a/common/static/common/js/jasmine.common.conf.js b/common/static/common/js/jasmine.common.conf.js deleted file mode 100644 index d6d7f7977380..000000000000 --- a/common/static/common/js/jasmine.common.conf.js +++ /dev/null @@ -1,12 +0,0 @@ -/* eslint-env node */ - -'use strict'; - -// By default, fixtures are loaded from spec/javascripts/fixtures but in karma everything gets served from /base -jasmine.getFixtures().fixturesPath = '/base/'; - -// https://github.com/edx/js-test-tool/blob/master/js_test_tool/templates/jasmine_test_runner.html#L10 -// Stub out modal dialog alerts, which will prevent -// us from accessing the test results in the DOM -window.confirm = function() { return true; }; -window.alert = function() { }; diff --git a/common/static/common/js/jasmine_stack_trace.js b/common/static/common/js/jasmine_stack_trace.js deleted file mode 100644 index f61d591f0a43..000000000000 --- a/common/static/common/js/jasmine_stack_trace.js +++ /dev/null @@ -1,29 +0,0 @@ -/* This file overrides ExceptionFormatter of jasmine before it's initialization in karma-jasmine's - boot.js. It's important because ExceptionFormatter returns a constructor function. Once the method has been - initialized we can't override the ExceptionFormatter as Jasmine then uses the stored reference to the function */ -(function() { - /* globals jasmineRequire */ - - 'use strict'; - - var OldExceptionFormatter = jasmineRequire.ExceptionFormatter(), - oldExceptionFormatter = new OldExceptionFormatter(), - MAX_STACK_TRACE_LINES = 10; - - jasmineRequire.ExceptionFormatter = function() { - function ExceptionFormatter() { - this.message = oldExceptionFormatter.message; - this.stack = function(error) { - var errorMsg = null; - - if (error) { - errorMsg = error.stack.split('\n').slice(0, MAX_STACK_TRACE_LINES).join('\n'); - } - - return errorMsg; - }; - } - - return ExceptionFormatter; - }; -}()); diff --git a/common/static/common/js/karma.common.conf.js b/common/static/common/js/karma.common.conf.js deleted file mode 100644 index 7b92442aaf6b..000000000000 --- a/common/static/common/js/karma.common.conf.js +++ /dev/null @@ -1,467 +0,0 @@ -// Common settings and helpers for setting up Karma config. -// -// To run all the tests in a suite and print results to the console: -// -// karma start -// E.g. karma start lms/static/karma_lms.conf.js -// -// -// To run the tests for debugging: Debugging can be done in any browser -// but Chrome's developer console debugging experience is best. -// -// karma start --browsers=BROWSER --single-run=false -// -// -// To run the tests with coverage and junit reports: -// -// karma start --browsers=BROWSER -// --coverage --junitreportpath= --coveragereportpath= -// -// where `BROWSER` could be Chrome or Firefox. -// -// -// Troubleshooting tips: -// -// If you get an error like: "TypeError: __cov_KBCc7ZI4xZm8W2BC5NQLDg.s is undefined", -// that means the patterns in sourceFiles and specFiles are matching the same file. -// This causes Istanbul, which is used for tracking coverage to instrument the file -// multiple times. -// -// -// If you see the error: "EMFILE, too many open files" that means the files pattern -// that has been added is matching too many files. The glob library used by Karma -// does not use graceful-fs and tries to read files simultaneously. -// - -/* eslint-env node */ -/* globals process */ - -'use strict'; - -var path = require('path'); -var _ = require('underscore'); - -var appRoot = path.join(__dirname, '../../../../'); -// eslint-disable-next-line import/no-extraneous-dependencies -var webdriver = require('selenium-webdriver'); -// eslint-disable-next-line import/no-extraneous-dependencies -var firefox = require('selenium-webdriver/firefox'); - -var webpackConfig = require(path.join(appRoot, 'webpack.dev.config.js')); - -// The following crazy bit is to work around the webpack.optimize.CommonsChunkPlugin -// plugin. The problem is that it it factors out the code that defines webpackJsonp -// and puts in in the commons JS, which Karma doesn't know to load first. This is a -// workaround recommended in the karma-webpack bug report that basically just removes -// the plugin for the purposes of Karma testing (the plugin is meant to be an -// optimization only). -// https://github.com/webpack-contrib/karma-webpack/issues/24#issuecomment-257613167 -// -// This should be fixed in v3 of karma-webpack -var commonsChunkPluginIndex = webpackConfig[0].plugins.findIndex(function(plugin) { return plugin.chunkNames; }); - -// Files which are needed by all lms/cms suites. -var commonFiles = { - libraryFiles: [ - {pattern: 'common/js/vendor/**/*.js'}, - {pattern: 'edx-ui-toolkit/js/**/*.js'}, - {pattern: 'xmodule_js/common_static/common/js/**/!(*spec).js'}, - {pattern: 'xmodule_js/common_static/js/**/!(*spec).js'}, - {pattern: 'xmodule_js/src/**/*.js'} - ], - - sourceFiles: [ - {pattern: 'common/js/!(spec_helpers)/**/!(*spec).js'} - ], - - specFiles: [ - {pattern: 'common/js/spec_helpers/**/*.js'} - ], - - fixtureFiles: [ - {pattern: 'common/templates/**/*.underscore'} - ] -}; - -webpackConfig[0].plugins.splice(commonsChunkPluginIndex, 1); - -delete webpackConfig[0].entry; - -/** - * Customize the name attribute in xml testcase element - * @param {Object} browser - * @param {Object} result - * @return {String} - */ -function junitNameFormatter(browser, result) { - return result.suite[0] + ': ' + result.description; -} - -/** - * Customize the classname attribute in xml testcase element - * @param {Object} browser - * @return {String} - */ -function junitClassNameFormatter(browser) { - return 'Javascript.' + browser.name.split(' ')[0]; -} - -/** - * Return array containing default and user supplied reporters - * @param {Object} config - * @return {Array} - */ -function reporters(config) { - var defaultReporters = ['spec', 'junit', 'kjhtml']; - if (config.coverage) { - defaultReporters.push('coverage'); - } - return defaultReporters; -} - -/** - * Split a filepath into basepath and filename - * @param {String} filepath - * @return {Object} - */ -function getBasepathAndFilename(filepath) { - var file, dir; - - if (!filepath) { - // these will configure the reporters to create report files relative to this karma config file - return { - dir: undefined, - file: undefined - }; - } - file = filepath.replace(/^.*[\\/]/, ''); - dir = filepath.replace(file, ''); - - return { - dir: dir, - file: file - }; -} - -/** - * Return coverage reporter settings - * @param {String} config - * @return {Object} - */ -function coverageSettings(config) { - var pth = getBasepathAndFilename(config.coveragereportpath); - return { - dir: pth.dir, - subdir: '.', - includeAllSources: true, - reporters: [ - {type: 'cobertura', file: pth.file}, - {type: 'text-summary'} - ] - }; -} - -/** - * Return junit reporter settings - * @param {String} config - * @return {Object} - */ -function junitSettings(config) { - var pth = getBasepathAndFilename(config.junitreportpath); - return { - outputDir: pth.dir, - outputFile: pth.file, - suite: 'javascript', - useBrowserName: false, - nameFormatter: junitNameFormatter, - classNameFormatter: junitClassNameFormatter - }; -} - -/** - * Return absolute path for files in common and xmodule_js symlink dirs. - * @param {String} appRoot - * @param {String} pattern - * @return {String} - */ -// I'd like to fix the no-shadow violation on the next line, but it would break this shared conf's API. -function defaultNormalizeFunc(appRoot, pattern) { // eslint-disable-line no-shadow - var pat = pattern; - if (pat.match(/^common\/js/)) { - pat = path.join(appRoot, '/common/static/' + pat); - } else if (pat.match(/^xmodule_js\/common_static/)) { - pat = path.join(appRoot, '/common/static/' - + pat.replace(/^xmodule_js\/common_static\//, '')); - } - return pat; -} - -function normalizePathsForCoverage(files, normalizeFunc, preprocessors) { - var normalizeFn = normalizeFunc || defaultNormalizeFunc, - normalizedFile, - filesForCoverage = {}; - - files.forEach(function(file) { - if (!file.ignoreCoverage) { - normalizedFile = normalizeFn(appRoot, file.pattern); - if (preprocessors && preprocessors.hasOwnProperty(normalizedFile)) { - filesForCoverage[normalizedFile] = ['coverage'].concat(preprocessors[normalizedFile]); - } else { - filesForCoverage[normalizedFile] = ['coverage']; - } - } - }); - - return filesForCoverage; -} - -/** - * Sets defaults for each file pattern. - * RequireJS files are excluded by default. - * Webpack files are included by default. - * @param {Object} files - * @return {Object} - */ -function setDefaults(files) { - return files.map(function(f) { - var file = _.isObject(f) ? f : {pattern: f}; - if (!file.included && !file.webpack) { - file.included = false; - } - return file; - }); -} - -function getBaseConfig(config, useRequireJs) { - var getFrameworkFiles = function() { - var files = [ - 'common/static/common/js/vendor/jquery.js', - 'node_modules/jasmine-core/lib/jasmine-core/jasmine.js', - 'common/static/common/js/jasmine_stack_trace.js', - 'node_modules/karma-jasmine/lib/boot.js', - 'node_modules/karma-jasmine/lib/adapter.js', - 'node_modules/jasmine-jquery/lib/jasmine-jquery.js', - 'node_modules/popper.js/dist/umd/popper.js', - 'node_modules/bootstrap/dist/js/bootstrap.js', - 'node_modules/underscore/underscore.js', - 'node_modules/backbone/backbone.js', - 'common/static/js/test/i18n.js' - ]; - - if (useRequireJs) { - files = files.concat([ - 'node_modules/requirejs/require.js', - 'node_modules/karma-requirejs/lib/adapter.js' - ]); - } - - return files; - }; - - // Manually prepends the framework files to the karma files array - // bypassing the karma's framework config. This is necessary if you want - // to add a library or framework that isn't a karma plugin. e.g. we add jasmine-jquery - // which isn't a karma plugin. Though a karma framework for jasmine-jquery is available - // but it's not actively maintained. In future we also wanna add jQuery at the top when - // we upgrade to jQuery 2 - var initFrameworks = function(files) { - getFrameworkFiles().reverse().forEach(function(f) { - files.unshift({ - pattern: path.join(appRoot, f), - included: true, - served: true, - watch: false - }); - }); - }; - - var hostname = 'localhost'; - var port = 9876; - var customPlugin = { - 'framework:custom': ['factory', initFrameworks] - }; - - if (process.env.hasOwnProperty('BOK_CHOY_HOSTNAME')) { - hostname = process.env.BOK_CHOY_HOSTNAME; - if (hostname === 'edx.devstack.lms') { - port = 19876; - } else { - port = 19877; - } - } - - initFrameworks.$inject = ['config.files']; - - return { - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: '', - - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['custom'], - - plugins: [ - 'karma-jasmine', - 'karma-jasmine-html-reporter', - 'karma-requirejs', - 'karma-junit-reporter', - 'karma-coverage', - 'karma-chrome-launcher', - 'karma-firefox-launcher', - 'karma-spec-reporter', - 'karma-selenium-webdriver-launcher', - 'karma-webpack', - 'karma-sourcemap-loader', - customPlugin - ], - - // list of files to exclude - exclude: [], - - // karma-reporter - reporters: reporters(config), - - // Spec Reporter configuration - specReporter: { - maxLogLines: 5, - showSpecTiming: true - }, - - coverageReporter: coverageSettings(config), - - junitReporter: junitSettings(config), - - // web server hostname and port - hostname: hostname, - port: port, - - // enable / disable colors in the output (reporters and logs) - colors: true, - - // level of logging - /* possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN - || config.LOG_INFO || config.LOG_DEBUG */ - logLevel: config.LOG_INFO, - - // enable / disable watching file and executing tests whenever any file changes - autoWatch: false, - - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['FirefoxNoUpdates'], - - customLaunchers: { - // Firefox configuration that doesn't perform auto-updates - FirefoxNoUpdates: { - base: 'Firefox', - prefs: { - 'app.update.auto': false, - 'app.update.enabled': false - } - }, - ChromeDocker: { - base: 'SeleniumWebdriver', - browserName: 'chrome', - getDriver: function() { - return new webdriver.Builder() - .forBrowser('chrome') - .usingServer('http://edx.devstack.chrome:4444/wd/hub') - .build(); - } - }, - FirefoxDocker: { - base: 'SeleniumWebdriver', - browserName: 'firefox', - getDriver: function() { - var options = new firefox.Options(), - profile = new firefox.Profile(); - profile.setPreference('focusmanager.testmode', true); - options.setProfile(profile); - return new webdriver.Builder() - .forBrowser('firefox') - .usingServer('http://edx.devstack.firefox:4444/wd/hub') - .setFirefoxOptions(options) - .build(); - } - } - }, - - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: config.singleRun, - - // Concurrency level - // how many browser should be started simultaneous - concurrency: Infinity, - - browserNoActivityTimeout: 50000, - - client: { - captureConsole: false - }, - - webpack: webpackConfig[0], - - webpackMiddleware: { - watchOptions: { - poll: true - } - } - }; -} - -function configure(config, options) { - var useRequireJs = options.useRequireJs === undefined ? true : options.useRequireJs, - baseConfig = getBaseConfig(config, useRequireJs), - files, filesForCoverage, preprocessors; - - if (options.includeCommonFiles) { - _.forEach(['libraryFiles', 'sourceFiles', 'specFiles', 'fixtureFiles'], function(collectionName) { - options[collectionName] = _.flatten([commonFiles[collectionName], options[collectionName]]); - }); - } - - files = _.flatten( - _.map( - ['libraryFilesToInclude', 'libraryFiles', 'sourceFiles', 'specFiles', 'fixtureFiles', 'runFiles'], - function(collectionName) { return options[collectionName] || []; } - ) - ); - - files.unshift( - {pattern: path.join(appRoot, 'common/static/common/js/jasmine.common.conf.js'), included: true} - ); - - if (useRequireJs) { - files.unshift({pattern: 'common/js/utils/require-serial.js', included: true}); - } - - // Karma sets included=true by default. - // We set it to false by default because RequireJS should be used instead. - files = setDefaults(files); - - filesForCoverage = _.flatten( - _.map( - ['sourceFiles', 'specFiles'], - function(collectionName) { return options[collectionName]; } - ) - ); - - // If we give symlink paths to Istanbul, coverage for each path gets tracked - // separately. So we pass absolute paths to the karma-coverage preprocessor. - preprocessors = _.extend( - {}, - options.preprocessors, - normalizePathsForCoverage(filesForCoverage, options.normalizePathsForCoverageFunc, options.preprocessors) - ); - - config.set(_.extend(baseConfig, { - files: files, - preprocessors: preprocessors - })); -} - -module.exports = { - configure: configure, - appRoot: appRoot -}; diff --git a/docs/decisions/0004-managing-django-settings.rst b/docs/decisions/0004-managing-django-settings.rst index 97c15b6cf4b5..bf5698af3992 100644 --- a/docs/decisions/0004-managing-django-settings.rst +++ b/docs/decisions/0004-managing-django-settings.rst @@ -58,8 +58,6 @@ and for all environments to use __init__.py to load their settings. The following files should be obviated by this change: -* bok_choy_docker.py -* bok_choy.py * devstack_docker.py * devstack_optimized.py * devstack.py diff --git a/lms/envs/bok_choy.py b/lms/envs/bok_choy.py deleted file mode 100644 index 9a39d4d8bb72..000000000000 --- a/lms/envs/bok_choy.py +++ /dev/null @@ -1,154 +0,0 @@ -""" -Settings for Bok Choy tests that are used when running LMS. - -Bok Choy uses two different settings files: -1. test_static_optimized is used when invoking collectstatic -2. bok_choy is used when running the tests - -Note: it isn't possible to have a single settings file, because Django doesn't -support both generating static assets to a directory and also serving static -from the same directory. -""" - - -# Silence noisy logs -import logging -import os -from tempfile import mkdtemp - -from django.utils.translation import gettext_lazy -from path import Path as path - -from openedx.core.release import RELEASE_LINE -from xmodule.modulestore.modulestore_settings import update_module_store_settings # lint-amnesty, pylint: disable=wrong-import-order - -CONFIG_ROOT = path(__file__).abspath().dirname() -TEST_ROOT = CONFIG_ROOT.dirname().dirname() / "test_root" - -########################## Prod-like settings ################################### -# These should be as close as possible to the settings we use in production. -# As in prod, we read in environment and auth variables from JSON files. -# Unlike in prod, we use the JSON files stored in this repo. -# This is a convenience for ensuring (a) that we can consistently find the files -# and (b) that the files are the same in Jenkins as in local dev. -os.environ['SERVICE_VARIANT'] = 'bok_choy_docker' if 'BOK_CHOY_HOSTNAME' in os.environ else 'bok_choy' -os.environ['LMS_CFG'] = str.format("{config_root}/{service_variant}.yml", - config_root=CONFIG_ROOT, service_variant=os.environ['SERVICE_VARIANT']) -os.environ['REVISION_CFG'] = f"{CONFIG_ROOT}/revisions.yml" - -from .production import * # pylint: disable=wildcard-import, unused-wildcard-import, wrong-import-position - - -######################### Testing overrides #################################### - -# Redirect to the test_root folder within the repo -GITHUB_REPO_ROOT = (TEST_ROOT / "data").abspath() -LOG_DIR = (TEST_ROOT / "log").abspath() - -# Configure modulestore to use the test folder within the repo -update_module_store_settings( - MODULESTORE, - module_store_options={ - 'fs_root': (TEST_ROOT / "data").abspath(), - }, - xml_store_options={ - 'data_dir': (TEST_ROOT / "data").abspath(), - }, - default_store=os.environ.get('DEFAULT_STORE', 'draft'), -) - -PLATFORM_NAME = gettext_lazy("édX") -PLATFORM_DESCRIPTION = gettext_lazy("Open édX Platform") - -############################ STATIC FILES ############################# - -# Serve static files at /static directly from the staticfiles directory under test root -# Note: optimized files for testing are generated with settings from test_static_optimized -STATIC_URL = "/static/" -STATICFILES_FINDERS = ['django.contrib.staticfiles.finders.FileSystemFinder'] -STATICFILES_DIRS = [ - (TEST_ROOT / "staticfiles" / "lms").abspath(), -] - -DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage' -MEDIA_ROOT = TEST_ROOT / "uploads" - -# Webpack loader must use webpack output setting -WEBPACK_LOADER['DEFAULT']['STATS_FILE'] = TEST_ROOT / "staticfiles" / "lms" / "webpack-stats.json" - -# Don't use compression during tests -PIPELINE['JS_COMPRESSOR'] = None - -###################### Grades ###################### -GRADES_DOWNLOAD = { - 'STORAGE_TYPE': 'localfs', - 'BUCKET': 'edx-grades', - 'ROOT_PATH': os.path.join(mkdtemp(), 'edx-s3', 'grades'), -} - - -LOG_OVERRIDES = [ - ('track.middleware', logging.CRITICAL), - ('common.djangoapps.edxmako.shortcuts', logging.ERROR), - ('edx.discussion', logging.CRITICAL), -] -for log_name, log_level in LOG_OVERRIDES: - logging.getLogger(log_name).setLevel(log_level) - - -YOUTUBE_HOSTNAME = os.environ.get('BOK_CHOY_HOSTNAME', '127.0.0.1') -# Point the URL used to test YouTube availability to our stub YouTube server -YOUTUBE_PORT = 9080 -YOUTUBE['TEST_TIMEOUT'] = 5000 -YOUTUBE['API'] = f"http://{YOUTUBE_HOSTNAME}:{YOUTUBE_PORT}/get_youtube_api/" -YOUTUBE['METADATA_URL'] = f"http://{YOUTUBE_HOSTNAME}:{YOUTUBE_PORT}/test_youtube/" - -############################# SECURITY SETTINGS ################################ -# Default to advanced security in common.py, so tests can reset here to use -# a simpler security model - -# Path at which to store the mock index -MOCK_SEARCH_BACKING_FILE = ( - TEST_ROOT / "index_file.dat" -).abspath() - -# Verify student settings -VERIFY_STUDENT["SOFTWARE_SECURE"] = { - "API_ACCESS_KEY": "BBBBBBBBBBBBBBBBBBBB", - "API_SECRET_KEY": "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC", -} - -# Set dummy values for profile image settings. -PROFILE_IMAGE_BACKEND = { - 'class': 'openedx.core.storage.OverwriteStorage', - 'options': { - 'location': os.path.join(MEDIA_ROOT, 'profile-images/'), - 'base_url': os.path.join(MEDIA_URL, 'profile-images/'), - }, -} - -LMS_ROOT_URL = "http://localhost:{}".format(os.environ.get('BOK_CHOY_LMS_PORT', 8003)) -CMS_BASE = "localhost:{}".format(os.environ.get('BOK_CHOY_CMS_PORT', 8031)) -LOGIN_REDIRECT_WHITELIST = [CMS_BASE] - -INSTALLED_APPS.append('openedx.testing.coverage_context_listener') - -if RELEASE_LINE == "master": - # On master, acceptance tests use edX books, not the default Open edX books. - HELP_TOKENS_BOOKS = { - 'learner': 'https://edx.readthedocs.io/projects/edx-guide-for-students', - 'course_author': 'https://edx.readthedocs.io/projects/edx-partner-course-staff', - } - -# API access management -API_ACCESS_MANAGER_EMAIL = 'api-access@example.com' -API_ACCESS_FROM_EMAIL = 'api-requests@example.com' -API_DOCUMENTATION_URL = 'https://course-catalog-api-guide.readthedocs.io/en/latest/' -AUTH_DOCUMENTATION_URL = 'https://course-catalog-api-guide.readthedocs.io/en/latest/authentication/index.html' - -##################################################################### -# Lastly, see if the developer has any local overrides. -try: - from .private import * # pylint: disable=wildcard-import -except ImportError: - pass diff --git a/lms/envs/bok_choy.yml b/lms/envs/bok_choy.yml deleted file mode 100644 index 0468867eb74b..000000000000 --- a/lms/envs/bok_choy.yml +++ /dev/null @@ -1,274 +0,0 @@ -# ingested edx-platform/lms/envs/bok_choy.auth.json -# ingested edx-platform/lms/envs/bok_choy.env.json -ACTIVATION_EMAIL_SUPPORT_LINK: https://support.example.com/activation-email-help.html -ANALYTICS_DASHBOARD_URL: '' -AWS_ACCESS_KEY_ID: '' -AWS_SECRET_ACCESS_KEY: '' -BUGS_EMAIL: bugs@example.com -BULK_EMAIL_DEFAULT_FROM_EMAIL: no-reply@example.com -BADGING_BACKEND: 'lms.djangoapps.badges.backends.tests.dummy_backend.DummyBackend' -BLOCK_STRUCTURES_SETTINGS: - # We have CELERY_ALWAYS_EAGER set to True, so there's no asynchronous - # code running and the celery routing is unimportant. - # It does not make sense to retry. - TASK_MAX_RETRIES: 0 - # course publish task delay is irrelevant is because the task is run synchronously - COURSE_PUBLISH_TASK_DELAY: 0 - # retry delay is irrelevent because we never retry - TASK_DEFAULT_RETRY_DELAY: 0 - -CACHES: - celery: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: integration_celery - LOCATION: ['localhost:11211'] - default: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: sandbox_default - LOCATION: ['localhost:11211'] - general: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: sandbox_general - LOCATION: ['localhost:11211'] - mongo_metadata_inheritance: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: integration_mongo_metadata_inheritance - LOCATION: ['localhost:11211'] - staticfiles: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: integration_static_files - LOCATION: ['localhost:11211'] - -# Capture the console log via template includes, until webdriver supports log capture again -CAPTURE_CONSOLE_LOG: True - -CELERY_BROKER_HOSTNAME: localhost -CELERY_BROKER_PASSWORD: celery -CELERY_BROKER_TRANSPORT: amqp -CELERY_BROKER_USER: celery -CELERY_ALWAYS_EAGER: True -CELERY_RESULT_BACKEND: 'django-cache' -CLEAR_REQUEST_CACHE_ON_TASK_COMPLETION: False - -CERT_QUEUE: certificates -CMS_BASE: localhost:8031 -CODE_JAIL: - limits: {REALTIME: 3, VMEM: 0} -COMMENTS_SERVICE_KEY: password -COMMENTS_SERVICE_URL: http://localhost:4567 -COMPLETION_BY_VIEWING_DELAY_MS: 1000 -CONTACT_EMAIL: info@example.com -CONTENTSTORE: - DOC_STORE_CONFIG: - collection: modulestore - db: test - host: [localhost] - port: 27017 - ENGINE: xmodule.contentstore.mongo.MongoContentStore - OPTIONS: - db: test - host: [localhost] - port: 27017 -DATABASES: - default: {ENGINE: django.db.backends.mysql, HOST: localhost, NAME: edxtest, PASSWORD: '', - PORT: '3306', USER: root} - student_module_history: {ENGINE: django.db.backends.mysql, HOST: localhost, NAME: student_module_history_test, - PASSWORD: '', PORT: '3306', USER: root} -DEFAULT_FEEDBACK_EMAIL: feedback@example.com -DEFAULT_FROM_EMAIL: registration@example.com - -# Enable debug so that static assets are served by Django -DEBUG: True -DJFS: {aws_access_key_id: test, aws_secret_access_key: test, bucket: test, prefix: test, - type: s3fs} -DOC_STORE_CONFIG: - collection: modulestore - db: test - host: [localhost] - port: 27017 -# Configure the LMS to use our stub eCommerce implementation -ECOMMERCE_API_URL: 'http://localhost:8043/api/v2/' -# Configure the LMS to use our stub EdxNotes implementation -EDXNOTES_PUBLIC_API: 'http://localhost:8042/api/v1' -EDXNOTES_INTERNAL_API: 'http://localhost:8042/api/v1' - -EDXNOTES_CONNECT_TIMEOUT: 10 # time in seconds -EDXNOTES_READ_TIMEOUT: 10 # time in seconds - -NOTES_DISABLED_TABS: [] - -EMAIL_BACKEND: django.core.mail.backends.dummy.EmailBackend -EVENT_TRACKING_BACKENDS: - mongo: - ENGINE: eventtracking.backends.mongodb.MongoBackend - OPTIONS: {collection: events, database: test} -FEATURES: - ALLOW_AUTOMATED_SIGNUPS: true - AUTOMATIC_AUTH_FOR_TESTING: true - AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING: true - CERTIFICATES_HTML_VIEW: true - CERTIFICATES_INSTRUCTOR_GENERATION: true - CUSTOM_COURSES_EDX: true, - ENABLE_COURSE_DISCOVERY: true - ENABLE_DISCUSSION_SERVICE: true - ENABLE_GRADE_DOWNLOADS: true - ENABLE_SPECIAL_EXAMS: true - ENABLE_THIRD_PARTY_AUTH: true - ENABLE_VERIFIED_CERTIFICATES: true - EXPOSE_CACHE_PROGRAMS_ENDPOINT: true - MODE_CREATION_FOR_TESTING: true - PREVIEW_LMS_BASE: 'preview.localhost:8003' - RESTRICT_AUTOMATIC_AUTH: false - SHOW_HEADER_LANGUAGE_SELECTOR: true - ENABLE_MAX_FAILED_LOGIN_ATTEMPTS: False - SQUELCH_PII_IN_LOGS: False - PREVENT_CONCURRENT_LOGINS: False - ENABLE_MOBILE_REST_API: True # Show video bumper in LMS - ENABLE_VIDEO_BUMPER: True # Show video bumper in LMS - SHOW_BUMPER_PERIODICITY: 1 - # Enable courseware search for tests - ENABLE_COURSEWARE_SEARCH: True - # Enable dashboard search for tests - ENABLE_DASHBOARD_SEARCH: True - # discussion home panel, which includes a subscription on/off setting for discussion digest emails. - ENABLE_DISCUSSION_HOME_PANEL: True - # Enable support for OpenBadges accomplishments - ENABLE_OPENBADGES: True - ENABLE_LTI_PROVIDER: True - # Enable milestones app - MILESTONES_APP: True - # Enable oauth authentication, which we test. - ENABLE_OAUTH2_PROVIDER: True - OAUTH_ENFORCE_SECURE: False - ENABLE_PREREQUISITE_COURSES: True - ENABLE_COURSE_DISCOVERY: True - ENABLE_EDXNOTES: True - ENABLE_TEAMS: True - LICENSING: True - # Use the auto_auth workflow for creating users and logging them in - AUTOMATIC_AUTH_FOR_TESTING: True - RESTRICT_AUTOMATIC_AUTH: False - # Open up endpoint for faking Software Secure responses - ENABLE_SOFTWARE_SECURE_FAKE: True - # Disable instructor dash buttons for downloading course data when enrollment exceeds this number - MAX_ENROLLMENT_INSTR_BUTTONS: 4 - ENABLE_ENROLLMENT_TRACK_USER_PARTITION: True - ENTRANCE_EXAMS: True - ENABLE_SPECIAL_EXAMS: True - - -GITHUB_REPO_ROOT: '** OVERRIDDEN **' -JWT_AUTH: {JWT_PRIVATE_SIGNING_JWK: '{"e": "AQAB", "d": "HIiV7KNjcdhVbpn3KT-I9n3JPf5YbGXsCIedmPqDH1d4QhBofuAqZ9zebQuxkRUpmqtYMv0Zi6ECSUqH387GYQF_XvFUFcjQRPycISd8TH0DAKaDpGr-AYNshnKiEtQpINhcP44I1AYNPCwyoxXA1fGTtmkKChsuWea7o8kytwU5xSejvh5-jiqu2SF4GEl0BEXIAPZsgbzoPIWNxgO4_RzNnWs6nJZeszcaDD0CyezVSuH9QcI6g5QFzAC_YuykSsaaFJhZ05DocBsLczShJ9Omf6PnK9xlm26I84xrEh_7x4fVmNBg3xWTLh8qOnHqGko93A1diLRCrKHOvnpvgQ", - "n": "o5cn3ljSRi6FaDEKTn0PS-oL9EFyv1pI7dRgffQLD1qf5D6sprmYfWWokSsrWig8u2y0HChSygR6Jn5KXBqQn6FpM0dDJLnWQDRXHLl3Ey1iPYgDSmOIsIGrV9ZyNCQwk03wAgWbfdBTig3QSDYD-sTNOs3pc4UD_PqAvU2nz_1SS2ZiOwOn5F6gulE1L0iE3KEUEvOIagfHNVhz0oxa_VRZILkzV-zr6R_TW1m97h4H8jXl_VJyQGyhMGGypuDrQ9_vaY_RLEulLCyY0INglHWQ7pckxBtI5q55-Vio2wgewe2_qYcGsnBGaDNbySAsvYcWRrqDiFyzrJYivodqTQ", - "q": "3T3DEtBUka7hLGdIsDlC96Uadx_q_E4Vb1cxx_4Ss_wGp1Loz3N3ZngGyInsKlmbBgLo1Ykd6T9TRvRNEWEtFSOcm2INIBoVoXk7W5RuPa8Cgq2tjQj9ziGQ08JMejrPlj3Q1wmALJr5VTfvSYBu0WkljhKNCy1KB6fCby0C9WE", - "p": "vUqzWPZnDG4IXyo-k5F0bHV0BNL_pVhQoLW7eyFHnw74IOEfSbdsMspNcPSFIrtgPsn7981qv3lN_staZ6JflKfHayjB_lvltHyZxfl0dvruShZOx1N6ykEo7YrAskC_qxUyrIvqmJ64zPW3jkuOYrFs7Ykj3zFx3Zq1H5568G0", - "kid": "BTZ9HA6K", "kty": "RSA"}', JWT_PUBLIC_SIGNING_JWK_SET: '{"keys": [{"kid": - "BTZ9HA6K", "e": "AQAB", "kty": "RSA", "n": "o5cn3ljSRi6FaDEKTn0PS-oL9EFyv1pI7dRgffQLD1qf5D6sprmYfWWokSsrWig8u2y0HChSygR6Jn5KXBqQn6FpM0dDJLnWQDRXHLl3Ey1iPYgDSmOIsIGrV9ZyNCQwk03wAgWbfdBTig3QSDYD-sTNOs3pc4UD_PqAvU2nz_1SS2ZiOwOn5F6gulE1L0iE3KEUEvOIagfHNVhz0oxa_VRZILkzV-zr6R_TW1m97h4H8jXl_VJyQGyhMGGypuDrQ9_vaY_RLEulLCyY0INglHWQ7pckxBtI5q55-Vio2wgewe2_qYcGsnBGaDNbySAsvYcWRrqDiFyzrJYivodqTQ"}]}', - JWT_SECRET_KEY: super-secret-key} -LMS_BASE: localhost:8003 -LMS_ROOT_URL: http://localhost:8003 -LOCAL_LOGLEVEL: INFO -LOGGING_ENV: sandbox -LOG_DIR: '** OVERRIDDEN **' -MEDIA_URL: /media/ -MKTG_URL_LINK_MAP: {ABOUT: about, BLOG: blog, CAREERS: careers, CONTACT: contact, - COURSES: courses, DONATE: donate, HELP_CENTER: help-center, HONOR: honor, NEWS: news, - PRESS: press, PRIVACY: privacy, ROOT: root, SITEMAP.XML: sitemap_xml, TOS: tos, - WHAT_IS_VERIFIED_CERT: verified-certificate} -MODULESTORE: - default: - ENGINE: xmodule.modulestore.mixed.MixedModuleStore - OPTIONS: - mappings: {} - stores: - - DOC_STORE_CONFIG: - collection: modulestore - db: test - host: [localhost] - port: 27017 - ENGINE: xmodule.modulestore.mongo.DraftMongoModuleStore - NAME: draft - OPTIONS: - collection: modulestore - db: test - default_class: xmodule.hidden_block.HiddenBlock - fs_root: '** OVERRIDDEN **' - host: [localhost] - port: 27017 - render_template: common.djangoapps.edxmako.shortcuts.render_to_string - - ENGINE: xmodule.modulestore.xml.XMLModuleStore - NAME: xml - OPTIONS: {data_dir: '** OVERRIDDEN **', default_class: xmodule.hidden_block.HiddenBlock} -# We need to test different scenarios, following setting effectively disbale rate limiting -PASSWORD_RESET_IP_RATE: '1/s' -PASSWORD_RESET_EMAIL_RATE: '1/s' -PASSWORD_RESET_SUPPORT_LINK: https://support.example.com/password-reset-help.html -REGISTRATION_EXTENSION_FORM: openedx.core.djangoapps.user_api.tests.test_helpers.TestCaseForm -REGISTRATION_EXTRA_FIELDS: {city: hidden, country: required, gender: optional, goals: optional, - honor_code: required, level_of_education: optional, mailing_address: optional, terms_of_service: hidden, - year_of_birth: optional} -# Use MockSearchEngine as the search engine for test scenario -SEARCH_ENGINE: "search.tests.mock_search_engine.MockSearchEngine" -# this secret key should be the same as cms/envs/bok_choy.py's -SECRET_KEY: "very_secret_bok_choy_key" - -SERVER_EMAIL: devops@example.com -SESSION_COOKIE_DOMAIN: null -SITE_NAME: localhost:8003 -SOCIAL_SHARING_SETTINGS: {CERTIFICATE_FACEBOOK: true, CERTIFICATE_FACEBOOK_TEXT: 'Testing - facebook feature:', CUSTOM_COURSE_URLS: true, DASHBOARD_FACEBOOK: true, DASHBOARD_TWITTER: true, - DASHBOARD_TWITTER_TEXT: 'Testing feature:'} -STATIC_URL_BASE: /static/ -SUPPORT_SITE_LINK: https://support.example.com -SYSLOG_SERVER: '' -TECH_SUPPORT_EMAIL: technical@example.com -THIRD_PARTY_AUTH_BACKENDS: [social_core.backends.google.GoogleOAuth2, social_core.backends.linkedin.LinkedinOAuth2, - social_core.backends.facebook.FacebookOAuth2, common.djangoapps.third_party_auth.dummy.DummyBackend, - common.djangoapps.third_party_auth.saml.SAMLAuthBackend] -THIRD_PARTY_AUTH: - Google: - SOCIAL_AUTH_GOOGLE_OAUTH2_KEY": "test" - SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET": "test" - Facebook: - SOCIAL_AUTH_FACEBOOK_KEY": "test" - SOCIAL_AUTH_FACEBOOK_SECRET": "test" -TIME_ZONE: America/New_York -TRACKING_BACKENDS: - mongo: - ENGINE: common.djangoapps.track.backends.mongodb.MongoBackend - OPTIONS: {collection: events, database: test} -WIKI_ENABLED: true -WAFFLE_OVERRIDE: True -XQUEUE_INTERFACE: - basic_auth: [edx, edx] - django_auth: {password: password, username: lms} - # Configure the LMS to use our stub XQueue implementation - url: 'http://localhost:8040' - -ZENDESK_API_KEY: '' -ZENDESK_USER: '' diff --git a/lms/envs/bok_choy_docker.py b/lms/envs/bok_choy_docker.py deleted file mode 100644 index 991b22e37361..000000000000 --- a/lms/envs/bok_choy_docker.py +++ /dev/null @@ -1,27 +0,0 @@ -""" -Settings for Bok Choy tests that are used when running Studio in Docker-based devstack. -""" - -# noinspection PyUnresolvedReferences -from .bok_choy import * # pylint: disable=wildcard-import - -CMS_BASE = '{}:{}'.format(os.environ['BOK_CHOY_HOSTNAME'], os.environ.get('BOK_CHOY_CMS_PORT', 8031)) -LMS_BASE = '{}:{}'.format(os.environ['BOK_CHOY_HOSTNAME'], os.environ.get('BOK_CHOY_LMS_PORT', 8003)) -LMS_ROOT_URL = f'http://{LMS_BASE}' -LOGIN_REDIRECT_WHITELIST = [CMS_BASE] -SITE_NAME = LMS_BASE - -COMMENTS_SERVICE_URL = 'http://{}:4567'.format(os.environ['BOK_CHOY_HOSTNAME']) -EDXNOTES_PUBLIC_API = 'http://{}:8042/api/v1'.format(os.environ['BOK_CHOY_HOSTNAME']) - -# Docker does not support the syslog socket at /dev/log. Rely on the console. -LOGGING['handlers']['local'] = LOGGING['handlers']['tracking'] = { - 'class': 'logging.NullHandler', -} - -LOGGING['loggers']['tracking']['handlers'] = ['console'] - -# Point the URL used to test YouTube availability to our stub YouTube server -BOK_CHOY_HOST = os.environ['BOK_CHOY_HOSTNAME'] -YOUTUBE['API'] = f"http://{BOK_CHOY_HOST}:{YOUTUBE_PORT}/get_youtube_api/" -YOUTUBE['METADATA_URL'] = f"http://{BOK_CHOY_HOST}:{YOUTUBE_PORT}/test_youtube/" diff --git a/lms/envs/bok_choy_docker.yml b/lms/envs/bok_choy_docker.yml deleted file mode 100644 index afef10bb5d2c..000000000000 --- a/lms/envs/bok_choy_docker.yml +++ /dev/null @@ -1,183 +0,0 @@ -# ingested edx-platform/lms/envs/bok_choy_docker.auth.json -# ingested edx-platform/lms/envs/bok_choy_docker.env.json -ACTIVATION_EMAIL_SUPPORT_LINK: https://support.example.com/activation-email-help.html -ANALYTICS_DASHBOARD_URL: '' -AWS_ACCESS_KEY_ID: '' -AWS_SECRET_ACCESS_KEY: '' -BUGS_EMAIL: bugs@example.com -BULK_EMAIL_DEFAULT_FROM_EMAIL: no-reply@example.com -CACHES: - celery: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: integration_celery - LOCATION: ['edx.devstack.memcached:11211'] - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - default: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: sandbox_default - LOCATION: ['edx.devstack.memcached:11211'] - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - general: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: sandbox_general - LOCATION: ['edx.devstack.memcached:11211'] - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - mongo_metadata_inheritance: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: integration_mongo_metadata_inheritance - LOCATION: ['edx.devstack.memcached:11211'] - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - staticfiles: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: integration_static_files - LOCATION: ['edx.devstack.memcached:11211'] - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true -CELERY_BROKER_HOSTNAME: localhost -CELERY_BROKER_PASSWORD: celery -CELERY_BROKER_TRANSPORT: amqp -CELERY_BROKER_USER: celery -CERT_QUEUE: certificates -CMS_BASE: '** OVERRIDDEN **' -CODE_JAIL: - limits: {REALTIME: 3, VMEM: 0} -COMMENTS_SERVICE_KEY: password -COMMENTS_SERVICE_URL: http://edx.devstack.lms:4567 -CONTACT_EMAIL: info@example.com -CONTENTSTORE: - DOC_STORE_CONFIG: - collection: modulestore - db: test - host: [edx.devstack.mongo] - port: 27017 - ENGINE: xmodule.contentstore.mongo.MongoContentStore - OPTIONS: - db: test - host: [edx.devstack.mongo] - port: 27017 -DATABASES: - default: {ENGINE: django.db.backends.mysql, HOST: edx.devstack.mysql57, NAME: edxtest, - PASSWORD: '', PORT: '3306', USER: root} - student_module_history: {ENGINE: django.db.backends.mysql, HOST: edx.devstack.mysql57, - NAME: student_module_history_test, PASSWORD: '', PORT: '3306', USER: root} -DEFAULT_FEEDBACK_EMAIL: feedback@example.com -DEFAULT_FROM_EMAIL: registration@example.com -DJFS: {aws_access_key_id: test, aws_secret_access_key: test, bucket: test, prefix: test, - type: s3fs} -DOC_STORE_CONFIG: - collection: modulestore - db: test - host: [edx.devstack.mongo] - port: 27017 -EMAIL_BACKEND: django.core.mail.backends.dummy.EmailBackend -EVENT_TRACKING_BACKENDS: - mongo: - ENGINE: eventtracking.backends.mongodb.MongoBackend - OPTIONS: - collection: events - database: test - host: [edx.devstack.mongo] - port: 27017 -FEATURES: {ALLOW_AUTOMATED_SIGNUPS: true, AUTOMATIC_AUTH_FOR_TESTING: true, - AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING: true, CERTIFICATES_HTML_VIEW: true, - CERTIFICATES_INSTRUCTOR_GENERATION: true, CUSTOM_COURSES_EDX: true, - ENABLE_COURSE_DISCOVERY: true, ENABLE_DISCUSSION_SERVICE: true, ENABLE_GRADE_DOWNLOADS: true, - ENABLE_SPECIAL_EXAMS: true, ENABLE_THIRD_PARTY_AUTH: true, - ENABLE_VERIFIED_CERTIFICATES: true, EXPOSE_CACHE_PROGRAMS_ENDPOINT: true, MODE_CREATION_FOR_TESTING: true, - PREVIEW_LMS_BASE: 'preview.localhost:8003', RESTRICT_AUTOMATIC_AUTH: false, SHOW_HEADER_LANGUAGE_SELECTOR: true} -GITHUB_REPO_ROOT: '** OVERRIDDEN **' -JWT_AUTH: {JWT_PRIVATE_SIGNING_JWK: '{"e": "AQAB", "d": "HIiV7KNjcdhVbpn3KT-I9n3JPf5YbGXsCIedmPqDH1d4QhBofuAqZ9zebQuxkRUpmqtYMv0Zi6ECSUqH387GYQF_XvFUFcjQRPycISd8TH0DAKaDpGr-AYNshnKiEtQpINhcP44I1AYNPCwyoxXA1fGTtmkKChsuWea7o8kytwU5xSejvh5-jiqu2SF4GEl0BEXIAPZsgbzoPIWNxgO4_RzNnWs6nJZeszcaDD0CyezVSuH9QcI6g5QFzAC_YuykSsaaFJhZ05DocBsLczShJ9Omf6PnK9xlm26I84xrEh_7x4fVmNBg3xWTLh8qOnHqGko93A1diLRCrKHOvnpvgQ", - "n": "o5cn3ljSRi6FaDEKTn0PS-oL9EFyv1pI7dRgffQLD1qf5D6sprmYfWWokSsrWig8u2y0HChSygR6Jn5KXBqQn6FpM0dDJLnWQDRXHLl3Ey1iPYgDSmOIsIGrV9ZyNCQwk03wAgWbfdBTig3QSDYD-sTNOs3pc4UD_PqAvU2nz_1SS2ZiOwOn5F6gulE1L0iE3KEUEvOIagfHNVhz0oxa_VRZILkzV-zr6R_TW1m97h4H8jXl_VJyQGyhMGGypuDrQ9_vaY_RLEulLCyY0INglHWQ7pckxBtI5q55-Vio2wgewe2_qYcGsnBGaDNbySAsvYcWRrqDiFyzrJYivodqTQ", - "q": "3T3DEtBUka7hLGdIsDlC96Uadx_q_E4Vb1cxx_4Ss_wGp1Loz3N3ZngGyInsKlmbBgLo1Ykd6T9TRvRNEWEtFSOcm2INIBoVoXk7W5RuPa8Cgq2tjQj9ziGQ08JMejrPlj3Q1wmALJr5VTfvSYBu0WkljhKNCy1KB6fCby0C9WE", - "p": "vUqzWPZnDG4IXyo-k5F0bHV0BNL_pVhQoLW7eyFHnw74IOEfSbdsMspNcPSFIrtgPsn7981qv3lN_staZ6JflKfHayjB_lvltHyZxfl0dvruShZOx1N6ykEo7YrAskC_qxUyrIvqmJ64zPW3jkuOYrFs7Ykj3zFx3Zq1H5568G0", - "kid": "BTZ9HA6K", "kty": "RSA"}', JWT_PUBLIC_SIGNING_JWK_SET: '{"keys": [{"kid": - "BTZ9HA6K", "e": "AQAB", "kty": "RSA", "n": "o5cn3ljSRi6FaDEKTn0PS-oL9EFyv1pI7dRgffQLD1qf5D6sprmYfWWokSsrWig8u2y0HChSygR6Jn5KXBqQn6FpM0dDJLnWQDRXHLl3Ey1iPYgDSmOIsIGrV9ZyNCQwk03wAgWbfdBTig3QSDYD-sTNOs3pc4UD_PqAvU2nz_1SS2ZiOwOn5F6gulE1L0iE3KEUEvOIagfHNVhz0oxa_VRZILkzV-zr6R_TW1m97h4H8jXl_VJyQGyhMGGypuDrQ9_vaY_RLEulLCyY0INglHWQ7pckxBtI5q55-Vio2wgewe2_qYcGsnBGaDNbySAsvYcWRrqDiFyzrJYivodqTQ"}]}', - JWT_SECRET_KEY: super-secret-key} -LMS_BASE: http://edx.devstack.lms:18003 -LMS_ROOT_URL: http://edx.devstack.lms:18003 -LOCAL_LOGLEVEL: INFO -LOGGING_ENV: sandbox -LOG_DIR: '** OVERRIDDEN **' -MEDIA_URL: /media/ -MKTG_URL_LINK_MAP: {ABOUT: about, BLOG: blog, CAREERS: careers, CONTACT: contact, - COURSES: courses, DONATE: donate, HELP_CENTER: help-center, HONOR: honor, NEWS: news, - PRESS: press, PRIVACY: privacy, ROOT: root, SITEMAP.XML: sitemap_xml, TOS: tos, - WHAT_IS_VERIFIED_CERT: verified-certificate} -MODULESTORE: - default: - ENGINE: xmodule.modulestore.mixed.MixedModuleStore - OPTIONS: - mappings: {} - stores: - - DOC_STORE_CONFIG: - collection: modulestore - db: test - host: [edx.devstack.mongo] - port: 27017 - ENGINE: xmodule.modulestore.mongo.DraftMongoModuleStore - NAME: draft - OPTIONS: - collection: modulestore - db: test - default_class: xmodule.hidden_block.HiddenBlock - fs_root: '** OVERRIDDEN **' - host: [edx.devstack.mongo] - port: 27017 - render_template: common.djangoapps.edxmako.shortcuts.render_to_string - - ENGINE: xmodule.modulestore.xml.XMLModuleStore - NAME: xml - OPTIONS: {data_dir: '** OVERRIDDEN **', default_class: xmodule.hidden_block.HiddenBlock} -PASSWORD_RESET_SUPPORT_LINK: https://support.example.com/password-reset-help.html -REGISTRATION_EXTENSION_FORM: openedx.core.djangoapps.user_api.tests.test_helpers.TestCaseForm -REGISTRATION_EXTRA_FIELDS: {city: hidden, country: required, gender: optional, goals: optional, - honor_code: required, level_of_education: optional, mailing_address: optional, terms_of_service: hidden, - year_of_birth: optional} -SECRET_KEY: 'bokchoy_docker_secret_key' -SERVER_EMAIL: devops@example.com -SESSION_COOKIE_DOMAIN: null -SITE_NAME: localhost:8003 -SOCIAL_SHARING_SETTINGS: {CERTIFICATE_FACEBOOK: true, CERTIFICATE_FACEBOOK_TEXT: 'Testing - facebook feature:', CUSTOM_COURSE_URLS: true, DASHBOARD_FACEBOOK: true, DASHBOARD_TWITTER: true, - DASHBOARD_TWITTER_TEXT: 'Testing feature:'} -STATIC_URL_BASE: /static/ -SUPPORT_SITE_LINK: https://support.example.com -SYSLOG_SERVER: '' -TECH_SUPPORT_EMAIL: technical@example.com -THIRD_PARTY_AUTH_BACKENDS: [social_core.backends.google.GoogleOAuth2, social_core.backends.linkedin.LinkedinOAuth2, - social_core.backends.facebook.FacebookOAuth2, common.djangoapps.third_party_auth.dummy.DummyBackend, - common.djangoapps.third_party_auth.saml.SAMLAuthBackend] -TIME_ZONE: America/New_York -TRACKING_BACKENDS: - mongo: - ENGINE: common.djangoapps.track.backends.mongodb.MongoBackend - OPTIONS: - collection: events - database: test - host: [edx.devstack.mongo] - port: 27017 -WIKI_ENABLED: true -XQUEUE_INTERFACE: - basic_auth: [edx, edx] - django_auth: {password: password, username: lms} - url: '** OVERRIDDEN **' -ZENDESK_API_KEY: '' -ZENDESK_USER: '' diff --git a/openedx/core/djangoapps/util/management/commands/update_fixtures.py b/openedx/core/djangoapps/util/management/commands/update_fixtures.py deleted file mode 100644 index 53e7db56eae4..000000000000 --- a/openedx/core/djangoapps/util/management/commands/update_fixtures.py +++ /dev/null @@ -1,30 +0,0 @@ -""" -Django management command to update the loaded test fixtures as necessary for -the current test environment. Currently just sets an appropriate domain for -each Site fixture. -""" - - -import os - -from django.contrib.sites.models import Site -from django.core.management.base import BaseCommand - - -class Command(BaseCommand): - """ - update_fixtures management command - """ - - help = "Update fixtures to match the current test environment." - - def handle(self, *args, **options): - if 'BOK_CHOY_HOSTNAME' in os.environ: - # Fix the Site fixture domains so third party auth tests work correctly - host = os.environ['BOK_CHOY_HOSTNAME'] - cms_port = os.environ['BOK_CHOY_CMS_PORT'] - lms_port = os.environ['BOK_CHOY_LMS_PORT'] - cms_domain = f'{host}:{cms_port}' - Site.objects.filter(name='cms').update(domain=cms_domain) - lms_domain = f'{host}:{lms_port}' - Site.objects.filter(name='lms').update(domain=lms_domain) diff --git a/openedx/core/djangoapps/util/tests/test_update_fixtures.py b/openedx/core/djangoapps/util/tests/test_update_fixtures.py deleted file mode 100644 index fb43fa34a88c..000000000000 --- a/openedx/core/djangoapps/util/tests/test_update_fixtures.py +++ /dev/null @@ -1,42 +0,0 @@ -""" # lint-amnesty, pylint: disable=django-not-configured -Tests of the update_fixtures management command for bok-choy test database -initialization. -""" - - -import os - -import pytest -from django.contrib.sites.models import Site -from django.core.management import call_command - - -@pytest.fixture(scope='function') -def sites(db): # lint-amnesty, pylint: disable=unused-argument - Site.objects.create(name='cms', domain='localhost:8031') - Site.objects.create(name='lms', domain='localhost:8003') - - -def test_localhost(db, monkeypatch, sites): # lint-amnesty, pylint: disable=redefined-outer-name, unused-argument - monkeypatch.delitem(os.environ, 'BOK_CHOY_HOSTNAME', raising=False) - call_command('update_fixtures') - assert Site.objects.get(name='cms').domain == 'localhost:8031' - assert Site.objects.get(name='lms').domain == 'localhost:8003' - - -def test_devstack_cms(db, monkeypatch, sites): # lint-amnesty, pylint: disable=redefined-outer-name, unused-argument - monkeypatch.setitem(os.environ, 'BOK_CHOY_HOSTNAME', 'edx.devstack.cms') - monkeypatch.setitem(os.environ, 'BOK_CHOY_CMS_PORT', '18031') - monkeypatch.setitem(os.environ, 'BOK_CHOY_LMS_PORT', '18003') - call_command('update_fixtures') - assert Site.objects.get(name='cms').domain == 'edx.devstack.cms:18031' - assert Site.objects.get(name='lms').domain == 'edx.devstack.cms:18003' - - -def test_devstack_lms(db, monkeypatch, sites): # lint-amnesty, pylint: disable=redefined-outer-name, unused-argument - monkeypatch.setitem(os.environ, 'BOK_CHOY_HOSTNAME', 'edx.devstack.lms') - monkeypatch.setitem(os.environ, 'BOK_CHOY_CMS_PORT', '18031') - monkeypatch.setitem(os.environ, 'BOK_CHOY_LMS_PORT', '18003') - call_command('update_fixtures') - assert Site.objects.get(name='cms').domain == 'edx.devstack.lms:18031' - assert Site.objects.get(name='lms').domain == 'edx.devstack.lms:18003' diff --git a/openedx/features/content_type_gating/tests/test_access.py b/openedx/features/content_type_gating/tests/test_access.py index c66359fc923a..53582df34a4b 100644 --- a/openedx/features/content_type_gating/tests/test_access.py +++ b/openedx/features/content_type_gating/tests/test_access.py @@ -228,8 +228,7 @@ def setUpClass(cls): graded=False, ) cls.graded_score_weight_blocks[(graded, has_score, weight)] = block - - host = os.environ.get('BOK_CHOY_HOSTNAME', '127.0.0.1') + host = os.environ.get('127.0.0.1') metadata_lti_xblock = { 'lti_id': 'correct_lti_id', 'launch_url': 'http://{}:{}/{}'.format(host, '8765', 'correct_lti_endpoint'), diff --git a/openedx/testing/coverage_context_listener/pytest_plugin.py b/openedx/testing/coverage_context_listener/pytest_plugin.py index cdafa7df8143..e4530e76f5b0 100644 --- a/openedx/testing/coverage_context_listener/pytest_plugin.py +++ b/openedx/testing/coverage_context_listener/pytest_plugin.py @@ -3,9 +3,9 @@ """ import pytest -import requests +# import requests -from pavelib.utils.envs import Env +# from pavelib.utils.envs import Env class RemoteContextPlugin: @@ -25,16 +25,17 @@ def pytest_runtest_teardown(self, item): def pytest_runtest_call(self, item): self.doit(item, "call") - def doit(self, item, when): # lint-amnesty, pylint: disable=missing-function-docstring - if self.active: - for cfg in Env.BOK_CHOY_SERVERS.values(): - result = requests.post( - 'http://{host}:{port}/coverage_context/update_context'.format(**cfg), - { - 'context': f"{item.nodeid}|{when}", - } - ) - assert result.status_code == 204 + # commented for testing + # def doit(self, item, when): # lint-amnesty, pylint: disable=missing-function-docstring + # if self.active: + # for cfg in Env.BOK_CHOY_SERVERS.values(): + # result = requests.post( + # 'http://{host}:{port}/coverage_context/update_context'.format(**cfg), + # { + # 'context': f"{item.nodeid}|{when}", + # } + # ) + # assert result.status_code == 204 @pytest.hookimpl(tryfirst=True) diff --git a/pavelib/utils/envs.py b/pavelib/utils/envs.py index 9e2e2fe5b831..fe7cd0964dcf 100644 --- a/pavelib/utils/envs.py +++ b/pavelib/utils/envs.py @@ -61,18 +61,6 @@ class Env: # Python unittest dirs PYTHON_COVERAGERC = REPO_ROOT / ".coveragerc" - # Bok_choy dirs - BOK_CHOY_DIR = REPO_ROOT / "common" / "test" / "acceptance" - BOK_CHOY_LOG_DIR = GEN_LOG_DIR - BOK_CHOY_REPORT_DIR = REPORT_DIR / "bok_choy" - BOK_CHOY_A11Y_REPORT_DIR = REPORT_DIR / "a11y" - BOK_CHOY_COVERAGERC = BOK_CHOY_DIR / ".coveragerc" - BOK_CHOY_A11Y_COVERAGERC = BOK_CHOY_DIR / ".a11ycoveragerc" - BOK_CHOY_A11Y_CUSTOM_RULES_FILE = ( - REPO_ROOT / "node_modules" / "edx-custom-a11y-rules" / - "lib" / "custom_a11y_rules.js" - ) - # Which Python version should be used in xdist workers? PYTHON_VERSION = os.environ.get("PYTHON_VERSION", "2.7") @@ -82,95 +70,18 @@ class Env: # build steps. For local development/testing, this shouldn't be needed. if os.environ.get("SHARD", None): shard_str = "shard_{}".format(os.environ.get("SHARD")) - BOK_CHOY_REPORT_DIR = BOK_CHOY_REPORT_DIR / shard_str - BOK_CHOY_LOG_DIR = BOK_CHOY_LOG_DIR / shard_str - - # The stubs package is currently located in the Django app called "terrain" - # from when they were used by both the bok-choy and lettuce (deprecated) acceptance tests - BOK_CHOY_STUB_DIR = REPO_ROOT / "common" / "djangoapps" / "terrain" # Directory that videos are served from VIDEO_SOURCE_DIR = REPO_ROOT / "test_root" / "data" / "video" - PRINT_SETTINGS_LOG_FILE = BOK_CHOY_LOG_DIR / "print_settings.log" + PRINT_SETTINGS_LOG_FILE = GEN_LOG_DIR / "print_settings.log" # Detect if in a Docker container, and if so which one - SERVER_HOST = os.environ.get('BOK_CHOY_HOSTNAME', '0.0.0.0') + SERVER_HOST = os.environ.get('0.0.0.0') USING_DOCKER = SERVER_HOST != '0.0.0.0' - SETTINGS = 'bok_choy_docker' if USING_DOCKER else 'bok_choy' DEVSTACK_SETTINGS = 'devstack_docker' if USING_DOCKER else 'devstack' TEST_SETTINGS = 'test' - BOK_CHOY_SERVERS = { - 'lms': { - 'host': SERVER_HOST, - 'port': os.environ.get('BOK_CHOY_LMS_PORT', '8003'), - 'log': BOK_CHOY_LOG_DIR / "bok_choy_lms.log" - }, - 'cms': { - 'host': SERVER_HOST, - 'port': os.environ.get('BOK_CHOY_CMS_PORT', '8031'), - 'log': BOK_CHOY_LOG_DIR / "bok_choy_studio.log" - } - } - - BOK_CHOY_STUBS = { - - 'xqueue': { - 'port': 8040, - 'log': BOK_CHOY_LOG_DIR / "bok_choy_xqueue.log", - 'config': 'register_submission_url=http://0.0.0.0:8041/test/register_submission', - }, - - 'ora': { - 'port': 8041, - 'log': BOK_CHOY_LOG_DIR / "bok_choy_ora.log", - 'config': '', - }, - - 'comments': { - 'port': 4567, - 'log': BOK_CHOY_LOG_DIR / "bok_choy_comments.log", - }, - - 'video': { - 'port': 8777, - 'log': BOK_CHOY_LOG_DIR / "bok_choy_video_sources.log", - 'config': f"root_dir={VIDEO_SOURCE_DIR}", - }, - - 'youtube': { - 'port': 9080, - 'log': BOK_CHOY_LOG_DIR / "bok_choy_youtube.log", - }, - - 'edxnotes': { - 'port': 8042, - 'log': BOK_CHOY_LOG_DIR / "bok_choy_edxnotes.log", - }, - - 'ecommerce': { - 'port': 8043, - 'log': BOK_CHOY_LOG_DIR / "bok_choy_ecommerce.log", - }, - - 'catalog': { - 'port': 8091, - 'log': BOK_CHOY_LOG_DIR / "bok_choy_catalog.log", - }, - - 'lti': { - 'port': 8765, - 'log': BOK_CHOY_LOG_DIR / "bok_choy_lti.log", - }, - } - - # Mongo databases that will be dropped before/after the tests run - MONGO_HOST = 'edx.devstack.mongo' if USING_DOCKER else 'localhost' - BOK_CHOY_MONGO_DATABASE = "test" - BOK_CHOY_CACHE_HOST = 'edx.devstack.memcached' if USING_DOCKER else '0.0.0.0' - BOK_CHOY_CACHE = memcache.Client([f'{BOK_CHOY_CACHE_HOST}:11211'], debug=0) - # Test Ids Directory TEST_DIR = REPO_ROOT / ".testids" diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt index 7c5173ccaaed..3b1c6ce672e7 100644 --- a/requirements/edx/development.txt +++ b/requirements/edx/development.txt @@ -138,8 +138,6 @@ bleach[css]==6.0.0 # ora2 # xblock-drag-and-drop-v2 # xblock-poll -bok-choy==2.0.2 - # via -r requirements/edx/testing.txt boto==2.39.0 # via # -c requirements/edx/../constraints.txt @@ -1122,7 +1120,6 @@ lazy==1.6 # -r requirements/edx/doc.txt # -r requirements/edx/testing.txt # acid-xblock - # bok-choy # lti-consumer-xblock # ora2 # xblock @@ -1809,10 +1806,6 @@ scipy==1.7.3 # -r requirements/edx/testing.txt # chem # openedx-calc -selenium==3.141.0 - # via - # -r requirements/edx/testing.txt - # bok-choy semantic-version==2.10.0 # via # -r requirements/edx/doc.txt @@ -2121,7 +2114,6 @@ urllib3==1.26.16 # pact-python # py2neo # requests - # selenium # snowflake-connector-python user-util==1.0.0 # via diff --git a/requirements/edx/testing.in b/requirements/edx/testing.in index 93310adc88f1..b7806b027e73 100644 --- a/requirements/edx/testing.in +++ b/requirements/edx/testing.in @@ -18,7 +18,6 @@ -r coverage.txt # Utilities for calculating test coverage beautifulsoup4 # Library for extracting data from HTML and XML files -bok-choy # Framework for browser automation tests, based on selenium code-annotations # Perform code annotation checking, such as for PII annotations cssselect # Used to extract HTML fragments via CSS selectors in 2 test cases and pyquery ddt # Run a test case multiple times with different input; used in many, many of our tests @@ -41,7 +40,6 @@ pytest-json-report # Output json formatted warnings after running pytest pytest-metadata==1.8.0 # To prevent 'make upgrade' failure, dependency of pytest-json-report pytest-randomly # pytest plugin to randomly order tests pytest-xdist[psutil] # Parallel execution of tests on multiple CPU cores or hosts -selenium # Browser automation library, used for acceptance tests singledispatch # Backport of functools.singledispatch from Python 3.4+, used in tests of XBlock rendering testfixtures # Provides a LogCapture utility used by several tests tox # virtualenv management for tests diff --git a/requirements/edx/testing.txt b/requirements/edx/testing.txt index 2a07c19de058..dd51467f1599 100644 --- a/requirements/edx/testing.txt +++ b/requirements/edx/testing.txt @@ -104,8 +104,6 @@ bleach[css]==6.0.0 # ora2 # xblock-drag-and-drop-v2 # xblock-poll -bok-choy==2.0.2 - # via -r requirements/edx/testing.in boto==2.39.0 # via # -c requirements/edx/../constraints.txt @@ -856,7 +854,6 @@ lazy==1.6 # via # -r requirements/edx/base.txt # acid-xblock - # bok-choy # lti-consumer-xblock # ora2 # xblock @@ -1373,10 +1370,6 @@ scipy==1.7.3 # -r requirements/edx/base.txt # chem # openedx-calc -selenium==3.141.0 - # via - # -r requirements/edx/testing.in - # bok-choy semantic-version==2.10.0 # via # -r requirements/edx/base.txt @@ -1568,7 +1561,6 @@ urllib3==1.26.16 # pact-python # py2neo # requests - # selenium # snowflake-connector-python user-util==1.0.0 # via -r requirements/edx/base.txt diff --git a/scripts/reset-test-db.sh b/scripts/reset-test-db.sh deleted file mode 100755 index b0573a8e1369..000000000000 --- a/scripts/reset-test-db.sh +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env bash - -############################################################################ -# -# reset-test-db.sh -# -# Resets the MySQL test database for the bok-choy acceptance tests. -# -# If it finds a cached schema and migration history, it will start -# from the cached version to speed up migrations. -# -# If no cached database exists, it will create one. This can be -# checked into the repo to speed up future tests. -# -# Note that we do NOT want to re-use the cache between test runs! -# A newer commit could introduce migrations that do not exist -# in other commits, which could cause migrations to fail in the other -# commits. -# -# For this reason, we always use a cache that was committed to master -# at the time the branch was created. -# -############################################################################ - -# Fail fast -set -e - -DB_CACHE_DIR="common/test/db_cache" - -if [[ -z "$BOK_CHOY_HOSTNAME" ]]; then - MYSQL_HOST="" - SETTINGS="bok_choy" -else - MYSQL_HOST="--host=edx.devstack.mysql57" - SETTINGS="bok_choy_docker" -fi - -for i in "$@"; do - case $i in - -r|--rebuild_cache) - REBUILD_CACHE=true - ;; - -m|--migrations) - APPLY_MIGRATIONS=true - ;; - -c|--calculate_migrations) - CALCULATE_MIGRATIONS=true - ;; - -u|--use-existing-db) - USE_EXISTING_DB=true - ;; - esac -done - -declare -A databases -declare -a database_order -databases=(["default"]="edxtest" ["student_module_history"]="student_module_history_test") -database_order=("default" "student_module_history") - -calculate_migrations() { - echo "Calculating migrations for fingerprinting." - output_file="common/test/db_cache/bok_choy_${db}_migrations.yaml" - # Redirect stdout to /dev/null because the script will print - # out all migrations to both stdout and the output file. - ./manage.py lms --settings "$SETTINGS" show_unapplied_migrations --database "$db" --output_file "$output_file" 1>/dev/null -} - -run_migrations() { - echo "Running the lms migrations on the $db bok_choy DB." - ./manage.py lms --settings "$SETTINGS" migrate --database "$db" --traceback --noinput - echo "Running the cms migrations on the $db bok_choy DB." - ./manage.py cms --settings "$SETTINGS" migrate --database "$db" --traceback --noinput -} - -load_cache_into_db() { - echo "Loading the schema from the filesystem into the $db MySQL DB." - mysql "$MYSQL_HOST" -u root "${databases["$db"]}" < "$DB_CACHE_DIR/bok_choy_schema_$db.sql" - echo "Loading the fixture data from the filesystem into the $db MySQL DB." - ./manage.py lms --settings "$SETTINGS" loaddata --database "$db" "$DB_CACHE_DIR/bok_choy_data_$db.json" - echo "Loading the migration data from the filesystem into the $db MySQL DB." - mysql "$MYSQL_HOST" -u root "${databases["$db"]}" < "$DB_CACHE_DIR/bok_choy_migrations_data_$db.sql" -} - -rebuild_cache_for_db() { - # Make sure the DB has all migrations applied - run_migrations - - # Dump the schema and data to the cache - echo "Using the dumpdata command to save the $db fixture data to the filesystem." - ./manage.py lms --settings "$SETTINGS" dumpdata --database "$db" > "$DB_CACHE_DIR/bok_choy_data_$db.json" --exclude=api_admin.Catalog - echo "Saving the schema of the $db bok_choy DB to the filesystem." - mysqldump "$MYSQL_HOST" -u root --no-data --skip-comments --skip-dump-date "${databases[$db]}" > "$DB_CACHE_DIR/bok_choy_schema_$db.sql" - - # dump_data does not dump the django_migrations table so we do it separately. - echo "Saving the django_migrations table of the $db bok_choy DB to the filesystem." - mysqldump $MYSQL_HOST -u root --no-create-info --skip-comments --skip-dump-date "${databases["$db"]}" django_migrations > "$DB_CACHE_DIR/bok_choy_migrations_data_$db.sql" -} - -for db in "${database_order[@]}"; do - if ! [[ $USE_EXISTING_DB ]]; then - echo "CREATE DATABASE IF NOT EXISTS ${databases[$db]};" | mysql $MYSQL_HOST -u root - - # Clear out the test database - # - # We are using the reset_db command which uses "DROP DATABASE" and - # "CREATE DATABASE" in case the tests are being run in an environment (e.g. devstack - # or a jenkins worker environment) that already ran tests on another commit that had - # different migrations that created, dropped, or altered tables. - echo "Issuing a reset_db command to the $db bok_choy MySQL database." - ./manage.py lms --settings "$SETTINGS" reset_db --traceback --router "$db" - fi - - if ! [[ $CALCULATE_MIGRATIONS ]]; then - # If there are cached database schemas/data, then load them. - # If they are missing, then we will want to build new cache files even if - # not explicitly directed to do so via arguments passed to this script. - if [[ ! -f $DB_CACHE_DIR/bok_choy_schema_$db.sql || ! -f $DB_CACHE_DIR/bok_choy_data_$db.json || ! -f $DB_CACHE_DIR/bok_choy_migrations_data_$db.sql ]]; then - REBUILD_CACHE=true - else - load_cache_into_db - fi - fi -done - -if [[ $REBUILD_CACHE ]]; then - echo "Cleaning the DB cache directory and building new files." - mkdir -p $DB_CACHE_DIR && rm -f $DB_CACHE_DIR/bok_choy* - - for db in "${database_order[@]}"; do - rebuild_cache_for_db - done -elif [[ $APPLY_MIGRATIONS ]]; then - for db in "${database_order[@]}"; do - run_migrations - done -elif [[ $CALCULATE_MIGRATIONS ]]; then - for db in "${database_order[@]}"; do - calculate_migrations - done -fi diff --git a/tox.ini b/tox.ini index 689407650699..ce00efa87092 100644 --- a/tox.ini +++ b/tox.ini @@ -26,10 +26,6 @@ setenv = PYTHONHASHSEED=0 TOXENV={envname} passenv = - BOK_CHOY_CMS_PORT - BOKCHOY_HEADLESS - BOK_CHOY_HOSTNAME - BOK_CHOY_LMS_PORT DISABLE_COURSEENROLLMENT_HISTORY DISPLAY DJANGO_SETTINGS_MODULE diff --git a/xmodule/modulestore/tests/mongo_connection.py b/xmodule/modulestore/tests/mongo_connection.py index 8da1fbd42387..a0ffe7e7c6f1 100644 --- a/xmodule/modulestore/tests/mongo_connection.py +++ b/xmodule/modulestore/tests/mongo_connection.py @@ -9,5 +9,4 @@ import os MONGO_PORT_NUM = int(os.environ.get('EDXAPP_TEST_MONGO_PORT', '27017')) -MONGO_HOST = os.environ.get('EDXAPP_TEST_MONGO_HOST', - 'edx.devstack.mongo' if 'BOK_CHOY_HOSTNAME' in os.environ else 'localhost') +MONGO_HOST = os.environ.get('EDXAPP_TEST_MONGO_HOST', 'localhost') diff --git a/xmodule/tests/test_mongo_utils.py b/xmodule/tests/test_mongo_utils.py index 94182b24a725..cfa08ba15708 100644 --- a/xmodule/tests/test_mongo_utils.py +++ b/xmodule/tests/test_mongo_utils.py @@ -3,7 +3,6 @@ """ -import os from unittest import TestCase from uuid import uuid4 @@ -29,7 +28,7 @@ def test_connect_to_mongo_read_preference(self, enum_name, mongos_name, expected """ Test that read_preference parameter gets converted to a valid pymongo read preference. """ - host = 'edx.devstack.mongo' if 'BOK_CHOY_HOSTNAME' in os.environ else 'localhost' + host = 'localhost' db = 'test_read_preference_%s' % uuid4().hex # Support for read_preference given in constant name form (ie. PRIMARY, SECONDARY_PREFERRED) connection = connect_to_mongodb(db, host, read_preference=enum_name) diff --git a/xmodule/tests/test_video.py b/xmodule/tests/test_video.py index 7daa6bdfe097..e5180843d7c6 100644 --- a/xmodule/tests/test_video.py +++ b/xmodule/tests/test_video.py @@ -15,7 +15,6 @@ import datetime import json -import os import shutil import unittest from tempfile import mkdtemp @@ -937,7 +936,7 @@ def test_student_view_data_with_hls_flag(self, mock_get_video_info, mock_get_vid @patch.object(settings, 'CONTENTSTORE', create=True, new={ 'ENGINE': 'xmodule.contentstore.mongo.MongoContentStore', 'DOC_STORE_CONFIG': { - 'host': 'edx.devstack.mongo' if 'BOK_CHOY_HOSTNAME' in os.environ else 'localhost', + 'host': 'localhost', 'db': 'test_xcontent_%s' % uuid4().hex, }, # allow for additional options that can be keyed on a name, e.g. 'trashcan' From 73c4e110fee4b780588bf68352d5776cacff86e5 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Wed, 27 Sep 2023 11:27:41 +0500 Subject: [PATCH 003/170] chore: remove karma --- pavelib/utils/envs.py | 30 +++++++++++++++--------------- tox.ini | 6 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pavelib/utils/envs.py b/pavelib/utils/envs.py index fe7cd0964dcf..ca7ec0f4c617 100644 --- a/pavelib/utils/envs.py +++ b/pavelib/utils/envs.py @@ -86,25 +86,25 @@ class Env: TEST_DIR = REPO_ROOT / ".testids" # Configured browser to use for the js test suites - SELENIUM_BROWSER = os.environ.get('SELENIUM_BROWSER', 'firefox') - if USING_DOCKER: - KARMA_BROWSER = 'ChromeDocker' if SELENIUM_BROWSER == 'chrome' else 'FirefoxDocker' - else: - KARMA_BROWSER = 'FirefoxNoUpdates' + # SELENIUM_BROWSER = os.environ.get('SELENIUM_BROWSER', 'firefox') + # if USING_DOCKER: + # KARMA_BROWSER = 'ChromeDocker' if SELENIUM_BROWSER == 'chrome' else 'FirefoxDocker' + # else: + # KARMA_BROWSER = 'FirefoxNoUpdates' # Files used to run each of the js test suites # TODO: Store this as a dict. Order seems to matter for some # reason. See issue TE-415. - KARMA_CONFIG_FILES = [ - REPO_ROOT / 'cms/static/karma_cms.conf.js', - REPO_ROOT / 'cms/static/karma_cms_squire.conf.js', - REPO_ROOT / 'cms/static/karma_cms_webpack.conf.js', - REPO_ROOT / 'lms/static/karma_lms.conf.js', - REPO_ROOT / 'xmodule/js/karma_xmodule.conf.js', - REPO_ROOT / 'xmodule/js/karma_xmodule_webpack.conf.js', - REPO_ROOT / 'common/static/karma_common.conf.js', - REPO_ROOT / 'common/static/karma_common_requirejs.conf.js', - ] + # KARMA_CONFIG_FILES = [ + # REPO_ROOT / 'cms/static/karma_cms.conf.js', + # REPO_ROOT / 'cms/static/karma_cms_squire.conf.js', + # REPO_ROOT / 'cms/static/karma_cms_webpack.conf.js', + # REPO_ROOT / 'lms/static/karma_lms.conf.js', + # REPO_ROOT / 'xmodule/js/karma_xmodule.conf.js', + # REPO_ROOT / 'xmodule/js/karma_xmodule_webpack.conf.js', + # REPO_ROOT / 'common/static/karma_common.conf.js', + # REPO_ROOT / 'common/static/karma_common_requirejs.conf.js', + # ] JS_TEST_ID_KEYS = [ 'cms', diff --git a/tox.ini b/tox.ini index ce00efa87092..cacd77ea0ba6 100644 --- a/tox.ini +++ b/tox.ini @@ -40,9 +40,9 @@ passenv = NPM_CONFIG_PREFIX PYTHON_VERSION SCRAPY_SETTINGS_MODULE - SELENIUM_BROWSER - SELENIUM_HOST - SELENIUM_PORT + #SELENIUM_BROWSER + #SELENIUM_HOST + #SELENIUM_PORT SHARD SKIP_NPM_INSTALL SSH_AUTH_SOCK From a06ac2f6a2869db7dc859b2c825029e09fccb370 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Wed, 27 Sep 2023 11:42:57 +0500 Subject: [PATCH 004/170] chore: remove karma --- pavelib/paver_tests/test_js_test.py | 130 +++++++++++++------------- pavelib/utils/test/suites/js_suite.py | 98 +++++++++---------- 2 files changed, 114 insertions(+), 114 deletions(-) diff --git a/pavelib/paver_tests/test_js_test.py b/pavelib/paver_tests/test_js_test.py index 9d89a944448f..a066a3ea1949 100644 --- a/pavelib/paver_tests/test_js_test.py +++ b/pavelib/paver_tests/test_js_test.py @@ -55,15 +55,15 @@ def setUp(self): ["--suite=lms"], ["--suite=lms --coverage"], ) - @ddt.unpack - def test_test_js_run(self, options_string): - """ - Test the "test_js_run" task. - """ - options = self.parse_options_string(options_string) - self.reset_task_messages() - call_task("pavelib.js_test.test_js_run", options=options) - self.verify_messages(options=options, dev_mode=False) + # @ddt.unpack + # def test_test_js_run(self, options_string): + # """ + # Test the "test_js_run" task. + # """ + # options = self.parse_options_string(options_string) + # self.reset_task_messages() + # call_task("pavelib.js_test.test_js_run", options=options) + # self.verify_messages(options=options, dev_mode=False) @ddt.data( [""], @@ -71,15 +71,15 @@ def test_test_js_run(self, options_string): ["--suite=lms"], ["--suite=lms --port=9999"], ) - @ddt.unpack - def test_test_js_dev(self, options_string): - """ - Test the "test_js_run" task. - """ - options = self.parse_options_string(options_string) - self.reset_task_messages() - call_task("pavelib.js_test.test_js_dev", options=options) - self.verify_messages(options=options, dev_mode=True) + # @ddt.unpack + # def test_test_js_dev(self, options_string): + # """ + # Test the "test_js_run" task. + # """ + # options = self.parse_options_string(options_string) + # self.reset_task_messages() + # call_task("pavelib.js_test.test_js_dev", options=options) + # self.verify_messages(options=options, dev_mode=True) def parse_options_string(self, options_string): """ @@ -101,50 +101,50 @@ def parse_options_string(self, options_string): "port": port, } - def verify_messages(self, options, dev_mode): - """ - Verify that the messages generated when running tests are as expected - for the specified options and dev_mode. - """ - is_coverage = options['coverage'] - port = options['port'] - expected_messages = [] - suites = Env.JS_TEST_ID_KEYS if options['suite'] == 'all' else [options['suite']] - - expected_messages.extend(self.EXPECTED_COMMANDS) - if not dev_mode and not is_coverage: - expected_messages.append(self.EXPECTED_DELETE_JAVASCRIPT_REPORT_COMMAND.format( - platform_root=self.platform_root - )) - expected_messages.append(self.EXPECTED_INSTALL_NPM_ASSETS_COMMAND) - - command_template = ( - 'node --max_old_space_size=4096 node_modules/.bin/karma start {options}' - ) - - for suite in suites: - # Karma test command - if suite != 'jest-snapshot': - karma_config_file = Env.KARMA_CONFIG_FILES[Env.JS_TEST_ID_KEYS.index(suite)] - expected_test_tool_command = command_template.format( - options=self.EXPECTED_KARMA_OPTIONS.format( - config_file=karma_config_file, - single_run='false' if dev_mode else 'true', - suite=suite, - platform_root=self.platform_root, - browser=Env.KARMA_BROWSER, - ), - ) - if is_coverage: - expected_test_tool_command += self.EXPECTED_COVERAGE_OPTIONS.format( - platform_root=self.platform_root, - suite=suite - ) - if port: - expected_test_tool_command += f" --port={port}" - else: - expected_test_tool_command = 'jest' - - expected_messages.append(expected_test_tool_command) - - assert self.task_messages == expected_messages + # def verify_messages(self, options, dev_mode): + # """ + # Verify that the messages generated when running tests are as expected + # for the specified options and dev_mode. + # """ + # is_coverage = options['coverage'] + # port = options['port'] + # expected_messages = [] + # suites = Env.JS_TEST_ID_KEYS if options['suite'] == 'all' else [options['suite']] + + # expected_messages.extend(self.EXPECTED_COMMANDS) + # if not dev_mode and not is_coverage: + # expected_messages.append(self.EXPECTED_DELETE_JAVASCRIPT_REPORT_COMMAND.format( + # platform_root=self.platform_root + # )) + # expected_messages.append(self.EXPECTED_INSTALL_NPM_ASSETS_COMMAND) + + # command_template = ( + # 'node --max_old_space_size=4096 node_modules/.bin/karma start {options}' + # ) + + # for suite in suites: + # # Karma test command + # if suite != 'jest-snapshot': + # karma_config_file = Env.KARMA_CONFIG_FILES[Env.JS_TEST_ID_KEYS.index(suite)] + # expected_test_tool_command = command_template.format( + # options=self.EXPECTED_KARMA_OPTIONS.format( + # config_file=karma_config_file, + # single_run='false' if dev_mode else 'true', + # suite=suite, + # platform_root=self.platform_root, + # browser=Env.KARMA_BROWSER, + # ), + # ) + # if is_coverage: + # expected_test_tool_command += self.EXPECTED_COVERAGE_OPTIONS.format( + # platform_root=self.platform_root, + # suite=suite + # ) + # if port: + # expected_test_tool_command += f" --port={port}" + # else: + # expected_test_tool_command = 'jest' + + # expected_messages.append(expected_test_tool_command) + + # assert self.task_messages == expected_messages diff --git a/pavelib/utils/test/suites/js_suite.py b/pavelib/utils/test/suites/js_suite.py index 65c5feaf843b..b7099c591fcf 100644 --- a/pavelib/utils/test/suites/js_suite.py +++ b/pavelib/utils/test/suites/js_suite.py @@ -47,55 +47,55 @@ def _default_subsuites(self): return [JsTestSubSuite(test_id, **self.opts) for test_id in Env.JS_TEST_ID_KEYS if test_id != 'jest-snapshot'] -class JsTestSubSuite(TestSuite): - """ - Class for JS suites like cms, cms-squire, lms, common, - common-requirejs and xmodule - """ - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.test_id = args[0] - self.run_under_coverage = kwargs.get('with_coverage', True) - self.mode = kwargs.get('mode', 'run') - self.port = kwargs.get('port') - self.root = self.root + ' javascript' - self.report_dir = Env.JS_REPORT_DIR - - try: - self.test_conf_file = Env.KARMA_CONFIG_FILES[Env.JS_TEST_ID_KEYS.index(self.test_id)] - except ValueError: - self.test_conf_file = Env.KARMA_CONFIG_FILES[0] - - self.coverage_report = self.report_dir / f'coverage-{self.test_id}.xml' - self.xunit_report = self.report_dir / f'javascript_xunit-{self.test_id}.xml' - - @property - def cmd(self): - """ - Run the tests using karma runner. - """ - cmd = [ - "node", - "--max_old_space_size=4096", - "node_modules/.bin/karma", - "start", - self.test_conf_file, - "--single-run={}".format('false' if self.mode == 'dev' else 'true'), - "--capture-timeout=60000", - f"--junitreportpath={self.xunit_report}", - f"--browsers={Env.KARMA_BROWSER}", - ] - - if self.port: - cmd.append(f"--port={self.port}") - - if self.run_under_coverage: - cmd.extend([ - "--coverage", - f"--coveragereportpath={self.coverage_report}", - ]) - - return cmd +# class JsTestSubSuite(TestSuite): +# """ +# Class for JS suites like cms, cms-squire, lms, common, +# common-requirejs and xmodule +# """ +# def __init__(self, *args, **kwargs): +# super().__init__(*args, **kwargs) +# self.test_id = args[0] +# self.run_under_coverage = kwargs.get('with_coverage', True) +# self.mode = kwargs.get('mode', 'run') +# self.port = kwargs.get('port') +# self.root = self.root + ' javascript' +# self.report_dir = Env.JS_REPORT_DIR + +# try: +# self.test_conf_file = Env.KARMA_CONFIG_FILES[Env.JS_TEST_ID_KEYS.index(self.test_id)] +# except ValueError: +# self.test_conf_file = Env.KARMA_CONFIG_FILES[0] + +# self.coverage_report = self.report_dir / f'coverage-{self.test_id}.xml' +# self.xunit_report = self.report_dir / f'javascript_xunit-{self.test_id}.xml' + +# @property +# def cmd(self): +# """ +# Run the tests using karma runner. +# """ +# cmd = [ +# "node", +# "--max_old_space_size=4096", +# "node_modules/.bin/karma", +# "start", +# self.test_conf_file, +# "--single-run={}".format('false' if self.mode == 'dev' else 'true'), +# "--capture-timeout=60000", +# f"--junitreportpath={self.xunit_report}", +# f"--browsers={Env.KARMA_BROWSER}", +# ] + +# if self.port: +# cmd.append(f"--port={self.port}") + +# if self.run_under_coverage: +# cmd.extend([ +# "--coverage", +# f"--coveragereportpath={self.coverage_report}", +# ]) + +# return cmd class JestSnapshotTestSuite(TestSuite): From caeb8d9694998ce5d0bd9dc058bf8ec060a56fef Mon Sep 17 00:00:00 2001 From: salman2013 Date: Wed, 27 Sep 2023 16:11:11 +0500 Subject: [PATCH 005/170] chore: remove bok choy --- pavelib/utils/test/suites/js_suite.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pavelib/utils/test/suites/js_suite.py b/pavelib/utils/test/suites/js_suite.py index b7099c591fcf..40f491f5d67f 100644 --- a/pavelib/utils/test/suites/js_suite.py +++ b/pavelib/utils/test/suites/js_suite.py @@ -25,7 +25,7 @@ def __init__(self, *args, **kwargs): self.opts = kwargs suite = args[0] - self.subsuites = self._default_subsuites if suite == 'all' else [JsTestSubSuite(*args, **kwargs)] + # self.subsuites = self._default_subsuites if suite == 'all' else [JsTestSubSuite(*args, **kwargs)] def __enter__(self): super().__enter__() @@ -39,12 +39,12 @@ def __enter__(self): if self.mode == 'run' and not self.run_under_coverage: test_utils.clean_dir(self.report_dir) - @property - def _default_subsuites(self): - """ - Returns all JS test suites - """ - return [JsTestSubSuite(test_id, **self.opts) for test_id in Env.JS_TEST_ID_KEYS if test_id != 'jest-snapshot'] + # @property + # def _default_subsuites(self): + # """ + # Returns all JS test suites + # """ + # return [JsTestSubSuite(test_id, **self.opts) for test_id in Env.JS_TEST_ID_KEYS if test_id != 'jest-snapshot'] # class JsTestSubSuite(TestSuite): From 3abf5971526f564d56cc90ec9feeafdbb374b74b Mon Sep 17 00:00:00 2001 From: salman2013 Date: Wed, 27 Sep 2023 16:57:53 +0500 Subject: [PATCH 006/170] chore: fix test cases --- .github/workflows/js-tests.yml | 8 --- .../pytest_plugin.py | 17 +---- pavelib/paver_tests/test_js_test.py | 70 +------------------ 3 files changed, 3 insertions(+), 92 deletions(-) diff --git a/.github/workflows/js-tests.yml b/.github/workflows/js-tests.yml index 092e6e38e2f1..e4903af83b7b 100644 --- a/.github/workflows/js-tests.yml +++ b/.github/workflows/js-tests.yml @@ -30,14 +30,6 @@ jobs: - name: Setup npm run: npm i -g npm@8.5.x - # - name: Install Firefox 61.0 - # run: | - # sudo apt-get purge firefox - # wget "https://ftp.mozilla.org/pub/firefox/releases/61.0/linux-x86_64/en-US/firefox-61.0.tar.bz2" - # tar -xjf firefox-61.0.tar.bz2 - # sudo mv firefox /opt/firefox - # sudo ln -s /opt/firefox/firefox /usr/bin/firefox - - name: Install Required System Packages run: sudo apt-get update && sudo apt-get install libxmlsec1-dev ubuntu-restricted-extras xvfb diff --git a/openedx/testing/coverage_context_listener/pytest_plugin.py b/openedx/testing/coverage_context_listener/pytest_plugin.py index e4530e76f5b0..37051385c0e7 100644 --- a/openedx/testing/coverage_context_listener/pytest_plugin.py +++ b/openedx/testing/coverage_context_listener/pytest_plugin.py @@ -3,9 +3,6 @@ """ import pytest -# import requests - -# from pavelib.utils.envs import Env class RemoteContextPlugin: @@ -25,19 +22,7 @@ def pytest_runtest_teardown(self, item): def pytest_runtest_call(self, item): self.doit(item, "call") - # commented for testing - # def doit(self, item, when): # lint-amnesty, pylint: disable=missing-function-docstring - # if self.active: - # for cfg in Env.BOK_CHOY_SERVERS.values(): - # result = requests.post( - # 'http://{host}:{port}/coverage_context/update_context'.format(**cfg), - # { - # 'context': f"{item.nodeid}|{when}", - # } - # ) - # assert result.status_code == 204 - - + @pytest.hookimpl(tryfirst=True) def pytest_configure(config): config.pluginmanager.register(RemoteContextPlugin(config), "remotecontextplugin") diff --git a/pavelib/paver_tests/test_js_test.py b/pavelib/paver_tests/test_js_test.py index a066a3ea1949..ee4df7ea4e99 100644 --- a/pavelib/paver_tests/test_js_test.py +++ b/pavelib/paver_tests/test_js_test.py @@ -55,15 +55,6 @@ def setUp(self): ["--suite=lms"], ["--suite=lms --coverage"], ) - # @ddt.unpack - # def test_test_js_run(self, options_string): - # """ - # Test the "test_js_run" task. - # """ - # options = self.parse_options_string(options_string) - # self.reset_task_messages() - # call_task("pavelib.js_test.test_js_run", options=options) - # self.verify_messages(options=options, dev_mode=False) @ddt.data( [""], @@ -71,16 +62,7 @@ def setUp(self): ["--suite=lms"], ["--suite=lms --port=9999"], ) - # @ddt.unpack - # def test_test_js_dev(self, options_string): - # """ - # Test the "test_js_run" task. - # """ - # options = self.parse_options_string(options_string) - # self.reset_task_messages() - # call_task("pavelib.js_test.test_js_dev", options=options) - # self.verify_messages(options=options, dev_mode=True) - + def parse_options_string(self, options_string): """ Parse a string containing the options for a test run @@ -99,52 +81,4 @@ def parse_options_string(self, options_string): "suite": suite, "coverage": coverage, "port": port, - } - - # def verify_messages(self, options, dev_mode): - # """ - # Verify that the messages generated when running tests are as expected - # for the specified options and dev_mode. - # """ - # is_coverage = options['coverage'] - # port = options['port'] - # expected_messages = [] - # suites = Env.JS_TEST_ID_KEYS if options['suite'] == 'all' else [options['suite']] - - # expected_messages.extend(self.EXPECTED_COMMANDS) - # if not dev_mode and not is_coverage: - # expected_messages.append(self.EXPECTED_DELETE_JAVASCRIPT_REPORT_COMMAND.format( - # platform_root=self.platform_root - # )) - # expected_messages.append(self.EXPECTED_INSTALL_NPM_ASSETS_COMMAND) - - # command_template = ( - # 'node --max_old_space_size=4096 node_modules/.bin/karma start {options}' - # ) - - # for suite in suites: - # # Karma test command - # if suite != 'jest-snapshot': - # karma_config_file = Env.KARMA_CONFIG_FILES[Env.JS_TEST_ID_KEYS.index(suite)] - # expected_test_tool_command = command_template.format( - # options=self.EXPECTED_KARMA_OPTIONS.format( - # config_file=karma_config_file, - # single_run='false' if dev_mode else 'true', - # suite=suite, - # platform_root=self.platform_root, - # browser=Env.KARMA_BROWSER, - # ), - # ) - # if is_coverage: - # expected_test_tool_command += self.EXPECTED_COVERAGE_OPTIONS.format( - # platform_root=self.platform_root, - # suite=suite - # ) - # if port: - # expected_test_tool_command += f" --port={port}" - # else: - # expected_test_tool_command = 'jest' - - # expected_messages.append(expected_test_tool_command) - - # assert self.task_messages == expected_messages + } \ No newline at end of file From 3d893a510a8a222bbdcb1eea587238d4ddb37f0f Mon Sep 17 00:00:00 2001 From: salman2013 Date: Wed, 27 Sep 2023 18:56:25 +0500 Subject: [PATCH 007/170] chore: remove bok-choy --- openedx/testing/coverage_context_listener/pytest_plugin.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/openedx/testing/coverage_context_listener/pytest_plugin.py b/openedx/testing/coverage_context_listener/pytest_plugin.py index 37051385c0e7..bb8dfcd37a15 100644 --- a/openedx/testing/coverage_context_listener/pytest_plugin.py +++ b/openedx/testing/coverage_context_listener/pytest_plugin.py @@ -4,7 +4,6 @@ import pytest - class RemoteContextPlugin: """ Pytest plugin for reporting pytests contexts to coverage running in another process @@ -22,7 +21,6 @@ def pytest_runtest_teardown(self, item): def pytest_runtest_call(self, item): self.doit(item, "call") - @pytest.hookimpl(tryfirst=True) def pytest_configure(config): config.pluginmanager.register(RemoteContextPlugin(config), "remotecontextplugin") From 0370f44b50b1063a9d018206d3226978c465dc55 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Wed, 27 Sep 2023 19:16:01 +0500 Subject: [PATCH 008/170] chore: fix test cases --- openedx/testing/coverage_context_listener/pytest_plugin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openedx/testing/coverage_context_listener/pytest_plugin.py b/openedx/testing/coverage_context_listener/pytest_plugin.py index bb8dfcd37a15..355c5abc0ecd 100644 --- a/openedx/testing/coverage_context_listener/pytest_plugin.py +++ b/openedx/testing/coverage_context_listener/pytest_plugin.py @@ -4,6 +4,7 @@ import pytest + class RemoteContextPlugin: """ Pytest plugin for reporting pytests contexts to coverage running in another process @@ -21,6 +22,7 @@ def pytest_runtest_teardown(self, item): def pytest_runtest_call(self, item): self.doit(item, "call") + @pytest.hookimpl(tryfirst=True) def pytest_configure(config): config.pluginmanager.register(RemoteContextPlugin(config), "remotecontextplugin") From 875de8eb715a9bd4174806004923550817909b04 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Thu, 28 Sep 2023 12:27:00 +0500 Subject: [PATCH 009/170] chore: fix test cases --- pavelib/paver_tests/test_js_test.py | 70 ++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/pavelib/paver_tests/test_js_test.py b/pavelib/paver_tests/test_js_test.py index ee4df7ea4e99..2180d28d4579 100644 --- a/pavelib/paver_tests/test_js_test.py +++ b/pavelib/paver_tests/test_js_test.py @@ -55,6 +55,15 @@ def setUp(self): ["--suite=lms"], ["--suite=lms --coverage"], ) + @ddt.unpack + def test_test_js_run(self, options_string): + """ + Test the "test_js_run" task. + """ + options = self.parse_options_string(options_string) + self.reset_task_messages() + call_task("pavelib.js_test.test_js_run", options=options) + self.verify_messages(options=options, dev_mode=False) @ddt.data( [""], @@ -62,7 +71,16 @@ def setUp(self): ["--suite=lms"], ["--suite=lms --port=9999"], ) - + @ddt.unpack + def test_test_js_dev(self, options_string): + """ + Test the "test_js_run" task. + """ + options = self.parse_options_string(options_string) + self.reset_task_messages() + call_task("pavelib.js_test.test_js_dev", options=options) + self.verify_messages(options=options, dev_mode=True) + def parse_options_string(self, options_string): """ Parse a string containing the options for a test run @@ -81,4 +99,52 @@ def parse_options_string(self, options_string): "suite": suite, "coverage": coverage, "port": port, - } \ No newline at end of file + } + + def verify_messages(self, options, dev_mode): + """ + Verify that the messages generated when running tests are as expected + for the specified options and dev_mode. + """ + is_coverage = options['coverage'] + port = options['port'] + expected_messages = [] + suites = Env.JS_TEST_ID_KEYS if options['suite'] == 'all' else [options['suite']] + + expected_messages.extend(self.EXPECTED_COMMANDS) + if not dev_mode and not is_coverage: + expected_messages.append(self.EXPECTED_DELETE_JAVASCRIPT_REPORT_COMMAND.format( + platform_root=self.platform_root + )) + expected_messages.append(self.EXPECTED_INSTALL_NPM_ASSETS_COMMAND) + + command_template = ( + 'node --max_old_space_size=4096 node_modules/.bin/karma start {options}' + ) + + # for suite in suites: + # # Karma test command + # if suite != 'jest-snapshot': + # karma_config_file = Env.KARMA_CONFIG_FILES[Env.JS_TEST_ID_KEYS.index(suite)] + # expected_test_tool_command = command_template.format( + # options=self.EXPECTED_KARMA_OPTIONS.format( + # config_file=karma_config_file, + # single_run='false' if dev_mode else 'true', + # suite=suite, + # platform_root=self.platform_root, + # browser=Env.KARMA_BROWSER, + # ), + # ) + # if is_coverage: + # expected_test_tool_command += self.EXPECTED_COVERAGE_OPTIONS.format( + # platform_root=self.platform_root, + # suite=suite + # ) + # if port: + # expected_test_tool_command += f" --port={port}" + # else: + # expected_test_tool_command = 'jest' + + # expected_messages.append(expected_test_tool_command) + + assert self.task_messages == expected_messages From a763287152bdff07267acd5b0d50decb100547b8 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Thu, 28 Sep 2023 16:05:15 +0500 Subject: [PATCH 010/170] chore: remove all reference for bok-choy --- .dockerignore | 1 - cms/envs/test_static_optimized.py | 4 ---- lms/envs/test_static_optimized.py | 4 ---- openedx/tests/xblock_integration/xblock_testcase.py | 2 +- scripts/generic-ci-tests.sh | 3 +-- 5 files changed, 2 insertions(+), 12 deletions(-) diff --git a/.dockerignore b/.dockerignore index e8f6e66311c7..1665783ba48e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -89,7 +89,6 @@ test_root/paver_logs/ test_root/uploads/ **/django-pyfs **/.tox/ -common/test/db_cache/bok_choy_*.yaml common/test/data/badges/*.png ### Installation artifacts diff --git a/cms/envs/test_static_optimized.py b/cms/envs/test_static_optimized.py index 61738c92548b..c92d9a7262ce 100644 --- a/cms/envs/test_static_optimized.py +++ b/cms/envs/test_static_optimized.py @@ -1,10 +1,6 @@ """ Settings used when generating static assets for use in tests. -For example, Bok Choy uses two different settings files: -1. test_static_optimized is used when invoking collectstatic -2. bok_choy is used when running CMS and LMS - Note: it isn't possible to have a single settings file, because Django doesn't support both generating static assets to a directory and also serving static from the same directory. diff --git a/lms/envs/test_static_optimized.py b/lms/envs/test_static_optimized.py index 5c9cf062083f..b57276b04036 100644 --- a/lms/envs/test_static_optimized.py +++ b/lms/envs/test_static_optimized.py @@ -1,10 +1,6 @@ """ Settings used when generating static assets for use in tests. -For example, Bok Choy uses two different settings files: -1. test_static_optimized is used when invoking collectstatic -2. bok_choy is used when running CMS and LMS - Note: it isn't possible to have a single settings file, because Django doesn't support both generating static assets to a directory and also serving static from the same directory. diff --git a/openedx/tests/xblock_integration/xblock_testcase.py b/openedx/tests/xblock_integration/xblock_testcase.py index e75ca9a63d41..a6a4ac67a427 100644 --- a/openedx/tests/xblock_integration/xblock_testcase.py +++ b/openedx/tests/xblock_integration/xblock_testcase.py @@ -71,7 +71,7 @@ class XBlockEventTestMixin: 2. assert_event_published verifies that an event of a given search specification was published. - The Mongo/bok_choy event tests in cohorts have nice examplars for + The Mongo event tests in cohorts have nice examplars for how such functionality might look. In the future, we would like to expand both search diff --git a/scripts/generic-ci-tests.sh b/scripts/generic-ci-tests.sh index 5aabf8fde4c2..f854a3e36cda 100755 --- a/scripts/generic-ci-tests.sh +++ b/scripts/generic-ci-tests.sh @@ -20,11 +20,10 @@ set -e # - "pavelib-unit": Run Python unit tests from the pavelib/lib directory # - "pavelib-js-unit": Run the JavaScript tests and the Python unit # tests from the pavelib/lib directory -# - "bok-choy": Run acceptance tests that use the bok-choy framework # # `SHARD` is a number indicating which subset of the tests to build. # -# For "bok-choy" and "lms-unit", the tests are put into shard groups +# For "lms-unit", the tests are put into shard groups # using the 'attr' decorator (e.g. "@attr(shard=1)"). Anything with # the 'shard=n' attribute will run in the nth shard. If there isn't a # shard explicitly assigned, the test will run in the last shard. From 3fc454c7e31fcccbd65726dec74e08bd25df5f71 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Thu, 28 Sep 2023 16:24:40 +0500 Subject: [PATCH 011/170] chore: remove bok-choy --- .github/workflows/static-assets-check.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/static-assets-check.yml b/.github/workflows/static-assets-check.yml index 7aa7dce78330..3e136e65699b 100644 --- a/.github/workflows/static-assets-check.yml +++ b/.github/workflows/static-assets-check.yml @@ -62,6 +62,11 @@ jobs: - name: Add node_modules bin to $Path run: echo $GITHUB_WORKSPACE/node_modules/.bin >> $GITHUB_PATH + - name: Run Static Assets Check + env: + LMS_CFG: lms/envs/minimal.yml + CMS_CFG: cms/envs/minimal.yml + run: | paver update_assets lms paver update_assets cms From 3ecf2b9a554bfccf7665d038e85d8fcda823ad98 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Thu, 28 Sep 2023 16:25:45 +0500 Subject: [PATCH 012/170] chore: remove bok-choy --- .github/workflows/static-assets-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/static-assets-check.yml b/.github/workflows/static-assets-check.yml index 3e136e65699b..db8b9ded2172 100644 --- a/.github/workflows/static-assets-check.yml +++ b/.github/workflows/static-assets-check.yml @@ -66,7 +66,7 @@ jobs: env: LMS_CFG: lms/envs/minimal.yml CMS_CFG: cms/envs/minimal.yml - + run: | paver update_assets lms paver update_assets cms From d668af2fce52562a3ff178d143306045d560038a Mon Sep 17 00:00:00 2001 From: salman2013 Date: Mon, 2 Oct 2023 16:04:33 +0500 Subject: [PATCH 013/170] chore: fix comments, remove and add some code for karma --- common/djangoapps/terrain/stubs/lti.py | 4 +- .../static/common/js/jasmine.common.conf.js | 12 + .../static/common/js/jasmine_stack_trace.js | 29 ++ common/static/common/js/karma.common.conf.js | 415 ++++++++++++++++++ .../0004-managing-django-settings.rst | 1 + .../content_type_gating/tests/test_access.py | 2 +- .../pytest_plugin.py | 36 +- pavelib/paver_tests/test_js_test.py | 48 +- pavelib/utils/envs.py | 29 +- tox.ini | 6 +- 10 files changed, 514 insertions(+), 68 deletions(-) create mode 100644 common/static/common/js/jasmine.common.conf.js create mode 100644 common/static/common/js/jasmine_stack_trace.js create mode 100644 common/static/common/js/karma.common.conf.js diff --git a/common/djangoapps/terrain/stubs/lti.py b/common/djangoapps/terrain/stubs/lti.py index b3518f22cf25..158bf860da52 100644 --- a/common/djangoapps/terrain/stubs/lti.py +++ b/common/djangoapps/terrain/stubs/lti.py @@ -78,7 +78,7 @@ def do_POST(self): 'callback_url': self.post_dict.get('lis_outcome_service_url').replace('https', 'http'), 'sourcedId': self.post_dict.get('lis_result_sourcedid') } - host = os.environ.get(self.server.server_address[0]) + host = self.server.server_address[0] submit_url = f'//{host}:{self.server.server_address[1]}' content = self._create_content(status_message, submit_url) self.send_response(200, content) @@ -296,7 +296,7 @@ def _check_oauth_signature(self, params, client_signature): """ client_secret = str(self.server.config.get('client_secret', self.DEFAULT_CLIENT_SECRET)) - host = os.environ.get('127.0.0.1') + host = '127.0.0.1' port = self.server.server_address[1] lti_base = self.DEFAULT_LTI_ADDRESS.format(host=host, port=port) lti_endpoint = self.server.config.get('lti_endpoint', self.DEFAULT_LTI_ENDPOINT) diff --git a/common/static/common/js/jasmine.common.conf.js b/common/static/common/js/jasmine.common.conf.js new file mode 100644 index 000000000000..d6d7f7977380 --- /dev/null +++ b/common/static/common/js/jasmine.common.conf.js @@ -0,0 +1,12 @@ +/* eslint-env node */ + +'use strict'; + +// By default, fixtures are loaded from spec/javascripts/fixtures but in karma everything gets served from /base +jasmine.getFixtures().fixturesPath = '/base/'; + +// https://github.com/edx/js-test-tool/blob/master/js_test_tool/templates/jasmine_test_runner.html#L10 +// Stub out modal dialog alerts, which will prevent +// us from accessing the test results in the DOM +window.confirm = function() { return true; }; +window.alert = function() { }; diff --git a/common/static/common/js/jasmine_stack_trace.js b/common/static/common/js/jasmine_stack_trace.js new file mode 100644 index 000000000000..f61d591f0a43 --- /dev/null +++ b/common/static/common/js/jasmine_stack_trace.js @@ -0,0 +1,29 @@ +/* This file overrides ExceptionFormatter of jasmine before it's initialization in karma-jasmine's + boot.js. It's important because ExceptionFormatter returns a constructor function. Once the method has been + initialized we can't override the ExceptionFormatter as Jasmine then uses the stored reference to the function */ +(function() { + /* globals jasmineRequire */ + + 'use strict'; + + var OldExceptionFormatter = jasmineRequire.ExceptionFormatter(), + oldExceptionFormatter = new OldExceptionFormatter(), + MAX_STACK_TRACE_LINES = 10; + + jasmineRequire.ExceptionFormatter = function() { + function ExceptionFormatter() { + this.message = oldExceptionFormatter.message; + this.stack = function(error) { + var errorMsg = null; + + if (error) { + errorMsg = error.stack.split('\n').slice(0, MAX_STACK_TRACE_LINES).join('\n'); + } + + return errorMsg; + }; + } + + return ExceptionFormatter; + }; +}()); diff --git a/common/static/common/js/karma.common.conf.js b/common/static/common/js/karma.common.conf.js new file mode 100644 index 000000000000..274d4efa7e8b --- /dev/null +++ b/common/static/common/js/karma.common.conf.js @@ -0,0 +1,415 @@ +// Common settings and helpers for setting up Karma config. +// +// To run all the tests in a suite and print results to the console: +// +// karma start +// E.g. karma start lms/static/karma_lms.conf.js +// +// +// To run the tests for debugging: Debugging can be done in any browser +// but Chrome's developer console debugging experience is best. +// +// karma start --browsers=BROWSER --single-run=false +// +// +// To run the tests with coverage and junit reports: +// +// karma start --browsers=BROWSER +// --coverage --junitreportpath= --coveragereportpath= +// +// where `BROWSER` could be Chrome or Firefox. +// +// +// Troubleshooting tips: +// +// If you get an error like: "TypeError: __cov_KBCc7ZI4xZm8W2BC5NQLDg.s is undefined", +// that means the patterns in sourceFiles and specFiles are matching the same file. +// This causes Istanbul, which is used for tracking coverage to instrument the file +// multiple times. +// +// +// If you see the error: "EMFILE, too many open files" that means the files pattern +// that has been added is matching too many files. The glob library used by Karma +// does not use graceful-fs and tries to read files simultaneously. +// + +/* eslint-env node */ +/* globals process */ + +'use strict'; + +var path = require('path'); +var _ = require('underscore'); + +var appRoot = path.join(__dirname, '../../../../'); +// eslint-disable-next-line import/no-extraneous-dependencies +var webdriver = require('selenium-webdriver'); +// eslint-disable-next-line import/no-extraneous-dependencies + +var webpackConfig = require(path.join(appRoot, 'webpack.dev.config.js')); + +// The following crazy bit is to work around the webpack.optimize.CommonsChunkPlugin +// plugin. The problem is that it it factors out the code that defines webpackJsonp +// and puts in in the commons JS, which Karma doesn't know to load first. This is a +// workaround recommended in the karma-webpack bug report that basically just removes +// the plugin for the purposes of Karma testing (the plugin is meant to be an +// optimization only). +// https://github.com/webpack-contrib/karma-webpack/issues/24#issuecomment-257613167 +// +// This should be fixed in v3 of karma-webpack +var commonsChunkPluginIndex = webpackConfig[0].plugins.findIndex(function(plugin) { return plugin.chunkNames; }); + +// Files which are needed by all lms/cms suites. +var commonFiles = { + libraryFiles: [ + {pattern: 'common/js/vendor/**/*.js'}, + {pattern: 'edx-ui-toolkit/js/**/*.js'}, + {pattern: 'xmodule_js/common_static/common/js/**/!(*spec).js'}, + {pattern: 'xmodule_js/common_static/js/**/!(*spec).js'}, + {pattern: 'xmodule_js/src/**/*.js'} + ], + + sourceFiles: [ + {pattern: 'common/js/!(spec_helpers)/**/!(*spec).js'} + ], + + specFiles: [ + {pattern: 'common/js/spec_helpers/**/*.js'} + ], + + fixtureFiles: [ + {pattern: 'common/templates/**/*.underscore'} + ] +}; + +webpackConfig[0].plugins.splice(commonsChunkPluginIndex, 1); + +delete webpackConfig[0].entry; + +/** + * Customize the name attribute in xml testcase element + * @param {Object} browser + * @param {Object} result + * @return {String} + */ +function junitNameFormatter(browser, result) { + return result.suite[0] + ': ' + result.description; +} + +/** + * Customize the classname attribute in xml testcase element + * @param {Object} browser + * @return {String} + */ +function junitClassNameFormatter(browser) { + return 'Javascript.' + browser.name.split(' ')[0]; +} + +/** + * Return array containing default and user supplied reporters + * @param {Object} config + * @return {Array} + */ +function reporters(config) { + var defaultReporters = ['spec', 'junit', 'kjhtml']; + if (config.coverage) { + defaultReporters.push('coverage'); + } + return defaultReporters; +} + +/** + * Split a filepath into basepath and filename + * @param {String} filepath + * @return {Object} + */ +function getBasepathAndFilename(filepath) { + var file, dir; + + if (!filepath) { + // these will configure the reporters to create report files relative to this karma config file + return { + dir: undefined, + file: undefined + }; + } + file = filepath.replace(/^.*[\\/]/, ''); + dir = filepath.replace(file, ''); + + return { + dir: dir, + file: file + }; +} + +/** + * Return coverage reporter settings + * @param {String} config + * @return {Object} + */ +function coverageSettings(config) { + var pth = getBasepathAndFilename(config.coveragereportpath); + return { + dir: pth.dir, + subdir: '.', + includeAllSources: true, + reporters: [ + {type: 'cobertura', file: pth.file}, + {type: 'text-summary'} + ] + }; +} + +/** + * Return junit reporter settings + * @param {String} config + * @return {Object} + */ +function junitSettings(config) { + var pth = getBasepathAndFilename(config.junitreportpath); + return { + outputDir: pth.dir, + outputFile: pth.file, + suite: 'javascript', + useBrowserName: false, + nameFormatter: junitNameFormatter, + classNameFormatter: junitClassNameFormatter + }; +} + +/** + * Return absolute path for files in common and xmodule_js symlink dirs. + * @param {String} appRoot + * @param {String} pattern + * @return {String} + */ +// I'd like to fix the no-shadow violation on the next line, but it would break this shared conf's API. +function defaultNormalizeFunc(appRoot, pattern) { // eslint-disable-line no-shadow + var pat = pattern; + if (pat.match(/^common\/js/)) { + pat = path.join(appRoot, '/common/static/' + pat); + } else if (pat.match(/^xmodule_js\/common_static/)) { + pat = path.join(appRoot, '/common/static/' + + pat.replace(/^xmodule_js\/common_static\//, '')); + } + return pat; +} + +function normalizePathsForCoverage(files, normalizeFunc, preprocessors) { + var normalizeFn = normalizeFunc || defaultNormalizeFunc, + normalizedFile, + filesForCoverage = {}; + + files.forEach(function(file) { + if (!file.ignoreCoverage) { + normalizedFile = normalizeFn(appRoot, file.pattern); + if (preprocessors && preprocessors.hasOwnProperty(normalizedFile)) { + filesForCoverage[normalizedFile] = ['coverage'].concat(preprocessors[normalizedFile]); + } else { + filesForCoverage[normalizedFile] = ['coverage']; + } + } + }); + + return filesForCoverage; +} + +/** + * Sets defaults for each file pattern. + * RequireJS files are excluded by default. + * Webpack files are included by default. + * @param {Object} files + * @return {Object} + */ +function setDefaults(files) { + return files.map(function(f) { + var file = _.isObject(f) ? f : {pattern: f}; + if (!file.included && !file.webpack) { + file.included = false; + } + return file; + }); +} + +function getBaseConfig(config, useRequireJs) { + var getFrameworkFiles = function() { + var files = [ + 'common/static/common/js/vendor/jquery.js', + 'node_modules/jasmine-core/lib/jasmine-core/jasmine.js', + 'common/static/common/js/jasmine_stack_trace.js', + 'node_modules/karma-jasmine/lib/boot.js', + 'node_modules/karma-jasmine/lib/adapter.js', + 'node_modules/jasmine-jquery/lib/jasmine-jquery.js', + 'node_modules/popper.js/dist/umd/popper.js', + 'node_modules/bootstrap/dist/js/bootstrap.js', + 'node_modules/underscore/underscore.js', + 'node_modules/backbone/backbone.js', + 'common/static/js/test/i18n.js' + ]; + + if (useRequireJs) { + files = files.concat([ + 'node_modules/requirejs/require.js', + 'node_modules/karma-requirejs/lib/adapter.js' + ]); + } + + return files; + }; + + // Manually prepends the framework files to the karma files array + // bypassing the karma's framework config. This is necessary if you want + // to add a library or framework that isn't a karma plugin. e.g. we add jasmine-jquery + // which isn't a karma plugin. Though a karma framework for jasmine-jquery is available + // but it's not actively maintained. In future we also wanna add jQuery at the top when + // we upgrade to jQuery 2 + var initFrameworks = function(files) { + getFrameworkFiles().reverse().forEach(function(f) { + files.unshift({ + pattern: path.join(appRoot, f), + included: true, + served: true, + watch: false + }); + }); + }; + + var hostname = 'localhost'; + var port = 9876; + var customPlugin = { + 'framework:custom': ['factory', initFrameworks] + }; + + initFrameworks.$inject = ['config.files']; + + return { + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['custom'], + + plugins: [ + 'karma-jasmine', + 'karma-jasmine-html-reporter', + 'karma-requirejs', + 'karma-junit-reporter', + 'karma-coverage', + 'karma-spec-reporter', + 'karma-selenium-webdriver-launcher', + 'karma-webpack', + 'karma-sourcemap-loader', + customPlugin + ], + + // list of files to exclude + exclude: [], + + // karma-reporter + reporters: reporters(config), + + // Spec Reporter configuration + specReporter: { + maxLogLines: 5, + showSpecTiming: true + }, + + coverageReporter: coverageSettings(config), + + junitReporter: junitSettings(config), + + // web server hostname and port + hostname: hostname, + port: port, + + // enable / disable colors in the output (reporters and logs) + colors: true, + + // level of logging + /* possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN + || config.LOG_INFO || config.LOG_DEBUG */ + logLevel: config.LOG_INFO, + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: false, + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: config.singleRun, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: Infinity, + + browserNoActivityTimeout: 50000, + + client: { + captureConsole: false + }, + + webpack: webpackConfig[0], + + webpackMiddleware: { + watchOptions: { + poll: true + } + } + }; +} + +function configure(config, options) { + var useRequireJs = options.useRequireJs === undefined ? true : options.useRequireJs, + baseConfig = getBaseConfig(config, useRequireJs), + files, filesForCoverage, preprocessors; + + if (options.includeCommonFiles) { + _.forEach(['libraryFiles', 'sourceFiles', 'specFiles', 'fixtureFiles'], function(collectionName) { + options[collectionName] = _.flatten([commonFiles[collectionName], options[collectionName]]); + }); + } + + files = _.flatten( + _.map( + ['libraryFilesToInclude', 'libraryFiles', 'sourceFiles', 'specFiles', 'fixtureFiles', 'runFiles'], + function(collectionName) { return options[collectionName] || []; } + ) + ); + + files.unshift( + {pattern: path.join(appRoot, 'common/static/common/js/jasmine.common.conf.js'), included: true} + ); + + if (useRequireJs) { + files.unshift({pattern: 'common/js/utils/require-serial.js', included: true}); + } + + // Karma sets included=true by default. + // We set it to false by default because RequireJS should be used instead. + files = setDefaults(files); + + filesForCoverage = _.flatten( + _.map( + ['sourceFiles', 'specFiles'], + function(collectionName) { return options[collectionName]; } + ) + ); + + // If we give symlink paths to Istanbul, coverage for each path gets tracked + // separately. So we pass absolute paths to the karma-coverage preprocessor. + preprocessors = _.extend( + {}, + options.preprocessors, + normalizePathsForCoverage(filesForCoverage, options.normalizePathsForCoverageFunc, options.preprocessors) + ); + + config.set(_.extend(baseConfig, { + files: files, + preprocessors: preprocessors + })); +} + +module.exports = { + configure: configure, + appRoot: appRoot +}; diff --git a/docs/decisions/0004-managing-django-settings.rst b/docs/decisions/0004-managing-django-settings.rst index bf5698af3992..6da93a76163e 100644 --- a/docs/decisions/0004-managing-django-settings.rst +++ b/docs/decisions/0004-managing-django-settings.rst @@ -58,6 +58,7 @@ and for all environments to use __init__.py to load their settings. The following files should be obviated by this change: +* bok_choy_docker.py * devstack_docker.py * devstack_optimized.py * devstack.py diff --git a/openedx/features/content_type_gating/tests/test_access.py b/openedx/features/content_type_gating/tests/test_access.py index 53582df34a4b..3ad9ab2757ae 100644 --- a/openedx/features/content_type_gating/tests/test_access.py +++ b/openedx/features/content_type_gating/tests/test_access.py @@ -228,7 +228,7 @@ def setUpClass(cls): graded=False, ) cls.graded_score_weight_blocks[(graded, has_score, weight)] = block - host = os.environ.get('127.0.0.1') + host = '127.0.0.1' metadata_lti_xblock = { 'lti_id': 'correct_lti_id', 'launch_url': 'http://{}:{}/{}'.format(host, '8765', 'correct_lti_endpoint'), diff --git a/openedx/testing/coverage_context_listener/pytest_plugin.py b/openedx/testing/coverage_context_listener/pytest_plugin.py index 355c5abc0ecd..13325163080f 100644 --- a/openedx/testing/coverage_context_listener/pytest_plugin.py +++ b/openedx/testing/coverage_context_listener/pytest_plugin.py @@ -13,26 +13,16 @@ def __init__(self, config): self.config = config self.active = config.getoption("pytest-contexts") - def pytest_runtest_setup(self, item): - self.doit(item, "setup") - - def pytest_runtest_teardown(self, item): - self.doit(item, "teardown") - - def pytest_runtest_call(self, item): - self.doit(item, "call") - - -@pytest.hookimpl(tryfirst=True) -def pytest_configure(config): - config.pluginmanager.register(RemoteContextPlugin(config), "remotecontextplugin") - - -def pytest_addoption(parser): - group = parser.getgroup("coverage") - group.addoption( - "--pytest-remote-contexts", - action="store_true", - dest="pytest-contexts", - help="Capture the pytest contexts that coverage is being captured in in another process", - ) + @pytest.hookimpl(tryfirst=True) + def pytest_configure(config): + config.pluginmanager.register(RemoteContextPlugin(config), "remotecontextplugin") + + + def pytest_addoption(parser): + group = parser.getgroup("coverage") + group.addoption( + "--pytest-remote-contexts", + action="store_true", + dest="pytest-contexts", + help="Capture the pytest contexts that coverage is being captured in in another process", + ) diff --git a/pavelib/paver_tests/test_js_test.py b/pavelib/paver_tests/test_js_test.py index 2180d28d4579..c6860e127a71 100644 --- a/pavelib/paver_tests/test_js_test.py +++ b/pavelib/paver_tests/test_js_test.py @@ -122,29 +122,29 @@ def verify_messages(self, options, dev_mode): 'node --max_old_space_size=4096 node_modules/.bin/karma start {options}' ) - # for suite in suites: - # # Karma test command - # if suite != 'jest-snapshot': - # karma_config_file = Env.KARMA_CONFIG_FILES[Env.JS_TEST_ID_KEYS.index(suite)] - # expected_test_tool_command = command_template.format( - # options=self.EXPECTED_KARMA_OPTIONS.format( - # config_file=karma_config_file, - # single_run='false' if dev_mode else 'true', - # suite=suite, - # platform_root=self.platform_root, - # browser=Env.KARMA_BROWSER, - # ), - # ) - # if is_coverage: - # expected_test_tool_command += self.EXPECTED_COVERAGE_OPTIONS.format( - # platform_root=self.platform_root, - # suite=suite - # ) - # if port: - # expected_test_tool_command += f" --port={port}" - # else: - # expected_test_tool_command = 'jest' - - # expected_messages.append(expected_test_tool_command) + for suite in suites: + # Karma test command + if suite != 'jest-snapshot': + karma_config_file = Env.KARMA_CONFIG_FILES[Env.JS_TEST_ID_KEYS.index(suite)] + expected_test_tool_command = command_template.format( + options=self.EXPECTED_KARMA_OPTIONS.format( + config_file=karma_config_file, + single_run='false' if dev_mode else 'true', + suite=suite, + platform_root=self.platform_root, + browser=Env.KARMA_BROWSER, + ), + ) + if is_coverage: + expected_test_tool_command += self.EXPECTED_COVERAGE_OPTIONS.format( + platform_root=self.platform_root, + suite=suite + ) + if port: + expected_test_tool_command += f" --port={port}" + else: + expected_test_tool_command = 'jest' + + expected_messages.append(expected_test_tool_command) assert self.task_messages == expected_messages diff --git a/pavelib/utils/envs.py b/pavelib/utils/envs.py index ca7ec0f4c617..40b616571ee6 100644 --- a/pavelib/utils/envs.py +++ b/pavelib/utils/envs.py @@ -77,34 +77,33 @@ class Env: PRINT_SETTINGS_LOG_FILE = GEN_LOG_DIR / "print_settings.log" # Detect if in a Docker container, and if so which one - SERVER_HOST = os.environ.get('0.0.0.0') - USING_DOCKER = SERVER_HOST != '0.0.0.0' - DEVSTACK_SETTINGS = 'devstack_docker' if USING_DOCKER else 'devstack' + # USING_DOCKER = SERVER_HOST != '0.0.0.0' + DEVSTACK_SETTINGS = 'devstack' TEST_SETTINGS = 'test' # Test Ids Directory TEST_DIR = REPO_ROOT / ".testids" # Configured browser to use for the js test suites - # SELENIUM_BROWSER = os.environ.get('SELENIUM_BROWSER', 'firefox') + SELENIUM_BROWSER = os.environ.get('SELENIUM_BROWSER', 'firefox') # if USING_DOCKER: # KARMA_BROWSER = 'ChromeDocker' if SELENIUM_BROWSER == 'chrome' else 'FirefoxDocker' # else: - # KARMA_BROWSER = 'FirefoxNoUpdates' + KARMA_BROWSER = 'FirefoxNoUpdates' # Files used to run each of the js test suites # TODO: Store this as a dict. Order seems to matter for some # reason. See issue TE-415. - # KARMA_CONFIG_FILES = [ - # REPO_ROOT / 'cms/static/karma_cms.conf.js', - # REPO_ROOT / 'cms/static/karma_cms_squire.conf.js', - # REPO_ROOT / 'cms/static/karma_cms_webpack.conf.js', - # REPO_ROOT / 'lms/static/karma_lms.conf.js', - # REPO_ROOT / 'xmodule/js/karma_xmodule.conf.js', - # REPO_ROOT / 'xmodule/js/karma_xmodule_webpack.conf.js', - # REPO_ROOT / 'common/static/karma_common.conf.js', - # REPO_ROOT / 'common/static/karma_common_requirejs.conf.js', - # ] + KARMA_CONFIG_FILES = [ + REPO_ROOT / 'cms/static/karma_cms.conf.js', + REPO_ROOT / 'cms/static/karma_cms_squire.conf.js', + REPO_ROOT / 'cms/static/karma_cms_webpack.conf.js', + REPO_ROOT / 'lms/static/karma_lms.conf.js', + REPO_ROOT / 'xmodule/js/karma_xmodule.conf.js', + REPO_ROOT / 'xmodule/js/karma_xmodule_webpack.conf.js', + REPO_ROOT / 'common/static/karma_common.conf.js', + REPO_ROOT / 'common/static/karma_common_requirejs.conf.js', + ] JS_TEST_ID_KEYS = [ 'cms', diff --git a/tox.ini b/tox.ini index cacd77ea0ba6..ce00efa87092 100644 --- a/tox.ini +++ b/tox.ini @@ -40,9 +40,9 @@ passenv = NPM_CONFIG_PREFIX PYTHON_VERSION SCRAPY_SETTINGS_MODULE - #SELENIUM_BROWSER - #SELENIUM_HOST - #SELENIUM_PORT + SELENIUM_BROWSER + SELENIUM_HOST + SELENIUM_PORT SHARD SKIP_NPM_INSTALL SSH_AUTH_SOCK From 74a4c88c3d0ff82c073f9d5034985fa0f6506c0a Mon Sep 17 00:00:00 2001 From: salman2013 Date: Mon, 2 Oct 2023 16:51:12 +0500 Subject: [PATCH 014/170] chore: fix tests --- .github/workflows/static-assets-check.yml | 2 +- openedx/testing/coverage_context_listener/pytest_plugin.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/static-assets-check.yml b/.github/workflows/static-assets-check.yml index db8b9ded2172..bec7349fe34e 100644 --- a/.github/workflows/static-assets-check.yml +++ b/.github/workflows/static-assets-check.yml @@ -65,7 +65,7 @@ jobs: - name: Run Static Assets Check env: LMS_CFG: lms/envs/minimal.yml - CMS_CFG: cms/envs/minimal.yml + CMS_CFG: lms/envs/minimal.yml run: | paver update_assets lms diff --git a/openedx/testing/coverage_context_listener/pytest_plugin.py b/openedx/testing/coverage_context_listener/pytest_plugin.py index 13325163080f..28fd90fc6aa3 100644 --- a/openedx/testing/coverage_context_listener/pytest_plugin.py +++ b/openedx/testing/coverage_context_listener/pytest_plugin.py @@ -17,7 +17,6 @@ def __init__(self, config): def pytest_configure(config): config.pluginmanager.register(RemoteContextPlugin(config), "remotecontextplugin") - def pytest_addoption(parser): group = parser.getgroup("coverage") group.addoption( From 683145156bed229e08659f2f2abcf002ba46136a Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Thu, 28 Sep 2023 15:16:21 -0400 Subject: [PATCH 015/170] feat: Update the minimum password length. --- cms/envs/common.py | 21 +++------------------ lms/envs/common.py | 2 +- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/cms/envs/common.py b/cms/envs/common.py index 2021d372bcc7..90227b44666f 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -121,6 +121,9 @@ # Methods to derive settings _make_mako_template_dirs, _make_locale_paths, + + # Password Validator Settings + AUTH_PASSWORD_VALIDATORS ) from path import Path as path from django.urls import reverse_lazy @@ -1878,24 +1881,6 @@ EVENT_TRACKING_SEGMENTIO_EMIT_WHITELIST = [] #### PASSWORD POLICY SETTINGS ##### -AUTH_PASSWORD_VALIDATORS = [ - { - "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", - }, - { - "NAME": "common.djangoapps.util.password_policy_validators.MinimumLengthValidator", - "OPTIONS": { - "min_length": 2 - } - }, - { - "NAME": "common.djangoapps.util.password_policy_validators.MaximumLengthValidator", - "OPTIONS": { - "max_length": 75 - } - }, -] - PASSWORD_POLICY_COMPLIANCE_ROLLOUT_CONFIG = { 'ENFORCE_COMPLIANCE_ON_LOGIN': False } diff --git a/lms/envs/common.py b/lms/envs/common.py index 2c12037e921b..e5089e86b0b2 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -3756,7 +3756,7 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring { "NAME": "common.djangoapps.util.password_policy_validators.MinimumLengthValidator", "OPTIONS": { - "min_length": 2 + "min_length": 8 } }, { From ae42b094eaed70c3d8206e55a17e7a814cbaf2e2 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Thu, 28 Sep 2023 16:01:13 -0400 Subject: [PATCH 016/170] test: Fix validation tests. Make them resilient to the default changing where it makes sense. --- common/djangoapps/student/tests/test_email.py | 2 +- .../tests/test_password_policy_validators.py | 16 +++++++++++++--- .../user_authn/views/tests/test_register.py | 14 ++++++++++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/common/djangoapps/student/tests/test_email.py b/common/djangoapps/student/tests/test_email.py index 7f1287fba048..f39591c77945 100644 --- a/common/djangoapps/student/tests/test_email.py +++ b/common/djangoapps/student/tests/test_email.py @@ -136,7 +136,7 @@ def _create_account(self): params = { 'username': 'test_user', 'email': 'test_user@example.com', - 'password': 'edx', + 'password': 'long_password', 'name': 'Test User', 'honor_code': True, 'terms_of_service': True diff --git a/common/djangoapps/util/tests/test_password_policy_validators.py b/common/djangoapps/util/tests/test_password_policy_validators.py index f0ffe3c2b178..f5eea255bff2 100644 --- a/common/djangoapps/util/tests/test_password_policy_validators.py +++ b/common/djangoapps/util/tests/test_password_policy_validators.py @@ -45,6 +45,11 @@ def validation_errors_checker(self, password, msg, user=None): validate_password(password, user) assert msg in ' '.join(cm.value.messages) + @override_settings(AUTH_PASSWORD_VALIDATORS=[ + create_validator_config( + 'common.djangoapps.util.password_policy_validators.MinimumLengthValidator', {'min_length': 4} + ) + ]) def test_unicode_password(self): """ Tests that validate_password enforces unicode """ unicode_str = '𤭮' @@ -55,12 +60,17 @@ def test_unicode_password(self): assert len(unicode_str) == 1 # Test length check - self.validation_errors_checker(byte_str, 'This password is too short. It must contain at least 2 characters.') - self.validation_errors_checker(byte_str + byte_str, None) + self.validation_errors_checker(byte_str, 'This password is too short. It must contain at least 4 characters.') + self.validation_errors_checker(byte_str * 4, None) # Test badly encoded password self.validation_errors_checker(b'\xff\xff', 'Invalid password.') + @override_settings(AUTH_PASSWORD_VALIDATORS=[ + create_validator_config( + 'common.djangoapps.util.password_policy_validators.MinimumLengthValidator', {'min_length': 4} + ) + ]) def test_password_unicode_normalization(self): """ Tests that validate_password normalizes passwords """ # s ̣ ̇ (s with combining dot below and combining dot above) @@ -70,7 +80,7 @@ def test_password_unicode_normalization(self): # When we normalize we expect the not_normalized password to fail # because it should be normalized to '\u1E69' -> ṩ self.validation_errors_checker(not_normalized_password, - 'This password is too short. It must contain at least 2 characters.') + 'This password is too short. It must contain at least 4 characters.') @data( ([create_validator_config('common.djangoapps.util.password_policy_validators.MinimumLengthValidator', {'min_length': 2})], # lint-amnesty, pylint: disable=line-too-long diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_register.py b/openedx/core/djangoapps/user_authn/views/tests/test_register.py index 0bc05545f775..8e73ab2ec3c9 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_register.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_register.py @@ -2689,20 +2689,30 @@ def test_username_invalid_ascii_validation_decision(self, username): {"username": str(USERNAME_INVALID_CHARS_ASCII)} ) + @override_settings(AUTH_PASSWORD_VALIDATORS=[ + create_validator_config( + 'common.djangoapps.util.password_policy_validators.MinimumLengthValidator', {'min_length': 4} + ) + ]) def test_password_empty_validation_decision(self): # 2 is the default setting for minimum length found in lms/envs/common.py # under AUTH_PASSWORD_VALIDATORS.MinimumLengthValidator - msg = 'This password is too short. It must contain at least 2 characters.' + msg = 'This password is too short. It must contain at least 4 characters.' self.assertValidationDecision( {'password': ''}, {"password": msg} ) + @override_settings(AUTH_PASSWORD_VALIDATORS=[ + create_validator_config( + 'common.djangoapps.util.password_policy_validators.MinimumLengthValidator', {'min_length': 4} + ) + ]) def test_password_bad_min_length_validation_decision(self): password = 'p' # 2 is the default setting for minimum length found in lms/envs/common.py # under AUTH_PASSWORD_VALIDATORS.MinimumLengthValidator - msg = 'This password is too short. It must contain at least 2 characters.' + msg = 'This password is too short. It must contain at least 4 characters.' self.assertValidationDecision( {'password': password}, {"password": msg} From 65d3b1084ba22de992e09f2000ee332472152a97 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Tue, 3 Oct 2023 00:11:23 +0500 Subject: [PATCH 017/170] chore: fix test cases --- common/djangoapps/terrain/stubs/lti.py | 1 - .../pytest_plugin.py | 29 +++++++++++-------- pavelib/paver_tests/test_js_test.py | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/common/djangoapps/terrain/stubs/lti.py b/common/djangoapps/terrain/stubs/lti.py index 158bf860da52..46535abb9f80 100644 --- a/common/djangoapps/terrain/stubs/lti.py +++ b/common/djangoapps/terrain/stubs/lti.py @@ -13,7 +13,6 @@ import base64 import hashlib import logging -import os import textwrap from unittest import mock from uuid import uuid4 diff --git a/openedx/testing/coverage_context_listener/pytest_plugin.py b/openedx/testing/coverage_context_listener/pytest_plugin.py index 28fd90fc6aa3..6ed194b91bb1 100644 --- a/openedx/testing/coverage_context_listener/pytest_plugin.py +++ b/openedx/testing/coverage_context_listener/pytest_plugin.py @@ -3,6 +3,9 @@ """ import pytest +# import requests + +# from pavelib.utils.envs import Env class RemoteContextPlugin: @@ -13,15 +16,17 @@ def __init__(self, config): self.config = config self.active = config.getoption("pytest-contexts") - @pytest.hookimpl(tryfirst=True) - def pytest_configure(config): - config.pluginmanager.register(RemoteContextPlugin(config), "remotecontextplugin") - - def pytest_addoption(parser): - group = parser.getgroup("coverage") - group.addoption( - "--pytest-remote-contexts", - action="store_true", - dest="pytest-contexts", - help="Capture the pytest contexts that coverage is being captured in in another process", - ) + +@pytest.hookimpl(tryfirst=True) +def pytest_configure(config): + config.pluginmanager.register(RemoteContextPlugin(config), "remotecontextplugin") + + +def pytest_addoption(parser): + group = parser.getgroup("coverage") + group.addoption( + "--pytest-remote-contexts", + action="store_true", + dest="pytest-contexts", + help="Capture the pytest contexts that coverage is being captured in in another process", + ) diff --git a/pavelib/paver_tests/test_js_test.py b/pavelib/paver_tests/test_js_test.py index c6860e127a71..9d89a944448f 100644 --- a/pavelib/paver_tests/test_js_test.py +++ b/pavelib/paver_tests/test_js_test.py @@ -127,7 +127,7 @@ def verify_messages(self, options, dev_mode): if suite != 'jest-snapshot': karma_config_file = Env.KARMA_CONFIG_FILES[Env.JS_TEST_ID_KEYS.index(suite)] expected_test_tool_command = command_template.format( - options=self.EXPECTED_KARMA_OPTIONS.format( + options=self.EXPECTED_KARMA_OPTIONS.format( config_file=karma_config_file, single_run='false' if dev_mode else 'true', suite=suite, From 4dbefe33f4b2aba025f689ef95c56c3dace1461e Mon Sep 17 00:00:00 2001 From: salman2013 Date: Tue, 3 Oct 2023 08:59:21 +0500 Subject: [PATCH 018/170] chore: fix tests --- openedx/features/content_type_gating/tests/test_access.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openedx/features/content_type_gating/tests/test_access.py b/openedx/features/content_type_gating/tests/test_access.py index 3ad9ab2757ae..c42a530e3ccf 100644 --- a/openedx/features/content_type_gating/tests/test_access.py +++ b/openedx/features/content_type_gating/tests/test_access.py @@ -1,7 +1,6 @@ """ Test audit user's access to various content based on content-gating features. """ -import os from datetime import datetime, timedelta from unittest.mock import patch, Mock From 70eafef79842b0916298f5a089b5b432432a4e16 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Wed, 4 Oct 2023 15:28:49 +0500 Subject: [PATCH 019/170] chore: fixed comments as per review, code improvements --- .../pytest_plugin.py | 3 - pavelib/utils/envs.py | 4 - pavelib/utils/test/suites/js_suite.py | 114 +++++++++--------- 3 files changed, 57 insertions(+), 64 deletions(-) diff --git a/openedx/testing/coverage_context_listener/pytest_plugin.py b/openedx/testing/coverage_context_listener/pytest_plugin.py index 6ed194b91bb1..a3679027e888 100644 --- a/openedx/testing/coverage_context_listener/pytest_plugin.py +++ b/openedx/testing/coverage_context_listener/pytest_plugin.py @@ -3,9 +3,6 @@ """ import pytest -# import requests - -# from pavelib.utils.envs import Env class RemoteContextPlugin: diff --git a/pavelib/utils/envs.py b/pavelib/utils/envs.py index 40b616571ee6..4cfbec7790ff 100644 --- a/pavelib/utils/envs.py +++ b/pavelib/utils/envs.py @@ -85,10 +85,6 @@ class Env: TEST_DIR = REPO_ROOT / ".testids" # Configured browser to use for the js test suites - SELENIUM_BROWSER = os.environ.get('SELENIUM_BROWSER', 'firefox') - # if USING_DOCKER: - # KARMA_BROWSER = 'ChromeDocker' if SELENIUM_BROWSER == 'chrome' else 'FirefoxDocker' - # else: KARMA_BROWSER = 'FirefoxNoUpdates' # Files used to run each of the js test suites diff --git a/pavelib/utils/test/suites/js_suite.py b/pavelib/utils/test/suites/js_suite.py index 40f491f5d67f..d96d95f39cfe 100644 --- a/pavelib/utils/test/suites/js_suite.py +++ b/pavelib/utils/test/suites/js_suite.py @@ -39,63 +39,63 @@ def __enter__(self): if self.mode == 'run' and not self.run_under_coverage: test_utils.clean_dir(self.report_dir) - # @property - # def _default_subsuites(self): - # """ - # Returns all JS test suites - # """ - # return [JsTestSubSuite(test_id, **self.opts) for test_id in Env.JS_TEST_ID_KEYS if test_id != 'jest-snapshot'] - - -# class JsTestSubSuite(TestSuite): -# """ -# Class for JS suites like cms, cms-squire, lms, common, -# common-requirejs and xmodule -# """ -# def __init__(self, *args, **kwargs): -# super().__init__(*args, **kwargs) -# self.test_id = args[0] -# self.run_under_coverage = kwargs.get('with_coverage', True) -# self.mode = kwargs.get('mode', 'run') -# self.port = kwargs.get('port') -# self.root = self.root + ' javascript' -# self.report_dir = Env.JS_REPORT_DIR - -# try: -# self.test_conf_file = Env.KARMA_CONFIG_FILES[Env.JS_TEST_ID_KEYS.index(self.test_id)] -# except ValueError: -# self.test_conf_file = Env.KARMA_CONFIG_FILES[0] - -# self.coverage_report = self.report_dir / f'coverage-{self.test_id}.xml' -# self.xunit_report = self.report_dir / f'javascript_xunit-{self.test_id}.xml' - -# @property -# def cmd(self): -# """ -# Run the tests using karma runner. -# """ -# cmd = [ -# "node", -# "--max_old_space_size=4096", -# "node_modules/.bin/karma", -# "start", -# self.test_conf_file, -# "--single-run={}".format('false' if self.mode == 'dev' else 'true'), -# "--capture-timeout=60000", -# f"--junitreportpath={self.xunit_report}", -# f"--browsers={Env.KARMA_BROWSER}", -# ] - -# if self.port: -# cmd.append(f"--port={self.port}") - -# if self.run_under_coverage: -# cmd.extend([ -# "--coverage", -# f"--coveragereportpath={self.coverage_report}", -# ]) - -# return cmd + @property + def _default_subsuites(self): + """ + Returns all JS test suites + """ + return [JsTestSubSuite(test_id, **self.opts) for test_id in Env.JS_TEST_ID_KEYS if test_id != 'jest-snapshot'] + + +class JsTestSubSuite(TestSuite): + """ + Class for JS suites like cms, cms-squire, lms, common, + common-requirejs and xmodule + """ + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.test_id = args[0] + self.run_under_coverage = kwargs.get('with_coverage', True) + self.mode = kwargs.get('mode', 'run') + self.port = kwargs.get('port') + self.root = self.root + ' javascript' + self.report_dir = Env.JS_REPORT_DIR + + try: + self.test_conf_file = Env.KARMA_CONFIG_FILES[Env.JS_TEST_ID_KEYS.index(self.test_id)] + except ValueError: + self.test_conf_file = Env.KARMA_CONFIG_FILES[0] + + self.coverage_report = self.report_dir / f'coverage-{self.test_id}.xml' + self.xunit_report = self.report_dir / f'javascript_xunit-{self.test_id}.xml' + + @property + def cmd(self): + """ + Run the tests using karma runner. + """ + cmd = [ + "node", + "--max_old_space_size=4096", + "node_modules/.bin/karma", + "start", + self.test_conf_file, + "--single-run={}".format('false' if self.mode == 'dev' else 'true'), + "--capture-timeout=60000", + f"--junitreportpath={self.xunit_report}", + f"--browsers={Env.KARMA_BROWSER}", + ] + + if self.port: + cmd.append(f"--port={self.port}") + + if self.run_under_coverage: + cmd.extend([ + "--coverage", + f"--coveragereportpath={self.coverage_report}", + ]) + + return cmd class JestSnapshotTestSuite(TestSuite): From 2b6a6f867e94bac3f66ab04321b2d39434495eff Mon Sep 17 00:00:00 2001 From: salman2013 Date: Wed, 4 Oct 2023 15:57:33 +0500 Subject: [PATCH 020/170] chore: remove plugin which is not using --- .../pytest_plugin.py | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 openedx/testing/coverage_context_listener/pytest_plugin.py diff --git a/openedx/testing/coverage_context_listener/pytest_plugin.py b/openedx/testing/coverage_context_listener/pytest_plugin.py deleted file mode 100644 index a3679027e888..000000000000 --- a/openedx/testing/coverage_context_listener/pytest_plugin.py +++ /dev/null @@ -1,29 +0,0 @@ -""" -A pytest plugin that reports test contexts to coverage running in another process. -""" - -import pytest - - -class RemoteContextPlugin: - """ - Pytest plugin for reporting pytests contexts to coverage running in another process - """ - def __init__(self, config): - self.config = config - self.active = config.getoption("pytest-contexts") - - -@pytest.hookimpl(tryfirst=True) -def pytest_configure(config): - config.pluginmanager.register(RemoteContextPlugin(config), "remotecontextplugin") - - -def pytest_addoption(parser): - group = parser.getgroup("coverage") - group.addoption( - "--pytest-remote-contexts", - action="store_true", - dest="pytest-contexts", - help="Capture the pytest contexts that coverage is being captured in in another process", - ) From 936a6c0983f63d9e25d242f9b70121ad43fc21ff Mon Sep 17 00:00:00 2001 From: salman2013 Date: Wed, 4 Oct 2023 19:02:16 +0500 Subject: [PATCH 021/170] chore: resolve conflicts --- lms/envs/bok_choy_docker.yml | 184 ----------------------------------- scripts/reset-test-db.sh | 141 --------------------------- 2 files changed, 325 deletions(-) delete mode 100644 lms/envs/bok_choy_docker.yml delete mode 100755 scripts/reset-test-db.sh diff --git a/lms/envs/bok_choy_docker.yml b/lms/envs/bok_choy_docker.yml deleted file mode 100644 index b68beb648df0..000000000000 --- a/lms/envs/bok_choy_docker.yml +++ /dev/null @@ -1,184 +0,0 @@ -# ingested edx-platform/lms/envs/bok_choy_docker.auth.json -# ingested edx-platform/lms/envs/bok_choy_docker.env.json -ACTIVATION_EMAIL_SUPPORT_LINK: https://support.example.com/activation-email-help.html -ANALYTICS_DASHBOARD_URL: '' -AWS_ACCESS_KEY_ID: '' -AWS_SECRET_ACCESS_KEY: '' -BUGS_EMAIL: bugs@example.com -BULK_EMAIL_DEFAULT_FROM_EMAIL: no-reply@example.com -CACHES: - celery: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: integration_celery - LOCATION: ['edx.devstack.memcached:11211'] - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - default: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: sandbox_default - LOCATION: ['edx.devstack.memcached:11211'] - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - general: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: sandbox_general - LOCATION: ['edx.devstack.memcached:11211'] - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - mongo_metadata_inheritance: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: integration_mongo_metadata_inheritance - LOCATION: ['edx.devstack.memcached:11211'] - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true - staticfiles: - BACKEND: django.core.cache.backends.memcached.PyMemcacheCache - KEY_FUNCTION: common.djangoapps.util.memcache.safe_key - KEY_PREFIX: integration_static_files - LOCATION: ['edx.devstack.memcached:11211'] - OPTIONS: - no_delay: true - ignore_exc: true - use_pooling: true -CELERY_BROKER_HOSTNAME: localhost -CELERY_BROKER_PASSWORD: celery -CELERY_BROKER_TRANSPORT: amqp -CELERY_BROKER_USER: celery -CERT_QUEUE: certificates -CMS_BASE: '** OVERRIDDEN **' -CODE_JAIL: - limits: {REALTIME: 3, VMEM: 0} -COMMENTS_SERVICE_KEY: password -COMMENTS_SERVICE_URL: http://edx.devstack.lms:4567 -CONTACT_EMAIL: info@example.com -CONTENTSTORE: - DOC_STORE_CONFIG: - collection: modulestore - db: test - host: [edx.devstack.mongo] - port: 27017 - ENGINE: xmodule.contentstore.mongo.MongoContentStore - OPTIONS: - db: test - host: [edx.devstack.mongo] - port: 27017 -DATABASES: - default: {ENGINE: django.db.backends.mysql, HOST: edx.devstack.mysql80, NAME: edxtest, - PASSWORD: '', PORT: '3306', USER: root} - student_module_history: {ENGINE: django.db.backends.mysql, HOST: edx.devstack.mysql80, - NAME: student_module_history_test, PASSWORD: '', PORT: '3306', USER: root} -DEFAULT_FEEDBACK_EMAIL: feedback@example.com -DEFAULT_FROM_EMAIL: registration@example.com -DJFS: {aws_access_key_id: test, aws_secret_access_key: test, bucket: test, prefix: test, - type: s3fs} -DOC_STORE_CONFIG: - collection: modulestore - db: test - host: [edx.devstack.mongo] - port: 27017 -EMAIL_BACKEND: django.core.mail.backends.dummy.EmailBackend -EVENT_TRACKING_BACKENDS: - mongo: - ENGINE: eventtracking.backends.mongodb.MongoBackend - OPTIONS: - collection: events - database: test - host: [edx.devstack.mongo] - port: 27017 -FEATURES: {ALLOW_AUTOMATED_SIGNUPS: true, AUTOMATIC_AUTH_FOR_TESTING: true, - AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING: true, CERTIFICATES_HTML_VIEW: true, - CERTIFICATES_INSTRUCTOR_GENERATION: true, CUSTOM_COURSES_EDX: true, - ENABLE_COURSE_DISCOVERY: true, ENABLE_DISCUSSION_SERVICE: true, ENABLE_GRADE_DOWNLOADS: true, - ENABLE_SPECIAL_EXAMS: true, ENABLE_THIRD_PARTY_AUTH: true, - ENABLE_VERIFIED_CERTIFICATES: true, EXPOSE_CACHE_PROGRAMS_ENDPOINT: true, MODE_CREATION_FOR_TESTING: true, - PREVIEW_LMS_BASE: 'preview.localhost:8003', RESTRICT_AUTOMATIC_AUTH: false, SHOW_HEADER_LANGUAGE_SELECTOR: true} -GITHUB_REPO_ROOT: '** OVERRIDDEN **' -JWT_AUTH: {JWT_PRIVATE_SIGNING_JWK: '{"e": "AQAB", "d": "HIiV7KNjcdhVbpn3KT-I9n3JPf5YbGXsCIedmPqDH1d4QhBofuAqZ9zebQuxkRUpmqtYMv0Zi6ECSUqH387GYQF_XvFUFcjQRPycISd8TH0DAKaDpGr-AYNshnKiEtQpINhcP44I1AYNPCwyoxXA1fGTtmkKChsuWea7o8kytwU5xSejvh5-jiqu2SF4GEl0BEXIAPZsgbzoPIWNxgO4_RzNnWs6nJZeszcaDD0CyezVSuH9QcI6g5QFzAC_YuykSsaaFJhZ05DocBsLczShJ9Omf6PnK9xlm26I84xrEh_7x4fVmNBg3xWTLh8qOnHqGko93A1diLRCrKHOvnpvgQ", - "n": "o5cn3ljSRi6FaDEKTn0PS-oL9EFyv1pI7dRgffQLD1qf5D6sprmYfWWokSsrWig8u2y0HChSygR6Jn5KXBqQn6FpM0dDJLnWQDRXHLl3Ey1iPYgDSmOIsIGrV9ZyNCQwk03wAgWbfdBTig3QSDYD-sTNOs3pc4UD_PqAvU2nz_1SS2ZiOwOn5F6gulE1L0iE3KEUEvOIagfHNVhz0oxa_VRZILkzV-zr6R_TW1m97h4H8jXl_VJyQGyhMGGypuDrQ9_vaY_RLEulLCyY0INglHWQ7pckxBtI5q55-Vio2wgewe2_qYcGsnBGaDNbySAsvYcWRrqDiFyzrJYivodqTQ", - "q": "3T3DEtBUka7hLGdIsDlC96Uadx_q_E4Vb1cxx_4Ss_wGp1Loz3N3ZngGyInsKlmbBgLo1Ykd6T9TRvRNEWEtFSOcm2INIBoVoXk7W5RuPa8Cgq2tjQj9ziGQ08JMejrPlj3Q1wmALJr5VTfvSYBu0WkljhKNCy1KB6fCby0C9WE", - "p": "vUqzWPZnDG4IXyo-k5F0bHV0BNL_pVhQoLW7eyFHnw74IOEfSbdsMspNcPSFIrtgPsn7981qv3lN_staZ6JflKfHayjB_lvltHyZxfl0dvruShZOx1N6ykEo7YrAskC_qxUyrIvqmJ64zPW3jkuOYrFs7Ykj3zFx3Zq1H5568G0", - "kid": "BTZ9HA6K", "kty": "RSA"}', JWT_PUBLIC_SIGNING_JWK_SET: '{"keys": [{"kid": - "BTZ9HA6K", "e": "AQAB", "kty": "RSA", "n": "o5cn3ljSRi6FaDEKTn0PS-oL9EFyv1pI7dRgffQLD1qf5D6sprmYfWWokSsrWig8u2y0HChSygR6Jn5KXBqQn6FpM0dDJLnWQDRXHLl3Ey1iPYgDSmOIsIGrV9ZyNCQwk03wAgWbfdBTig3QSDYD-sTNOs3pc4UD_PqAvU2nz_1SS2ZiOwOn5F6gulE1L0iE3KEUEvOIagfHNVhz0oxa_VRZILkzV-zr6R_TW1m97h4H8jXl_VJyQGyhMGGypuDrQ9_vaY_RLEulLCyY0INglHWQ7pckxBtI5q55-Vio2wgewe2_qYcGsnBGaDNbySAsvYcWRrqDiFyzrJYivodqTQ"}]}', - JWT_SECRET_KEY: super-secret-key} -LMS_BASE: http://edx.devstack.lms:18003 -LMS_ROOT_URL: http://edx.devstack.lms:18003 -LOCAL_LOGLEVEL: INFO -LOGGING_ENV: sandbox -LOG_DIR: '** OVERRIDDEN **' -MEDIA_URL: /media/ -MKTG_URL_LINK_MAP: {ABOUT: about, BLOG: blog, CAREERS: careers, CONTACT: contact, - COURSES: courses, DONATE: donate, HELP_CENTER: help-center, HONOR: honor, NEWS: news, - PRESS: press, PRIVACY: privacy, ROOT: root, SITEMAP.XML: sitemap_xml, TOS: tos, - WHAT_IS_VERIFIED_CERT: verified-certificate} -MODULESTORE: - default: - ENGINE: xmodule.modulestore.mixed.MixedModuleStore - OPTIONS: - mappings: {} - stores: - - DOC_STORE_CONFIG: - collection: modulestore - db: test - host: [edx.devstack.mongo] - port: 27017 - ENGINE: xmodule.modulestore.mongo.DraftMongoModuleStore - NAME: draft - OPTIONS: - collection: modulestore - db: test - default_class: xmodule.hidden_block.HiddenBlock - fs_root: '** OVERRIDDEN **' - host: [edx.devstack.mongo] - port: 27017 - render_template: common.djangoapps.edxmako.shortcuts.render_to_string - - ENGINE: xmodule.modulestore.xml.XMLModuleStore - NAME: xml - OPTIONS: {data_dir: '** OVERRIDDEN **', default_class: xmodule.hidden_block.HiddenBlock} -PASSWORD_RESET_SUPPORT_LINK: https://support.example.com/password-reset-help.html -REGISTRATION_EXTENSION_FORM: openedx.core.djangoapps.user_api.tests.test_helpers.TestCaseForm -REGISTRATION_EXTRA_FIELDS: {city: hidden, country: required, gender: optional, goals: optional, - honor_code: required, level_of_education: optional, mailing_address: optional, terms_of_service: hidden, - year_of_birth: optional} -SECRET_KEY: 'bokchoy_docker_secret_key' -SERVER_EMAIL: devops@example.com -SESSION_COOKIE_DOMAIN: null -SITE_NAME: localhost:8003 -SOCIAL_SHARING_SETTINGS: {CERTIFICATE_FACEBOOK: true, CERTIFICATE_FACEBOOK_TEXT: 'Testing - facebook feature:', CUSTOM_COURSE_URLS: true, DASHBOARD_FACEBOOK: true, DASHBOARD_TWITTER: true, - DASHBOARD_TWITTER_TEXT: 'Testing feature:'} -STATIC_URL_BASE: /static/ -SUPPORT_SITE_LINK: https://support.example.com -SYSLOG_SERVER: '' -TECH_SUPPORT_EMAIL: technical@example.com -THIRD_PARTY_AUTH_BACKENDS: [social_core.backends.google.GoogleOAuth2, social_core.backends.linkedin.LinkedinOAuth2, - social_core.backends.facebook.FacebookOAuth2, common.djangoapps.third_party_auth.dummy.DummyBackend, - common.djangoapps.third_party_auth.saml.SAMLAuthBackend] -TIME_ZONE: America/New_York -TRACKING_BACKENDS: - mongo: - ENGINE: common.djangoapps.track.backends.mongodb.MongoBackend - OPTIONS: - collection: events - database: test - host: [edx.devstack.mongo] - port: 27017 -WIKI_ENABLED: true -XQUEUE_INTERFACE: - basic_auth: [edx, edx] - django_auth: {password: password, username: lms} - url: '** OVERRIDDEN **' -ZENDESK_API_KEY: '' -ZENDESK_USER: '' - diff --git a/scripts/reset-test-db.sh b/scripts/reset-test-db.sh deleted file mode 100755 index 4700f5a99ad0..000000000000 --- a/scripts/reset-test-db.sh +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env bash - -############################################################################ -# -# reset-test-db.sh -# -# Resets the MySQL test database for the bok-choy acceptance tests. -# -# If it finds a cached schema and migration history, it will start -# from the cached version to speed up migrations. -# -# If no cached database exists, it will create one. This can be -# checked into the repo to speed up future tests. -# -# Note that we do NOT want to re-use the cache between test runs! -# A newer commit could introduce migrations that do not exist -# in other commits, which could cause migrations to fail in the other -# commits. -# -# For this reason, we always use a cache that was committed to master -# at the time the branch was created. -# -############################################################################ - -# Fail fast -set -e - -DB_CACHE_DIR="common/test/db_cache" - -if [[ -z "$BOK_CHOY_HOSTNAME" ]]; then - MYSQL_HOST="" - SETTINGS="bok_choy" -else - MYSQL_HOST="--host=edx.devstack.mysql80" - SETTINGS="bok_choy_docker" -fi - -for i in "$@"; do - case $i in - -r|--rebuild_cache) - REBUILD_CACHE=true - ;; - -m|--migrations) - APPLY_MIGRATIONS=true - ;; - -c|--calculate_migrations) - CALCULATE_MIGRATIONS=true - ;; - -u|--use-existing-db) - USE_EXISTING_DB=true - ;; - esac -done - -declare -A databases -declare -a database_order -databases=(["default"]="edxtest" ["student_module_history"]="student_module_history_test") -database_order=("default" "student_module_history") - -calculate_migrations() { - echo "Calculating migrations for fingerprinting." - output_file="common/test/db_cache/bok_choy_${db}_migrations.yaml" - # Redirect stdout to /dev/null because the script will print - # out all migrations to both stdout and the output file. - ./manage.py lms --settings "$SETTINGS" show_unapplied_migrations --database "$db" --output_file "$output_file" 1>/dev/null -} - -run_migrations() { - echo "Running the lms migrations on the $db bok_choy DB." - ./manage.py lms --settings "$SETTINGS" migrate --database "$db" --traceback --noinput - echo "Running the cms migrations on the $db bok_choy DB." - ./manage.py cms --settings "$SETTINGS" migrate --database "$db" --traceback --noinput -} - -load_cache_into_db() { - echo "Loading the schema from the filesystem into the $db MySQL DB." - mysql "$MYSQL_HOST" -u root "${databases["$db"]}" < "$DB_CACHE_DIR/bok_choy_schema_$db.sql" - echo "Loading the fixture data from the filesystem into the $db MySQL DB." - ./manage.py lms --settings "$SETTINGS" loaddata --database "$db" "$DB_CACHE_DIR/bok_choy_data_$db.json" - echo "Loading the migration data from the filesystem into the $db MySQL DB." - mysql "$MYSQL_HOST" -u root "${databases["$db"]}" < "$DB_CACHE_DIR/bok_choy_migrations_data_$db.sql" -} - -rebuild_cache_for_db() { - # Make sure the DB has all migrations applied - run_migrations - - # Dump the schema and data to the cache - echo "Using the dumpdata command to save the $db fixture data to the filesystem." - ./manage.py lms --settings "$SETTINGS" dumpdata --database "$db" > "$DB_CACHE_DIR/bok_choy_data_$db.json" --exclude=api_admin.Catalog - echo "Saving the schema of the $db bok_choy DB to the filesystem." - mysqldump "$MYSQL_HOST" -u root --no-data --skip-comments --skip-dump-date "${databases[$db]}" > "$DB_CACHE_DIR/bok_choy_schema_$db.sql" - - # dump_data does not dump the django_migrations table so we do it separately. - echo "Saving the django_migrations table of the $db bok_choy DB to the filesystem." - mysqldump $MYSQL_HOST -u root --no-create-info --skip-comments --skip-dump-date "${databases["$db"]}" django_migrations > "$DB_CACHE_DIR/bok_choy_migrations_data_$db.sql" -} - -for db in "${database_order[@]}"; do - if ! [[ $USE_EXISTING_DB ]]; then - echo "CREATE DATABASE IF NOT EXISTS ${databases[$db]};" | mysql $MYSQL_HOST -u root - - # Clear out the test database - # - # We are using the reset_db command which uses "DROP DATABASE" and - # "CREATE DATABASE" in case the tests are being run in an environment (e.g. devstack - # or a jenkins worker environment) that already ran tests on another commit that had - # different migrations that created, dropped, or altered tables. - echo "Issuing a reset_db command to the $db bok_choy MySQL database." - ./manage.py lms --settings "$SETTINGS" reset_db --traceback --router "$db" - fi - - if ! [[ $CALCULATE_MIGRATIONS ]]; then - # If there are cached database schemas/data, then load them. - # If they are missing, then we will want to build new cache files even if - # not explicitly directed to do so via arguments passed to this script. - if [[ ! -f $DB_CACHE_DIR/bok_choy_schema_$db.sql || ! -f $DB_CACHE_DIR/bok_choy_data_$db.json || ! -f $DB_CACHE_DIR/bok_choy_migrations_data_$db.sql ]]; then - REBUILD_CACHE=true - else - load_cache_into_db - fi - fi -done - -if [[ $REBUILD_CACHE ]]; then - echo "Cleaning the DB cache directory and building new files." - mkdir -p $DB_CACHE_DIR && rm -f $DB_CACHE_DIR/bok_choy* - - for db in "${database_order[@]}"; do - rebuild_cache_for_db - done -elif [[ $APPLY_MIGRATIONS ]]; then - for db in "${database_order[@]}"; do - run_migrations - done -elif [[ $CALCULATE_MIGRATIONS ]]; then - for db in "${database_order[@]}"; do - calculate_migrations - done -fi - From 01a4908562d56f03814dcae31506efe3202c7f05 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Wed, 4 Oct 2023 19:41:57 +0500 Subject: [PATCH 022/170] chore: fix tests --- .../pytest_plugin.py | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 openedx/testing/coverage_context_listener/pytest_plugin.py diff --git a/openedx/testing/coverage_context_listener/pytest_plugin.py b/openedx/testing/coverage_context_listener/pytest_plugin.py deleted file mode 100644 index a3679027e888..000000000000 --- a/openedx/testing/coverage_context_listener/pytest_plugin.py +++ /dev/null @@ -1,29 +0,0 @@ -""" -A pytest plugin that reports test contexts to coverage running in another process. -""" - -import pytest - - -class RemoteContextPlugin: - """ - Pytest plugin for reporting pytests contexts to coverage running in another process - """ - def __init__(self, config): - self.config = config - self.active = config.getoption("pytest-contexts") - - -@pytest.hookimpl(tryfirst=True) -def pytest_configure(config): - config.pluginmanager.register(RemoteContextPlugin(config), "remotecontextplugin") - - -def pytest_addoption(parser): - group = parser.getgroup("coverage") - group.addoption( - "--pytest-remote-contexts", - action="store_true", - dest="pytest-contexts", - help="Capture the pytest contexts that coverage is being captured in in another process", - ) From 5bc3dfa6fef97bec287fc129e885687d6c99247d Mon Sep 17 00:00:00 2001 From: salman2013 Date: Fri, 6 Oct 2023 11:21:11 +0500 Subject: [PATCH 023/170] chore: uncomment the code --- pavelib/utils/test/suites/js_suite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pavelib/utils/test/suites/js_suite.py b/pavelib/utils/test/suites/js_suite.py index d96d95f39cfe..65c5feaf843b 100644 --- a/pavelib/utils/test/suites/js_suite.py +++ b/pavelib/utils/test/suites/js_suite.py @@ -25,7 +25,7 @@ def __init__(self, *args, **kwargs): self.opts = kwargs suite = args[0] - # self.subsuites = self._default_subsuites if suite == 'all' else [JsTestSubSuite(*args, **kwargs)] + self.subsuites = self._default_subsuites if suite == 'all' else [JsTestSubSuite(*args, **kwargs)] def __enter__(self): super().__enter__() From cda018e67bb82f8bbd9e6310dab6746e092a5e4e Mon Sep 17 00:00:00 2001 From: salman2013 Date: Fri, 6 Oct 2023 15:10:44 +0500 Subject: [PATCH 024/170] chore: fix test case --- pavelib/utils/envs.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pavelib/utils/envs.py b/pavelib/utils/envs.py index 4cfbec7790ff..69a9e060757b 100644 --- a/pavelib/utils/envs.py +++ b/pavelib/utils/envs.py @@ -77,7 +77,7 @@ class Env: PRINT_SETTINGS_LOG_FILE = GEN_LOG_DIR / "print_settings.log" # Detect if in a Docker container, and if so which one - # USING_DOCKER = SERVER_HOST != '0.0.0.0' + USING_DOCKER = SERVER_HOST != '0.0.0.0' DEVSTACK_SETTINGS = 'devstack' TEST_SETTINGS = 'test' @@ -85,6 +85,10 @@ class Env: TEST_DIR = REPO_ROOT / ".testids" # Configured browser to use for the js test suites + SELENIUM_BROWSER = os.environ.get('SELENIUM_BROWSER', 'firefox') + if USING_DOCKER: + KARMA_BROWSER = 'ChromeDocker' if SELENIUM_BROWSER == 'chrome' else 'FirefoxDocker' + else: KARMA_BROWSER = 'FirefoxNoUpdates' # Files used to run each of the js test suites From 7049cb2d2cb90ec810f0acca4c4c8bdfb09fc563 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Fri, 6 Oct 2023 15:21:27 +0500 Subject: [PATCH 025/170] chore: fix test case --- pavelib/utils/envs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pavelib/utils/envs.py b/pavelib/utils/envs.py index 69a9e060757b..af21118bb89b 100644 --- a/pavelib/utils/envs.py +++ b/pavelib/utils/envs.py @@ -89,7 +89,7 @@ class Env: if USING_DOCKER: KARMA_BROWSER = 'ChromeDocker' if SELENIUM_BROWSER == 'chrome' else 'FirefoxDocker' else: - KARMA_BROWSER = 'FirefoxNoUpdates' + KARMA_BROWSER = 'FirefoxNoUpdates' # Files used to run each of the js test suites # TODO: Store this as a dict. Order seems to matter for some From 8dddb538fff56211f18c8a5d31d2d90b3df7492a Mon Sep 17 00:00:00 2001 From: salman2013 Date: Fri, 6 Oct 2023 15:27:15 +0500 Subject: [PATCH 026/170] chore: fix test case --- pavelib/utils/envs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pavelib/utils/envs.py b/pavelib/utils/envs.py index af21118bb89b..1b82f9be75cb 100644 --- a/pavelib/utils/envs.py +++ b/pavelib/utils/envs.py @@ -85,6 +85,7 @@ class Env: TEST_DIR = REPO_ROOT / ".testids" # Configured browser to use for the js test suites + SERVER_HOST = '0.0.0.0' SELENIUM_BROWSER = os.environ.get('SELENIUM_BROWSER', 'firefox') if USING_DOCKER: KARMA_BROWSER = 'ChromeDocker' if SELENIUM_BROWSER == 'chrome' else 'FirefoxDocker' From 9d543254b0c3cb22ae3c4e63a8c08aff61d08f1e Mon Sep 17 00:00:00 2001 From: salman2013 Date: Fri, 6 Oct 2023 15:36:48 +0500 Subject: [PATCH 027/170] chore: fix test case --- pavelib/utils/envs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pavelib/utils/envs.py b/pavelib/utils/envs.py index 1b82f9be75cb..eca00713eabc 100644 --- a/pavelib/utils/envs.py +++ b/pavelib/utils/envs.py @@ -77,6 +77,7 @@ class Env: PRINT_SETTINGS_LOG_FILE = GEN_LOG_DIR / "print_settings.log" # Detect if in a Docker container, and if so which one + SERVER_HOST = '0.0.0.0' USING_DOCKER = SERVER_HOST != '0.0.0.0' DEVSTACK_SETTINGS = 'devstack' TEST_SETTINGS = 'test' @@ -84,8 +85,7 @@ class Env: # Test Ids Directory TEST_DIR = REPO_ROOT / ".testids" - # Configured browser to use for the js test suites - SERVER_HOST = '0.0.0.0' + # Configured browser to use for the js test suites SELENIUM_BROWSER = os.environ.get('SELENIUM_BROWSER', 'firefox') if USING_DOCKER: KARMA_BROWSER = 'ChromeDocker' if SELENIUM_BROWSER == 'chrome' else 'FirefoxDocker' From 2d78b2d952b0ee9c37b9b45fcfc787770dcc2a0a Mon Sep 17 00:00:00 2001 From: salman2013 Date: Fri, 6 Oct 2023 16:56:17 +0500 Subject: [PATCH 028/170] chore: fix test case --- pavelib/utils/test/suites/js_suite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pavelib/utils/test/suites/js_suite.py b/pavelib/utils/test/suites/js_suite.py index 65c5feaf843b..8651ea496135 100644 --- a/pavelib/utils/test/suites/js_suite.py +++ b/pavelib/utils/test/suites/js_suite.py @@ -25,7 +25,7 @@ def __init__(self, *args, **kwargs): self.opts = kwargs suite = args[0] - self.subsuites = self._default_subsuites if suite == 'all' else [JsTestSubSuite(*args, **kwargs)] + #self.subsuites = self._default_subsuites if suite == 'all' else [JsTestSubSuite(*args, **kwargs)] def __enter__(self): super().__enter__() From 52aea3529a4930c5183da8d1ae44262771fb764e Mon Sep 17 00:00:00 2001 From: salman2013 Date: Mon, 9 Oct 2023 11:29:57 +0500 Subject: [PATCH 029/170] chore: fix test case --- .github/workflows/js-tests.yml | 8 ++++++++ pavelib/utils/test/suites/js_suite.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/js-tests.yml b/.github/workflows/js-tests.yml index e4903af83b7b..c26e4e79fc77 100644 --- a/.github/workflows/js-tests.yml +++ b/.github/workflows/js-tests.yml @@ -30,6 +30,14 @@ jobs: - name: Setup npm run: npm i -g npm@8.5.x + - name: Install Firefox 61.0 + run: | + sudo apt-get purge firefox + wget "https://ftp.mozilla.org/pub/firefox/releases/61.0/linux-x86_64/en-US/firefox-61.0.tar.bz2" + tar -xjf firefox-61.0.tar.bz2 + sudo mv firefox /opt/firefox + sudo ln -s /opt/firefox/firefox /usr/bin/firefox + - name: Install Required System Packages run: sudo apt-get update && sudo apt-get install libxmlsec1-dev ubuntu-restricted-extras xvfb diff --git a/pavelib/utils/test/suites/js_suite.py b/pavelib/utils/test/suites/js_suite.py index 8651ea496135..65c5feaf843b 100644 --- a/pavelib/utils/test/suites/js_suite.py +++ b/pavelib/utils/test/suites/js_suite.py @@ -25,7 +25,7 @@ def __init__(self, *args, **kwargs): self.opts = kwargs suite = args[0] - #self.subsuites = self._default_subsuites if suite == 'all' else [JsTestSubSuite(*args, **kwargs)] + self.subsuites = self._default_subsuites if suite == 'all' else [JsTestSubSuite(*args, **kwargs)] def __enter__(self): super().__enter__() From cdeaaa54584a9db9f14e784c279d937125a4b193 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Mon, 9 Oct 2023 19:12:10 +0500 Subject: [PATCH 030/170] chore: fix test case --- common/static/common/js/karma.common.conf.js | 43 ++++++++++++++++++++ pavelib/utils/envs.py | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/common/static/common/js/karma.common.conf.js b/common/static/common/js/karma.common.conf.js index 274d4efa7e8b..09f6a21848c3 100644 --- a/common/static/common/js/karma.common.conf.js +++ b/common/static/common/js/karma.common.conf.js @@ -45,6 +45,7 @@ var appRoot = path.join(__dirname, '../../../../'); // eslint-disable-next-line import/no-extraneous-dependencies var webdriver = require('selenium-webdriver'); // eslint-disable-next-line import/no-extraneous-dependencies +var firefox = require('selenium-webdriver/firefox'); var webpackConfig = require(path.join(appRoot, 'webpack.dev.config.js')); @@ -296,6 +297,8 @@ function getBaseConfig(config, useRequireJs) { 'karma-requirejs', 'karma-junit-reporter', 'karma-coverage', + 'karma-chrome-launcher', + 'karma-firefox-launcher', 'karma-spec-reporter', 'karma-selenium-webdriver-launcher', 'karma-webpack', @@ -333,6 +336,46 @@ function getBaseConfig(config, useRequireJs) { // enable / disable watching file and executing tests whenever any file changes autoWatch: false, + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['FirefoxNoUpdates'], + + customLaunchers: { + // Firefox configuration that doesn't perform auto-updates + FirefoxNoUpdates: { + base: 'Firefox', + prefs: { + 'app.update.auto': false, + 'app.update.enabled': false + } + }, + ChromeDocker: { + base: 'SeleniumWebdriver', + browserName: 'chrome', + getDriver: function() { + return new webdriver.Builder() + .forBrowser('chrome') + .usingServer('http://edx.devstack.chrome:4444/wd/hub') + .build(); + } + }, + FirefoxDocker: { + base: 'SeleniumWebdriver', + browserName: 'firefox', + getDriver: function() { + var options = new firefox.Options(), + profile = new firefox.Profile(); + profile.setPreference('focusmanager.testmode', true); + options.setProfile(profile); + return new webdriver.Builder() + .forBrowser('firefox') + .usingServer('http://edx.devstack.firefox:4444/wd/hub') + .setFirefoxOptions(options) + .build(); + } + } + }, // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits diff --git a/pavelib/utils/envs.py b/pavelib/utils/envs.py index eca00713eabc..20764a613e34 100644 --- a/pavelib/utils/envs.py +++ b/pavelib/utils/envs.py @@ -85,7 +85,7 @@ class Env: # Test Ids Directory TEST_DIR = REPO_ROOT / ".testids" - # Configured browser to use for the js test suites + # Configured browser to use for the js test suites SELENIUM_BROWSER = os.environ.get('SELENIUM_BROWSER', 'firefox') if USING_DOCKER: KARMA_BROWSER = 'ChromeDocker' if SELENIUM_BROWSER == 'chrome' else 'FirefoxDocker' From 8bd5be2ab49f849cd33c660052449769e83c5799 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Mon, 9 Oct 2023 22:38:13 +0500 Subject: [PATCH 031/170] chore: fix test case --- pavelib/utils/envs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pavelib/utils/envs.py b/pavelib/utils/envs.py index 20764a613e34..53288780bd48 100644 --- a/pavelib/utils/envs.py +++ b/pavelib/utils/envs.py @@ -79,7 +79,7 @@ class Env: # Detect if in a Docker container, and if so which one SERVER_HOST = '0.0.0.0' USING_DOCKER = SERVER_HOST != '0.0.0.0' - DEVSTACK_SETTINGS = 'devstack' + DEVSTACK_SETTINGS = 'devstack_docker' if USING_DOCKER else 'devstack' TEST_SETTINGS = 'test' # Test Ids Directory From 8f97ac90cf86749a47729fab01559b4cbee45504 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Tue, 10 Oct 2023 09:56:28 +0500 Subject: [PATCH 032/170] chore: fix test case --- pavelib/utils/envs.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pavelib/utils/envs.py b/pavelib/utils/envs.py index 53288780bd48..9ffe8887ff02 100644 --- a/pavelib/utils/envs.py +++ b/pavelib/utils/envs.py @@ -82,6 +82,9 @@ class Env: DEVSTACK_SETTINGS = 'devstack_docker' if USING_DOCKER else 'devstack' TEST_SETTINGS = 'test' + # Mongo databases that will be dropped before/after the tests run + MONGO_HOST = 'edx.devstack.mongo' if USING_DOCKER else 'localhost' + # Test Ids Directory TEST_DIR = REPO_ROOT / ".testids" From 1e2ea85372cf777122cb1f13c7c6a63c982b8790 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Fri, 29 Sep 2023 13:24:31 -0400 Subject: [PATCH 033/170] test: Update more tests that had short passwords. --- .../tests/test_course_create_rerun.py | 2 +- .../contentstore/tests/test_course_listing.py | 4 +- .../tests/test_course_settings.py | 4 +- .../contentstore/tests/test_i18n.py | 2 +- .../tests/test_users_default_role.py | 2 +- cms/djangoapps/contentstore/tests/tests.py | 2 +- .../views/tests/test_certificates.py | 10 ++-- .../views/tests/test_organizations.py | 5 +- cms/djangoapps/maintenance/tests.py | 16 +++--- .../course_modes/tests/test_admin.py | 2 +- common/djangoapps/student/tests/factories.py | 4 +- .../student/tests/test_admin_views.py | 17 ++++--- .../student/tests/test_bulk_email_settings.py | 2 +- .../djangoapps/student/tests/test_filters.py | 2 +- .../student/tests/test_retirement.py | 2 +- .../student/tests/test_userstanding.py | 2 +- common/djangoapps/student/tests/test_views.py | 7 ++- common/djangoapps/student/tests/tests.py | 29 ++++++----- .../third_party_auth/tests/specs/base.py | 2 +- .../third_party_auth/tests/test_admin.py | 7 ++- lms/djangoapps/badges/api/tests.py | 2 +- .../bulk_email/tests/test_course_optout.py | 10 ++-- lms/djangoapps/bulk_email/tests/test_email.py | 2 +- .../bulk_email/tests/test_err_handling.py | 2 +- .../bulk_email/tests/test_signals.py | 4 +- lms/djangoapps/ccx/api/v0/tests/test_views.py | 8 +-- lms/djangoapps/ccx/tests/test_views.py | 31 ++++++------ lms/djangoapps/ccx/tests/utils.py | 6 +-- .../commerce/api/v1/tests/test_views.py | 2 +- lms/djangoapps/commerce/tests/test_views.py | 5 +- .../course_api/blocks/tests/test_views.py | 14 +++--- .../transformers/tests/helpers.py | 4 +- lms/djangoapps/course_wiki/tests/tests.py | 2 +- lms/djangoapps/courseware/tests/helpers.py | 4 +- lms/djangoapps/courseware/tests/test_about.py | 2 +- .../courseware/tests/test_access.py | 6 +-- .../courseware/tests/test_block_render.py | 4 +- .../courseware/tests/test_course_survey.py | 2 +- .../tests/test_discussion_xblock.py | 2 +- .../courseware/tests/test_entrance_exam.py | 6 +-- .../courseware/tests/test_masquerade.py | 10 ++-- .../courseware/tests/test_split_module.py | 4 +- .../tests/test_submitting_problems.py | 2 +- lms/djangoapps/courseware/tests/test_tabs.py | 6 +-- .../tests/test_view_authentication.py | 4 +- lms/djangoapps/courseware/tests/test_views.py | 28 +++++------ lms/djangoapps/courseware/testutils.py | 2 +- .../django_comment_client/base/tests.py | 4 +- .../discussion/rest_api/tests/test_views.py | 16 +++--- lms/djangoapps/discussion/tests/test_views.py | 22 ++++---- .../grades/rest_api/v1/tests/mixins.py | 2 +- .../grades/rest_api/v1/tests/test_views.py | 2 +- .../grades/tests/integration/test_access.py | 4 +- .../grades/tests/integration/test_events.py | 4 +- .../grades/tests/integration/test_problems.py | 10 ++-- lms/djangoapps/instructor/tests/test_api.py | 50 +++++++++---------- .../tests/test_api_email_localization.py | 2 +- .../instructor/tests/test_certificates.py | 40 +++++++-------- lms/djangoapps/instructor/tests/test_email.py | 4 +- .../instructor/tests/test_filters.py | 2 +- .../instructor/tests/test_proctoring.py | 2 +- .../instructor/tests/test_spoc_gradebook.py | 2 +- .../tests/views/test_instructor_dashboard.py | 14 +++--- .../rest_api/v1/tests/test_views.py | 22 ++++---- .../instructor_task/tests/test_base.py | 2 +- .../api/v0/tests/test_views.py | 6 +-- .../learner_dashboard/tests/test_programs.py | 11 ++-- .../learner_dashboard/tests/test_views.py | 7 ++- .../tests/test_views.py | 12 +++-- lms/djangoapps/mobile_api/testutils.py | 2 +- lms/djangoapps/staticbook/tests.py | 2 +- lms/djangoapps/survey/tests/test_models.py | 2 +- lms/djangoapps/survey/tests/test_utils.py | 2 +- lms/djangoapps/survey/tests/test_views.py | 2 +- .../verify_student/tests/test_views.py | 16 +++--- .../contentserver/test/test_contentserver.py | 14 +++--- .../course_apps/rest_api/tests/test_views.py | 2 +- .../notifications/tests/test_views.py | 37 +++++++------- .../tests/test_dot_overrides.py | 19 ++++--- .../oauth_dispatch/tests/test_views.py | 11 ++-- .../safe_sessions/tests/test_middleware.py | 12 +++-- .../tests/test_theme_style_overrides.py | 5 +- .../djangoapps/theming/tests/test_views.py | 2 +- .../user_api/accounts/tests/test_api.py | 2 +- .../djangoapps/user_api/tests/test_views.py | 1 + .../verification_api/tests/test_views.py | 2 +- .../user_authn/api/tests/test_views.py | 4 +- .../core/djangoapps/user_authn/tests/utils.py | 2 +- .../user_authn/views/tests/test_password.py | 8 +-- .../tests/test_course_expiration.py | 10 ++-- .../tests/views/test_course_sock.py | 2 +- .../tests/views/test_masquerade.py | 2 +- .../test_crowdsource_hinter.py | 4 +- .../xblock_integration/test_recommender.py | 6 +-- .../xblock_integration/xblock_testcase.py | 6 +-- xmodule/modulestore/tests/django_utils.py | 2 +- 96 files changed, 365 insertions(+), 351 deletions(-) diff --git a/cms/djangoapps/contentstore/tests/test_course_create_rerun.py b/cms/djangoapps/contentstore/tests/test_course_create_rerun.py index 264d6de8ff2f..c8d8c6e8d71d 100644 --- a/cms/djangoapps/contentstore/tests/test_course_create_rerun.py +++ b/cms/djangoapps/contentstore/tests/test_course_create_rerun.py @@ -51,7 +51,7 @@ def setUp(self): self.factory = RequestFactory() self.global_admin = AdminFactory() self.client = AjaxEnabledTestClient() - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) self.course_create_rerun_url = reverse('course_handler') self.course_start = datetime.datetime.utcnow() self.course_end = self.course_start + datetime.timedelta(days=30) diff --git a/cms/djangoapps/contentstore/tests/test_course_listing.py b/cms/djangoapps/contentstore/tests/test_course_listing.py index 461a1281f55d..66c16dc6dd8c 100644 --- a/cms/djangoapps/contentstore/tests/test_course_listing.py +++ b/cms/djangoapps/contentstore/tests/test_course_listing.py @@ -56,12 +56,12 @@ def setUp(self): super().setUp() # create and log in a staff user. # create and log in a non-staff user - self.user = UserFactory() + self.user = UserFactory(password=self.TEST_PASSWORD) self.factory = RequestFactory() self.request = self.factory.get('/course') self.request.user = self.user self.client = AjaxEnabledTestClient() - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) def _create_course_with_access_groups(self, course_location, user=None): """ diff --git a/cms/djangoapps/contentstore/tests/test_course_settings.py b/cms/djangoapps/contentstore/tests/test_course_settings.py index 605e0d21330e..f19f35efe2db 100644 --- a/cms/djangoapps/contentstore/tests/test_course_settings.py +++ b/cms/djangoapps/contentstore/tests/test_course_settings.py @@ -1866,10 +1866,10 @@ def _get_course_details_response(self, global_staff): """ Return the course details page as either global or non-global staff """ - user = UserFactory(is_staff=global_staff) + user = UserFactory(is_staff=global_staff, password=self.TEST_PASSWORD) CourseInstructorRole(self.course.id).add_users(user) - self.client.login(username=user.username, password='test') + self.client.login(username=user.username, password=self.TEST_PASSWORD) return self.client.get_html(self.course_details_url) diff --git a/cms/djangoapps/contentstore/tests/test_i18n.py b/cms/djangoapps/contentstore/tests/test_i18n.py index dc7740307169..be2003f981aa 100644 --- a/cms/djangoapps/contentstore/tests/test_i18n.py +++ b/cms/djangoapps/contentstore/tests/test_i18n.py @@ -184,7 +184,7 @@ def setUp(self): self.uname = 'testuser' self.email = 'test+courses@edx.org' - self.password = 'foo' + self.password = 'password' # Create the use so we can log them in. self.user = UserFactory.create(username=self.uname, email=self.email, password=self.password) diff --git a/cms/djangoapps/contentstore/tests/test_users_default_role.py b/cms/djangoapps/contentstore/tests/test_users_default_role.py index 590efc0bff67..1abf0a0ec697 100644 --- a/cms/djangoapps/contentstore/tests/test_users_default_role.py +++ b/cms/djangoapps/contentstore/tests/test_users_default_role.py @@ -27,7 +27,7 @@ def setUp(self): # create and log in a staff user. self.user = UserFactory(is_staff=True) self.client = AjaxEnabledTestClient() - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) # create a course via the view handler to create course self.course_key = self.store.make_course_key('Org_1', 'Course_1', 'Run_1') diff --git a/cms/djangoapps/contentstore/tests/tests.py b/cms/djangoapps/contentstore/tests/tests.py index f212bc39f1d8..bd2c3dbfd3c8 100644 --- a/cms/djangoapps/contentstore/tests/tests.py +++ b/cms/djangoapps/contentstore/tests/tests.py @@ -95,7 +95,7 @@ def setUp(self): super().setUp() self.email = 'a@b.com' - self.pw = 'xyz' + self.pw = 'password1234' self.username = 'testuser' self.client = AjaxEnabledTestClient() # clear the cache so ratelimiting won't affect these tests diff --git a/cms/djangoapps/contentstore/views/tests/test_certificates.py b/cms/djangoapps/contentstore/views/tests/test_certificates.py index 76dfb3be95d7..7af7a448de10 100644 --- a/cms/djangoapps/contentstore/views/tests/test_certificates.py +++ b/cms/djangoapps/contentstore/views/tests/test_certificates.py @@ -249,7 +249,7 @@ def test_cannot_create_certificate_if_user_has_no_write_permissions(self): Tests user without write permissions on course should not able to create certificate """ user = UserFactory() - self.client.login(username=user.username, password='test') + self.client.login(username=user.username, password=self.TEST_PASSWORD) response = self.client.ajax_post( self._url(), data=CERTIFICATE_JSON @@ -635,7 +635,7 @@ def test_delete_certificate_without_write_permissions(self, signatory_path): """ self._add_course_certificates(count=2, signatory_count=1, asset_path_format=signatory_path) user = UserFactory() - self.client.login(username=user.username, password='test') + self.client.login(username=user.username, password=self.TEST_PASSWORD) response = self.client.delete( self._url(cid=1), content_type="application/json", @@ -653,7 +653,7 @@ def test_delete_certificate_without_global_staff_permissions(self, signatory_pat user = UserFactory() for role in [CourseInstructorRole, CourseStaffRole]: role(self.course.id).add_users(user) - self.client.login(username=user.username, password='test') + self.client.login(username=user.username, password=self.TEST_PASSWORD) response = self.client.delete( self._url(cid=1), content_type="application/json", @@ -681,7 +681,7 @@ def test_update_active_certificate_without_global_staff_permissions(self, signat user = UserFactory() for role in [CourseInstructorRole, CourseStaffRole]: role(self.course.id).add_users(user) - self.client.login(username=user.username, password='test') + self.client.login(username=user.username, password=self.TEST_PASSWORD) response = self.client.put( self._url(cid=1), data=json.dumps(cert_data), @@ -799,7 +799,7 @@ def test_certificate_activation_without_write_permissions(self, activate, signat test_url = reverse_course_url('certificate_activation_handler', self.course.id) self._add_course_certificates(count=1, signatory_count=2, asset_path_format=signatory_path) user = UserFactory() - self.client.login(username=user.username, password='test') + self.client.login(username=user.username, password=self.TEST_PASSWORD) response = self.client.post( test_url, data=json.dumps({"is_active": activate}), diff --git a/cms/djangoapps/contentstore/views/tests/test_organizations.py b/cms/djangoapps/contentstore/views/tests/test_organizations.py index 6f3b67671101..cf3a376f3461 100644 --- a/cms/djangoapps/contentstore/views/tests/test_organizations.py +++ b/cms/djangoapps/contentstore/views/tests/test_organizations.py @@ -14,8 +14,9 @@ class TestOrganizationListing(TestCase): """Verify Organization listing behavior.""" def setUp(self): super().setUp() - self.staff = UserFactory(is_staff=True) - self.client.login(username=self.staff.username, password='test') + self.password = "password1234" + self.staff = UserFactory(is_staff=True, password=self.password) + self.client.login(username=self.staff.username, password=self.password) self.org_names_listing_url = reverse('organizations') self.org_short_names = ["alphaX", "betaX", "orgX"] for index, short_name in enumerate(self.org_short_names): diff --git a/cms/djangoapps/maintenance/tests.py b/cms/djangoapps/maintenance/tests.py index dd060c4c0113..a487f8e37faa 100644 --- a/cms/djangoapps/maintenance/tests.py +++ b/cms/djangoapps/maintenance/tests.py @@ -30,7 +30,7 @@ class TestMaintenanceIndex(ModuleStoreTestCase): def setUp(self): super().setUp() self.user = AdminFactory() - login_success = self.client.login(username=self.user.username, password='test') + login_success = self.client.login(username=self.user.username, password=self.TEST_PASSWORD) self.assertTrue(login_success) self.view_url = reverse('maintenance:maintenance_index') @@ -56,7 +56,7 @@ class MaintenanceViewTestCase(ModuleStoreTestCase): def setUp(self): super().setUp() self.user = AdminFactory() - login_success = self.client.login(username=self.user.username, password='test') + login_success = self.client.login(username=self.user.username, password=self.TEST_PASSWORD) self.assertTrue(login_success) def verify_error_message(self, data, error_message): @@ -110,8 +110,8 @@ def test_non_global_staff_access(self, url): """ Test that all maintenance app views are not accessible to non-global-staff user. """ - user = UserFactory(username='test', email='test@example.com', password='test') - login_success = self.client.login(username=user.username, password='test') + user = UserFactory(username='test', email='test@example.com', password=self.TEST_PASSWORD) + login_success = self.client.login(username=user.username, password=self.TEST_PASSWORD) self.assertTrue(login_success) response = self.client.get(url) @@ -245,13 +245,13 @@ def setUp(self): self.admin = AdminFactory.create( email='staff@edx.org', username='admin', - password='pass' + password=self.TEST_PASSWORD ) - self.client.login(username=self.admin.username, password='pass') + self.client.login(username=self.admin.username, password=self.TEST_PASSWORD) self.non_staff_user = UserFactory.create( email='test@edx.org', username='test', - password='pass' + password=self.TEST_PASSWORD ) def test_index(self): @@ -301,7 +301,7 @@ def _test_403(self, viewname, kwargs=None): self.assertEqual(response.status_code, 403) def test_authorization(self): - self.client.login(username=self.non_staff_user, password='pass') + self.client.login(username=self.non_staff_user, password=self.TEST_PASSWORD) announcement = Announcement.objects.create(content="Test Delete") announcement.save() diff --git a/common/djangoapps/course_modes/tests/test_admin.py b/common/djangoapps/course_modes/tests/test_admin.py index 52640dc52fe5..25b6558d24ab 100644 --- a/common/djangoapps/course_modes/tests/test_admin.py +++ b/common/djangoapps/course_modes/tests/test_admin.py @@ -54,7 +54,7 @@ def test_expiration_timezone(self): '_expiration_datetime_1': expiration.time(), } - self.client.login(username=user.username, password='test') + self.client.login(username=user.username, password=self.TEST_PASSWORD) # Create a new course mode from django admin page response = self.client.post(reverse('admin:course_modes_coursemode_add'), data=data) diff --git a/common/djangoapps/student/tests/factories.py b/common/djangoapps/student/tests/factories.py index 708082412516..506d1818e4c4 100644 --- a/common/djangoapps/student/tests/factories.py +++ b/common/djangoapps/student/tests/factories.py @@ -35,7 +35,7 @@ from openedx.core.djangoapps.content.course_overviews.models import CourseOverview from openedx.core.djangoapps.content.course_overviews.tests.factories import CourseOverviewFactory -TEST_PASSWORD = 'test' +TEST_PASSWORD = 'password' class GroupFactory(DjangoModelFactory): # lint-amnesty, pylint: disable=missing-class-docstring @@ -81,7 +81,7 @@ class Meta: model = User django_get_or_create = ('email', 'username') - _DEFAULT_PASSWORD = 'test' + _DEFAULT_PASSWORD = 'password' username = factory.Sequence('robot{}'.format) email = factory.Sequence('robot+test+{}@edx.org'.format) diff --git a/common/djangoapps/student/tests/test_admin_views.py b/common/djangoapps/student/tests/test_admin_views.py index 5c6350c2f0ce..7ae693606daf 100644 --- a/common/djangoapps/student/tests/test_admin_views.py +++ b/common/djangoapps/student/tests/test_admin_views.py @@ -53,7 +53,7 @@ def test_save_valid_data(self): 'email': self.user.email } - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) # # adding new role from django admin page response = self.client.post(reverse('admin:student_courseaccessrole_add'), data=data) @@ -78,7 +78,7 @@ def test_save_without_org_and_course_data(self): 'course_id': str(self.course.id) } - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) # # adding new role from django admin page response = self.client.post(reverse('admin:student_courseaccessrole_add'), data=data) @@ -96,7 +96,7 @@ def test_save_with_course_only(self): } - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) # # adding new role from django admin page response = self.client.post(reverse('admin:student_courseaccessrole_add'), data=data) @@ -115,7 +115,7 @@ def test_save_with_org_only(self): } - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) # # adding new role from django admin page response = self.client.post(reverse('admin:student_courseaccessrole_add'), data=data) @@ -136,7 +136,7 @@ def test_save_with_invalid_course(self): 'email': email } - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) # Adding new role with invalid data response = self.client.post(reverse('admin:student_courseaccessrole_add'), data=data) @@ -163,7 +163,7 @@ def test_save_valid_course_invalid_org(self): 'email': self.user.email } - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) # # adding new role from django admin page response = self.client.post(reverse('admin:student_courseaccessrole_add'), data=data) @@ -230,7 +230,7 @@ def setUp(self): user=self.user, course_id=self.course.id, # pylint: disable=no-member ) - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) @ddt.data(*ADMIN_URLS) @ddt.unpack @@ -326,11 +326,12 @@ def setUpClass(cls): super().setUpClass() cls.user = UserFactory.create(username='§', is_staff=True, is_superuser=True) cls.user.save() + cls.TEST_PASSWORD = 'password' def setUp(self): """Setup.""" super().setUp() - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) self.user2 = UserFactory.create(username='Zażółć gęślą jaźń') self.user_lockout_until = datetime.datetime.now(UTC) LoginFailures.objects.create(user=self.user, failure_count=10, lockout_until=self.user_lockout_until) diff --git a/common/djangoapps/student/tests/test_bulk_email_settings.py b/common/djangoapps/student/tests/test_bulk_email_settings.py index d9bfd15621ca..308ccf66e09d 100644 --- a/common/djangoapps/student/tests/test_bulk_email_settings.py +++ b/common/djangoapps/student/tests/test_bulk_email_settings.py @@ -33,7 +33,7 @@ def setUp(self): # Create student account student = UserFactory.create() CourseEnrollmentFactory.create(user=student, course_id=self.course.id) - self.client.login(username=student.username, password="test") + self.client.login(username=student.username, password=self.TEST_PASSWORD) self.url = reverse('dashboard') # URL for email settings modal diff --git a/common/djangoapps/student/tests/test_filters.py b/common/djangoapps/student/tests/test_filters.py index 6e429fd39a5c..376595a8507b 100644 --- a/common/djangoapps/student/tests/test_filters.py +++ b/common/djangoapps/student/tests/test_filters.py @@ -316,7 +316,7 @@ class StudentDashboardFiltersTest(ModuleStoreTestCase): def setUp(self): # pylint: disable=arguments-differ super().setUp() self.user = UserFactory() - self.client.login(username=self.user.username, password="test") + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) self.dashboard_url = reverse("dashboard") self.first_course = CourseFactory.create( org="test1", course="course1", display_name="run1", diff --git a/common/djangoapps/student/tests/test_retirement.py b/common/djangoapps/student/tests/test_retirement.py index a7e5fac86571..96c0034a0e7c 100644 --- a/common/djangoapps/student/tests/test_retirement.py +++ b/common/djangoapps/student/tests/test_retirement.py @@ -260,7 +260,7 @@ def setUp(self): 'username': 'username', 'email': 'foo_bar' + '@bar.com', 'name': 'foo bar', - 'password': '123', + 'password': '12345678', 'terms_of_service': 'true', 'honor_code': 'true', } diff --git a/common/djangoapps/student/tests/test_userstanding.py b/common/djangoapps/student/tests/test_userstanding.py index 832127e474ed..e7b9bab233a1 100644 --- a/common/djangoapps/student/tests/test_userstanding.py +++ b/common/djangoapps/student/tests/test_userstanding.py @@ -43,7 +43,7 @@ def setUp(self): (self.non_staff, self.non_staff_client), (self.admin, self.admin_client), ]: - client.login(username=user.username, password='test') + client.login(username=user.username, password='password') UserStandingFactory.create( user=self.bad_user, diff --git a/common/djangoapps/student/tests/test_views.py b/common/djangoapps/student/tests/test_views.py index b9518efa0446..1230f8320a75 100644 --- a/common/djangoapps/student/tests/test_views.py +++ b/common/djangoapps/student/tests/test_views.py @@ -49,7 +49,6 @@ from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order -PASSWORD = 'test' TOMORROW = now() + timedelta(days=1) ONE_WEEK_AGO = now() - timedelta(weeks=1) THREE_YEARS_FROM_NOW = now() + timedelta(days=(365 * 3)) @@ -81,7 +80,7 @@ def setUp(self): self.user = UserFactory() self.enrollment = CourseEnrollmentFactory(course_id=self.course.id, user=self.user) self.cert_status = 'processing' - self.client.login(username=self.user.username, password=PASSWORD) + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) def mock_cert(self, _user, _course_overview): """ Return a preset certificate status. """ @@ -212,7 +211,7 @@ def setUp(self): """ super().setUp() self.user = UserFactory() - self.client.login(username=self.user.username, password=PASSWORD) + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) self.path = reverse('dashboard') def set_course_sharing_urls(self, set_marketing, set_social_sharing): @@ -1018,7 +1017,7 @@ class TestCourseDashboardNoticesRedirects(SharedModuleStoreTestCase): def setUp(self): super().setUp() self.user = UserFactory() - self.client.login(username=self.user.username, password=PASSWORD) + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) self.path = reverse('dashboard') def test_check_for_unacknowledged_notices(self): diff --git a/common/djangoapps/student/tests/tests.py b/common/djangoapps/student/tests/tests.py index b41ad2f856d6..a90b2504d137 100644 --- a/common/djangoapps/student/tests/tests.py +++ b/common/djangoapps/student/tests/tests.py @@ -278,7 +278,7 @@ class DashboardTest(ModuleStoreTestCase, TestVerificationBase): def setUp(self): super().setUp() self.course = CourseFactory.create() - self.user = UserFactory.create(username="jack", email="jack@fake.edx.org", password='test') + self.user = UserFactory.create(username="jack", email="jack@fake.edx.org", password=self.TEST_PASSWORD) self.client = Client() cache.clear() @@ -307,7 +307,7 @@ def test_verification_status_visible(self): """ Test that the certificate verification status for courses is visible on the dashboard. """ - self.client.login(username="jack", password="test") + self.client.login(username="jack", password=self.TEST_PASSWORD) self._check_verification_status_on('verified', 'You're enrolled as a verified student') self._check_verification_status_on('honor', 'You're enrolled as an honor code student') self._check_verification_status_off('audit', '') @@ -345,7 +345,7 @@ def test_verification_status_invisible(self): Test that the certificate verification status for courses is not visible on the dashboard if the verified certificates setting is off. """ - self.client.login(username="jack", password="test") + self.client.login(username="jack", password=self.TEST_PASSWORD) self._check_verification_status_off('verified', 'You\'re enrolled as a verified student') self._check_verification_status_off('honor', 'You\'re enrolled as an honor code student') self._check_verification_status_off('audit', '') @@ -371,7 +371,7 @@ def test_course_mode_info(self): @skip_unless_lms def test_linked_in_add_to_profile_btn_not_appearing_without_config(self): # Without linked-in config don't show Add Certificate to LinkedIn button - self.client.login(username="jack", password="test") + self.client.login(username="jack", password=self.TEST_PASSWORD) CourseModeFactory.create( course_id=self.course.id, @@ -409,7 +409,7 @@ def test_linked_in_add_to_profile_btn_not_appearing_without_config(self): def test_linked_in_add_to_profile_btn_with_certificate(self): # If user has a certificate with valid linked-in config then Add Certificate to LinkedIn button # should be visible. and it has URL value with valid parameters. - self.client.login(username="jack", password="test") + self.client.login(username="jack", password=self.TEST_PASSWORD) linkedin_config = LinkedInAddToProfileConfiguration.objects.create(company_identifier='1337', enabled=True) CourseModeFactory.create( @@ -480,7 +480,7 @@ def test_dashboard_metadata_caching(self): # Create a course and log in the user. # Creating a new course will trigger a publish event and the course will be cached test_course = CourseFactory.create(emit_signals=True) - self.client.login(username="jack", password="test") + self.client.login(username="jack", password=self.TEST_PASSWORD) with check_mongo_calls(0): CourseEnrollment.enroll(self.user, test_course.id) @@ -495,7 +495,7 @@ def test_dashboard_metadata_caching(self): @skip_unless_lms def test_dashboard_header_nav_has_find_courses(self): - self.client.login(username="jack", password="test") + self.client.login(username="jack", password=self.TEST_PASSWORD) response = self.client.get(reverse("dashboard")) # "Explore courses" is shown in the side panel @@ -542,7 +542,7 @@ def setUp(self): super().setUp() self.org = 'fakeX' self.course = CourseFactory.create(org=self.org) - self.user = UserFactory.create(username='jack', email='jack@fake.edx.org', password='test') + self.user = UserFactory.create(username='jack', email='jack@fake.edx.org', password=self.TEST_PASSWORD) CourseModeFactory.create(mode_slug='no-id-professional', course_id=self.course.id) CourseEnrollment.enroll(self.user, self.course.location.course_key, mode='no-id-professional') cache.clear() @@ -564,7 +564,7 @@ def test_course_mode_visible(self, site_domain, site_configuration_values): 'course_org_filter': self.org }) self.set_up_site(site_domain, site_configuration_values) - self.client.login(username='jack', password='test') + self.client.login(username='jack', password=self.TEST_PASSWORD) response = self.client.get(reverse('dashboard')) self.assertContains(response, 'class="course professional"') @@ -585,7 +585,7 @@ def test_course_mode_invisible(self, site_domain, site_configuration_values): 'course_org_filter': self.org }) self.set_up_site(site_domain, site_configuration_values) - self.client.login(username='jack', password='test') + self.client.login(username='jack', password=self.TEST_PASSWORD) response = self.client.get(reverse('dashboard')) self.assertNotContains(response, 'class="course professional"') @@ -899,8 +899,8 @@ class ChangeEnrollmentViewTest(ModuleStoreTestCase): def setUp(self): super().setUp() self.course = CourseFactory.create() - self.user = UserFactory.create(password='secret') - self.client.login(username=self.user.username, password='secret') + self.user = UserFactory.create(password=self.TEST_PASSWORD) + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) self.url = reverse('change_enrollment') def _enroll_through_view(self, course): @@ -1056,14 +1056,13 @@ def test_anonymous_id_secret_key_changes_result_in_diff_values_for_same_new_user class RelatedProgramsTests(ProgramsApiConfigMixin, SharedModuleStoreTestCase): """Tests verifying that related programs appear on the course dashboard.""" maxDiff = None - password = 'test' related_programs_preface = 'Related Programs' @classmethod def setUpClass(cls): super().setUpClass() - cls.user = UserFactory() + cls.user = UserFactory(password=cls.TEST_PASSWORD) cls.course = CourseFactory() cls.enrollment = CourseEnrollmentFactory(user=cls.user, course_id=cls.course.id) # pylint: disable=no-member @@ -1073,7 +1072,7 @@ def setUp(self): self.url = reverse('dashboard') self.create_programs_config() - self.client.login(username=self.user.username, password=self.password) + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) course_run = CourseRunFactory(key=str(self.course.id)) # pylint: disable=no-member course = CatalogCourseFactory(course_runs=[course_run]) diff --git a/common/djangoapps/third_party_auth/tests/specs/base.py b/common/djangoapps/third_party_auth/tests/specs/base.py index 116deacf5e1d..4974627fd0ee 100644 --- a/common/djangoapps/third_party_auth/tests/specs/base.py +++ b/common/djangoapps/third_party_auth/tests/specs/base.py @@ -481,7 +481,7 @@ def _test_login(self): # The AJAX on the page will log them in: ajax_login_response = self.client.post( reverse('user_api_login_session', kwargs={'api_version': 'v1'}), - {'email': self.user.email, 'password': 'test'} + {'email': self.user.email, 'password': 'password'} ) assert ajax_login_response.status_code == 200 # Then the AJAX will finish the third party auth: diff --git a/common/djangoapps/third_party_auth/tests/test_admin.py b/common/djangoapps/third_party_auth/tests/test_admin.py index c5481a3a09b4..a1b2e2235d9f 100644 --- a/common/djangoapps/third_party_auth/tests/test_admin.py +++ b/common/djangoapps/third_party_auth/tests/test_admin.py @@ -14,6 +14,9 @@ from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth +TEST_PASSWORD = 'password' + + # This is necessary because cms does not implement third party auth @skip_unless_thirdpartyauth() class Oauth2ProviderConfigAdminTest(testutil.TestCase): @@ -36,9 +39,9 @@ def test_oauth2_provider_edit_icon_image(self): prepopulated correctly, and that we can clear and update the image. """ # Login as a super user - user = UserFactory.create(is_staff=True, is_superuser=True) + user = UserFactory.create(is_staff=True, is_superuser=True, password=TEST_PASSWORD) user.save() - self.client.login(username=user.username, password='test') + self.client.login(username=user.username, password=TEST_PASSWORD) # Get baseline provider count providers = OAuth2ProviderConfig.objects.all() diff --git a/lms/djangoapps/badges/api/tests.py b/lms/djangoapps/badges/api/tests.py index e0031c29dee4..cadb30d11a9a 100644 --- a/lms/djangoapps/badges/api/tests.py +++ b/lms/djangoapps/badges/api/tests.py @@ -29,7 +29,7 @@ def setUp(self): self.course = CourseFactory.create() self.user = UserFactory.create() # Password defined by factory. - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) def url(self): """ diff --git a/lms/djangoapps/bulk_email/tests/test_course_optout.py b/lms/djangoapps/bulk_email/tests/test_course_optout.py index a618545bcd68..fe0f70fbdc3b 100644 --- a/lms/djangoapps/bulk_email/tests/test_course_optout.py +++ b/lms/djangoapps/bulk_email/tests/test_course_optout.py @@ -40,7 +40,7 @@ def setUp(self): # load initial content (since we don't run migrations as part of tests): call_command("loaddata", "course_email_template.json") - self.client.login(username=self.student.username, password="test") + self.client.login(username=self.student.username, password=self.TEST_PASSWORD) self.send_mail_url = reverse('send_email', kwargs={'course_id': str(self.course.id)}) self.success_content = { @@ -70,7 +70,7 @@ def test_optout_course(self): self.client.logout() - self.client.login(username=self.instructor.username, password="test") + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) self.navigate_to_email_view() test_email = { @@ -92,7 +92,7 @@ def test_optout_using_unsubscribe_link_in_email(self): """ self.client.logout() - self.client.login(username=self.instructor.username, password="test") + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) unsubscribe_link = get_unsubscribed_link(self.student.username, str(self.course.id)) response = self.client.post(unsubscribe_link, {'unsubscribe': True}) @@ -122,7 +122,7 @@ def test_optin_course(self): assert CourseEnrollment.is_enrolled(self.student, self.course.id) - self.client.login(username=self.instructor.username, password="test") + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) self.navigate_to_email_view() test_email = { @@ -155,7 +155,7 @@ def setUp(self): self.student = UserFactory.create() CourseEnrollmentFactory.create(user=self.student, course_id=self.course.id) - self.client.login(username=self.student.username, password="test") + self.client.login(username=self.student.username, password=self.TEST_PASSWORD) self._set_email_optout(False) self.policy = CourseEmailOptout() diff --git a/lms/djangoapps/bulk_email/tests/test_email.py b/lms/djangoapps/bulk_email/tests/test_email.py index b67864381bfa..ba95bd26ddda 100644 --- a/lms/djangoapps/bulk_email/tests/test_email.py +++ b/lms/djangoapps/bulk_email/tests/test_email.py @@ -87,7 +87,7 @@ def login_as_user(self, user): """ Log in self.client as user. """ - self.client.login(username=user.username, password="test") + self.client.login(username=user.username, password=self.TEST_PASSWORD) def goto_instructor_dash_email_view(self): """ diff --git a/lms/djangoapps/bulk_email/tests/test_err_handling.py b/lms/djangoapps/bulk_email/tests/test_err_handling.py index 3f3ffe9b6977..06e9a1dce40f 100644 --- a/lms/djangoapps/bulk_email/tests/test_err_handling.py +++ b/lms/djangoapps/bulk_email/tests/test_err_handling.py @@ -53,7 +53,7 @@ def setUp(self): course_title = "ẗëṡẗ title イ乇丂イ ᄊ乇丂丂ムg乇 キo尺 ムレレ тэѕт мэѕѕаБэ" self.course = CourseFactory.create(display_name=course_title) self.instructor = AdminFactory.create() - self.client.login(username=self.instructor.username, password="test") + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) # load initial content (since we don't run migrations as part of tests): call_command("loaddata", "course_email_template.json") diff --git a/lms/djangoapps/bulk_email/tests/test_signals.py b/lms/djangoapps/bulk_email/tests/test_signals.py index ea369fa80524..1a3715284b12 100644 --- a/lms/djangoapps/bulk_email/tests/test_signals.py +++ b/lms/djangoapps/bulk_email/tests/test_signals.py @@ -33,7 +33,7 @@ def setUp(self): # load initial content (since we don't run migrations as part of tests): call_command("loaddata", "course_email_template.json") - self.client.login(username=self.student.username, password="test") + self.client.login(username=self.student.username, password=self.TEST_PASSWORD) self.send_mail_url = reverse('send_email', kwargs={'course_id': str(self.course.id)}) self.success_content = { @@ -78,7 +78,7 @@ def test_optout_course(self): force_optout_all(sender=self.__class__, user=self.student) # Try to send a bulk course email - self.client.login(username=self.instructor.username, password="test") + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) self.send_test_email() # Assert that self.student.email not in mail.to, outbox should only contain "myself" target diff --git a/lms/djangoapps/ccx/api/v0/tests/test_views.py b/lms/djangoapps/ccx/api/v0/tests/test_views.py index d3daf72244cf..195fafb11cca 100644 --- a/lms/djangoapps/ccx/api/v0/tests/test_views.py +++ b/lms/djangoapps/ccx/api/v0/tests/test_views.py @@ -33,7 +33,7 @@ from lms.djangoapps.instructor.enrollment import enroll_email, get_email_params from openedx.core.lib.courses import get_course_by_id -USER_PASSWORD = 'test' +USER_PASSWORD = 'password' class CcxRestApiTest(CcxTestCase, APITestCase): @@ -760,7 +760,7 @@ def test_authorization_no_oauth_staff(self): """ # create a staff user staff_user = UserFactory.create( - username='test_staff_user', email='test_staff_user@openedx.org', password='test', + username='test_staff_user', email='test_staff_user@openedx.org', password=USER_PASSWORD, ) # add staff role to the staff user CourseStaffRole(self.master_course_key).add_users(staff_user) @@ -779,7 +779,7 @@ def test_authorization_no_oauth_instructor(self): """ # create an instructor user instructor_user = UserFactory.create( - username='test_instructor_user', email='test_instructor_user@openedx.org', password='test', + username='test_instructor_user', email='test_instructor_user@openedx.org', password=USER_PASSWORD, ) # add instructor role to the instructor user CourseInstructorRole(self.master_course_key).add_users(instructor_user) @@ -798,7 +798,7 @@ def test_authorization_no_oauth_other_coach(self): """ # create an coach user coach_user = UserFactory.create( - username='test_coach_user', email='test_coach_user@openedx.org', password='test', + username='test_coach_user', email='test_coach_user@openedx.org', password=USER_PASSWORD, ) # add coach role to the coach user CourseCcxCoachRole(self.master_course_key).add_users(coach_user) diff --git a/lms/djangoapps/ccx/tests/test_views.py b/lms/djangoapps/ccx/tests/test_views.py index b18ed5c2aae1..6dd569c0fb59 100644 --- a/lms/djangoapps/ccx/tests/test_views.py +++ b/lms/djangoapps/ccx/tests/test_views.py @@ -129,13 +129,14 @@ def setUp(self): ccx = self.make_ccx() ccx_key = CCXLocator.from_course_locator(self.course.id, ccx.id) self.url = reverse('ccx_coach_dashboard', kwargs={'course_id': ccx_key}) + self.TEST_PASSWORD = 'password' def test_staff_access_coach_dashboard(self): """ User is staff, should access coach dashboard. """ staff = self.make_staff() - self.client.login(username=staff.username, password="test") + self.client.login(username=staff.username, password=self.TEST_PASSWORD) response = self.client.get(self.url) assert response.status_code == 200 @@ -145,7 +146,7 @@ def test_instructor_access_coach_dashboard(self): User is instructor, should access coach dashboard. """ instructor = self.make_instructor() - self.client.login(username=instructor.username, password="test") + self.client.login(username=instructor.username, password=self.TEST_PASSWORD) # Now access URL response = self.client.get(self.url) @@ -155,8 +156,8 @@ def test_forbidden_user_access_coach_dashboard(self): """ Assert user with no access must not see dashboard. """ - user = UserFactory.create(password="test") - self.client.login(username=user.username, password="test") + user = UserFactory.create(password=self.TEST_PASSWORD) + self.client.login(username=user.username, password=self.TEST_PASSWORD) response = self.client.get(self.url) assert response.status_code == 403 @@ -211,12 +212,12 @@ def assert_progress_summary(self, ccx_course_key, due): """ assert signal and schedule update. """ - student = UserFactory.create(is_staff=False, password="test") + student = UserFactory.create(is_staff=False, password=self.TEST_PASSWORD) CourseEnrollment.enroll(student, ccx_course_key) assert CourseEnrollment.objects.filter(course_id=ccx_course_key, user=student).exists() # login as student - self.client.login(username=student.username, password="test") + self.client.login(username=student.username, password=self.TEST_PASSWORD) progress_page_response = self.client.get( reverse('progress', kwargs={'course_id': ccx_course_key}) ) @@ -236,7 +237,7 @@ def test_edit_schedule(self): self.make_coach() ccx = self.make_ccx() ccx_course_key = CCXLocator.from_course_locator(self.course.id, str(ccx.id)) - self.client.login(username=self.coach.username, password="test") + self.client.login(username=self.coach.username, password=self.TEST_PASSWORD) url = reverse('ccx_coach_dashboard', kwargs={'course_id': ccx_course_key}) response = self.client.get(url) @@ -295,7 +296,7 @@ def setUp(self): """ super().setUp() # Login with the instructor account - self.client.login(username=self.coach.username, password="test") + self.client.login(username=self.coach.username, password=self.TEST_PASSWORD) # adding staff to master course. staff = UserFactory() @@ -315,8 +316,8 @@ def test_not_a_coach(self): ccx = self.make_ccx() # create session of non-coach user - user = UserFactory.create(password="test") - self.client.login(username=user.username, password="test") + user = UserFactory.create(password=self.TEST_PASSWORD) + self.client.login(username=user.username, password=self.TEST_PASSWORD) url = reverse( 'ccx_coach_dashboard', kwargs={'course_id': CCXLocator.from_course_locator(self.course.id, ccx.id)}) @@ -841,7 +842,7 @@ def setUp(self): self.mstore = modulestore() # Login with the instructor account - self.client.login(username=self.coach.username, password="test") + self.client.login(username=self.coach.username, password=self.TEST_PASSWORD) # adding staff to master course. staff = UserFactory() @@ -981,7 +982,7 @@ def setUp(self): # Create instructor account self.coach = coach = AdminFactory.create() - self.client.login(username=coach.username, password="test") + self.client.login(username=coach.username, password=self.TEST_PASSWORD) # Create CCX role = CourseCcxCoachRole(self._course.id) @@ -1009,7 +1010,7 @@ def setUp(self): self.course = get_course_by_id(self.ccx_key, depth=None) CourseOverview.load_from_module_store(self.course.id) setup_students_and_grades(self) - self.client.login(username=coach.username, password="test") + self.client.login(username=coach.username, password=self.TEST_PASSWORD) self.addCleanup(RequestCache.clear_all_namespaces) from xmodule.modulestore.django import SignalHandler @@ -1068,7 +1069,7 @@ def test_student_progress(self): get_course.return_value = self.course self.addCleanup(patch_context.stop) - self.client.login(username=self.student.username, password="test") # lint-amnesty, pylint: disable=no-member + self.client.login(username=self.student.username, password=self.TEST_PASSWORD) # lint-amnesty, pylint: disable=no-member url = reverse( 'progress', kwargs={'course_id': self.ccx_key} @@ -1194,7 +1195,7 @@ def setUp(self): # Create a Split Mongo course and enroll a student user in it. self.student_password = "foobar" - self.student = UserFactory.create(username="test", password=self.student_password, is_staff=False) + self.student = UserFactory.create(username=self.TEST_PASSWORD, password=self.student_password, is_staff=False) self.split_course = SampleCourseFactory.create(default_store=ModuleStoreEnum.Type.split) CourseEnrollment.enroll(self.student, self.split_course.id) diff --git a/lms/djangoapps/ccx/tests/utils.py b/lms/djangoapps/ccx/tests/utils.py index 4d36353b9a75..4f8c34e14c2d 100644 --- a/lms/djangoapps/ccx/tests/utils.py +++ b/lms/djangoapps/ccx/tests/utils.py @@ -68,7 +68,7 @@ def setUp(self): """ super().setUp() # Create instructor account - self.coach = UserFactory.create(password="test") + self.coach = UserFactory.create() # create an instance of modulestore self.mstore = modulestore() @@ -76,7 +76,7 @@ def make_staff(self): """ create staff user. """ - staff = UserFactory.create(password="test") + staff = UserFactory.create() role = CourseStaffRole(self.course.id) role.add_users(staff) @@ -86,7 +86,7 @@ def make_instructor(self): """ create instructor user. """ - instructor = UserFactory.create(password="test") + instructor = UserFactory.create() role = CourseInstructorRole(self.course.id) role.add_users(instructor) diff --git a/lms/djangoapps/commerce/api/v1/tests/test_views.py b/lms/djangoapps/commerce/api/v1/tests/test_views.py index 47de5d8ff598..68f3d92d52af 100644 --- a/lms/djangoapps/commerce/api/v1/tests/test_views.py +++ b/lms/djangoapps/commerce/api/v1/tests/test_views.py @@ -23,7 +23,7 @@ from ....tests.mocks import mock_order_endpoint from ....tests.test_views import UserMixin -PASSWORD = 'test' +PASSWORD = 'password' JSON_CONTENT_TYPE = 'application/json' diff --git a/lms/djangoapps/commerce/tests/test_views.py b/lms/djangoapps/commerce/tests/test_views.py index 9af2ee7d9701..8932c826c7fc 100644 --- a/lms/djangoapps/commerce/tests/test_views.py +++ b/lms/djangoapps/commerce/tests/test_views.py @@ -3,6 +3,9 @@ from common.djangoapps.student.tests.factories import UserFactory +TEST_PASSWORD = "password" + + class UserMixin: """ Mixin for tests involving users. """ @@ -12,4 +15,4 @@ def setUp(self): def _login(self): """ Log into LMS. """ - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=TEST_PASSWORD) diff --git a/lms/djangoapps/course_api/blocks/tests/test_views.py b/lms/djangoapps/course_api/blocks/tests/test_views.py index 72e5e430f6d8..e2426708d6bc 100644 --- a/lms/djangoapps/course_api/blocks/tests/test_views.py +++ b/lms/djangoapps/course_api/blocks/tests/test_views.py @@ -60,7 +60,7 @@ def setUp(self): self.admin_user = AdminFactory.create() self.data_researcher = UserFactory.create() CourseDataResearcherRole(self.course_key).add_users(self.data_researcher) - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) CourseEnrollmentFactory.create(user=self.user, course_id=self.course_key) # default values for url and query_params @@ -248,7 +248,7 @@ def test_public_course_all_blocks_and_empty_username(self): self.client.logout() self.verify_response(403, cacheable=False) # Verify response for a staff user. - self.client.login(username=self.admin_user.username, password='test') + self.client.login(username=self.admin_user.username, password=self.TEST_PASSWORD) self.verify_response(cacheable=False) def test_non_existent_course(self): @@ -269,7 +269,7 @@ def test_no_user_staff_not_all_blocks(self): self.verify_response(400) def test_no_user_staff_all_blocks(self): - self.client.login(username=self.admin_user.username, password='test') + self.client.login(username=self.admin_user.username, password=self.TEST_PASSWORD) self.query_params.pop('username') self.query_params['all_blocks'] = True self.verify_response() @@ -319,7 +319,7 @@ def test_extra_field_when_requested(self): - other_course_settings - course_visibility """ - self.client.login(username=self.admin_user.username, password='test') + self.client.login(username=self.admin_user.username, password=self.TEST_PASSWORD) response = self.verify_response(params={ 'all_blocks': True, 'requested_fields': ['other_course_settings', 'course_visibility'], @@ -351,7 +351,7 @@ def test_extra_field_when_not_requested(self): - other_course_settings - course_visibility """ - self.client.login(username=self.admin_user.username, password='test') + self.client.login(username=self.admin_user.username, password=self.TEST_PASSWORD) response = self.verify_response(params={ 'all_blocks': True, 'requested_fields': ['course_visibility'], @@ -370,7 +370,7 @@ def test_data_researcher_access(self): """ Test if data researcher has access to the api endpoint """ - self.client.login(username=self.data_researcher.username, password='test') + self.client.login(username=self.data_researcher.username, password=self.TEST_PASSWORD) self.verify_response(params={ 'all_blocks': True, @@ -556,7 +556,7 @@ def setUpClass(cls): def setUp(self): super().setUp() self.admin_user = AdminFactory.create() - self.client.login(username=self.admin_user.username, password='test') + self.client.login(username=self.admin_user.username, password=self.TEST_PASSWORD) self.usage_key = list(self.non_orphaned_block_usage_keys)[0] self.url = reverse( 'blocks_metadata', diff --git a/lms/djangoapps/course_blocks/transformers/tests/helpers.py b/lms/djangoapps/course_blocks/transformers/tests/helpers.py index 27e7a686abcd..29c15e828976 100644 --- a/lms/djangoapps/course_blocks/transformers/tests/helpers.py +++ b/lms/djangoapps/course_blocks/transformers/tests/helpers.py @@ -50,7 +50,7 @@ def setUp(self): """ super().setUp() # Set up users. - self.password = 'test' + self.password = 'password' self.user = UserFactory.create(password=self.password) self.staff = UserFactory.create(password=self.password, is_staff=True) @@ -253,7 +253,7 @@ def setUp(self): parent_block.children.append(self.xblock_keys[i]) update_block(parent_block) - self.password = 'test' + self.password = 'password' self.student = UserFactory.create(is_staff=False, username='test_student', password=self.password) self.staff = UserFactory.create(is_staff=True, username='test_staff', password=self.password) CourseEnrollmentFactory.create( diff --git a/lms/djangoapps/course_wiki/tests/tests.py b/lms/djangoapps/course_wiki/tests/tests.py index 8cdd93115d6b..1afdea5d741e 100644 --- a/lms/djangoapps/course_wiki/tests/tests.py +++ b/lms/djangoapps/course_wiki/tests/tests.py @@ -24,7 +24,7 @@ def setUp(self): # Create two accounts self.student = 'view@test.com' self.instructor = 'view2@test.com' - self.password = 'foo' + self.password = 'password' for username, email in [('u1', self.student), ('u2', self.instructor)]: self.create_account(username, email, self.password) self.activate_user(email) diff --git a/lms/djangoapps/courseware/tests/helpers.py b/lms/djangoapps/courseware/tests/helpers.py index 3a2ddbc45630..30398dad3c23 100644 --- a/lms/djangoapps/courseware/tests/helpers.py +++ b/lms/djangoapps/courseware/tests/helpers.py @@ -128,7 +128,7 @@ def setup_course(self): # lint-amnesty, pylint: disable=missing-function-docstr self.clients = {user.username: Client() for user in self.users} self.login_statuses = [ self.clients[user.username].login( - username=user.username, password='test') + username=user.username, password=self.TEST_PASSWORD) for user in self.users ] @@ -173,7 +173,7 @@ def setup_user(self): Create a user account, activate, and log in. """ self.email = 'foo@test.com' # lint-amnesty, pylint: disable=attribute-defined-outside-init - self.password = 'bar' # lint-amnesty, pylint: disable=attribute-defined-outside-init + self.password = 'password' # lint-amnesty, pylint: disable=attribute-defined-outside-init self.username = 'test' # lint-amnesty, pylint: disable=attribute-defined-outside-init self.user = self.create_account( self.username, diff --git a/lms/djangoapps/courseware/tests/test_about.py b/lms/djangoapps/courseware/tests/test_about.py index f1f915fd02f4..f6c71119a7ad 100644 --- a/lms/djangoapps/courseware/tests/test_about.py +++ b/lms/djangoapps/courseware/tests/test_about.py @@ -284,7 +284,7 @@ def test_enrollment_cap(self): # pylint: disable=attribute-defined-outside-init # create a new account since the first account is already enrolled in the course self.email = 'foo_second@test.com' - self.password = 'bar' + self.password = 'password' self.username = 'test_second' self.create_account(self.username, self.email, self.password) self.activate_user(self.email) diff --git a/lms/djangoapps/courseware/tests/test_access.py b/lms/djangoapps/courseware/tests/test_access.py index 8a4cbabad6cc..ba93ec676205 100644 --- a/lms/djangoapps/courseware/tests/test_access.py +++ b/lms/djangoapps/courseware/tests/test_access.py @@ -82,8 +82,8 @@ def setUp(self): super().setUp() # Create ccx coach account - self.coach = AdminFactory.create(password="test") - self.client.login(username=self.coach.username, password="test") + self.coach = AdminFactory.create(password=self.TEST_PASSWORD) + self.client.login(username=self.coach.username, password=self.TEST_PASSWORD) # assign role to coach role = CourseCcxCoachRole(self.course.id) @@ -152,7 +152,7 @@ def test_access_student_progress_ccx(self): assert resp.status_code == 200 # Assert access of a student - self.client.login(username=student.username, password='test') + self.client.login(username=student.username, password=self.TEST_PASSWORD) resp = self.client.get(reverse('student_progress', args=[str(ccx_locator), self.coach.id])) assert resp.status_code == 404 diff --git a/lms/djangoapps/courseware/tests/test_block_render.py b/lms/djangoapps/courseware/tests/test_block_render.py index 80827afa632c..be1ebd5c05c0 100644 --- a/lms/djangoapps/courseware/tests/test_block_render.py +++ b/lms/djangoapps/courseware/tests/test_block_render.py @@ -362,7 +362,7 @@ def test_anonymous_post_xblock_callback(self): def test_session_authentication(self): """ Test that the xblock endpoint supports session authentication.""" - self.client.login(username=self.mock_user.username, password="test") + self.client.login(username=self.mock_user.username, password=self.TEST_PASSWORD) dispatch_url = self._get_dispatch_url() response = self.client.post(dispatch_url) assert 200 == response.status_code @@ -387,7 +387,7 @@ def test_missing_position_handler(self): """ Test that sending POST request without or invalid position argument don't raise server error """ - self.client.login(username=self.mock_user.username, password="test") + self.client.login(username=self.mock_user.username, password=self.TEST_PASSWORD) dispatch_url = self._get_dispatch_url() response = self.client.post(dispatch_url) assert 200 == response.status_code diff --git a/lms/djangoapps/courseware/tests/test_course_survey.py b/lms/djangoapps/courseware/tests/test_course_survey.py index d729add1b6c8..e5aa97cfaa2a 100644 --- a/lms/djangoapps/courseware/tests/test_course_survey.py +++ b/lms/djangoapps/courseware/tests/test_course_survey.py @@ -22,7 +22,7 @@ class SurveyViewsTests(LoginEnrollmentTestCase, SharedModuleStoreTestCase, XssTe """ All tests for the views.py file """ - STUDENT_INFO = [('view@test.com', 'foo')] + STUDENT_INFO = [('view@test.com', 'password1234')] @classmethod def setUpClass(cls): diff --git a/lms/djangoapps/courseware/tests/test_discussion_xblock.py b/lms/djangoapps/courseware/tests/test_discussion_xblock.py index bbe0e68bdcd1..599f125a7e38 100644 --- a/lms/djangoapps/courseware/tests/test_discussion_xblock.py +++ b/lms/djangoapps/courseware/tests/test_discussion_xblock.py @@ -366,7 +366,7 @@ def test_discussion_student_view_data(self): """ Tests that course block api returns student_view_data for discussion xblock """ - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) url = reverse('blocks_in_block_tree', kwargs={'usage_key_string': str(self.course_usage_key)}) query_params = { 'depth': 'all', diff --git a/lms/djangoapps/courseware/tests/test_entrance_exam.py b/lms/djangoapps/courseware/tests/test_entrance_exam.py index 240a9494fc8f..338a7bedfcf1 100644 --- a/lms/djangoapps/courseware/tests/test_entrance_exam.py +++ b/lms/djangoapps/courseware/tests/test_entrance_exam.py @@ -136,7 +136,7 @@ def setUp(self): self.request = get_mock_request(UserFactory()) self.course = self.update_course(self.course, self.request.user.id) - self.client.login(username=self.request.user.username, password="test") + self.client.login(username=self.request.user.username, password=self.TEST_PASSWORD) CourseEnrollment.enroll(self.request.user, self.course.id) self.expected_locked_toc = ( @@ -257,7 +257,7 @@ def test_skip_entrance_exam_gating(self): # hit skip entrance exam api in instructor app instructor = InstructorFactory(course_key=self.course.id) - self.client.login(username=instructor.username, password='test') + self.client.login(username=instructor.username, password=self.TEST_PASSWORD) url = reverse('mark_student_can_skip_entrance_exam', kwargs={'course_id': str(self.course.id)}) response = self.client.post(url, { 'unique_student_identifier': self.request.user.email, @@ -277,7 +277,7 @@ def test_entrance_exam_gating_for_staff(self): self.client.logout() staff_user = StaffFactory(course_key=self.course.id) staff_user.is_staff = True - self.client.login(username=staff_user.username, password='test') + self.client.login(username=staff_user.username, password=self.TEST_PASSWORD) # assert staff has access to all toc self.request.user = staff_user diff --git a/lms/djangoapps/courseware/tests/test_masquerade.py b/lms/djangoapps/courseware/tests/test_masquerade.py index 43041b1437e1..9d211b05ea21 100644 --- a/lms/djangoapps/courseware/tests/test_masquerade.py +++ b/lms/djangoapps/courseware/tests/test_masquerade.py @@ -88,7 +88,7 @@ def setUp(self): super().setUp() self.test_user = self.create_user() - self.login(self.test_user.email, 'test') + self.login(self.test_user.email, self.TEST_PASSWORD) self.enroll(self.course, True) def get_courseware_page(self): @@ -298,12 +298,12 @@ def setUp(self): def login_staff(self): """ Login as a staff user """ self.logout() - self.login(self.test_user.email, 'test') + self.login(self.test_user.email, self.TEST_PASSWORD) def login_student(self): """ Login as a student """ self.logout() - self.login(self.student_user.email, 'test') + self.login(self.student_user.email, self.TEST_PASSWORD) def submit_answer(self, response1, response2): """ @@ -351,7 +351,7 @@ def test_masquerade_as_specific_student(self, username): student = UserFactory.create(username=username) CourseEnrollment.enroll(student, self.course.id) self.logout() - self.login(student.email, 'test') + self.login(student.email, self.TEST_PASSWORD) # Answer correctly as the student, and check progress. self.submit_answer('Correct', 'Correct') assert self.get_progress_detail() == '2/2' @@ -378,7 +378,7 @@ def test_masquerade_as_specific_student(self, username): # Verify the student state did not change. self.logout() - self.login(student.email, 'test') + self.login(student.email, self.TEST_PASSWORD) assert self.get_progress_detail() == '2/2' def test_masquerading_with_language_preference(self): diff --git a/lms/djangoapps/courseware/tests/test_split_module.py b/lms/djangoapps/courseware/tests/test_split_module.py index 7e6b88718eac..5026f05ca221 100644 --- a/lms/djangoapps/courseware/tests/test_split_module.py +++ b/lms/djangoapps/courseware/tests/test_split_module.py @@ -59,7 +59,7 @@ def setUp(self): self.student = UserFactory.create() CourseEnrollmentFactory.create(user=self.student, course_id=self.course.id) - self.client.login(username=self.student.username, password='test') + self.client.login(username=self.student.username, password=self.TEST_PASSWORD) self.included_usage_keys = None self.excluded_usage_keys = None @@ -309,7 +309,7 @@ def setUp(self): self.student = UserFactory.create() CourseEnrollmentFactory.create(user=self.student, course_id=self.course.id) - self.client.login(username=self.student.username, password='test') + self.client.login(username=self.student.username, password=self.TEST_PASSWORD) def test_changing_position_works(self): # Make a mock FieldDataCache for this course, so we can get the course block diff --git a/lms/djangoapps/courseware/tests/test_submitting_problems.py b/lms/djangoapps/courseware/tests/test_submitting_problems.py index 8ffcea0298bf..9536067f52be 100644 --- a/lms/djangoapps/courseware/tests/test_submitting_problems.py +++ b/lms/djangoapps/courseware/tests/test_submitting_problems.py @@ -154,7 +154,7 @@ def setUp(self): # create a test student self.course = CourseFactory.create(display_name=self.COURSE_NAME, number=self.COURSE_SLUG) self.student = 'view@test.com' - self.password = 'foo' + self.password = 'password' self.create_account('u1', self.student, self.password) self.activate_user(self.student) self.enroll(self.course) diff --git a/lms/djangoapps/courseware/tests/test_tabs.py b/lms/djangoapps/courseware/tests/test_tabs.py index db59fa373bc5..6ad7ef73de01 100644 --- a/lms/djangoapps/courseware/tests/test_tabs.py +++ b/lms/djangoapps/courseware/tests/test_tabs.py @@ -404,7 +404,7 @@ def test_get_course_tabs_list_skipped_entrance_exam(self): # login as instructor hit skip entrance exam api in instructor app instructor = InstructorFactory(course_key=self.course.id) self.client.logout() - self.client.login(username=instructor.username, password='test') + self.client.login(username=instructor.username, password=self.TEST_PASSWORD) url = reverse('mark_student_can_skip_entrance_exam', kwargs={'course_id': str(self.course.id)}) response = self.client.post(url, { @@ -426,7 +426,7 @@ def test_course_tabs_list_for_staff_members(self): # Login as member of staff self.client.logout() staff_user = StaffFactory(course_key=self.course.id) - self.client.login(username=staff_user.username, password='test') + self.client.login(username=staff_user.username, password=self.TEST_PASSWORD) course_tab_list = get_course_tab_list(staff_user, self.course) assert len(course_tab_list) == 4 @@ -685,7 +685,7 @@ def test_course_tabs_staff_only(self): # Login as member of staff self.client.logout() staff_user = StaffFactory(course_key=self.course.id) - self.client.login(username=staff_user.username, password='test') + self.client.login(username=staff_user.username, password=self.TEST_PASSWORD) course_tab_list_staff = get_course_tab_list(staff_user, self.course) name_list_staff = [x.name for x in course_tab_list_staff] assert 'Static Tab Free' in name_list_staff diff --git a/lms/djangoapps/courseware/tests/test_view_authentication.py b/lms/djangoapps/courseware/tests/test_view_authentication.py index 42f2275e0fd2..aa53561ee56b 100644 --- a/lms/djangoapps/courseware/tests/test_view_authentication.py +++ b/lms/djangoapps/courseware/tests/test_view_authentication.py @@ -29,7 +29,7 @@ class TestViewAuth(EnterpriseTestConsentRequired, ModuleStoreTestCase, LoginEnro Check that view authentication works properly. """ - ACCOUNT_INFO = [('view@test.com', 'foo'), ('view2@test.com', 'foo')] + ACCOUNT_INFO = [('view@test.com', 'password1234'), ('view2@test.com', 'password1234')] ENABLED_SIGNALS = ['course_published'] @staticmethod @@ -111,7 +111,7 @@ def _check_staff(self, course): self.assert_request_status_code(302, url) def login(self, user): # lint-amnesty, pylint: disable=arguments-differ - return super().login(user.email, 'test') + return super().login(user.email, self.TEST_PASSWORD) def setUp(self): super().setUp() diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index c7d7ce7b177e..67d403a215eb 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -712,7 +712,7 @@ def test_submission_history_accepts_valid_ids(self): # log into a staff account admin = AdminFactory() - assert self.client.login(username=admin.username, password='test') + assert self.client.login(username=admin.username, password=TEST_PASSWORD) url = reverse('submission_history', kwargs={ 'course_id': str(self.course_key), @@ -727,7 +727,7 @@ def test_submission_history_xss(self): # log into a staff account admin = AdminFactory() - assert self.client.login(username=admin.username, password='test') + assert self.client.login(username=admin.username, password=TEST_PASSWORD) # try it with an existing user and a malicious location url = reverse('submission_history', kwargs={ @@ -751,7 +751,7 @@ def test_submission_history_contents(self): # log into a staff account admin = AdminFactory.create() - assert self.client.login(username=admin.username, password='test') + assert self.client.login(username=admin.username, password=TEST_PASSWORD) usage_key = self.course_key.make_usage_key('problem', 'test-history') state_client = DjangoXBlockUserStateClient(admin) @@ -814,7 +814,7 @@ def test_submission_history_timezone(self, timezone, hour_diff): course_key = course.id client = Client() admin = AdminFactory.create() - assert client.login(username=admin.username, password='test') + assert client.login(username=admin.username, password=TEST_PASSWORD) state_client = DjangoXBlockUserStateClient(admin) usage_key = course_key.make_usage_key('problem', 'test-history') state_client.set( @@ -1253,7 +1253,7 @@ class ProgressPageBaseTests(ModuleStoreTestCase): def setUp(self): super().setUp() self.user = UserFactory.create() - assert self.client.login(username=self.user.username, password='test') + assert self.client.login(username=self.user.username, password=TEST_PASSWORD) self.setup_course() @@ -1352,7 +1352,7 @@ def test_unenrolled_student_progress_for_credit_course(self): # Create a new course, a user which will not be enrolled in course, admin user for staff access course = CourseFactory.create(default_store=ModuleStoreEnum.Type.split) admin = AdminFactory.create() - assert self.client.login(username=admin.username, password='test') + assert self.client.login(username=admin.username, password=TEST_PASSWORD) # Create and enable Credit course CreditCourse.objects.create(course_key=course.id, enabled=True) @@ -1646,7 +1646,7 @@ def test_progress_with_course_duration_limits(self, course_mode): """ CourseDurationLimitConfig.objects.create(enabled=True, enabled_as_of=datetime(2018, 1, 1)) user = UserFactory.create() - assert self.client.login(username=user.username, password='test') + assert self.client.login(username=user.username, password=TEST_PASSWORD) add_course_mode(self.course, mode_slug=CourseMode.AUDIT) add_course_mode(self.course) CourseEnrollmentFactory(user=user, course_id=self.course.id, mode=course_mode) @@ -1679,7 +1679,7 @@ def test_progress_without_course_duration_limits(self, course_mode): """ CourseDurationLimitConfig.objects.create(enabled=False) user = UserFactory.create() - assert self.client.login(username=user.username, password='test') + assert self.client.login(username=user.username, password=TEST_PASSWORD) CourseModeFactory.create( course_id=self.course.id, mode_slug=course_mode @@ -1698,7 +1698,7 @@ def test_message_for_ineligible_mode(self, course_mode): in an ineligible mode. """ user = UserFactory.create() - assert self.client.login(username=user.username, password='test') + assert self.client.login(username=user.username, password=TEST_PASSWORD) CourseEnrollmentFactory(user=user, course_id=self.course.id, mode=course_mode) with patch('lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.read') as mock_create: @@ -2081,7 +2081,7 @@ def test_progress_page_hide_scores_from_learner(self, show_correctness, due_date self.setup_course(show_correctness=show_correctness, due_date=due_date, graded=graded) self.add_problem() - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=TEST_PASSWORD) resp = self._get_progress_page() # Ensure that expected text is present @@ -2133,7 +2133,7 @@ def test_progress_page_hide_scores_from_staff(self, show_correctness, due_date_n self.add_problem() # Login as a course staff user to view the student progress page. - self.client.login(username=self.staff_user.username, password='test') + self.client.login(username=self.staff_user.username, password=TEST_PASSWORD) resp = self._get_student_progress_page() @@ -3198,7 +3198,7 @@ class EnterpriseConsentTestCase(EnterpriseTestConsentRequired, ModuleStoreTestCa def setUp(self): super().setUp() self.user = UserFactory.create() - assert self.client.login(username=self.user.username, password='test') + assert self.client.login(username=self.user.username, password=TEST_PASSWORD) self.course = CourseFactory.create() CourseOverview.load_from_module_store(self.course.id) CourseEnrollmentFactory(user=self.user, course_id=self.course.id) @@ -3298,7 +3298,7 @@ def test_preview_no_redirect(self): # Previews will not redirect to the mfe course_staff = UserFactory.create(is_staff=False) CourseStaffRole(self.course_key).add_users(course_staff) - self.client.login(username=course_staff.username, password='test') + self.client.login(username=course_staff.username, password=TEST_PASSWORD) assert self.client.get(preview_url).status_code == 200 @@ -3435,7 +3435,7 @@ def test_course_wide_resources(self, url_name, param, is_instructor, is_rendered CourseEnrollmentFactory(user=user, course_id=course.id) if is_instructor: allow_access(course, user, 'instructor') - assert self.client.login(username=user.username, password='test') + assert self.client.login(username=user.username, password=TEST_PASSWORD) kwargs = None if param == 'course_id': diff --git a/lms/djangoapps/courseware/testutils.py b/lms/djangoapps/courseware/testutils.py index 3c2b946e91df..36774447fec4 100644 --- a/lms/djangoapps/courseware/testutils.py +++ b/lms/djangoapps/courseware/testutils.py @@ -81,7 +81,7 @@ def login(self): """ Logs in the test user. """ - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password='password') def course_options(self): """ diff --git a/lms/djangoapps/discussion/django_comment_client/base/tests.py b/lms/djangoapps/discussion/django_comment_client/base/tests.py index d450998a60c6..ea712e085242 100644 --- a/lms/djangoapps/discussion/django_comment_client/base/tests.py +++ b/lms/djangoapps/discussion/django_comment_client/base/tests.py @@ -241,7 +241,7 @@ def set_up_course(self, block_count=0): with patch('common.djangoapps.student.models.user.cc.User.save'): uname = 'student' email = 'student@edx.org' - self.password = 'test' + self.password = 'password' # Create the user and make them active so we can log them in. self.student = UserFactory.create(username=uname, email=email, password=self.password) @@ -464,7 +464,7 @@ def setUp(self): with patch('common.djangoapps.student.models.user.cc.User.save'): uname = 'student' email = 'student@edx.org' - self.password = 'test' + self.password = 'password' # Create the user and make them active so we can log them in. self.student = UserFactory.create(username=uname, email=email, password=self.password) diff --git a/lms/djangoapps/discussion/rest_api/tests/test_views.py b/lms/djangoapps/discussion/rest_api/tests/test_views.py index 0e303cc24092..3fe9d6445061 100644 --- a/lms/djangoapps/discussion/rest_api/tests/test_views.py +++ b/lms/djangoapps/discussion/rest_api/tests/test_views.py @@ -2758,7 +2758,7 @@ def setUp(self): discussion_topics={"Test Topic": {"id": "test_topic"}} ) self.path = reverse('discussion_course_settings', kwargs={'course_id': str(self.course.id)}) - self.password = 'edx' + self.password = 'password' self.user = UserFactory(username='staff', password=self.password, is_staff=True) def _get_oauth_headers(self, user): @@ -3056,7 +3056,7 @@ def setUp(self): run="z", start=datetime.now(UTC), ) - self.password = 'edx' + self.password = 'password' self.user = UserFactory(username='staff', password=self.password, is_staff=True) course_key = CourseKey.from_string('course-v1:x+y+z') seed_permissions_roles(course_key) @@ -3278,7 +3278,7 @@ def test_regular_user(self): """ Tests that for a regular user stats are returned without flag counts """ - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) response = self.client.get(self.url) data = response.json() assert data["results"] == self.stats_without_flags @@ -3288,7 +3288,7 @@ def test_moderator_user(self): """ Tests that for a moderator user stats are returned with flag counts """ - self.client.login(username=self.moderator.username, password='test') + self.client.login(username=self.moderator.username, password=self.TEST_PASSWORD) response = self.client.get(self.url) data = response.json() assert data["results"] == self.stats @@ -3308,7 +3308,7 @@ def test_sorting(self, username, ordering_requested, ordering_performed): """ Test valid sorting options and defaults """ - self.client.login(username=username, password='test') + self.client.login(username=username, password=self.TEST_PASSWORD) params = {} if ordering_requested: params = {"order_by": ordering_requested} @@ -3326,7 +3326,7 @@ def test_sorting_error_regular_user(self, order_by): """ Test for invalid sorting options for regular users. """ - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) response = self.client.get(self.url, {"order_by": order_by}) assert "order_by" in response.json()["field_errors"] @@ -3341,7 +3341,7 @@ def test_with_username_param(self, username_search_string, comma_separated_usern Test for endpoint with username param. """ params = {'username': username_search_string} - self.client.login(username=self.moderator.username, password='test') + self.client.login(username=self.moderator.username, password=self.TEST_PASSWORD) self.client.get(self.url, params) assert urlparse( httpretty.last_request().path # lint-amnesty, pylint: disable=no-member @@ -3356,7 +3356,7 @@ def test_with_username_param_with_no_matches(self): Test for endpoint with username param with no matches. """ params = {'username': 'unknown'} - self.client.login(username=self.moderator.username, password='test') + self.client.login(username=self.moderator.username, password=self.TEST_PASSWORD) response = self.client.get(self.url, params) data = response.json() self.assertFalse(data['results']) diff --git a/lms/djangoapps/discussion/tests/test_views.py b/lms/djangoapps/discussion/tests/test_views.py index ada3db7792e2..e0d3b869da3d 100644 --- a/lms/djangoapps/discussion/tests/test_views.py +++ b/lms/djangoapps/discussion/tests/test_views.py @@ -463,7 +463,7 @@ def test_private_team_thread_html(self, mock_request): CourseTeamFactory.create(discussion_topic_id=discussion_topic_id) user_not_in_team = UserFactory.create() CourseEnrollmentFactory.create(user=user_not_in_team, course_id=self.course.id) - self.client.login(username=user_not_in_team.username, password='test') + self.client.login(username=user_not_in_team.username, password=self.TEST_PASSWORD) mock_request.side_effect = make_mock_request_impl( course=self.course, @@ -624,7 +624,7 @@ def test_ajax(self, mock_request): def test_html(self, mock_request): _mock_text, mock_thread_id = self._create_mock_cohorted_thread(mock_request) - self.client.login(username=self.student.username, password='test') + self.client.login(username=self.student.username, password=self.TEST_PASSWORD) response = self.client.get( reverse('single_thread', kwargs={ 'course_id': str(self.course.id), @@ -758,7 +758,7 @@ def call_view(self, mock_request, commentable_id, user, group_id, pass_group_id= if is_ajax: headers['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest" - self.client.login(username=user.username, password='test') + self.client.login(username=user.username, password=self.TEST_PASSWORD) return self.client.get( reverse('single_thread', args=[str(self.course.id), commentable_id, "dummy_thread_id"]), @@ -824,7 +824,7 @@ def call_view(self, mock_request, user): # lint-amnesty, pylint: disable=missin text="dummy content", thread_list=self.thread_list ) - self.client.login(username=user.username, password='test') + self.client.login(username=user.username, password=self.TEST_PASSWORD) return self.client.get( reverse("forum_form_discussion", args=[str(self.course.id)]), HTTP_X_REQUESTED_WITH="XMLHttpRequest" @@ -889,7 +889,7 @@ def assert_can_access(self, user, discussion_id, thread_id, should_have_access): verify that the user does not have access to that thread. """ def call_single_thread(): - self.client.login(username=user.username, password='test') + self.client.login(username=user.username, password=self.TEST_PASSWORD) return self.client.get( reverse('single_thread', args=[str(self.course.id), discussion_id, thread_id]) ) @@ -1113,7 +1113,7 @@ def call_view(self, mock_request, commentable_id, user, group_id, pass_group_id= if is_ajax: headers['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest" - self.client.login(username=user.username, password='test') + self.client.login(username=user.username, password=self.TEST_PASSWORD) return self.client.get( reverse("forum_form_discussion", args=[str(self.course.id)]), data=request_data, @@ -1165,7 +1165,7 @@ def call_view_for_profiled_user( if is_ajax: headers['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest" - self.client.login(username=requesting_user.username, password='test') + self.client.login(username=requesting_user.username, password=self.TEST_PASSWORD) return self.client.get( reverse('user_profile', args=[str(self.course.id), profiled_user.id]), data=request_data, @@ -1414,7 +1414,7 @@ def get_response(self, mock_request, params, **headers): # lint-amnesty, pylint mock_request.side_effect = make_mock_request_impl( course=self.course, text=self.TEST_THREAD_TEXT, thread_id=self.TEST_THREAD_ID ) - self.client.login(username=self.student.username, password='test') + self.client.login(username=self.student.username, password=self.TEST_PASSWORD) response = self.client.get( reverse('user_profile', kwargs={ @@ -2300,7 +2300,7 @@ def test_redirect_from_legacy_base_url_to_new_experience(self): """ with override_waffle_flag(ENABLE_DISCUSSIONS_MFE, True): - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) url = reverse("forum_form_discussion", args=[self.course.id]) response = self.client.get(url) assert response.status_code == 302 @@ -2315,7 +2315,7 @@ def test_redirect_from_legacy_profile_url_to_new_experience(self): """ with override_waffle_flag(ENABLE_DISCUSSIONS_MFE, True): - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) url = reverse("user_profile", args=[self.course.id, self.user.id]) response = self.client.get(url) assert response.status_code == 302 @@ -2330,7 +2330,7 @@ def test_redirect_from_legacy_single_thread_to_new_experience(self): """ with override_waffle_flag(ENABLE_DISCUSSIONS_MFE, True): - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) url = reverse("single_thread", args=[self.course.id, "test_discussion", "test_thread"]) response = self.client.get(url) assert response.status_code == 302 diff --git a/lms/djangoapps/grades/rest_api/v1/tests/mixins.py b/lms/djangoapps/grades/rest_api/v1/tests/mixins.py index e5e7f269e3a2..9131ebd290bd 100644 --- a/lms/djangoapps/grades/rest_api/v1/tests/mixins.py +++ b/lms/djangoapps/grades/rest_api/v1/tests/mixins.py @@ -97,7 +97,7 @@ def _create_user_program_enrollments(self, *users, **kwargs): # lint-amnesty, p def setUp(self): super().setUp() - self.password = 'test' + self.password = 'password' self.global_staff = GlobalStaffFactory.create() self.student = UserFactory(password=self.password, username='student', email='student@example.com') self.other_student = UserFactory( diff --git a/lms/djangoapps/grades/rest_api/v1/tests/test_views.py b/lms/djangoapps/grades/rest_api/v1/tests/test_views.py index 1fbfb6070dd3..0dd6ea257314 100644 --- a/lms/djangoapps/grades/rest_api/v1/tests/test_views.py +++ b/lms/djangoapps/grades/rest_api/v1/tests/test_views.py @@ -548,7 +548,7 @@ class CourseSubmissionHistoryWithDataTest(TestSubmittingProblems): def setUp(self): super().setUp() self.namespaced_url = 'grades_api:v1:submission_history' - self.password = 'test' + self.password = 'password' self.basic_setup() self.global_staff = GlobalStaffFactory.create() diff --git a/lms/djangoapps/grades/tests/integration/test_access.py b/lms/djangoapps/grades/tests/integration/test_access.py index 380962b19e99..6545094a3ce5 100644 --- a/lms/djangoapps/grades/tests/integration/test_access.py +++ b/lms/djangoapps/grades/tests/integration/test_access.py @@ -73,9 +73,9 @@ def setUp(self): self.addCleanup(set_current_request, None) self.request = get_mock_request(UserFactory()) self.student = self.request.user - self.client.login(username=self.student.username, password="test") + self.client.login(username=self.student.username, password=self.TEST_PASSWORD) CourseEnrollment.enroll(self.student, self.course.id) - self.instructor = UserFactory.create(is_staff=True, username='test_instructor', password='test') + self.instructor = UserFactory.create(is_staff=True, username='test_instructor', password=self.TEST_PASSWORD) self.refresh_course() def test_subsection_access_changed(self): diff --git a/lms/djangoapps/grades/tests/integration/test_events.py b/lms/djangoapps/grades/tests/integration/test_events.py index 868b55eeae67..881ad049b3d8 100644 --- a/lms/djangoapps/grades/tests/integration/test_events.py +++ b/lms/djangoapps/grades/tests/integration/test_events.py @@ -70,9 +70,9 @@ def setUp(self): self.addCleanup(set_current_request, None) self.request = get_mock_request(UserFactory()) self.student = self.request.user - self.client.login(username=self.student.username, password="test") + self.client.login(username=self.student.username, password=self.TEST_PASSWORD) CourseEnrollment.enroll(self.student, self.course.id) - self.instructor = UserFactory.create(is_staff=True, username='test_instructor', password='test') + self.instructor = UserFactory.create(is_staff=True, username='test_instructor', password=self.TEST_PASSWORD) self.refresh_course() @patch('lms.djangoapps.grades.events.tracker') diff --git a/lms/djangoapps/grades/tests/integration/test_problems.py b/lms/djangoapps/grades/tests/integration/test_problems.py index 36c54bec86e9..b4a2d06c9f45 100644 --- a/lms/djangoapps/grades/tests/integration/test_problems.py +++ b/lms/djangoapps/grades/tests/integration/test_problems.py @@ -43,9 +43,8 @@ def setUpClass(cls): def setUp(self): super().setUp() - password = 'test' - self.student = UserFactory.create(is_staff=False, username='test_student', password=password) - self.client.login(username=self.student.username, password=password) + self.student = UserFactory.create(is_staff=False, username='test_student', password=self.TEST_PASSWORD) + self.client.login(username=self.student.username, password=self.TEST_PASSWORD) self.addCleanup(set_current_request, None) self.request = get_mock_request(self.student) self.course_structure = get_course_blocks(self.student, self.course.location) @@ -58,8 +57,7 @@ def load_scoreable_course(cls): For details on the contents and structure of the file, see `common/test/data/scoreable/README`. """ - password = 'test' - user = UserFactory.create(is_staff=False, username='test_student', password=password) + user = UserFactory.create(is_staff=False, username='test_student', password=cls.TEST_PASSWORD) course_items = import_course_from_xml( cls.store, @@ -144,7 +142,7 @@ def setUp(self): ''' self.addCleanup(set_current_request, None) self.request = get_mock_request(UserFactory()) - self.client.login(username=self.request.user.username, password="test") + self.client.login(username=self.request.user.username, password=self.TEST_PASSWORD) CourseEnrollment.enroll(self.request.user, self.course.id) def _get_altered_metadata(self, alterations): diff --git a/lms/djangoapps/instructor/tests/test_api.py b/lms/djangoapps/instructor/tests/test_api.py index 468bca31f780..bb534d9b026a 100644 --- a/lms/djangoapps/instructor/tests/test_api.py +++ b/lms/djangoapps/instructor/tests/test_api.py @@ -325,7 +325,7 @@ def setUp(self): """ super().setUp() global_user = GlobalStaffFactory() - self.client.login(username=global_user.username, password='test') + self.client.login(username=global_user.username, password=self.TEST_PASSWORD) @ddt.data(*INSTRUCTOR_POST_ENDPOINTS) def test_endpoints_reject_get(self, data): @@ -478,7 +478,7 @@ def test_student_level(self): """ Ensure that an enrolled student can't access staff or instructor endpoints. """ - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) for endpoint, args in self.staff_level_endpoints: self._access_endpoint( @@ -518,7 +518,7 @@ def test_staff_level(self): CourseEnrollment.enroll(staff_member, self.course.id) CourseFinanceAdminRole(self.course.id).add_users(staff_member) CourseDataResearcherRole(self.course.id).add_users(staff_member) - self.client.login(username=staff_member.username, password='test') + self.client.login(username=staff_member.username, password=self.TEST_PASSWORD) # Try to promote to forums admin - not working # update_forum_role(self.course.id, staff_member, FORUM_ROLE_ADMINISTRATOR, 'allow') @@ -558,7 +558,7 @@ def test_instructor_level(self): CourseFinanceAdminRole(self.course.id).add_users(inst) CourseDataResearcherRole(self.course.id).add_users(inst) - self.client.login(username=inst.username, password='test') + self.client.login(username=inst.username, password=self.TEST_PASSWORD) for endpoint, args in self.staff_level_endpoints: expected_status = 200 @@ -632,7 +632,7 @@ def setUp(self): self.audit_course_instructor = InstructorFactory(course_key=self.audit_course.id) self.white_label_course_instructor = InstructorFactory(course_key=self.white_label_course.id) - self.client.login(username=self.instructor.username, password='test') + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) self.not_enrolled_student = UserFactory( username='NotEnrolledStudent', @@ -945,7 +945,7 @@ def test_audit_enrollment_mode(self): Test that enrollment mode for audit courses (paid courses) is 'audit'. """ # Login Audit Course instructor - self.client.login(username=self.audit_course_instructor.username, password='test') + self.client.login(username=self.audit_course_instructor.username, password=self.TEST_PASSWORD) csv_content = b"test_student_wl@example.com,test_student_wl,Test Student,USA" uploaded_file = SimpleUploadedFile("temp.csv", csv_content) @@ -976,7 +976,7 @@ def test_honor_enrollment_mode(self): self.white_label_course_mode.save() # Login Audit Course instructor - self.client.login(username=self.white_label_course_instructor.username, password='test') + self.client.login(username=self.white_label_course_instructor.username, password=self.TEST_PASSWORD) csv_content = b"test_student_wl@example.com,test_student_wl,Test Student,USA" uploaded_file = SimpleUploadedFile("temp.csv", csv_content) @@ -1024,7 +1024,7 @@ def setUp(self): self.request = RequestFactory().request() self.instructor = InstructorFactory(course_key=self.course.id) - self.client.login(username=self.instructor.username, password='test') + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) self.enrolled_student = UserFactory(username='EnrolledStudent', first_name='Enrolled', last_name='Student') CourseEnrollment.enroll( @@ -1873,7 +1873,7 @@ def setUp(self): super().setUp() self.instructor = InstructorFactory(course_key=self.course.id) - self.client.login(username=self.instructor.username, password='test') + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) self.beta_tester = BetaTesterFactory(course_key=self.course.id) CourseEnrollment.enroll( @@ -2218,7 +2218,7 @@ def setUp(self): super().setUp() self.instructor = InstructorFactory(course_key=self.course.id) - self.client.login(username=self.instructor.username, password='test') + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) self.other_instructor = InstructorFactory(course_key=self.course.id) self.other_staff = StaffFactory(course_key=self.course.id) @@ -2458,7 +2458,7 @@ def setUp(self): self.course_mode.save() self.instructor = InstructorFactory(course_key=self.course.id) CourseDataResearcherRole(self.course.id).add_users(self.instructor) - self.client.login(username=self.instructor.username, password='test') + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) self.students = [UserFactory() for _ in range(6)] for student in self.students: @@ -2600,7 +2600,7 @@ def test_get_students_features_teams(self, has_teams): })) course_instructor = InstructorFactory(course_key=self.course.id) CourseDataResearcherRole(self.course.id).add_users(course_instructor) - self.client.login(username=course_instructor.username, password='test') + self.client.login(username=course_instructor.username, password=self.TEST_PASSWORD) url = reverse('get_students_features', kwargs={'course_id': str(self.course.id)}) @@ -2972,7 +2972,7 @@ def setUpClass(cls): def setUp(self): super().setUp() self.instructor = InstructorFactory(course_key=self.course.id) - self.client.login(username=self.instructor.username, password='test') + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) self.student = UserFactory() CourseEnrollment.enroll(self.student, self.course.id) @@ -3158,7 +3158,7 @@ def setUp(self): self.instructor = InstructorFactory(course_key=self.course.id) # Add instructor to invalid ee course CourseInstructorRole(self.course_with_invalid_ee.id).add_users(self.instructor) - self.client.login(username=self.instructor.username, password='test') + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) self.student = UserFactory() CourseEnrollment.enroll(self.student, self.course.id) @@ -3261,7 +3261,7 @@ def test_entrance_exam_delete_state_with_staff(self): """ Test entrance exam delete state failure with staff access. """ self.client.logout() staff_user = StaffFactory(course_key=self.course.id) - self.client.login(username=staff_user.username, password='test') + self.client.login(username=staff_user.username, password=self.TEST_PASSWORD) url = reverse('reset_student_attempts_for_entrance_exam', kwargs={'course_id': str(self.course.id)}) response = self.client.post(url, { @@ -3414,7 +3414,7 @@ def setUp(self): } self.instructor = InstructorFactory(course_key=self.course.id) - self.client.login(username=self.instructor.username, password='test') + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) def tearDown(self): super().tearDown() @@ -3434,7 +3434,7 @@ def test_send_email_but_not_logged_in(self): def test_send_email_but_not_staff(self): self.client.logout() student = UserFactory() - self.client.login(username=student.username, password='test') + self.client.login(username=student.username, password=self.TEST_PASSWORD) url = reverse('send_email', kwargs={'course_id': str(self.course.id)}) response = self.client.post(url, self.full_test_message) assert response.status_code == 403 @@ -3631,7 +3631,7 @@ def setUpClass(cls): def setUp(self): super().setUp() self.instructor = InstructorFactory(course_key=self.course.id) - self.client.login(username=self.instructor.username, password='test') + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) self.student = UserFactory() CourseEnrollment.enroll(self.student, self.course.id) @@ -3768,7 +3768,7 @@ def setUp(self): super().setUp() self.instructor = InstructorFactory(course_key=self.course.id) - self.client.login(username=self.instructor.username, password='test') + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) self.tasks = {} self.emails = {} self.emails_info = {} @@ -4030,7 +4030,7 @@ def setUp(self): CourseEnrollmentFactory.create(user=self.user1, course_id=self.course.id) CourseEnrollmentFactory.create(user=self.user2, course_id=self.course.id) self.instructor = InstructorFactory(course_key=self.course.id) - self.client.login(username=self.instructor.username, password='test') + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) extract_dates(None, self.course.id) def test_change_due_date(self): @@ -4206,7 +4206,7 @@ def setUp(self): CourseEnrollmentFactory.create(user=self.user1, course_id=self.course.id) CourseEnrollmentFactory.create(user=self.user2, course_id=self.course.id) self.instructor = InstructorFactory(course_key=self.course.id) - self.client.login(username=self.instructor.username, password='test') + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) extract_dates(None, self.course.id) @override_waffle_flag(RELATIVE_DATES_FLAG, active=True) @@ -4251,7 +4251,7 @@ def setUpClass(cls): def setUp(self): super().setUp() self.instructor = InstructorFactory(course_key=self.course.id) - self.client.login(username=self.instructor.username, password='test') + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) def generate_certificate(self, course_id, mode, status): """ @@ -4379,7 +4379,7 @@ def expect_error_on_file_content(self, file_content, error, file_suffix='.csv'): """ Verify that we get the error we expect for a given file input. """ - self.client.login(username=self.staff_user.username, password='test') + self.client.login(username=self.staff_user.username, password=self.TEST_PASSWORD) response = self.call_add_users_to_cohorts(file_content, suffix=file_suffix) assert response.status_code == 400 result = json.loads(response.content.decode('utf-8')) @@ -4392,7 +4392,7 @@ def verify_success_on_file_content(self, file_content, mock_store_upload, mock_c background task. """ mock_store_upload.return_value = (None, 'fake_file_name.csv') - self.client.login(username=self.staff_user.username, password='test') + self.client.login(username=self.staff_user.username, password=self.TEST_PASSWORD) response = self.call_add_users_to_cohorts(file_content) assert response.status_code == 204 assert mock_store_upload.called @@ -4438,7 +4438,7 @@ def test_non_staff_no_access(self): """ Verify that we can't access the view when we aren't a staff user. """ - self.client.login(username=self.non_staff_user.username, password='test') + self.client.login(username=self.non_staff_user.username, password=self.TEST_PASSWORD) response = self.call_add_users_to_cohorts('') assert response.status_code == 403 diff --git a/lms/djangoapps/instructor/tests/test_api_email_localization.py b/lms/djangoapps/instructor/tests/test_api_email_localization.py index e0cef6a7af0b..a23b94ece021 100644 --- a/lms/djangoapps/instructor/tests/test_api_email_localization.py +++ b/lms/djangoapps/instructor/tests/test_api_email_localization.py @@ -35,7 +35,7 @@ def setUp(self): # Esperanto. self.instructor = InstructorFactory(course_key=self.course.id) set_user_preference(self.instructor, LANGUAGE_KEY, 'zh-cn') - self.client.login(username=self.instructor.username, password='test') + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) self.student = UserFactory.create() set_user_preference(self.student, LANGUAGE_KEY, 'eo') diff --git a/lms/djangoapps/instructor/tests/test_certificates.py b/lms/djangoapps/instructor/tests/test_certificates.py index 5350d1d07f71..11fd82bfb302 100644 --- a/lms/djangoapps/instructor/tests/test_certificates.py +++ b/lms/djangoapps/instructor/tests/test_certificates.py @@ -64,11 +64,11 @@ def setUp(self): def test_visible_only_to_global_staff(self): # Instructors don't see the certificates section - self.client.login(username=self.instructor.username, password="test") + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) self._assert_certificates_visible(False) # Global staff can see the certificates section - self.client.login(username=self.global_staff.username, password="test") + self.client.login(username=self.global_staff.username, password=self.TEST_PASSWORD) self._assert_certificates_visible(True) def test_visible_only_when_feature_flag_enabled(self): @@ -77,17 +77,17 @@ def test_visible_only_when_feature_flag_enabled(self): cache.clear() # Now even global staff can't see the certificates section - self.client.login(username=self.global_staff.username, password="test") + self.client.login(username=self.global_staff.username, password=self.TEST_PASSWORD) self._assert_certificates_visible(False) @ddt.data("started", "error", "success") def test_show_certificate_status(self, status): - self.client.login(username=self.global_staff.username, password="test") + self.client.login(username=self.global_staff.username, password=self.TEST_PASSWORD) with self._certificate_status("honor", status): self._assert_certificate_status("honor", status) def test_show_enabled_button(self): - self.client.login(username=self.global_staff.username, password="test") + self.client.login(username=self.global_staff.username, password=self.TEST_PASSWORD) # Initially, no example certs are generated, so # the enable button should be disabled @@ -104,7 +104,7 @@ def test_show_enabled_button(self): self._assert_enable_certs_button(False) def test_can_disable_even_after_failure(self): - self.client.login(username=self.global_staff.username, password="test") + self.client.login(username=self.global_staff.username, password=self.TEST_PASSWORD) with self._certificate_status("honor", "error"): # When certs are disabled for a course, then don't allow them @@ -127,7 +127,7 @@ def test_show_enabled_button_for_html_certs(self): self.course.cert_html_view_enabled = True self.course.save() self.store.update_item(self.course, self.global_staff.id) - self.client.login(username=self.global_staff.username, password="test") + self.client.login(username=self.global_staff.username, password=self.TEST_PASSWORD) response = self.client.get(self.url) self.assertContains(response, 'Enable Student-Generated Certificates') self.assertContains(response, 'enable-certificates-submit') @@ -143,7 +143,7 @@ def test_buttons_for_html_certs_in_self_paced_course(self): self.course.cert_html_view_enabled = True self.course.save() self.store.update_item(self.course, self.global_staff.id) - self.client.login(username=self.global_staff.username, password="test") + self.client.login(username=self.global_staff.username, password=self.TEST_PASSWORD) response = self.client.get(self.url) self.assertContains(response, 'Enable Student-Generated Certificates') self.assertContains(response, 'enable-certificates-submit') @@ -233,18 +233,18 @@ def test_allow_only_global_staff(self, url_name): url = reverse(url_name, kwargs={'course_id': self.course.id}) # Instructors do not have access - self.client.login(username=self.instructor.username, password='test') + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) response = self.client.post(url) assert response.status_code == 403 # Global staff have access - self.client.login(username=self.global_staff.username, password='test') + self.client.login(username=self.global_staff.username, password=self.TEST_PASSWORD) response = self.client.post(url) assert response.status_code == 302 @ddt.data(True, False) def test_enable_certificate_generation(self, is_enabled): - self.client.login(username=self.global_staff.username, password='test') + self.client.login(username=self.global_staff.username, password=self.TEST_PASSWORD) url = reverse( 'enable_certificate_generation', kwargs={'course_id': str(self.course.id)} @@ -274,7 +274,7 @@ def test_certificate_generation_api_without_global_staff(self): user who made the request is not member of global staff. """ user = UserFactory.create() - self.client.login(username=user.username, password='test') + self.client.login(username=user.username, password=self.TEST_PASSWORD) url = reverse( 'start_certificate_generation', kwargs={'course_id': str(self.course.id)} @@ -283,7 +283,7 @@ def test_certificate_generation_api_without_global_staff(self): response = self.client.post(url) assert response.status_code == 403 - self.client.login(username=self.instructor.username, password='test') + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) response = self.client.post(url) assert response.status_code == 403 @@ -292,7 +292,7 @@ def test_certificate_generation_api_with_global_staff(self): Test certificates generation api endpoint returns success status when called with valid course key """ - self.client.login(username=self.global_staff.username, password='test') + self.client.login(username=self.global_staff.username, password=self.TEST_PASSWORD) url = reverse( 'start_certificate_generation', kwargs={'course_id': str(self.course.id)} @@ -319,7 +319,7 @@ def test_certificate_regeneration_success(self): ) # Login the client and access the url with 'certificate_statuses' - self.client.login(username=self.global_staff.username, password='test') + self.client.login(username=self.global_staff.username, password=self.TEST_PASSWORD) url = reverse('start_certificate_regeneration', kwargs={'course_id': str(self.course.id)}) response = self.client.post(url, data={'certificate_statuses': [CertificateStatuses.downloadable]}) @@ -352,7 +352,7 @@ def test_certificate_regeneration_error(self): ) # Login the client and access the url without 'certificate_statuses' - self.client.login(username=self.global_staff.username, password='test') + self.client.login(username=self.global_staff.username, password=self.TEST_PASSWORD) url = reverse('start_certificate_regeneration', kwargs={'course_id': str(self.course.id)}) response = self.client.post(url) @@ -419,7 +419,7 @@ def setUp(self): # Enable certificate generation cache.clear() CertificateGenerationConfiguration.objects.create(enabled=True) - self.client.login(username=self.global_staff.username, password='test') + self.client.login(username=self.global_staff.username, password=self.TEST_PASSWORD) def test_certificate_exception_added_successfully(self): """ @@ -712,7 +712,7 @@ def setUp(self): # Enable certificate generation cache.clear() CertificateGenerationConfiguration.objects.create(enabled=True) - self.client.login(username=self.global_staff.username, password='test') + self.client.login(username=self.global_staff.username, password=self.TEST_PASSWORD) def test_generate_certificate_exceptions_all_students(self): """ @@ -830,7 +830,7 @@ def setUp(self): CourseEnrollment.enroll(self.enrolled_user_2, self.course.id) # Global staff can see the certificates section - self.client.login(username=self.global_staff.username, password="test") + self.client.login(username=self.global_staff.username, password=self.TEST_PASSWORD) def test_create_allowlist_exception_record(self): """ @@ -1026,7 +1026,7 @@ def setUp(self): ) # Global staff can see the certificates section - self.client.login(username=self.global_staff.username, password="test") + self.client.login(username=self.global_staff.username, password=self.TEST_PASSWORD) def test_invalidate_certificate(self): """ diff --git a/lms/djangoapps/instructor/tests/test_email.py b/lms/djangoapps/instructor/tests/test_email.py index a84c728c30e9..322c734fa613 100644 --- a/lms/djangoapps/instructor/tests/test_email.py +++ b/lms/djangoapps/instructor/tests/test_email.py @@ -40,7 +40,7 @@ def setUp(self): # Create instructor account instructor = AdminFactory.create() - self.client.login(username=instructor.username, password="test") + self.client.login(username=instructor.username, password=self.TEST_PASSWORD) def tearDown(self): super().tearDown() @@ -148,7 +148,7 @@ def setUp(self): # Create instructor account instructor = AdminFactory.create() - self.client.login(username=instructor.username, password="test") + self.client.login(username=instructor.username, password=self.TEST_PASSWORD) # URL for instructor dash self.url = reverse('instructor_dashboard', kwargs={'course_id': str(self.course_key)}) diff --git a/lms/djangoapps/instructor/tests/test_filters.py b/lms/djangoapps/instructor/tests/test_filters.py index 19948da1449f..a676ab92a59c 100644 --- a/lms/djangoapps/instructor/tests/test_filters.py +++ b/lms/djangoapps/instructor/tests/test_filters.py @@ -99,7 +99,7 @@ def setUp(self): # pylint: disable=arguments-differ """ super().setUp() self.instructor = AdminFactory.create() - self.client.login(username=self.instructor.username, password="test") + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) self.course = CourseFactory.create( org="test1", course="course1", display_name="run1", ) diff --git a/lms/djangoapps/instructor/tests/test_proctoring.py b/lms/djangoapps/instructor/tests/test_proctoring.py index 491a2ee1f7ed..4b196f307b99 100644 --- a/lms/djangoapps/instructor/tests/test_proctoring.py +++ b/lms/djangoapps/instructor/tests/test_proctoring.py @@ -36,7 +36,7 @@ def setUp(self): # Create instructor account self.instructor = AdminFactory.create() - self.client.login(username=self.instructor.username, password="test") + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) def setup_course_url(self, course): """ diff --git a/lms/djangoapps/instructor/tests/test_spoc_gradebook.py b/lms/djangoapps/instructor/tests/test_spoc_gradebook.py index bf574e8f506f..221ed3603e27 100644 --- a/lms/djangoapps/instructor/tests/test_spoc_gradebook.py +++ b/lms/djangoapps/instructor/tests/test_spoc_gradebook.py @@ -56,7 +56,7 @@ def setUp(self): super().setUp() instructor = AdminFactory.create() - self.client.login(username=instructor.username, password='test') + self.client.login(username=instructor.username, password=self.TEST_PASSWORD) self.users = [UserFactory.create() for _ in range(USER_COUNT)] for user in self.users: CourseEnrollmentFactory.create(user=user, course_id=self.course.id) diff --git a/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py b/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py index bca16977a98c..db455f02587d 100644 --- a/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py +++ b/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py @@ -85,7 +85,7 @@ def setUp(self): self.course_mode.save() # Create instructor account self.instructor = AdminFactory.create() - self.client.login(username=self.instructor.username, password="test") + self.client.login(username=self.instructor.username, password=self.TEST_PASSWORD) # URL for instructor dash self.url = reverse('instructor_dashboard', kwargs={'course_id': str(self.course.id)}) @@ -169,7 +169,7 @@ def test_discussion_tab_for_course_staff_role(self, access_role, is_pages_and_re org=self.course.id.org ) set_course_cohorted(self.course.id, True) - self.client.login(username=self.user.username, password='test') + self.client.login(username=self.user.username, password=self.TEST_PASSWORD) response = self.client.get(self.url).content.decode('utf-8') self.assertEqual(discussion_section in response, is_discussion_tab_available) @@ -192,7 +192,7 @@ def test_discussion_tab_for_global_user(self, is_pages_and_resources_enabled, with override_waffle_flag(OVERRIDE_DISCUSSION_LEGACY_SETTINGS_FLAG, is_legacy_discussion_setting_enabled): user = UserFactory.create(is_staff=True) set_course_cohorted(self.course.id, True) - self.client.login(username=user.username, password='test') + self.client.login(username=user.username, password=self.TEST_PASSWORD) response = self.client.get(self.url).content.decode('utf-8') self.assertEqual(discussion_section in response, is_discussion_tab_available) @@ -224,7 +224,7 @@ def test_data_download(self, access_role, can_access, waffle_status): role=access_role, org=self.course.id.org ) - self.client.login(username=user.username, password="test") + self.client.login(username=user.username, password=self.TEST_PASSWORD) response = self.client.get(self.url) if can_access: self.assertContains(response, download_section) @@ -244,7 +244,7 @@ def test_data_download_only(self): role='data_researcher', org=self.course.id.org ) - self.client.login(username=user.username, password="test") + self.client.login(username=user.username, password=self.TEST_PASSWORD) response = self.client.get(self.url) matches = re.findall( rb'