From ed97b644e811275f06070ea42ef599167a329d1e Mon Sep 17 00:00:00 2001 From: Lyncoln Date: Sun, 20 Sep 2026 20:29:40 -0400 Subject: [PATCH] Move Verizon endpoint config into plugin --- dns_sync/config.py | 8 ------ external_plugins/verizon/__init__.py | 12 +++++++- tests/test_config.py | 42 ---------------------------- tests/test_verizon_adapter.py | 19 +++++++++++-- 4 files changed, 27 insertions(+), 54 deletions(-) diff --git a/dns_sync/config.py b/dns_sync/config.py index 3d573d0..215417c 100644 --- a/dns_sync/config.py +++ b/dns_sync/config.py @@ -100,7 +100,6 @@ class AppConfig: source_name: str provider_name: str npm_endpoints: tuple[Endpoint, ...] - verizon_endpoints: tuple[Endpoint, ...] proxy_ip: str proxy_api_port: int proxy_api_scheme: str @@ -122,12 +121,6 @@ class AppConfig: source_name = os.getenv("PROXY", "npm").strip().lower() provider_name = os.getenv("DNS_PROVIDER", "verizon").strip().lower() - verizon_endpoints = parse_endpoint_list( - "verizon", - os.getenv("VERIZON_ENDPOINTS", "192.168.1.1"), - 443, - ) - try: port = int(os.getenv("PROXY_API_PORT", "81")) except ValueError as exc: @@ -195,7 +188,6 @@ class AppConfig: source_name=source_name, provider_name=provider_name, npm_endpoints=npm_endpoints, - verizon_endpoints=verizon_endpoints, proxy_ip=proxy_ip, proxy_api_port=port, proxy_api_scheme=scheme, diff --git a/external_plugins/verizon/__init__.py b/external_plugins/verizon/__init__.py index d8952c5..1416f0e 100644 --- a/external_plugins/verizon/__init__.py +++ b/external_plugins/verizon/__init__.py @@ -1,3 +1,5 @@ +import os + from dns_sync.adapters import ( DNS_RECORDS, ApplyResult, @@ -13,12 +15,20 @@ from dns_sync.adapter_support import ( require_desired, require_endpoint_plugin, ) +from dns_sync.config import parse_endpoint_list from dns_sync.models import DesiredRecord from .provider import Plugin as VerizonProvider def configured_endpoints(config): - return config.verizon_endpoints + return parse_endpoint_list( + "verizon", + os.getenv( + "VERIZON_ENDPOINTS", + "192.168.1.1", + ), + 443, + ) class Plugin: diff --git a/tests/test_config.py b/tests/test_config.py index a616e02..cbb4de5 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -115,48 +115,6 @@ class AppConfigEndpointTests(unittest.TestCase): ): AppConfig.from_env() - def test_verizon_endpoint_list_is_plugin_specific(self): - with patch.dict( - os.environ, - { - "NPM_ENDPOINTS": "192.168.1.3", - "VERIZON_ENDPOINTS": ( - "192.168.1.1,192.168.1.254:8443" - ), - }, - clear=True, - ): - config = AppConfig.from_env() - - self.assertEqual( - tuple( - endpoint.identity - for endpoint in config.verizon_endpoints - ), - ( - "verizon://192.168.1.1:443", - "verizon://192.168.1.254:8443", - ), - ) - - def test_router_url_does_not_configure_generic_endpoint(self): - with patch.dict( - os.environ, - { - "NPM_ENDPOINTS": "192.168.1.3", - "ROUTER_URL": "https://192.168.1.254", - }, - clear=True, - ): - config = AppConfig.from_env() - - self.assertEqual( - tuple( - endpoint.identity - for endpoint in config.verizon_endpoints - ), - ("verizon://192.168.1.1:443",), - ) if __name__ == "__main__": diff --git a/tests/test_verizon_adapter.py b/tests/test_verizon_adapter.py index 16dad02..e13ca35 100644 --- a/tests/test_verizon_adapter.py +++ b/tests/test_verizon_adapter.py @@ -13,7 +13,10 @@ from dns_sync.adapters import ( ) from dns_sync.config import AppConfig from dns_sync.models import ProviderRecord -from dns_sync.registry import load_adapter +from dns_sync.registry import ( + configured_adapter_endpoints, + load_adapter, +) class VerizonAdapterTests(unittest.TestCase): @@ -57,10 +60,15 @@ class VerizonAdapterTests(unittest.TestCase): "VerizonProvider", return_value=provider, ): + endpoint = configured_adapter_endpoints( + "verizon", + config, + )[0] + return load_adapter( "verizon", config, - config.verizon_endpoints[0], + endpoint, ) @staticmethod @@ -143,10 +151,15 @@ class VerizonAdapterTests(unittest.TestCase): clear=True, ): config = AppConfig.from_env() + endpoint = configured_adapter_endpoints( + "verizon", + config, + )[0] + adapter = load_adapter( "verizon", config, - config.verizon_endpoints[0], + endpoint, ) self.assertEqual(