Example #1
0
 def test_kssh_reuse(self, test_config):
     # Test that kssh reuses unexpired keys
     with 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("""bin/kssh -q -o StrictHostKeyChecking=no root@sshd-prod "sha1sum /etc/unique" """))
         start = time.time()
         assert_contains_hash(test_config.expected_hash, run_command_with_agent("""bin/kssh -q -o StrictHostKeyChecking=no root@sshd-prod "sha1sum /etc/unique" """))
         elapsed = time.time() - start
         assert elapsed < 0.5
Example #2
0
 def test_kssh(self, test_config):
     # Test ksshing into staging as user
     with outputs_audit_log(test_config,
                            filename="/shared/ca.log",
                            expected_number=1):
         assert_contains_hash(
             test_config.expected_hash,
             run_command_with_agent(
                 """bin/kssh -q -o StrictHostKeyChecking=no user@sshd-staging "sha1sum /etc/unique" """
             ))
Example #3
0
 def test_kssh_default_user(self, test_config):
     # Set the default user to root
     run_command_with_agent("bin/kssh --set-default-user root")
     # A normal SSH connection
     assert_contains_hash(test_config.expected_hash, run_command_with_agent("bin/kssh -q -o StrictHostKeyChecking=no sshd-prod 'sha1sum /etc/unique'"))
     assert b"root" in run_command_with_agent("bin/kssh -q -o StrictHostKeyChecking=no sshd-prod 'whoami'")
     # A proxy jump (relies on the ssh agent)
     assert_contains_hash(test_config.expected_hash, run_command_with_agent("bin/kssh -q -o StrictHostKeyChecking=no -J sshd-staging sshd-prod 'sha1sum /etc/unique'"))
     # Reset the default user
     run_command_with_agent("bin/kssh --clear-default-user")
Example #4
0
 def test_kssh_prod_root(self, test_config):
     # Test ksshing into prod as root
     with 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(
                 """bin/kssh -q -o StrictHostKeyChecking=no root@sshd-prod "sha1sum /etc/unique" """
             ))
Example #5
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'"
             ))
Example #6
0
 def test_kssh_staging_root(self, test_config):
     # Test ksshing into staging as user
     with 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(
                 'bin/kssh -q -o StrictHostKeyChecking=no \
                 root@sshd-staging "sha1sum /etc/unique" '),
         )