mirror of
https://github.com/jtesta/ssh-audit.git
synced 2025-09-05 03:18:33 +02:00
* print config v2 - printconfig script - test_printconfig for tox testing - update globals for GUIDES_UPDATED date value - update ssh_audit for print_config argument and checks * pr307 update 1 * pr307 update 2 * pr307 - attempt 2 * Update ssh_audit.py Missed a TAB
This commit is contained in:
41
test/test_hardeningguides.py
Normal file
41
test/test_hardeningguides.py
Normal file
@ -0,0 +1,41 @@
|
||||
import pytest
|
||||
from ssh_audit.ssh_audit import process_commandline
|
||||
|
||||
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
class TestHardeningGuides:
|
||||
@pytest.fixture(autouse=True)
|
||||
def init(self, ssh_audit):
|
||||
self.OutputBuffer = ssh_audit.OutputBuffer()
|
||||
self.process_commandline = process_commandline
|
||||
|
||||
@staticmethod
|
||||
def _test_conf(conf, **kwargs):
|
||||
options = {
|
||||
'get_hardening_guides': '',
|
||||
}
|
||||
for k, v in kwargs.items():
|
||||
options[k] = v
|
||||
assert conf.get_hardening_guides == options['get_hardening_guides']
|
||||
|
||||
def test_printconfig_conf_process_commandline(self):
|
||||
# pylint: disable=too-many-statements
|
||||
c = lambda x: self.process_commandline(self.OutputBuffer, x.split()) # noqa
|
||||
with pytest.raises(SystemExit):
|
||||
conf = c('')
|
||||
with pytest.raises(SystemExit):
|
||||
conf = c('--get-hardening-guides')
|
||||
self._test_conf(conf)
|
||||
with pytest.raises(SystemExit):
|
||||
conf = c('--list-hardening-guides')
|
||||
self._test_conf(conf)
|
||||
|
||||
for vendor in ["Amazon", "Debian", "Rocky", "Mint", "Ubuntu", "NoOS", " "]:
|
||||
vendor = vendor
|
||||
for os_ver in ["2404", "2204", "2004", "1804", "2023", "22", "21", "20", "9", "Bookworm", "Bullseye", "NoVersion", ""]:
|
||||
os_ver = os_ver
|
||||
for cs_type in ["Client", "Server", "Mistake", ""]:
|
||||
cs_type = cs_type
|
||||
with pytest.raises(SystemExit):
|
||||
conf = c(f'--get-hardening-guides {vendor} {os_ver} {cs_type}')
|
||||
self._test_conf(conf)
|
Reference in New Issue
Block a user