Configure generic Verizon endpoints
This commit is contained in:
@@ -100,6 +100,7 @@ class AppConfig:
|
|||||||
source_name: str
|
source_name: str
|
||||||
provider_name: str
|
provider_name: str
|
||||||
npm_endpoints: tuple[Endpoint, ...]
|
npm_endpoints: tuple[Endpoint, ...]
|
||||||
|
verizon_endpoints: tuple[Endpoint, ...]
|
||||||
proxy_ip: str
|
proxy_ip: str
|
||||||
proxy_api_port: int
|
proxy_api_port: int
|
||||||
proxy_api_scheme: str
|
proxy_api_scheme: str
|
||||||
@@ -121,6 +122,12 @@ class AppConfig:
|
|||||||
source_name = os.getenv("PROXY", "npm").strip().lower()
|
source_name = os.getenv("PROXY", "npm").strip().lower()
|
||||||
provider_name = os.getenv("DNS_PROVIDER", "verizon").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:
|
try:
|
||||||
port = int(os.getenv("PROXY_API_PORT", "81"))
|
port = int(os.getenv("PROXY_API_PORT", "81"))
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
@@ -188,6 +195,7 @@ class AppConfig:
|
|||||||
source_name=source_name,
|
source_name=source_name,
|
||||||
provider_name=provider_name,
|
provider_name=provider_name,
|
||||||
npm_endpoints=npm_endpoints,
|
npm_endpoints=npm_endpoints,
|
||||||
|
verizon_endpoints=verizon_endpoints,
|
||||||
proxy_ip=proxy_ip,
|
proxy_ip=proxy_ip,
|
||||||
proxy_api_port=port,
|
proxy_api_port=port,
|
||||||
proxy_api_scheme=scheme,
|
proxy_api_scheme=scheme,
|
||||||
|
|||||||
@@ -115,6 +115,49 @@ class AppConfigEndpointTests(unittest.TestCase):
|
|||||||
):
|
):
|
||||||
AppConfig.from_env()
|
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__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user