3737from restalchemy .dm import filters as dm_filters
3838from restalchemy .storage .sql import engines
3939
40+ from exordos_core .agent .universal .drivers .secret import cert as cert_driver
4041from exordos_core .agent .universal .drivers .secret import password as password_driver
4142from exordos_core .common import constants as c
4243from exordos_core .common import utils
@@ -1429,19 +1430,18 @@ def factory(hostname, ip_addresses=None, key=None):
14291430
14301431
14311432@pytest .fixture ()
1432- def agent_service (
1433+ def password_agent_service (
14331434 default_node : tp .Dict [str , tp .Any ],
14341435 user_api_client : iam_clients .GenesisCoreTestRESTClient ,
14351436):
14361437 agent_uuid = sys_uuid .UUID (default_node ["uuid" ])
14371438 orch_client = orch_db .DatabaseOrchClient ()
14381439 with tempfile .TemporaryDirectory () as temp_dir :
1439- temp_file_path = os .path .join (temp_dir , "password_target_fields.json" )
1440-
1441- with open (temp_file_path , "w" , encoding = "utf-8" ) as f :
1440+ passwords_temp_file_path = os .path .join (temp_dir , "password_target_fields.json" )
1441+ with open (passwords_temp_file_path , "w" , encoding = "utf-8" ) as f :
14421442 json .dump ({}, f , indent = 4 )
14431443
1444- p_d = password_driver .PasswordCapabilityDriver (temp_file_path )
1444+ p_d = password_driver .PasswordCapabilityDriver (passwords_temp_file_path )
14451445 caps_drivers = [
14461446 p_d ,
14471447 ]
@@ -1460,11 +1460,53 @@ def agent_service(
14601460 yield agent
14611461
14621462
1463+ @pytest .fixture ()
1464+ def cert_agent_service (
1465+ default_node : tp .Dict [str , tp .Any ],
1466+ user_api_client : iam_clients .GenesisCoreTestRESTClient ,
1467+ ):
1468+ agent_uuid = sys_uuid .UUID (default_node ["uuid" ])
1469+ orch_client = orch_db .DatabaseOrchClient ()
1470+ with tempfile .TemporaryDirectory () as temp_dir :
1471+ cert_temp_file_path = os .path .join (temp_dir , "cert_target_fields.json" )
1472+ with open (cert_temp_file_path , "w" , encoding = "utf-8" ) as f :
1473+ json .dump ({}, f , indent = 4 )
1474+ privkey_temp_file_path = os .path .join (temp_dir , "privkey.pem" )
1475+ c_d = cert_driver .CoreDNSCertificateCapabilityDriver (
1476+ user_api_base_url = c .DEFAULT_ROOT_ENDPOINT ,
1477+ username = c .DEFAULT_DNS_CERT_USERNAME ,
1478+ password = c .DEFAULT_DNS_CERT_PASSWORD ,
1479+ storage_path = cert_temp_file_path ,
1480+ private_key_path = privkey_temp_file_path ,
1481+ )
1482+ caps_drivers = [
1483+ c_d ,
1484+ ]
1485+ agent = ua_agent_service .UniversalAgentService (
1486+ system_uuid = agent_uuid ,
1487+ agent_uuid = agent_uuid ,
1488+ orch_client = orch_client ,
1489+ caps_drivers = caps_drivers ,
1490+ facts_drivers = [],
1491+ iter_min_period = 3 ,
1492+ payload_path = None ,
1493+ verify_node_on_register = False ,
1494+ )
1495+ agent ._setup ()
1496+ agent ._register_agent ()
1497+ yield agent
1498+
1499+
14631500@pytest .fixture ()
14641501def password_builder ():
14651502 yield secret_service .PasswordBuilder ()
14661503
14671504
1505+ @pytest .fixture ()
1506+ def certificate_builder ():
1507+ yield secret_service .CertificateBuilder ()
1508+
1509+
14681510@pytest .fixture ()
14691511def universal_scheduler ():
14701512 yield ua_scheduler_service .UniversalAgentSchedulerService (capabilities = ["*" ])
0 commit comments