def test_client_for_cluster_with_azure_cli_auth(self): with self.assertLogs(_logger, logging.INFO) as cm: client = PyKustoClient('https://help.kusto.windows.net', fetch_by_default=False) self.assertIsInstance(client._PyKustoClient__client, KustoClient) self.assertEqual('https://help.kusto.windows.net', client.get_cluster_name()) self.assertEqual([], cm.output)
def test_client_for_cluster_fallback_to_aad_device_auth(self): with patch('pykusto._src.client._get_azure_cli_auth_token', lambda: None), self.assertLogs(_logger, logging.INFO) as cm: client = PyKustoClient('https://help.kusto.windows.net', fetch_by_default=False) self.assertIsInstance(client._PyKustoClient__client, KustoClient) self.assertEqual('https://help.kusto.windows.net', client.get_cluster_name()) self.assertEqual( ['INFO:pykusto:Failed to get Azure CLI token, falling back to AAD device authentication'], cm.output )
def test_client_for_cluster_with_aad_device_auth(self): with self.assertLogs(_logger, logging.INFO) as cm: client = PyKustoClient('https://help.kusto.windows.net', fetch_by_default=False, auth_method=KustoConnectionStringBuilder. with_aad_device_authentication) self.assertIsInstance(client._PyKustoClient__client, KustoClient) self.assertEqual('https://help.kusto.windows.net', client.get_cluster_name()) self.assertEqual([], cm.output)