Move NPM configuration and client behind plugin boundary
This commit is contained in:
+13
-33
@@ -47,28 +47,27 @@ class EndpointParsingTests(unittest.TestCase):
|
||||
)
|
||||
|
||||
|
||||
class AppConfigEndpointTests(unittest.TestCase):
|
||||
def test_legacy_proxy_ip_remains_supported(self):
|
||||
class AppConfigPolicyTests(unittest.TestCase):
|
||||
def test_explicit_dns_target_is_used(self):
|
||||
with patch.dict(
|
||||
os.environ,
|
||||
{"PROXY_IP": "192.168.1.101"},
|
||||
{
|
||||
"DNS_TARGET_IP": "192.168.1.101",
|
||||
"NPM_ENDPOINTS": "192.168.1.3,192.168.1.4",
|
||||
},
|
||||
clear=True,
|
||||
):
|
||||
config = AppConfig.from_env()
|
||||
|
||||
self.assertEqual(
|
||||
tuple(endpoint.identity for endpoint in config.npm_endpoints),
|
||||
("npm://192.168.1.101:81",),
|
||||
config.target_ip,
|
||||
"192.168.1.101",
|
||||
)
|
||||
self.assertEqual(config.target_ip, "192.168.1.101")
|
||||
|
||||
def test_endpoint_list_controls_api_and_proxy_ip_remains_target(self):
|
||||
def test_legacy_proxy_ip_remains_target_fallback(self):
|
||||
with patch.dict(
|
||||
os.environ,
|
||||
{
|
||||
"NPM_ENDPOINTS": (
|
||||
"192.168.1.3,192.168.1.4:8081,192.168.1.5"
|
||||
),
|
||||
"PROXY_IP": "192.168.1.101",
|
||||
},
|
||||
clear=True,
|
||||
@@ -76,33 +75,15 @@ class AppConfigEndpointTests(unittest.TestCase):
|
||||
config = AppConfig.from_env()
|
||||
|
||||
self.assertEqual(
|
||||
tuple(endpoint.identity for endpoint in config.npm_endpoints),
|
||||
(
|
||||
"npm://192.168.1.3:81",
|
||||
"npm://192.168.1.4:8081",
|
||||
"npm://192.168.1.5:81",
|
||||
),
|
||||
config.target_ip,
|
||||
"192.168.1.101",
|
||||
)
|
||||
self.assertEqual(config.target_ip, "192.168.1.101")
|
||||
|
||||
def test_explicit_dns_target_supports_multiple_endpoints(self):
|
||||
def test_dns_target_is_required_without_legacy_fallback(self):
|
||||
with patch.dict(
|
||||
os.environ,
|
||||
{
|
||||
"NPM_ENDPOINTS": "192.168.1.3,192.168.1.4",
|
||||
"DNS_TARGET_IP": "192.168.1.101",
|
||||
},
|
||||
clear=True,
|
||||
):
|
||||
config = AppConfig.from_env()
|
||||
|
||||
self.assertEqual(config.target_ip, "192.168.1.101")
|
||||
|
||||
def test_multiple_endpoints_require_target_without_proxy_ip(self):
|
||||
with patch.dict(
|
||||
os.environ,
|
||||
{
|
||||
"NPM_ENDPOINTS": "192.168.1.3,192.168.1.4",
|
||||
"NPM_ENDPOINTS": "192.168.1.3",
|
||||
},
|
||||
clear=True,
|
||||
):
|
||||
@@ -113,6 +94,5 @@ class AppConfigEndpointTests(unittest.TestCase):
|
||||
AppConfig.from_env()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user