Extract shared adapter validation helpers
This commit is contained in:
@@ -5,6 +5,7 @@ from unittest.mock import Mock, patch
|
||||
from dns_sync.adapters import (
|
||||
DNS_RECORDS,
|
||||
Capability,
|
||||
Endpoint,
|
||||
CapabilityOperation,
|
||||
NormalizedObject,
|
||||
PlanAction,
|
||||
@@ -79,6 +80,32 @@ class VerizonAdapterTests(unittest.TestCase):
|
||||
},
|
||||
)
|
||||
|
||||
def test_adapter_rejects_endpoint_for_other_plugin(self):
|
||||
config = self.config()
|
||||
endpoint = Endpoint(
|
||||
"npm",
|
||||
"192.168.1.3:81",
|
||||
)
|
||||
|
||||
with patch.dict(
|
||||
os.environ,
|
||||
{
|
||||
"ENABLED_PLUGINS": "npm,verizon",
|
||||
"DNS_SYNC_PLUGIN_PATH": "external_plugins",
|
||||
},
|
||||
clear=False,
|
||||
):
|
||||
with self.assertRaisesRegex(
|
||||
RuntimeError,
|
||||
"cannot use endpoint",
|
||||
):
|
||||
load_adapter(
|
||||
"verizon",
|
||||
config,
|
||||
endpoint,
|
||||
)
|
||||
|
||||
|
||||
def test_capabilities_cover_dns_discovery_apply_and_verify(self):
|
||||
adapter = self.adapter(Mock())
|
||||
|
||||
@@ -259,7 +286,7 @@ class VerizonAdapterTests(unittest.TestCase):
|
||||
with self.assertRaisesRegex(RuntimeError, "cannot discover"):
|
||||
adapter.discover("certificates")
|
||||
|
||||
with self.assertRaisesRegex(RuntimeError, "different endpoint"):
|
||||
with self.assertRaisesRegex(RuntimeError, "does not belong"):
|
||||
adapter.apply(
|
||||
PlanAction(
|
||||
endpoint_id="verizon://different:443",
|
||||
|
||||
Reference in New Issue
Block a user