3300ed2557
The adapter reads env.state_backend.bucket from the env JSON when present
(fallback to the computed nova-tfstate-{account_id}-{region} pattern for
backwards compat). dev.json bound to the real account 581513795199 +
bucket nova-tfstate-581513795199-us-east-1 (D-203). qa/prod/dr stay
placeholder (account_id 000000000000 — the pilot-readiness policy blocks
apply on placeholder, D-208). dynamodb added to the adapter test
EXPECTED_L1_KEYS + a resolution/emission test.
---ci---
project: acdl
phase: 3
milestone: v1.26
status: execute
wave: W3
---
62 lines
2.5 KiB
Python
62 lines
2.5 KiB
Python
"""REQ-103: sample contracts use naming patterns with interpolation."""
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
from core.contract_resolver import resolve
|
|
|
|
|
|
def test_static_assets_bucket_name_uses_naming_pattern():
|
|
stack = resolve(str(ROOT / "contracts" / "static-assets.yml"))
|
|
s3 = [r for r in stack["resources"] if r["type"] == "aws:s3:bucket"][0]
|
|
bucket = s3["inputs"]["bucket_name"]
|
|
# The naming pattern: acdl-<env>-<id>-<account_id>-<region>
|
|
# P03 W3 (REQ-319, D-203): dev is bound to the real account 581513795199.
|
|
assert bucket.startswith("acdl-dev-assets-")
|
|
assert "581513795199" in bucket
|
|
assert bucket.endswith("us-east-1")
|
|
assert bucket == "acdl-dev-assets-581513795199-us-east-1"
|
|
|
|
|
|
def test_static_assets_region_uses_env_region():
|
|
stack = resolve(str(ROOT / "contracts" / "static-assets.yml"))
|
|
s3 = [r for r in stack["resources"] if r["type"] == "aws:s3:bucket"][0]
|
|
assert s3["inputs"]["region"] == "us-east-1"
|
|
|
|
|
|
def test_static_assets_contract_has_interpolation_tokens_pre_resolve():
|
|
"""The contract file itself contains the raw ${env.*} tokens (pre-resolution)."""
|
|
text = (ROOT / "contracts" / "static-assets.yml").read_text()
|
|
assert "${env.environment}" in text
|
|
assert "${contract.id}" in text
|
|
assert "${env.account_id}" in text
|
|
assert "${env.region}" in text
|
|
|
|
|
|
def test_microservice_contract_has_interpolation_tokens():
|
|
text = (ROOT / "contracts" / "microservice.yml").read_text()
|
|
assert "${env.environment}" in text
|
|
assert "${env.account_id}" in text
|
|
assert "${env.region}" in text
|
|
|
|
|
|
def test_microservice_resolves_with_interpolation():
|
|
stack = resolve(str(ROOT / "contracts" / "microservice.yml"))
|
|
assert stack["stack"]["name"] == "msvc"
|
|
# Resolution succeeded — no unresolved tokens.
|
|
|
|
|
|
def test_interpolation_uses_all_naming_components():
|
|
"""The naming pattern includes region, account id, and environment (the binding requirement)."""
|
|
stack = resolve(str(ROOT / "contracts" / "static-assets.yml"))
|
|
s3 = [r for r in stack["resources"] if r["type"] == "aws:s3:bucket"][0]
|
|
bucket = s3["inputs"]["bucket_name"]
|
|
# Verify all three required components are present in the resolved name.
|
|
assert "dev" in bucket # environment
|
|
assert "581513795199" in bucket # account_id (real dev account, D-203)
|
|
assert "us-east-1" in bucket # region
|
|
assert "assets" in bucket # contract id |