Beispiel #1
0
 def test_kssh_errors_on_two_bots(self, test_config):
     # Test that kssh does not run if there are multiple bots, no kssh config, and no --bot flag
     with simulate_two_teams(test_config), outputs_audit_log(test_config, filename=test_env_1_log_filename, expected_number=0):
         try:
             run_command_with_agent("bin/kssh root@sshd-prod")
             assert False
         except subprocess.CalledProcessError as e:
             assert b"Found 2 config files" in e.output
Beispiel #2
0
 def test_kssh_bot_flag(self, test_config):
     # Test that kssh works with the --bot flag
     with simulate_two_teams(test_config), outputs_audit_log(
             test_config, filename=test_env_1_log_filename,
             expected_number=1):
         assert_contains_hash(
             test_config.expected_hash,
             run_command_with_agent(
                 f"bin/kssh --bot {test_config.bot_username} -q -o StrictHostKeyChecking=no root@sshd-prod 'sha1sum /etc/unique'"
             ))
Beispiel #3
0
 def test_kssh_clear_default_bot(self, test_config):
     # Test that kssh --clear-default-bot clears the default bot
     with simulate_two_teams(test_config), outputs_audit_log(test_config, filename=test_env_1_log_filename, expected_number=0):
         run_command_with_agent(f"bin/kssh --set-default-bot {test_config.bot_username}")
         run_command_with_agent("bin/kssh --clear-default-bot")
         try:
             # No default set and no bot specified so it will error out
             run_command_with_agent("bin/kssh root@sshd-prod")
             assert False
         except subprocess.CalledProcessError as e:
             assert b"Found 2 config files" in e.output
Beispiel #4
0
 def test_kssh_override_default_bot(self, test_config):
     # Test that the --bot flag overrides the local config file
     with simulate_two_teams(test_config), outputs_audit_log(
             test_config, filename=test_env_1_log_filename,
             expected_number=1):
         run_command_with_agent(f"bin/kssh --set-default-bot otherbotname")
         assert_contains_hash(
             test_config.expected_hash,
             run_command_with_agent(
                 f"bin/kssh --bot {test_config.bot_username} -q -o StrictHostKeyChecking=no root@sshd-prod 'sha1sum /etc/unique'"
             ))