From 1f69e67b9fccbbd577b562cb6237630763296351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Mon, 24 Jun 2019 12:36:19 +0200 Subject: [PATCH] Fix missing password values from generated configuration Passwords were not being stored to config.yml during the first quickstart. --- CHANGELOG.md | 4 ++++ tests/test_config.py | 11 +++++++++++ tutor/config.py | 6 +----- tutor/interactive.py | 6 +----- tutor/templates/config.yml | 8 +++++--- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2626ea6..5fc273a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ Note: Breaking changes between versions are indicated by "💥". +## Latest + +- [Bugfix] Fix missing password values from generated configuration + ## 3.4.2 (2019-06-23) - [Bugfix] Fix incorrect settings during lms/cms init (#224) diff --git a/tests/test_config.py b/tests/test_config.py index a9a95ea..52d6382 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -4,6 +4,7 @@ import tempfile from tutor import config as tutor_config from tutor import env +from tutor import interactive class ConfigTests(unittest.TestCase): @@ -61,3 +62,13 @@ class ConfigTests(unittest.TestCase): self.assertEqual("abcd", password1) self.assertEqual("efgh", password2) + + def test_interactive_load_all(self): + with tempfile.TemporaryDirectory() as rootdir: + config, defaults = interactive.load_all(rootdir, interactive=False) + + self.assertIn("MYSQL_ROOT_PASSWORD", config) + self.assertEqual(8, len(config["MYSQL_ROOT_PASSWORD"])) + self.assertNotIn("LMS_HOST", config) + self.assertEqual("www.myopenedx.com", defaults["LMS_HOST"]) + self.assertEqual("studio.{{ LMS_HOST }}", defaults["CMS_HOST"]) diff --git a/tutor/config.py b/tutor/config.py index 525063a..3112016 100644 --- a/tutor/config.py +++ b/tutor/config.py @@ -89,13 +89,9 @@ def load_env(config, defaults): def load_required(config, defaults): """ - All these keys must be present in the user's config.yml. This includes all important - values, such as LMS_HOST, and randomly-generated values, such as passwords. + All these keys must be present in the user's config.yml. This includes all values that are generated once and must be kept after that, such as passwords. """ for key in [ - "LMS_HOST", - "CMS_HOST", - "CONTACT_EMAIL", "SECRET_KEY", "MYSQL_ROOT_PASSWORD", "OPENEDX_MYSQL_PASSWORD", diff --git a/tutor/interactive.py b/tutor/interactive.py index 02d2bab..dd657b0 100644 --- a/tutor/interactive.py +++ b/tutor/interactive.py @@ -23,13 +23,9 @@ def load_all(root, interactive=True): Load configuration and interactively ask questions to collect param values from the user. """ defaults = tutor_config.load_defaults() - config = {} - if os.path.exists(tutor_config.config_path(root)): - config = tutor_config.load_current(root, defaults) - + config = tutor_config.load_current(root, defaults) if interactive: ask_questions(config, defaults) - return config, defaults diff --git a/tutor/templates/config.yml b/tutor/templates/config.yml index 2aea896..826623c 100644 --- a/tutor/templates/config.yml +++ b/tutor/templates/config.yml @@ -1,8 +1,5 @@ --- # These configuration values must be stored in the user's config.yml. -LMS_HOST: "www.myopenedx.com" -CMS_HOST: "studio.{{ LMS_HOST }}" -CONTACT_EMAIL: "contact@{{ LMS_HOST }}" SECRET_KEY: "{{ 24|random_string }}" MYSQL_ROOT_PASSWORD: "{{ 8|random_string }}" OPENEDX_MYSQL_PASSWORD: "{{ 8|random_string }}" @@ -15,6 +12,9 @@ XQUEUE_SECRET_KEY: "{{ 24|random_string }}" ANDROID_OAUTH2_SECRET: "{{ 24|random_string }}" ID: "{{ 24|random_string }}" +# This must be defined early +LMS_HOST: "www.myopenedx.com" + # The following are default values ACTIVATE_LMS: true ACTIVATE_CMS: true @@ -28,6 +28,8 @@ ACTIVATE_NOTES: false ACTIVATE_RABBITMQ: true ACTIVATE_SMTP: true ACTIVATE_XQUEUE: false +CMS_HOST: "studio.{{ LMS_HOST }}" +CONTACT_EMAIL: "contact@{{ LMS_HOST }}" OPENEDX_AWS_ACCESS_KEY: "" OPENEDX_AWS_SECRET_ACCESS_KEY: "" ANDROID_RELEASE_STORE_PASSWORD: "android store password"