from __future__ import annotations

import json
import sys
import unittest
from pathlib import Path

ROOT = Path(__file__).resolve().parents[2]
if str(ROOT) not in sys.path:
    sys.path.insert(0, str(ROOT))

import tools.validate_gitea_secrets_contract_v1 as validator


class TestValidateGiteaSecretsContract(unittest.TestCase):

    def test_validate_gitea_secrets_contract_passes(self):
        rc = validator.main()
        payload = json.loads((ROOT / "Temp" / "gitea_secrets_contract_v1.json").read_text(encoding="utf-8"))

        self.assertEqual(rc, 0)
        self.assertEqual(payload["gate"], "PASS")
        self.assertTrue(payload["evidence"][".gitea/workflows/kis_data_collection.yml"]["vars.KIS_APP_KEY"])


if __name__ == "__main__":
    unittest.main()

