def test_container_variables_json_serialized(minimal_project): with minimal_project: conf_file = Project().root / CONF_FILENAME config = { "project_name": "minimal", "variables": { "ALL_JWT_AUTH": { "default": { "JWT_AUDIENCE": "jwt-audience", "JWT_SECRET_KEY": "jwt-secret", }, "production": { "JWT_AUDIENCE": "prod-audience", "JWT_SECRET_KEY": "prod-secret", }, }, }, } conf_file.write_text(yaml.dump(config)) create_settings_file(Project().root, "production") project = Project() env = project.get_container_env() assert "DEREX_JSON_ALL_JWT_AUTH" in env expected = config["variables"]["ALL_JWT_AUTH"]["default"] assert expected == json.loads(env["DEREX_JSON_ALL_JWT_AUTH"]) project.settings = project._available_settings.production env = project.get_container_env() assert "DEREX_JSON_ALL_JWT_AUTH" in env expected = config["variables"]["ALL_JWT_AUTH"]["production"] assert expected == json.loads(env["DEREX_JSON_ALL_JWT_AUTH"])
def test_image_prefix(minimal_project): with minimal_project: conf_file = Project().root / CONF_FILENAME config = { "project_name": "minimal", "image_prefix": "registry.example.com/onlinecourses/edx-ironwood", } conf_file.write_text(yaml.dump(config)) # Create a requirements directory to signal derex # that we're going to build images for this project (Project().root / "requirements").mkdir() project = Project() assert project.image_prefix == config["image_prefix"] assert project.themes_image_name.startswith(project.image_prefix)
def test_container_variables(minimal_project): with minimal_project: conf_file = Project().root / CONF_FILENAME config = { "project_name": "minimal", "variables": { "lms_site_name": { "default": "dev.onlinecourses.example", "production": "onlinecourses.example", } }, } conf_file.write_text(yaml.dump(config)) create_settings_file(Project().root, "production") project = Project() env = project.get_container_env() assert "DEREX_LMS_SITE_NAME" in env assert env["DEREX_LMS_SITE_NAME"] == "dev.onlinecourses.example" project.settings = project.get_available_settings().production env = project.get_container_env() assert env["DEREX_LMS_SITE_NAME"] == "onlinecourses.example"
def test_secret_variables(complete_project): with complete_project: conf_file = Project().root / SECRETS_CONF_FILENAME config = { "variables": { "ALL_MYSQL_ROOT_PASSWORD": { "default": "base-secret-password", "production": "production-secret-password", }, }, } conf_file.write_text(yaml.dump(config)) create_settings_file(Project().root, "production") project = Project() env = project.get_container_env() assert "DEREX_ALL_MYSQL_ROOT_PASSWORD" in env expected = config["variables"]["ALL_MYSQL_ROOT_PASSWORD"]["default"] assert expected == env["DEREX_ALL_MYSQL_ROOT_PASSWORD"] project.settings = project._available_settings.production env = project.get_container_env() assert "DEREX_ALL_MYSQL_ROOT_PASSWORD" in env expected = config["variables"]["ALL_MYSQL_ROOT_PASSWORD"]["production"] assert expected == env["DEREX_ALL_MYSQL_ROOT_PASSWORD"]