示例#1
0
文件: test_ssh.py 项目: vin01/salt
def test_ssh_kwargs(test_opts):
    """
    test all ssh kwargs are not excluded from kwargs
    when preparing the SSH opts
    """
    opt_key = test_opts[0]
    opt_value = test_opts[1]
    # Is the kwarg in salt.utils.parsers?
    in_parser = test_opts[2]

    opts = {
        "eauth": "auto",
        "username": "******",
        "password": "******",
        "client": "ssh",
        "tgt": "localhost",
        "fun": "test.ping",
        opt_key: opt_value,
    }
    client = salt.client.ssh.client.SSHClient(disable_custom_roster=True)
    if in_parser:
        ssh_kwargs = salt.utils.parsers.SaltSSHOptionParser().defaults
        assert opt_key in ssh_kwargs

    with patch("salt.roster.get_roster_file", MagicMock(return_value="")):
        ssh_obj = client._prep_ssh(**opts)
        assert ssh_obj.opts.get(opt_key, None) == opt_value
示例#2
0
 def test_extra_filerefs(self):
     """
     test "extra_filerefs" are not excluded from kwargs
     when preparing the SSH opts
     """
     opts = {
         "eauth": "auto",
         "username": "******",
         "password": "******",
         "client": "ssh",
         "tgt": "localhost",
         "fun": "test.ping",
         "ssh_port": 22,
         "extra_filerefs": "salt://foobar",
     }
     roster = os.path.join(RUNTIME_VARS.TMP_CONF_DIR, "roster")
     client = salt.client.ssh.client.SSHClient(mopts=self.opts,
                                               disable_custom_roster=True)
     with patch("salt.roster.get_roster_file",
                MagicMock(return_value=roster)):
         ssh_obj = client._prep_ssh(**opts)
         assert ssh_obj.opts.get("extra_filerefs", None) == "salt://foobar"