99from elasticsearch import BadRequestError
1010from elasticsearch import ConnectionError as ESConnectionError
1111
12- from detection_rules .misc import get_default_config , get_elasticsearch_client , get_kibana_client , getdefault
12+ from detection_rules .misc import get_default_config
13+ from detection_rules .remote_validation import RemoteConnector
1314from detection_rules .rule_validators import ESQLValidator
1415
1516from .base import BaseRuleTest
@@ -29,20 +30,9 @@ def test_esql_rules(self):
2930 if not esql_rules :
3031 return
3132
32- kibana_client = get_kibana_client (
33- api_key = getdefault ("api_key" )(),
34- cloud_id = getdefault ("cloud_id" )(),
35- kibana_url = getdefault ("kibana_url" )(),
36- space = getdefault ("space" )(),
37- ignore_ssl_errors = getdefault ("ignore_ssl_errors" )(),
38- )
39-
40- elastic_client = get_elasticsearch_client (
41- api_key = getdefault ("api_key" )(),
42- cloud_id = getdefault ("cloud_id" )(),
43- elasticsearch_url = getdefault ("elasticsearch_url" )(),
44- ignore_ssl_errors = getdefault ("ignore_ssl_errors" )(),
45- )
33+ remote_connector = RemoteConnector ()
34+ if not remote_connector .es_client or not remote_connector .kibana_client :
35+ self .skipTest ("Skipping remote validation due to missing client" )
4636
4737 # Retrieve verbosity level from pytest
4838 verbosity : int = int (self ._outcome .result .config .get_verbosity ()) # type: ignore[reportIncompatibleMethodOverride]
@@ -56,7 +46,9 @@ def test_esql_rules(self):
5646 while retry_count < max_retries :
5747 try :
5848 validator = ESQLValidator (r .contents .data .query ) # type: ignore[reportIncompatibleMethodOverride]
59- validator .remote_validate_rule_contents (kibana_client , elastic_client , r .contents , verbosity )
49+ _ = validator .remote_validate_rule_contents (
50+ remote_connector .kibana_client , remote_connector .es_client , r .contents , verbosity
51+ )
6052 break
6153 except (ValueError , BadRequestError ) as e :
6254 print (f"FAILURE: { e } " )
0 commit comments