Publish curated ITWorx_MCP_Hub source from 6c7434368ce2a594005983c5a6601a31a639e7f1
This commit is contained in:
1 parent
77946d62c4
commit
6d40ab975c
86 files changed
+6784
-1478
No files matched your search
@@ -5,6 +5,7 @@ import json
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from uuid import uuid4
|
||||
|
||||
from fastapi import FastAPI
|
||||
@@ -30,6 +31,59 @@ def adapter_for(fake: FakeContextForge) -> ContextForgeClient:
|
||||
|
||||
|
||||
class CatalogLoaderTests(unittest.TestCase):
|
||||
def test_schema_store_loads_once_per_catalog_load_without_changing_validation(self) -> None:
|
||||
class CountingCatalogLoader(CatalogLoader):
|
||||
store_loads = 0
|
||||
|
||||
def _schema_store(self) -> dict[str, Any]:
|
||||
self.store_loads += 1
|
||||
return super()._schema_store()
|
||||
|
||||
loader = CountingCatalogLoader(ROOT / "catalog")
|
||||
report = loader.load()
|
||||
self.assertTrue(report.valid, report.issues)
|
||||
self.assertEqual(len(report.documents), 281)
|
||||
self.assertEqual(report.issues, ())
|
||||
self.assertEqual(loader.store_loads, 1)
|
||||
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory) / "catalog"
|
||||
project_dir = root / "projects"
|
||||
project_dir.mkdir(parents=True)
|
||||
payload = json.loads(
|
||||
(ROOT / "catalog/projects/general-infrastructure.yaml").read_text(encoding="utf-8")
|
||||
)
|
||||
payload["spec"]["virtualServers"][0]["endpointAlias"] = "not-an-alias"
|
||||
payload["spec"]["capabilityPacks"] = []
|
||||
payload["spec"]["connectorBindings"] = []
|
||||
payload["spec"]["credentialToken"] = "plain-secret-value"
|
||||
(project_dir / "bad.yaml").write_text(json.dumps(payload), encoding="utf-8")
|
||||
invalid_loader = CountingCatalogLoader(root, schema_root=ROOT / "contracts/schemas")
|
||||
invalid_report = invalid_loader.load()
|
||||
|
||||
self.assertFalse(invalid_report.valid)
|
||||
self.assertEqual(
|
||||
{
|
||||
(issue.code, issue.source.file, issue.source.pointer)
|
||||
for issue in invalid_report.issues
|
||||
},
|
||||
{
|
||||
(
|
||||
"schema_error",
|
||||
"projects/bad.yaml",
|
||||
"/spec/virtualServers/0/endpointAlias",
|
||||
),
|
||||
("schema_error", "projects/bad.yaml", "/spec/capabilityPacks"),
|
||||
("schema_error", "projects/bad.yaml", "/spec"),
|
||||
("secret_value", "projects/bad.yaml", "/spec/credentialToken"),
|
||||
},
|
||||
)
|
||||
self.assertEqual(invalid_loader.store_loads, 1)
|
||||
self.assertNotIn(
|
||||
"plain-secret-value",
|
||||
json.dumps([document.payload for document in invalid_report.documents]),
|
||||
)
|
||||
|
||||
def test_committed_catalog_validates_without_network_or_secret_values(self) -> None:
|
||||
report = CatalogLoader(ROOT / "catalog").load()
|
||||
self.assertTrue(report.valid, report.issues)
|
||||
|
||||
Reference in new issue
Block a user