Beispiel #1
0
def test__login_getting_empty_parameters_from_config():
    """
    Test get the connection data from config with an empty response
    """
    query_return = {"jsonrpc": "2.0", "result": "3.4.5", "id": 1}
    fake_connection_data = {}

    with patch.object(zabbix, "_query", return_value=query_return):
        with patch.dict(zabbix.__pillar__, fake_connection_data):
            with pytest.raises(SaltException) as login_exception:
                zabbix._login()
                assert (login_exception.strerror ==
                        "URL is probably not correct! ('user')")
Beispiel #2
0
    def test__login_getting_flat_parameters_from_config(self):
        """
        Test get the connection data as flat parameters from config
        """
        query_return = {"jsonrpc": "2.0", "result": "3.4.5", "id": 1}
        fake_connection_data = {
            "zabbix.user": "******",
            "zabbix.password": "******",
            "zabbix.url": "http://fake_url/zabbix/api_jsonrpc.php",
        }
        login_return = {
            "url": "http://fake_url/zabbix/api_jsonrpc.php",
            "auth": "3.4.5",
        }

        with patch.object(zabbix, "_query", return_value=query_return):
            with patch.dict(zabbix.__pillar__, fake_connection_data):
                self.assertEqual(zabbix._login(), login_return)
Beispiel #3
0
def test__login_getting_nested_parameters_from_config(query_return):
    """
    Test get the connection data as nested parameters from config
    """
    query_return({"jsonrpc": "2.0", "result": "3.4.5", "id": 1})
    fake_connection_data = {
        "zabbix": {
            "user": "******",
            "password": "******",
            "url": "http://fake_url/zabbix/api_jsonrpc.php",
        }
    }
    login_return = {
        "url": "http://fake_url/zabbix/api_jsonrpc.php",
        "auth": "3.4.5",
    }

    with patch.dict(zabbix.__pillar__, fake_connection_data):
        assert zabbix._login() == login_return