2026-09-16 14:02:46 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
"""Tests for check_app_terraform_isolation.isolation_violation."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
from check_app_terraform_isolation import isolation_violation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class IsolationTests(unittest.TestCase):
|
|
|
|
|
def test_terraform_only(self) -> None:
|
|
|
|
|
self.assertIsNone(
|
|
|
|
|
isolation_violation(
|
|
|
|
|
[
|
|
|
|
|
"terraform/live/dev/main.tf",
|
|
|
|
|
"terraform/live/README.md",
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_app_only(self) -> None:
|
|
|
|
|
self.assertIsNone(
|
|
|
|
|
isolation_violation(
|
|
|
|
|
[
|
|
|
|
|
"Api.SeaHavenIndustries/Controllers/WorkOrderController.cs",
|
|
|
|
|
".ebextensions/01_migrations.config",
|
|
|
|
|
"scripts/package-elastic-beanstalk.sh",
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_docs_and_workflows_with_terraform(self) -> None:
|
|
|
|
|
self.assertIsNone(
|
|
|
|
|
isolation_violation(
|
|
|
|
|
[
|
|
|
|
|
"terraform/live/modules/environment-owned/main.tf",
|
|
|
|
|
".github/workflows/deploy.yaml",
|
|
|
|
|
"QUALITY_GATES.md",
|
|
|
|
|
"scripts/governance-check.sh",
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_mixed_app_and_terraform_fails(self) -> None:
|
|
|
|
|
violation = isolation_violation(
|
|
|
|
|
[
|
|
|
|
|
"terraform/live/dev/main.tf",
|
|
|
|
|
"SeaHaven.Services/Implementation/WorkOrderService.cs",
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
self.assertIsNotNone(violation)
|
|
|
|
|
terraform_files, app_files = violation or ([], [])
|
|
|
|
|
self.assertEqual(terraform_files, ["terraform/live/dev/main.tf"])
|
|
|
|
|
self.assertTrue(any(path.endswith(".cs") for path in app_files))
|
|
|
|
|
|
2026-09-24 20:52:44 -03:00
|
|
|
def test_platform_proxy_config_is_app_side(self) -> None:
|
|
|
|
|
violation = isolation_violation(
|
|
|
|
|
[
|
|
|
|
|
"terraform/live/dev/main.tf",
|
|
|
|
|
".platform/nginx/conf.d/01_upload_body_size.conf",
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
self.assertIsNotNone(violation)
|
|
|
|
|
_, app_files = violation or ([], [])
|
|
|
|
|
self.assertEqual(app_files, [".platform/nginx/conf.d/01_upload_body_size.conf"])
|
|
|
|
|
|
2026-09-16 14:02:46 -04:00
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
unittest.main()
|