Example #1
0
 def test_apply_credentials_with_no_user(self, m_setup_keys):
     """Apply keys for root only."""
     keys = ["key1"]
     user = None
     cc_ssh.apply_credentials(keys, user, False, ssh_util.DISABLE_USER_OPTS)
     self.assertEqual([mock.call(set(keys), "root", options="")],
                      m_setup_keys.call_args_list)
Example #2
0
 def test_apply_credentials_with_user(self, m_setup_keys):
     """Apply keys for the given user and root."""
     keys = ["key1"]
     user = "******"
     cc_ssh.apply_credentials(keys, user, False, ssh_util.DISABLE_USER_OPTS)
     self.assertEqual([mock.call(set(keys), user),
                       mock.call(set(keys), "root", options="")],
                      m_setup_keys.call_args_list)
Example #3
0
 def test_apply_credentials_with_no_user_disable_root(self, m_setup_keys):
     """Apply keys no user and disable root ssh."""
     keys = ["key1"]
     user = None
     options = ssh_util.DISABLE_USER_OPTS
     cc_ssh.apply_credentials(keys, user, True, options)
     options = options.replace("$USER", "NONE")
     options = options.replace("$DISABLE_USER", "root")
     self.assertEqual([mock.call(set(keys), "root", options=options)],
                      m_setup_keys.call_args_list)
Example #4
0
 def test_apply_credentials(self, m_setup_keys, keys, user,
                            disable_root_opts):
     options = ssh_util.DISABLE_USER_OPTS
     cc_ssh.apply_credentials(keys, user, disable_root_opts, options)
     if not disable_root_opts:
         expected_options = ""
     else:
         expected_options = _replace_options(user)
     expected_calls = [
         mock.call(set(keys), "root", options=expected_options)
     ]
     if user:
         expected_calls = [mock.call(set(keys), user)] + expected_calls
     assert expected_calls == m_setup_keys.call_args_list
Example #5
0
 def test_apply_credentials_with_user_disable_root(self, m_setup_keys):
     """Apply keys for the given user and disable root ssh."""
     keys = ["key1"]
     user = "******"
     options = ssh_util.DISABLE_USER_OPTS
     cc_ssh.apply_credentials(keys, user, True, options)
     options = options.replace("$USER", user)
     options = options.replace("$DISABLE_USER", "root")
     self.assertEqual(
         [
             mock.call(set(keys), user),
             mock.call(set(keys), "root", options=options),
         ],
         m_setup_keys.call_args_list,
     )