-
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.
Merge pull request #4933 from freedomofpress/sdadmin-dead-code
cli: remove dead/unused validator classes in securedrop-admin
- Loading branch information
Showing
2 changed files
with
0 additions
and
96 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 |
---|---|---|
|
@@ -445,63 +445,6 @@ def test_validate_optional_email(self): | |
assert validator.validate(Document('[email protected]')) | ||
assert validator.validate(Document('')) | ||
|
||
def test_is_tails(self): | ||
validator = securedrop_admin.SiteConfig.ValidateDNS() | ||
with mock.patch('subprocess.check_output', return_value='Tails'): | ||
assert validator.is_tails() | ||
with mock.patch('subprocess.check_output', return_value='Debian'): | ||
assert validator.is_tails() is False | ||
with mock.patch('subprocess.check_output', | ||
side_effect=subprocess.CalledProcessError( | ||
1, 'cmd', 'BANG')): | ||
assert validator.is_tails() is False | ||
|
||
def test_lookup_dns(self, caplog): | ||
validator = securedrop_admin.SiteConfig.ValidateDNS() | ||
with mock.patch('securedrop_admin.SiteConfig.ValidateDNS.is_tails', | ||
return_value=True): | ||
with mock.patch('subprocess.check_output', | ||
return_value='has address') as check_output: | ||
assert validator.lookup_fqdn('gnu.org', '8.8.8.8') | ||
assert check_output.call_args[0][0][0] == 'torify' | ||
assert check_output.call_args[0][0][6] == '8.8.8.8' | ||
|
||
with mock.patch('securedrop_admin.SiteConfig.ValidateDNS.is_tails', | ||
return_value=False): | ||
with mock.patch('subprocess.check_output', | ||
return_value='failed') as check_output: | ||
assert validator.lookup_fqdn('gnu.org') is False | ||
assert not check_output.call_args[0][0][0] == 'torify' | ||
assert 'failed' in caplog.text | ||
|
||
with mock.patch('securedrop_admin.SiteConfig.ValidateDNS.is_tails', | ||
return_value=False): | ||
with mock.patch('subprocess.check_output', | ||
side_effect=subprocess.CalledProcessError( | ||
1, 'cmd', 'BANG')): | ||
assert validator.lookup_fqdn('gnu.org') is False | ||
assert 'BANG' in caplog.text | ||
|
||
def test_validate_dns_server(self, caplog): | ||
validator = securedrop_admin.SiteConfig.ValidateDNSServer() | ||
with mock.patch('securedrop_admin.SiteConfig.ValidateDNS.lookup_fqdn', | ||
return_value=True): | ||
assert validator.validate(Document('8.8.8.8')) | ||
with mock.patch('securedrop_admin.SiteConfig.ValidateDNS.lookup_fqdn', | ||
return_value=False): | ||
with pytest.raises(ValidationError): | ||
validator.validate(Document('8.8.8.8')) | ||
|
||
def test_lookup_fqdn(self, caplog): | ||
validator = securedrop_admin.SiteConfig.ValidateFQDN() | ||
with mock.patch('securedrop_admin.SiteConfig.ValidateDNS.lookup_fqdn', | ||
return_value=True): | ||
assert validator.validate(Document('gnu.org')) | ||
with mock.patch('securedrop_admin.SiteConfig.ValidateDNS.lookup_fqdn', | ||
return_value=False): | ||
with pytest.raises(ValidationError): | ||
assert validator.validate(Document('gnu.org')) | ||
|
||
def test_validate_user(self): | ||
validator = securedrop_admin.SiteConfig.ValidateUser() | ||
with pytest.raises(ValidationError): | ||
|