diff --git a/admin/securedrop_admin/__init__.py b/admin/securedrop_admin/__init__.py index 5e00f0ca523..4a50a106eb8 100755 --- a/admin/securedrop_admin/__init__.py +++ b/admin/securedrop_admin/__init__.py @@ -169,7 +169,7 @@ def validate(self, document): # Raise error if admin tries to disable v3 when v2 # is already disabled. if text == 'no' and \ - not self.caller._config.get("v2_onion_services"): + not self.caller._config_in_progress.get("v2_onion_services"): # noqa: E501 raise ValidationError(message="Since you disabled v2 onion services, you must enable v3 onion services.") # noqa: E501 if text == 'yes' or text == 'no': return True @@ -276,8 +276,9 @@ def validate(self, document): def __init__(self, args): self.args = args self.config = {} - # This is to hold runtime configuration before save - self._config = {} + # Hold runtime configuration before save, to support + # referencing other responses during validation + self._config_in_progress = {} translations = SiteConfig.Locales( self.args.app_path).get_translations() translations = " ".join(translations) @@ -464,23 +465,23 @@ def check_for_v3_onion(self): """ Check if v3 onion services should be enabled by default or not. """ - v2_value = self._config.get("v2_onion_services", False) + v2_value = self._config_in_progress.get("v2_onion_services", False) # We need to see the value in the configuration file # for v3_onion_services v3_value = self.config.get("v3_onion_services", True) return v3_value or not v2_value def user_prompt_config(self): - self._config = {} + self._config_in_progress = {} for desc in self.desc: (var, default, type, prompt, validator, transform, condition) = desc - if not condition(self._config): - self._config[var] = '' + if not condition(self._config_in_progress): + self._config_in_progress[var] = '' continue - self._config[var] = self.user_prompt_config_one(desc, + self._config_in_progress[var] = self.user_prompt_config_one(desc, self.config.get(var)) # noqa: E501 - return self._config + return self._config_in_progress def user_prompt_config_one(self, desc, from_config): (var, default, type, prompt, validator, transform, condition) = desc diff --git a/admin/tests/test_securedrop-admin.py b/admin/tests/test_securedrop-admin.py index d2facebbd86..f127bdc54e3 100644 --- a/admin/tests/test_securedrop-admin.py +++ b/admin/tests/test_securedrop-admin.py @@ -799,7 +799,7 @@ def verify_prompt_boolean_for_v3( # Now we will set v2_onion_services as True so that we # can set v3_onion_service as False. This is the case # when an admin particularly marked v3 as False. - site_config._config = {"v2_onion_services": True} + site_config._config_in_progress = {"v2_onion_services": True} site_config.config = {"v3_onion_services": False} # The next two tests should use the default from the above line,