Fix missing password values from generated configuration

Passwords were not being stored to config.yml during the first
quickstart.
This commit is contained in:
Régis Behmo 2019-06-24 12:36:19 +02:00
parent ad8e513fd2
commit 1f69e67b9f
5 changed files with 22 additions and 13 deletions

View File

@ -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)

View File

@ -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"])

View File

@ -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",

View File

@ -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

View File

@ -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"