Skip to content

Commit

Permalink
don't default with email addresses but raise Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanssen2 committed Mar 21, 2024
1 parent cae7fc7 commit fd0e9f7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
12 changes: 10 additions & 2 deletions qiita_core/configuration_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,19 @@ def _get_main(self, config):

self.help_email = config.get('main', 'HELP_EMAIL')
if not self.help_email:
self.help_email = '[email protected]'
raise ValueError(
"You did not specify the HELP_EMAIL address in the main "
"section of Qiita's config file. This address is essential "
"for users to ask for help as it is displayed at various "
"location throughout Qiita's web pages.")

self.sysadmin_email = config.get('main', 'SYSADMIN_EMAIL')
if not self.sysadmin_email:
self.sysadmin_email = '[email protected]'
raise ValueError(
"You did not specify the SYSADMIN_EMAIL address in the main "
"section of Qiita's config file. Serious issues will "
"automatically be reported to a sys admin, an according "
"address is therefore required!")

def _get_job_scheduler(self, config):
"""Get the configuration of the job_scheduler section"""
Expand Down
2 changes: 1 addition & 1 deletion qiita_core/support_files/config_test.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ COOKIE_SECRET = SECRET
# The value used to secure JWTs for delegated permission artifact download.
JWT_SECRET = SUPER_SECRET

# Address a user should write to when asking for help, default to [email protected]
# Address a user should write to when asking for help
HELP_EMAIL =

# The email address, Qiita sends internal notifications to a sys admin
Expand Down
8 changes: 4 additions & 4 deletions qiita_core/tests/test_configuration_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@ def test_help_email(self):

# test if it falls back to [email protected]
self.conf.set('main', 'HELP_EMAIL', '')
obs._get_main(self.conf)
self.assertEqual(obs.help_email, '[email protected]')
with self.assertRaises(ValueError):
obs._get_main(self.conf)

# test if it falls back to [email protected]
self.conf.set('main', 'SYSADMIN_EMAIL', '')
obs._get_main(self.conf)
self.assertEqual(obs.sysadmin_email, '[email protected]')
with self.assertRaises(ValueError):
obs._get_main(self.conf)

def test_get_job_scheduler(self):
obs = ConfigurationManager()
Expand Down

0 comments on commit fd0e9f7

Please sign in to comment.