Exemplo n.º 1
0
 def test_error_includes_stderr_if_given_and_hidden(self):
     """
     error() correctly prints stderr if it was previously hidden
     """
     # Mostly to catch regression bug(s)
     stderr = "this is my stderr"
     with hide('stderr'):
         error("error message", func=utils.abort, stderr=stderr)
     assert_contains(stderr, sys.stderr.getvalue())
Exemplo n.º 2
0
 def test_error_includes_stderr_if_given_and_hidden(self):
     """
     error() correctly prints stderr if it was previously hidden
     """
     # Mostly to catch regression bug(s)
     stderr = "this is my stderr"
     with hide('stderr'):
         error("error message", func=utils.abort, stderr=stderr)
     assert_contains(stderr, sys.stderr.getvalue())
Exemplo n.º 3
0
 def test_password_prompt_displays_host_string(self):
     """
     Password prompt lines should include the user/host in question
     """
     env.password = None
     env.no_agent = env.no_keys = True
     with show('everything'), password_response(PASSWORDS[env.user], silent=False):
         run("ls /simple")
     regex = r'^\[%s\] Login password for \'%s\': ' % (env.host_string, env.user)
     assert_contains(regex, sys.stderr.getvalue())
Exemplo n.º 4
0
 def test_passphrase_prompt_displays_host_string(self):
     """
     Passphrase prompt lines should include the user/host in question
     """
     env.password = None
     env.no_agent = env.no_keys = True
     env.key_filename = CLIENT_PRIVKEY
     with hide('everything'), password_response(CLIENT_PRIVKEY_PASSPHRASE, silent=False):
         run("ls /simple")
     regex = r'^\[%s\] Login password for \'%s\': ' % (env.host_string, env.user)
     assert_contains(regex, sys.stderr.getvalue())
Exemplo n.º 5
0
 def _invalid_file_obj_situations(self, remote_path):
     with settings(hide('running'), warn_only=True):
         get(remote_path, StringIO())
     assert_contains('is a glob or directory', sys.stderr.getvalue())
Exemplo n.º 6
0
 def test_includes_traceback_if_debug_logging_is_on(self):
     """
     error() includes traceback in message if debug logging is on (backwardis compatibility)
     """
     error("error message", func=utils.abort, stdout=error)
     assert_contains(self.dummy_string, sys.stdout.getvalue())
Exemplo n.º 7
0
 def test_includes_traceback_if_exceptions_logging_is_on(self):
     """
     error() includes traceback in message if exceptions logging is on
     """
     error("error message", func=utils.abort, stdout=error)
     assert_contains(self.dummy_string, sys.stdout.getvalue())
Exemplo n.º 8
0
 def test_includes_traceback_if_debug_logging_is_on(self):
     """
     error() includes traceback in message if debug logging is on (backwardis compatibility)
     """
     error("error message", func=utils.abort, stdout=error)
     assert_contains(self.dummy_string, sys.stdout.getvalue())
Exemplo n.º 9
0
 def test_includes_traceback_if_exceptions_logging_is_on(self):
     """
     error() includes traceback in message if exceptions logging is on
     """
     error("error message", func=utils.abort, stdout=error)
     assert_contains(self.dummy_string, sys.stdout.getvalue())
Exemplo n.º 10
0
Arquivo: cis3.py Projeto: ysoldak/syco
check_equal("grep umask /etc/sysconfig/init", "umask 027")

#
print_header("3.2 Remove X Windows (Scored)")
# Original CIS test
# check_equal(
#     'grep "^id:" /etc/inittab',
#     "id:3:initdefault"
# )
# Syco hardened servers use this.
check_equal('grep "^\~\~\:S\:wait\:\/sbin\/sulogin" /etc/inittab',
            "~~:S:wait:/sbin/sulogin")

result = x('yum grouplist "X Window System"')
max_lines = len(result)
assert_contains(result[max_lines - 3], "Available Groups:")
assert_contains(result[max_lines - 2], "  X Window System")
assert_contains(result[max_lines - 1], "Done")

#
print_header("3.3 Disable Avahi Server (Scored)")
check_equal("rpm -q avahi", "package avahi is not installed")
check_empty("chkconfig --list | grep avahi")

#
print_header("3.4 Disable Print Server - CUPS (Not Scored)")
check_equal("rpm -q cups", "package cups is not installed")
check_empty("chkconfig --list | grep cups")

#
print_header("3.5 Remove DHCP Server (Scored)")
Exemplo n.º 11
0
 def _invalid_file_obj_situations(self, remote_path):
     with settings(hide('running'), warn_only=True):
         get(remote_path, StringIO())
     assert_contains('is a glob or directory', sys.stderr.getvalue())
Exemplo n.º 12
0
Arquivo: cis3.py Projeto: Nemie/syco
#
print_header("3.2 Remove X Windows (Scored)")
# Original CIS test
# check_equal(
#     'grep "^id:" /etc/inittab',
#     "id:3:initdefault"
# )
# Syco hardened servers use this.
check_equal(
    'grep "^\~\~\:S\:wait\:\/sbin\/sulogin" /etc/inittab',
    "~~:S:wait:/sbin/sulogin"
)

result = x('yum grouplist "X Window System"')
max_lines = len(result)
assert_contains(result[max_lines-3], "Available Groups:")
assert_contains(result[max_lines-2], "  X Window System")
assert_contains(result[max_lines-1], "Done")

#
print_header("3.3 Disable Avahi Server (Scored)")
check_equal(
    "rpm -q avahi",
    "package avahi is not installed"
)
check_empty("chkconfig --list | grep avahi")

#
print_header("3.4 Disable Print Server - CUPS (Not Scored)")
check_equal(
    "rpm -q cups",