-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
securedrop-admin: when a journalist key is present, the email is requ…
…ired
- Loading branch information
Loic Dachary
committed
Apr 3, 2018
1 parent
a30499b
commit 0713b76
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -411,6 +411,41 @@ def test_validate_gpg_key(self, caplog): | |
site_config.validate_gpg_keys() | ||
assert 'FAIL does not match' in e.value.message | ||
|
||
def test_journalist_alert_email(self): | ||
args = argparse.Namespace(site_config='INVALID', | ||
ansible_path='tests/files', | ||
app_path=dirname(__file__)) | ||
site_config = securedrop_admin.SiteConfig(args) | ||
site_config.config = { | ||
'journalist_alert_gpg_public_key': | ||
'', | ||
|
||
'journalist_gpg_fpr': | ||
'', | ||
} | ||
assert site_config.validate_journalist_alert_email() | ||
site_config.config = { | ||
'journalist_alert_gpg_public_key': | ||
'test_journalist_key.pub', | ||
|
||
'journalist_gpg_fpr': | ||
'65A1B5FF195B56353CC63DFFCC40EF1228271441', | ||
} | ||
site_config.config['journalist_alert_email'] = '' | ||
with pytest.raises( | ||
securedrop_admin.JournalistAlertEmailException) as e: | ||
site_config.validate_journalist_alert_email() | ||
assert 'not be empty' in e.value.message | ||
|
||
site_config.config['journalist_alert_email'] = 'bademail' | ||
with pytest.raises( | ||
securedrop_admin.JournalistAlertEmailException) as e: | ||
site_config.validate_journalist_alert_email() | ||
assert 'Must contain a @' in e.value.message | ||
|
||
site_config.config['journalist_alert_email'] = '[email protected]' | ||
assert site_config.validate_journalist_alert_email() | ||
|
||
@mock.patch('securedrop_admin.SiteConfig.validated_input', | ||
side_effect=lambda p, d, v, t: d) | ||
@mock.patch('securedrop_admin.SiteConfig.save') | ||
|